mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Removed AbstactGNUSourceCodeParser#mostRelevantScopeNode
This commit is contained in:
parent
21c09e5d0f
commit
a27d2a6da5
3 changed files with 4908 additions and 4925 deletions
|
@ -484,7 +484,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
IASTCompoundStatement result = createCompoundStatement();
|
IASTCompoundStatement result = createCompoundStatement();
|
||||||
((ASTNode) result).setOffset(startingOffset);
|
((ASTNode) result).setOffset(startingOffset);
|
||||||
result.setParent(mostRelevantScopeNode);
|
|
||||||
result.setPropertyInParent(IASTFunctionDefinition.FUNCTION_BODY);
|
result.setPropertyInParent(IASTFunctionDefinition.FUNCTION_BODY);
|
||||||
while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tCOMPLETION && LT(1) != IToken.tEOC) {
|
while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tCOMPLETION && LT(1) != IToken.tEOC) {
|
||||||
int checkToken = LA(1).hashCode();
|
int checkToken = LA(1).hashCode();
|
||||||
|
@ -2087,6 +2086,5 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
throwBacktrack(token.getOffset(), token.getLength());
|
throwBacktrack(token.getOffset(), token.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTNode mostRelevantScopeNode;
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -559,7 +559,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
translationUnit.setLocationResolver(scanner.getLocationResolver());
|
translationUnit.setLocationResolver(scanner.getLocationResolver());
|
||||||
mostRelevantScopeNode = translationUnit;
|
|
||||||
|
|
||||||
int lastBacktrack = -1;
|
int lastBacktrack = -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -1450,12 +1450,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tIDENTIFIER)
|
if (LT(1) == IToken.tIDENTIFIER)
|
||||||
amb = true;
|
amb = true;
|
||||||
typeId = typeId(false, false);
|
typeId = typeId(false, false);
|
||||||
if( amb && typeId.getDeclSpecifier() instanceof IASTNamedTypeSpecifier )
|
if (amb
|
||||||
{
|
&& typeId.getDeclSpecifier() instanceof IASTNamedTypeSpecifier) {
|
||||||
if( ! queryIsTypeName( ((IASTNamedTypeSpecifier) typeId.getDeclSpecifier()).getName() ) )
|
if (!queryIsTypeName(((IASTNamedTypeSpecifier) typeId
|
||||||
{
|
.getDeclSpecifier()).getName())) {
|
||||||
backup(m);
|
backup(m);
|
||||||
throwBacktrack( ((CPPASTNode)typeId).getOffset(), ((CPPASTNode)typeId).getLength() );
|
throwBacktrack(((CPPASTNode) typeId).getOffset(),
|
||||||
|
((CPPASTNode) typeId).getLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
|
@ -2470,11 +2471,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
name.setParent(namespaceDefinition);
|
name.setParent(namespaceDefinition);
|
||||||
name.setPropertyInParent(ICPPASTNamespaceDefinition.NAMESPACE_NAME);
|
name.setPropertyInParent(ICPPASTNamespaceDefinition.NAMESPACE_NAME);
|
||||||
|
|
||||||
IASTNode n = mostRelevantScopeNode;
|
|
||||||
mostRelevantScopeNode = namespaceDefinition;
|
|
||||||
namespaceDefinition.setParent(n);
|
|
||||||
|
|
||||||
try {
|
|
||||||
namespaceDeclarationLoop: while (LT(1) != IToken.tRBRACE) {
|
namespaceDeclarationLoop: while (LT(1) != IToken.tRBRACE) {
|
||||||
int checkToken = LA(1).hashCode();
|
int checkToken = LA(1).hashCode();
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
|
@ -2492,8 +2488,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTProblemDeclaration pd = createProblemDeclaration();
|
IASTProblemDeclaration pd = createProblemDeclaration();
|
||||||
p.setParent(pd);
|
p.setParent(pd);
|
||||||
pd.setProblem(p);
|
pd.setProblem(p);
|
||||||
((CPPASTNode) pd)
|
((CPPASTNode) pd).setOffsetAndLength((CPPASTNode) p);
|
||||||
.setOffsetAndLength((CPPASTNode) p);
|
|
||||||
p.setPropertyInParent(IASTProblemHolder.PROBLEM);
|
p.setPropertyInParent(IASTProblemHolder.PROBLEM);
|
||||||
namespaceDefinition.addDeclaration(pd);
|
namespaceDefinition.addDeclaration(pd);
|
||||||
pd.setParent(namespaceDefinition);
|
pd.setParent(namespaceDefinition);
|
||||||
|
@ -2507,9 +2502,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (checkToken == LA(1).hashCode())
|
if (checkToken == LA(1).hashCode())
|
||||||
failParseWithErrorHandling();
|
failParseWithErrorHandling();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
mostRelevantScopeNode = n;
|
|
||||||
}
|
|
||||||
// consume the }
|
// consume the }
|
||||||
int end = consume(IToken.tRBRACE).getEndOffset();
|
int end = consume(IToken.tRBRACE).getEndOffset();
|
||||||
((CPPASTNode) namespaceDefinition).setLength(end
|
((CPPASTNode) namespaceDefinition).setLength(end
|
||||||
|
@ -3533,9 +3526,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throw eof;
|
throw eof;
|
||||||
}
|
}
|
||||||
} else if (LT(1) == IToken.tLPAREN) {
|
} else if (LT(1) == IToken.tLPAREN) {
|
||||||
if( d instanceof IASTFunctionDeclarator && d.getNestedDeclarator() == null ){
|
if (d instanceof IASTFunctionDeclarator
|
||||||
//constructor initializer doesn't make sense for a function declarator,
|
&& d.getNestedDeclarator() == null) {
|
||||||
//we must have an object to initialize, a function doesn't work.
|
// constructor initializer doesn't make sense for a function
|
||||||
|
// declarator,
|
||||||
|
// we must have an object to initialize, a function doesn't
|
||||||
|
// work.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// initializer in constructor
|
// initializer in constructor
|
||||||
|
@ -4100,11 +4096,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tLBRACE) {
|
if (LT(1) == IToken.tLBRACE) {
|
||||||
consume(IToken.tLBRACE);
|
consume(IToken.tLBRACE);
|
||||||
|
|
||||||
IASTNode n = mostRelevantScopeNode;
|
|
||||||
mostRelevantScopeNode = astClassSpecifier;
|
|
||||||
astClassSpecifier.setParent(n);
|
|
||||||
|
|
||||||
try {
|
|
||||||
memberDeclarationLoop: while (LT(1) != IToken.tRBRACE) {
|
memberDeclarationLoop: while (LT(1) != IToken.tRBRACE) {
|
||||||
int checkToken = LA(1).hashCode();
|
int checkToken = LA(1).hashCode();
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
|
@ -4152,9 +4144,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
failParseWithErrorHandling();
|
failParseWithErrorHandling();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
mostRelevantScopeNode = n;
|
|
||||||
}
|
|
||||||
// consume the }
|
// consume the }
|
||||||
int l = consume(IToken.tRBRACE).getEndOffset();
|
int l = consume(IToken.tRBRACE).getEndOffset();
|
||||||
((ASTNode) astClassSpecifier).setLength(l - classKey.getOffset());
|
((ASTNode) astClassSpecifier).setLength(l - classKey.getOffset());
|
||||||
|
@ -4438,7 +4428,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
translationUnit.setLocationResolver(scanner.getLocationResolver());
|
translationUnit.setLocationResolver(scanner.getLocationResolver());
|
||||||
|
|
||||||
mostRelevantScopeNode = translationUnit;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
if (LT(1) == IToken.tEOC)
|
if (LT(1) == IToken.tEOC)
|
||||||
|
@ -5024,9 +5013,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class HeuristicTypeDetector extends CPPASTVisitor
|
static class HeuristicTypeDetector extends CPPASTVisitor {
|
||||||
{
|
|
||||||
IASTName searchName;
|
IASTName searchName;
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
{
|
{
|
||||||
shouldVisitDeclarations = true;
|
shouldVisitDeclarations = true;
|
||||||
|
@ -5037,24 +5026,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int visit(IASTDeclaration declaration) {
|
public int visit(IASTDeclaration declaration) {
|
||||||
if( declaration instanceof IASTSimpleDeclaration )
|
if (declaration instanceof IASTSimpleDeclaration) {
|
||||||
{
|
|
||||||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) declaration;
|
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) declaration;
|
||||||
if( sd.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef )
|
if (sd.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef) {
|
||||||
{
|
|
||||||
IASTDeclarator[] declarators = sd.getDeclarators();
|
IASTDeclarator[] declarators = sd.getDeclarators();
|
||||||
for (int i = 0; i < declarators.length; ++i)
|
for (int i = 0; i < declarators.length; ++i)
|
||||||
if( CharArrayUtils.equals( declarators[i].getName().toCharArray(), searchName.toCharArray() ) )
|
if (CharArrayUtils.equals(declarators[i].getName()
|
||||||
{
|
.toCharArray(), searchName.toCharArray())) {
|
||||||
found = true;
|
found = true;
|
||||||
return PROCESS_ABORT;
|
return PROCESS_ABORT;
|
||||||
}
|
}
|
||||||
}
|
} else if (sd.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier) {
|
||||||
else if( sd.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier )
|
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) sd
|
||||||
{
|
.getDeclSpecifier();
|
||||||
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) sd.getDeclSpecifier();
|
if (CharArrayUtils.equals(comp.getName().toCharArray(),
|
||||||
if( CharArrayUtils.equals( comp.getName().toCharArray(), searchName.toCharArray() ) )
|
searchName.toCharArray())) {
|
||||||
{
|
|
||||||
found = true;
|
found = true;
|
||||||
return PROCESS_ABORT;
|
return PROCESS_ABORT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue