mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Patch for Bug 173874 - day one bug in getNestedClasses in CPPClassType. The binding didn't get cleared when moving to the next member.
This commit is contained in:
parent
e466f136ac
commit
cb85bd81a9
2 changed files with 17 additions and 4 deletions
|
@ -2654,4 +2654,16 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
|
|
||||||
assertInstances(col, bar, 1);
|
assertInstances(col, bar, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void test173874_nestedClasses() throws Exception {
|
||||||
|
String code = "class aClass { class bClass; int x; };";
|
||||||
|
IASTTranslationUnit tu = parse(code, true, ParserLanguage.CPP, true);
|
||||||
|
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
tu.accept(col);
|
||||||
|
|
||||||
|
ICPPClassType cls = (ICPPClassType)col.getName(0).resolveBinding();
|
||||||
|
ICPPClassType[] nested = cls.getNestedClasses();
|
||||||
|
assertEquals(1, nested.length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -793,7 +793,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
return new ICPPClassType[] { new CPPClassTypeProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
return new ICPPClassType[] { new CPPClassTypeProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IBinding binding = null;
|
|
||||||
ICPPClassType [] result = null;
|
ICPPClassType [] result = null;
|
||||||
|
|
||||||
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
||||||
|
@ -801,12 +801,13 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
IASTDeclaration decl = decls[i];
|
IASTDeclaration decl = decls[i];
|
||||||
while( decl instanceof ICPPASTTemplateDeclaration )
|
while( decl instanceof ICPPASTTemplateDeclaration )
|
||||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||||
if( decls[i] instanceof IASTSimpleDeclaration ){
|
if( decl instanceof IASTSimpleDeclaration ){
|
||||||
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decls[i]).getDeclSpecifier();
|
IBinding binding = null;
|
||||||
|
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||||
if( declSpec instanceof ICPPASTCompositeTypeSpecifier ){
|
if( declSpec instanceof ICPPASTCompositeTypeSpecifier ){
|
||||||
binding = ((ICPPASTCompositeTypeSpecifier)declSpec).getName().resolveBinding();
|
binding = ((ICPPASTCompositeTypeSpecifier)declSpec).getName().resolveBinding();
|
||||||
} else if( declSpec instanceof ICPPASTElaboratedTypeSpecifier &&
|
} else if( declSpec instanceof ICPPASTElaboratedTypeSpecifier &&
|
||||||
((IASTSimpleDeclaration)decls[i]).getDeclarators().length == 0 )
|
((IASTSimpleDeclaration)decl).getDeclarators().length == 0 )
|
||||||
{
|
{
|
||||||
binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding();
|
binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue