1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

handle typedefs as qualifying names

This commit is contained in:
Andrew Niefer 2005-05-24 18:15:52 +00:00
parent 2a6347f701
commit 14d4d30038
2 changed files with 24 additions and 0 deletions

View file

@ -4404,4 +4404,22 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame( state, col.getName(7).resolveBinding() ); assertSame( state, col.getName(7).resolveBinding() );
assertSame( state, col.getName(9).resolveBinding() ); assertSame( state, col.getName(9).resolveBinding() );
} }
public void testTypedefQualified() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("class _A { \n"); //$NON-NLS-1$
buffer.append(" static int i; \n"); //$NON-NLS-1$
buffer.append("}; \n"); //$NON-NLS-1$
buffer.append("typedef _A A; \n"); //$NON-NLS-1$
buffer.append("void f(){ \n"); //$NON-NLS-1$
buffer.append(" A::i++; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
ICPPField i = (ICPPField) col.getName(1).resolveBinding();
assertSame( i, col.getName(7).resolveBinding() );
}
} }

View file

@ -762,6 +762,12 @@ public class CPPVisitor {
} }
if( i > 0 ){ if( i > 0 ){
IBinding binding = names[i - 1].resolveBinding(); IBinding binding = names[i - 1].resolveBinding();
while( binding instanceof ITypedef ){
IType t = ((ITypedef)binding).getType();
if( t instanceof IBinding )
binding = (IBinding) t;
else break;
}
if( binding instanceof ICPPClassType ){ if( binding instanceof ICPPClassType ){
return ((ICPPClassType)binding).getCompositeScope(); return ((ICPPClassType)binding).getCompositeScope();
} else if( binding instanceof ICPPNamespace ){ } else if( binding instanceof ICPPNamespace ){