blob: 1d89b9b89dfc012e6261d5d0665d20451e40e994 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
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.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.IEditorPart;
/**
* MakefileAnnotationHover
*
*/
public class MakefileAnnotationHover implements IAnnotationHover {
private IEditorPart fEditor;
/**
*
*/
public MakefileAnnotationHover(IEditorPart editor) {
fEditor = editor;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer,
* int)
*/
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
IDocument document = sourceViewer.getDocument();
try {
IRegion info = document.getLineInformation(lineNumber);
String line = document.get(info.getOffset(), info.getLength());
int numberOfLines = document.getNumberOfLines();
while (line != null && line.endsWith("\\")) { //$NON-NLS-1$
line = line.substring(0, line.length() - 1);
lineNumber++;
if (lineNumber < numberOfLines) {
info = document.getLineInformation(lineNumber);
String l = document.get(info.getOffset(), info.getLength());
line += "\n" + l; //$NON-NLS-1$
}
}
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) {
}
return null;
}
}
|