mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Expand the string when doing Annotation hovering.
This commit is contained in:
parent
dd5fdea8fa
commit
6f281e37e4
3 changed files with 28 additions and 17 deletions
|
@ -176,6 +176,6 @@ public class MakefileSourceConfiguration extends SourceViewerConfiguration {
|
||||||
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer)
|
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer)
|
||||||
*/
|
*/
|
||||||
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
|
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
|
||||||
return new MakefileAnnotationHover();
|
return new MakefileAnnotationHover(fEditor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
/*
|
/**********************************************************************
|
||||||
* "The Java Developer's Guide to Eclipse"
|
* Copyright (c) 2002,2003 QNX Software Systems and others.
|
||||||
* by Shavor, D'Anjou, Fairbrother, Kehn, Kellerman, McCarthy
|
* All rights reserved. This program and the accompanying materials
|
||||||
*
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* (C) Copyright International Business Machines Corporation, 2003.
|
* which accompanies this distribution, and is available at
|
||||||
* All Rights Reserved.
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
*
|
*
|
||||||
* Code or samples provided herein are provided without warranty of any kind.
|
* Contributors:
|
||||||
*/
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.make.internal.ui.text;
|
package org.eclipse.cdt.make.internal.ui.text;
|
||||||
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
@ -72,7 +74,6 @@ public class WordPartDetector {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method getString.
|
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -11,11 +11,15 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.make.internal.ui.text.makefile;
|
package org.eclipse.cdt.make.internal.ui.text.makefile;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.makefile.IMakefile;
|
||||||
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
|
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.source.IAnnotationHover;
|
import org.eclipse.jface.text.source.IAnnotationHover;
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MakefileAnnotationHover
|
* MakefileAnnotationHover
|
||||||
|
@ -23,11 +27,13 @@ import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
*/
|
*/
|
||||||
public class MakefileAnnotationHover implements IAnnotationHover {
|
public class MakefileAnnotationHover implements IAnnotationHover {
|
||||||
|
|
||||||
|
private IEditorPart fEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public MakefileAnnotationHover() {
|
public MakefileAnnotationHover(IEditorPart editor) {
|
||||||
super();
|
fEditor = editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -38,15 +44,19 @@ public class MakefileAnnotationHover implements IAnnotationHover {
|
||||||
*/
|
*/
|
||||||
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
|
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
|
||||||
IDocument document = sourceViewer.getDocument();
|
IDocument document = sourceViewer.getDocument();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IRegion info = document.getLineInformation(lineNumber);
|
IRegion info = document.getLineInformation(lineNumber);
|
||||||
return document.get(info.getOffset(), info.getLength());
|
String line = document.get(info.getOffset(), info.getLength());
|
||||||
|
if (line != null && line.indexOf('$') != -1 && line.length() > 1) {
|
||||||
|
IWorkingCopyManager fManager = MakeUIPlugin.getDefault().getWorkingCopyManager();
|
||||||
|
IMakefile makefile = fManager.getWorkingCopy(fEditor.getEditorInput());
|
||||||
|
line = makefile.expandString(line);
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
return line;
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue