diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java index 975592267dd..2c5cef62a09 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java @@ -651,7 +651,10 @@ public class CompleteParseASTTest extends TestCase IASTVariable v = (IASTVariable)declarations.next(); assertEquals( v.getName(), "x"); assertEquals( ((IASTSimpleTypeSpecifier)v.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), classA ); - assertEquals( callback.getReferences().size(), 3 ); + assertEquals( callback.getReferences().size(), 3 ); + Iterator i = callback.getReferences().iterator(); + while( i.hasNext() ) + assertEquals( ((IASTReference)i.next()).getReferencedElement(), classA ); } public void testSimpleField() throws Exception @@ -777,8 +780,18 @@ public class CompleteParseASTTest extends TestCase assertEquals( enumeratorE_1.getOwnerEnumerationSpecifier(), enumE1 ); IASTVariable variableX = (IASTVariable)subB.next(); IASTClassSpecifier classC = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)subB.next()).getTypeSpecifier(); - - + } + + public void testAndrewsExample() throws Exception + { + Iterator declarations = parse( "namespace N{ class A {}; } using namespace N; class B: public A{};").getDeclarations(); + IASTNamespaceDefinition namespaceN = (IASTNamespaceDefinition)declarations.next(); + IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)getDeclarations( namespaceN ).next()).getTypeSpecifier(); + IASTUsingDirective usingClause = (IASTUsingDirective)declarations.next(); + IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); + IASTBaseSpecifier baseSpec = (IASTBaseSpecifier)classB.getBaseClauses().next(); + assertEquals( baseSpec.getParentClassSpecifier(), classA ); + assertEquals( callback.getReferences().size(), 2 ); } // public void testSimpleTypedef() throws Exception diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java index eb31af143a4..4de954467d8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java @@ -397,7 +397,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if( t.getType() == IToken.tCOLONCOLON ) continue; try { - symbol = symbol.LookupNestedNameSpecifier( t.getImage() ); + if( t == parentClassName.getLastToken()) + symbol = (IContainerSymbol)symbol.Lookup( t.getImage() ); + else + symbol = symbol.LookupNestedNameSpecifier( t.getImage() ); references.add( createReference( symbol, t.getImage(), t.getOffset() )); } catch( ParserSymbolTableException pste )