Blob Blame History Raw
--- ./results/plugins/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/DefinedSymbolHover.java.fix	2006-09-11 15:53:00.000000000 -0400
+++ ./results/plugins/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/DefinedSymbolHover.java	2006-09-11 15:52:51.000000000 -0400
@@ -0,0 +1,67 @@
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+
+public class DefinedSymbolHover extends AbstractCEditorTextHover {
+	
+	/**
+	 * 
+	 */
+	public DefinedSymbolHover() {
+		super();
+	}
+
+	/*
+	 * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
+	 */
+	public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+		IEditorPart editor = getEditor();
+		if (editor != null) {
+			IEditorInput input= editor.getEditorInput();
+			IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();				
+			IWorkingCopy copy = manager.getWorkingCopy(input);
+			if (copy == null) {
+				return null;
+			}
+			
+			String expression;
+			try {
+				expression = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
+				expression = expression.trim();
+				if (expression.length() == 0)
+					return null;
+
+				String source = null;
+				IResource res = copy.getUnderlyingResource();
+
+				IScannerInfo info;
+				IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(res.getProject());
+				if (provider != null) {
+					info = provider.getScannerInformation(res);
+					Map definedSymbols = info.getDefinedSymbols();
+					String x = (String)definedSymbols.get(expression);
+					if (x != null) {
+						source = "-D" + expression + (x.length() > 0 ? " = " +
+						x : "");
+					}
+				}
+				return source;
+			} catch (BadLocationException e) {
+			}
+		}
+		return null;
+	}
+}
--- ./results/plugins/org.eclipse.cdt.ui/plugin.properties.fix	2006-09-11 15:50:03.000000000 -0400
+++ ./results/plugins/org.eclipse.cdt.ui/plugin.properties	2006-09-11 15:50:43.000000000 -0400
@@ -283,6 +283,8 @@ ViewCommand.typeHierarchy.description= S
 CEditorTextHoversName=C Editor Text Hovers
 sourceHover= Source
 sourceHoverDescription= Shows the source of the selected element.
+definedSymbolHover= Defined Symbol
+definedSymbolHoverDescription= Shows the definition of a selected defined symbol.
 cdocHover= Documentation
 cdocHoverDescription= Shows the documentation of the selected element.
 sequentialHover= Combined Hover
--- ./results/plugins/org.eclipse.cdt.ui/plugin.xml.fix	2006-09-11 15:49:54.000000000 -0400
+++ ./results/plugins/org.eclipse.cdt.ui/plugin.xml	2006-09-11 15:51:19.000000000 -0400
@@ -145,6 +145,12 @@
             class="org.eclipse.cdt.internal.ui.text.c.hover.CSourceHover"
             id="org.eclipse.cdt.ui.CSourceHover">
       </hover>
+      <hover
+            label="%definedSymbolHover"
+            description="%definedSymbolHoverDescription"
+            class="org.eclipse.cdt.internal.ui.text.c.hover.DefinedSymbolHover"
+            id="org.eclipse.cdt.ui.DefinedSymbolHover">
+      </hover>
       <!--hover
             label="%problemHover"
             description="%problemHoverDescription"