1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

Fix invocation of macro explorere for selections beyond last declaration.

This commit is contained in:
Markus Schorn 2008-03-14 21:20:37 +00:00
parent 831dd9ee1f
commit e7bb0ea2c2

View file

@ -105,13 +105,19 @@ public class CMacroExpansionInput {
} }
if (fAllowSelection) { if (fAllowSelection) {
// selection // selection
fEnclosingNode= nodeSelector.findEnclosingNode(fTextRegion.getOffset(), fTextRegion.getLength());
if (fEnclosingNode != null) {
boolean macroOccurrence= false; boolean macroOccurrence= false;
if (fEnclosingNode.getParent() instanceof IASTPreprocessorMacroExpansion) { fEnclosingNode= nodeSelector.findEnclosingNode(fTextRegion.getOffset(), fTextRegion.getLength());
if (fEnclosingNode == null) {
// selection beyond last declaration
fEnclosingNode= ast;
}
else if (fEnclosingNode.getParent() instanceof IASTPreprocessorMacroExpansion) {
// selection enclosed by the name of a macro expansion
fEnclosingNode= fEnclosingNode.getParent(); fEnclosingNode= fEnclosingNode.getParent();
} }
if (fEnclosingNode instanceof IASTPreprocessorMacroExpansion) { if (fEnclosingNode instanceof IASTPreprocessorMacroExpansion) {
// selection enclosed by a macro expansion
addExpansionNode(fEnclosingNode); addExpansionNode(fEnclosingNode);
macroOccurrence= true; macroOccurrence= true;
} }
@ -136,7 +142,6 @@ public class CMacroExpansionInput {
} }
} }
} }
}
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
} }