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,35 +105,40 @@ public class CMacroExpansionInput {
} }
if (fAllowSelection) { if (fAllowSelection) {
// selection // selection
boolean macroOccurrence= false;
fEnclosingNode= nodeSelector.findEnclosingNode(fTextRegion.getOffset(), fTextRegion.getLength()); fEnclosingNode= nodeSelector.findEnclosingNode(fTextRegion.getOffset(), fTextRegion.getLength());
if (fEnclosingNode != null) { if (fEnclosingNode == null) {
boolean macroOccurrence= false; // selection beyond last declaration
if (fEnclosingNode.getParent() instanceof IASTPreprocessorMacroExpansion) { fEnclosingNode= ast;
fEnclosingNode= fEnclosingNode.getParent(); }
} else if (fEnclosingNode.getParent() instanceof IASTPreprocessorMacroExpansion) {
if (fEnclosingNode instanceof IASTPreprocessorMacroExpansion) { // selection enclosed by the name of a macro expansion
addExpansionNode(fEnclosingNode); fEnclosingNode= fEnclosingNode.getParent();
macroOccurrence= true; }
}
else { if (fEnclosingNode instanceof IASTPreprocessorMacroExpansion) {
IASTNodeLocation[] locations= fEnclosingNode.getNodeLocations(); // selection enclosed by a macro expansion
for (int i = 0; i < locations.length; i++) { addExpansionNode(fEnclosingNode);
IASTNodeLocation location= locations[i]; macroOccurrence= true;
if (location instanceof IASTMacroExpansionLocation) { }
IASTFileLocation fileLocation= location.asFileLocation(); else {
if (fileLocation != null && ast.getFilePath().equals(fileLocation.getFileName())) { IASTNodeLocation[] locations= fEnclosingNode.getNodeLocations();
if (fTextRegion.overlapsWith(fileLocation.getNodeOffset(), fileLocation.getNodeLength())) { for (int i = 0; i < locations.length; i++) {
addExpansionNode(nodeSelector.findEnclosingNode(fileLocation.getNodeOffset(), fileLocation.getNodeLength())); IASTNodeLocation location= locations[i];
macroOccurrence= true; if (location instanceof IASTMacroExpansionLocation) {
} IASTFileLocation fileLocation= location.asFileLocation();
if (fileLocation != null && ast.getFilePath().equals(fileLocation.getFileName())) {
if (fTextRegion.overlapsWith(fileLocation.getNodeOffset(), fileLocation.getNodeLength())) {
addExpansionNode(nodeSelector.findEnclosingNode(fileLocation.getNodeOffset(), fileLocation.getNodeLength()));
macroOccurrence= true;
} }
} }
} }
} }
if (macroOccurrence) { }
createMacroExpansionExplorer(ast); if (macroOccurrence) {
return Status.OK_STATUS; createMacroExpansionExplorer(ast);
} return Status.OK_STATUS;
} }
} }
} }