mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
a5188f1c75
commit
30081f07d5
3 changed files with 38 additions and 31 deletions
|
@ -21,7 +21,6 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTImplicitName extends IASTName {
|
public interface IASTImplicitName extends IASTName {
|
||||||
|
|
||||||
public static final IASTImplicitName[] EMPTY_NAME_ARRAY = {};
|
public static final IASTImplicitName[] EMPTY_NAME_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,8 +24,8 @@ import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public class ASTNodeSelector implements IASTNodeSelector {
|
public class ASTNodeSelector implements IASTNodeSelector {
|
||||||
private ASTTranslationUnit fTu;
|
private final ASTTranslationUnit fTu;
|
||||||
private ILocationResolver fLocationResolver;
|
private final ILocationResolver fLocationResolver;
|
||||||
private String fFilePath;
|
private String fFilePath;
|
||||||
private final boolean fIsValid;
|
private final boolean fIsValid;
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ public class ASTNodeSelector implements IASTNodeSelector {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends IASTNode> T findNode(int offsetInFile, int lengthInFile, Relation relation, Class<T> requiredClass) {
|
private <T extends IASTNode> T findNode(int offsetInFile, int lengthInFile, Relation relation,
|
||||||
|
Class<T> requiredClass) {
|
||||||
return findNode(offsetInFile, lengthInFile, relation, requiredClass, false);
|
return findNode(offsetInFile, lengthInFile, relation, requiredClass, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +69,8 @@ public class ASTNodeSelector implements IASTNodeSelector {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (lengthInFile > 0) {
|
if (lengthInFile > 0) {
|
||||||
sequenceLength= fLocationResolver.getSequenceNumberForFileOffset(fFilePath, offsetInFile+lengthInFile-1) + 1 - sequenceNumber;
|
sequenceLength= fLocationResolver.getSequenceNumberForFileOffset(fFilePath,
|
||||||
|
offsetInFile + lengthInFile - 1) + 1 - sequenceNumber;
|
||||||
} else {
|
} else {
|
||||||
sequenceLength= 0;
|
sequenceLength= 0;
|
||||||
if (offsetInFile > 0) {
|
if (offsetInFile > 0) {
|
||||||
|
@ -82,7 +84,8 @@ public class ASTNodeSelector implements IASTNodeSelector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ASTNodeSpecification<T> nodeSpec= new ASTNodeSpecification<T>(relation, requiredClass, offsetInFile, lengthInFile);
|
final ASTNodeSpecification<T> nodeSpec=
|
||||||
|
new ASTNodeSpecification<T>(relation, requiredClass, offsetInFile, lengthInFile);
|
||||||
nodeSpec.setRangeInSequence(sequenceNumber, sequenceLength, false);
|
nodeSpec.setRangeInSequence(sequenceNumber, sequenceLength, false);
|
||||||
nodeSpec.setSearchInExpansion(searchInExpansion);
|
nodeSpec.setSearchInExpansion(searchInExpansion);
|
||||||
getNode(nodeSpec);
|
getNode(nodeSpec);
|
||||||
|
@ -102,12 +105,14 @@ public class ASTNodeSelector implements IASTNodeSelector {
|
||||||
IASTPreprocessorMacroExpansion expansion= nodeSpec.findLeadingMacroExpansion(this);
|
IASTPreprocessorMacroExpansion expansion= nodeSpec.findLeadingMacroExpansion(this);
|
||||||
if (expansion != null) {
|
if (expansion != null) {
|
||||||
IASTFileLocation floc= expansion.getFileLocation();
|
IASTFileLocation floc= expansion.getFileLocation();
|
||||||
seqbegin= fLocationResolver.getSequenceNumberForFileOffset(fFilePath, floc.getNodeOffset() + floc.getNodeLength()-1)+1;
|
seqbegin= fLocationResolver.getSequenceNumberForFileOffset(fFilePath,
|
||||||
|
floc.getNodeOffset() + floc.getNodeLength() - 1) + 1;
|
||||||
}
|
}
|
||||||
expansion= nodeSpec.findTrailingMacroExpansion(this);
|
expansion= nodeSpec.findTrailingMacroExpansion(this);
|
||||||
if (expansion != null) {
|
if (expansion != null) {
|
||||||
IASTFileLocation floc= expansion.getFileLocation();
|
IASTFileLocation floc= expansion.getFileLocation();
|
||||||
seqend= fLocationResolver.getSequenceNumberForFileOffset(fFilePath, floc.getNodeOffset() + floc.getNodeLength());
|
seqend= fLocationResolver.getSequenceNumberForFileOffset(fFilePath,
|
||||||
|
floc.getNodeOffset() + floc.getNodeLength());
|
||||||
}
|
}
|
||||||
nodeSpec.setRangeInSequence(seqbegin, seqend - seqbegin);
|
nodeSpec.setRangeInSequence(seqbegin, seqend - seqbegin);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For searching ast-nodes by offset and length, instances of this class can be used to
|
* For searching ast-nodes by offset and length, instances of this class can be used to determine
|
||||||
* determine whether a node matches or not.
|
* whether a node matches or not.
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +35,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
|
||||||
private int fBestEndOffset;
|
private int fBestEndOffset;
|
||||||
private T fBestNode;
|
private T fBestNode;
|
||||||
private boolean fSearchInExpansion;
|
private boolean fSearchInExpansion;
|
||||||
private boolean fZeroToLeft= false;
|
private boolean fZeroToLeft;
|
||||||
|
|
||||||
public ASTNodeSpecification(Relation relation, Class<T> clazz, int fileOffset, int fileLength) {
|
public ASTNodeSpecification(Relation relation, Class<T> clazz, int fileOffset, int fileLength) {
|
||||||
fRelation= relation;
|
fRelation= relation;
|
||||||
|
@ -80,7 +80,8 @@ public class ASTNodeSpecification<T extends IASTNode> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void visit(ASTNode astNode) {
|
public void visit(ASTNode astNode) {
|
||||||
if (isAcceptableNode(astNode) && isMatchingRange(astNode.getOffset(), astNode.getLength(), fSeqNumber, fSeqEndNumber)) {
|
if (isAcceptableNode(astNode) &&
|
||||||
|
isMatchingRange(astNode.getOffset(), astNode.getLength(), fSeqNumber, fSeqEndNumber)) {
|
||||||
IASTFileLocation loc= astNode.getFileLocation();
|
IASTFileLocation loc= astNode.getFileLocation();
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
storeIfBest(loc, (T) astNode);
|
storeIfBest(loc, (T) astNode);
|
||||||
|
@ -211,7 +212,8 @@ public class ASTNodeSpecification<T extends IASTNode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTPreprocessorMacroExpansion findLeadingMacroExpansion(ASTNodeSelector nodeSelector) {
|
public IASTPreprocessorMacroExpansion findLeadingMacroExpansion(ASTNodeSelector nodeSelector) {
|
||||||
IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fZeroToLeft ? fFileOffset-1 : fFileOffset, 1);
|
IASTPreprocessorMacroExpansion exp=
|
||||||
|
nodeSelector.findEnclosingMacroExpansion(fZeroToLeft ? fFileOffset - 1 : fFileOffset, 1);
|
||||||
if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING)
|
if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING)
|
||||||
return exp;
|
return exp;
|
||||||
|
|
||||||
|
@ -228,7 +230,8 @@ public class ASTNodeSpecification<T extends IASTNode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTPreprocessorMacroExpansion findTrailingMacroExpansion(ASTNodeSelector nodeSelector) {
|
public IASTPreprocessorMacroExpansion findTrailingMacroExpansion(ASTNodeSelector nodeSelector) {
|
||||||
IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fFileEndOffset==fFileOffset && !fZeroToLeft ? fFileEndOffset : fFileEndOffset-1, 1);
|
IASTPreprocessorMacroExpansion exp=
|
||||||
|
nodeSelector.findEnclosingMacroExpansion(fFileEndOffset == fFileOffset && !fZeroToLeft ? fFileEndOffset : fFileEndOffset - 1, 1);
|
||||||
if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING)
|
if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING)
|
||||||
return exp;
|
return exp;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue