mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
fix bug 86369
This commit is contained in:
parent
c358a8c355
commit
c698546bba
2 changed files with 36 additions and 14 deletions
|
@ -2374,5 +2374,30 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertInstances( col, f_ref, 4 );
|
||||
assertInstances( col, g_ref, 2 );
|
||||
}
|
||||
|
||||
public void testBug86369() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("namespace Company_with_veryblahblah {} \n"); //$NON-NLS-1$
|
||||
buffer.append("namespace CWVLN = Company_with_veryblahblah; \n"); //$NON-NLS-1$
|
||||
buffer.append("namespace CWVLN = Company_with_veryblahblah; \n"); //$NON-NLS-1$
|
||||
buffer.append("namespace CWVLN = CWVLN; \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.getVisitor().visitTranslationUnit(col);
|
||||
|
||||
ICPPNamespace ns = (ICPPNamespace) col.getName(0).resolveBinding();
|
||||
IASTName [] refs = tu.getReferences( ns );
|
||||
assertEquals( refs.length, 3 );
|
||||
assertSame( refs[0], col.getName(2) );
|
||||
assertSame( refs[1], col.getName(4) );
|
||||
assertSame( refs[2], col.getName(6) );
|
||||
IASTName [] decls = tu.getDeclarations( ns );
|
||||
assertEquals( decls.length, 4 );
|
||||
assertSame( decls[0], col.getName(0) );
|
||||
assertSame( decls[1], col.getName(1) );
|
||||
assertSame( decls[2], col.getName(3) );
|
||||
assertSame( decls[3], col.getName(5) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -782,7 +782,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
|||
private static final int KIND_LABEL = 1;
|
||||
private static final int KIND_OBJ_FN = 2;
|
||||
private static final int KIND_TYPE = 3;
|
||||
private static final int KIND_NAMEPSACE = 4;
|
||||
private static final int KIND_NAMESPACE = 4;
|
||||
|
||||
|
||||
public CollectDeclarationsAction( IBinding binding ){
|
||||
|
@ -799,7 +799,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
|||
kind = KIND_TYPE;
|
||||
}
|
||||
else if( binding instanceof ICPPNamespace) {
|
||||
kind = KIND_NAMEPSACE;
|
||||
kind = KIND_NAMESPACE;
|
||||
} else
|
||||
kind = KIND_OBJ_FN;
|
||||
}
|
||||
|
@ -846,17 +846,16 @@ public class CPPVisitor implements ICPPASTVisitor {
|
|||
break;
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
case KIND_NAMEPSACE:
|
||||
if( prop == ICPPASTNamespaceDefinition.NAMESPACE_NAME )
|
||||
case KIND_NAMESPACE:
|
||||
if( prop == ICPPASTNamespaceDefinition.NAMESPACE_NAME ||
|
||||
prop == ICPPASTNamespaceAlias.ALIAS_NAME )
|
||||
{
|
||||
break;
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
if( binding != null &&
|
||||
CharArrayUtils.equals(name.toCharArray(), binding.getNameCharArray()) &&
|
||||
name.resolveBinding() == binding )
|
||||
if( binding != null && name.resolveBinding() == binding )
|
||||
{
|
||||
if( decls.length == idx ){
|
||||
IASTName [] temp = new IASTName[ decls.length * 2 ];
|
||||
|
@ -887,7 +886,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
|||
private static final int KIND_LABEL = 1;
|
||||
private static final int KIND_OBJ_FN = 2;
|
||||
private static final int KIND_TYPE = 3;
|
||||
private static final int KIND_NAMEPSACE = 4;
|
||||
private static final int KIND_NAMESPACE = 4;
|
||||
|
||||
|
||||
public CollectReferencesAction( IBinding binding ){
|
||||
|
@ -904,7 +903,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
|||
kind = KIND_TYPE;
|
||||
}
|
||||
else if( binding instanceof ICPPNamespace) {
|
||||
kind = KIND_NAMEPSACE;
|
||||
kind = KIND_NAMESPACE;
|
||||
} else
|
||||
kind = KIND_OBJ_FN;
|
||||
}
|
||||
|
@ -956,7 +955,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
|||
break;
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
case KIND_NAMEPSACE:
|
||||
case KIND_NAMESPACE:
|
||||
if( prop == ICPPASTUsingDirective.QUALIFIED_NAME ||
|
||||
prop == ICPPASTNamespaceAlias.MAPPING_NAME ||
|
||||
prop == ICPPASTUsingDeclaration.NAME ||
|
||||
|
@ -967,9 +966,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
if( binding != null &&
|
||||
CharArrayUtils.equals(name.toCharArray(), binding.getNameCharArray()) &&
|
||||
name.resolveBinding() == binding ){
|
||||
if( binding != null && name.resolveBinding() == binding ){
|
||||
if( refs.length == idx ){
|
||||
IASTName [] temp = new IASTName[ refs.length * 2 ];
|
||||
System.arraycopy( refs, 0, temp, 0, refs.length );
|
||||
|
@ -1052,8 +1049,8 @@ public class CPPVisitor implements ICPPASTVisitor {
|
|||
if( !visitName( ((ICPPASTUsingDirective)declaration).getQualifiedName(), action ) ) return false;
|
||||
} else if( declaration instanceof ICPPASTNamespaceAlias ){
|
||||
ICPPASTNamespaceAlias alias = (ICPPASTNamespaceAlias) declaration;
|
||||
if( !visitName( alias.getQualifiedName(), action ) ) return false;
|
||||
if( !visitName( alias.getAlias(), action ) ) return false;
|
||||
if( !visitName( alias.getQualifiedName(), action ) ) return false;
|
||||
} else if( declaration instanceof ICPPASTLinkageSpecification ){
|
||||
IASTDeclaration [] decls = ((ICPPASTLinkageSpecification) declaration).getDeclarations();
|
||||
for( int i = 0; i < decls.length; i++ ){
|
||||
|
|
Loading…
Add table
Reference in a new issue