1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 14:15:23 +02:00

Follow up for bug 249801.

This commit is contained in:
Markus Schorn 2008-10-07 14:41:02 +00:00
parent caac3238db
commit 4f6ab7cd2e

View file

@ -201,10 +201,36 @@ public class ASTNodeSpecification<T extends IASTNode> {
}
public IASTPreprocessorMacroExpansion findLeadingMacroExpansion(ASTNodeSelector nodeSelector) {
return nodeSelector.findEnclosingMacroExpansion(fZeroToLeft ? fFileOffset-1 : fFileOffset, 1);
IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fZeroToLeft ? fFileOffset-1 : fFileOffset, 1);
if (fRelation == Relation.ENCLOSING)
return exp;
if (exp != null) {
IASTFileLocation loc= exp.getFileLocation();
if (loc != null) {
final int offset= loc.getNodeOffset();
final int endOffset= offset+loc.getNodeLength();
if (offset == fFileOffset && endOffset <= fFileEndOffset)
return exp;
}
}
return null;
}
public IASTPreprocessorMacroExpansion findTrailingMacroExpansion(ASTNodeSelector nodeSelector) {
return nodeSelector.findEnclosingMacroExpansion(fZeroToLeft ? fFileEndOffset : fFileEndOffset-1, 1);
IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fFileEndOffset==fFileOffset && !fZeroToLeft ? fFileEndOffset : fFileEndOffset-1, 1);
if (fRelation == Relation.ENCLOSING)
return exp;
if (exp != null) {
IASTFileLocation loc= exp.getFileLocation();
if (loc != null) {
final int offset= loc.getNodeOffset();
final int endOffset= offset+loc.getNodeLength();
if (endOffset == fFileEndOffset && offset >= fFileOffset)
return exp;
}
}
return null;
}
}