diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java index b1c3f7b96e9..0cc9e55a6c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java @@ -2316,13 +2316,19 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { if (globalOffset == context.context_directive_start && length == context.context_directive_end - context.context_directive_start) { - result = createPreprocessorStatement(context); + result = createPreprocessorStatement(context); + } + else if( context instanceof _MacroExpansion && globalOffset == context.context_directive_start ) + { + _MacroExpansion expansion = (_MacroExpansion)context; + if( expansion.definition.getName().length == length ) + result = expansion.getName(); } // check if a sub node of the macro is the selection // TODO // determine how this can be kept in sync with logic in // getAllPreprocessorStatements (i.e. 1:1 mapping) - if (context instanceof _MacroDefinition) { + if (context.contains( globalOffset ) && context instanceof _MacroDefinition) { if (globalOffset == ((_MacroDefinition) context).nameOffset && length == ((_MacroDefinition) context).name.length) result = createASTMacroDefinition( diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/ShowInDOMViewAction.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/ShowInDOMViewAction.java index c69eb4a6e15..69f8612b7ec 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/ShowInDOMViewAction.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/ShowInDOMViewAction.java @@ -123,7 +123,7 @@ public class ShowInDOMViewAction extends ActionDelegate implements } private class FindDisplayNode implements Runnable { - private static final String IAST_NODE_NOT_FOUND = "IASTNode not found for the selection. Try refreshing the AST View if changes were made to the source."; //$NON-NLS-1$ + private static final String IAST_NODE_NOT_FOUND = "IASTNode not found for the selection. "; //$NON-NLS-1$ private static final String IASTNode_NOT_FOUND = IAST_NODE_NOT_FOUND; int offset = 0; int length = 0; @@ -155,7 +155,9 @@ public class ShowInDOMViewAction extends ActionDelegate implements if (tu != null && file != null && view instanceof DOMAST) { IASTNode node = tu.selectNodeForLocation(file, offset, length); if (node != null && ((DOMAST)view).getContentProvider() instanceof DOMAST.ViewContentProvider) { - ((DOMAST.ViewContentProvider)((DOMAST)view).getContentProvider()).findAndSelect(node, true); // use offsets when searching for node equality + boolean success = ((DOMAST.ViewContentProvider)((DOMAST)view).getContentProvider()).findAndSelect(node, true); // use offsets when searching for node equality + if( ! success ) + showMessage(IASTNode_NOT_FOUND); } else { showMessage(IASTNode_NOT_FOUND); }