diff options
author | Andrew Niefer | 2005-02-25 20:09:58 +0000 |
---|---|---|
committer | Andrew Niefer | 2005-02-25 20:09:58 +0000 |
commit | c698546bbaf67e52a86d3f90f03baf0d88b01d48 (patch) | |
tree | 47812eccea2e0843a5b10a8e98a77e46602edcb5 | |
parent | c358a8c35572c82238d64836114dfcd4d0f4bb4d (diff) | |
download | org.eclipse.cdt-c698546bbaf67e52a86d3f90f03baf0d88b01d48.tar.gz org.eclipse.cdt-c698546bbaf67e52a86d3f90f03baf0d88b01d48.tar.xz org.eclipse.cdt-c698546bbaf67e52a86d3f90f03baf0d88b01d48.zip |
fix bug 86369
2 files changed, 36 insertions, 14 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index c6cdc33a5af..fc3bd206ceb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -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) ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index 6d18ce089d9..06351fa6c56 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -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++ ){ |