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

Fix Symbol Table Lookup in addBaseSpecifier() for Andrew.

This commit is contained in:
John Camelon 2003-07-25 14:49:18 +00:00
parent 2ea02e1982
commit 8b6f29d3ad
2 changed files with 20 additions and 4 deletions

View file

@ -652,6 +652,9 @@ public class CompleteParseASTTest extends TestCase
assertEquals( v.getName(), "x"); assertEquals( v.getName(), "x");
assertEquals( ((IASTSimpleTypeSpecifier)v.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), classA ); 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 public void testSimpleField() throws Exception
@ -777,8 +780,18 @@ public class CompleteParseASTTest extends TestCase
assertEquals( enumeratorE_1.getOwnerEnumerationSpecifier(), enumE1 ); assertEquals( enumeratorE_1.getOwnerEnumerationSpecifier(), enumE1 );
IASTVariable variableX = (IASTVariable)subB.next(); IASTVariable variableX = (IASTVariable)subB.next();
IASTClassSpecifier classC = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)subB.next()).getTypeSpecifier(); 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 // public void testSimpleTypedef() throws Exception

View file

@ -397,6 +397,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( t.getType() == IToken.tCOLONCOLON ) continue; if( t.getType() == IToken.tCOLONCOLON ) continue;
try try
{ {
if( t == parentClassName.getLastToken())
symbol = (IContainerSymbol)symbol.Lookup( t.getImage() );
else
symbol = symbol.LookupNestedNameSpecifier( t.getImage() ); symbol = symbol.LookupNestedNameSpecifier( t.getImage() );
references.add( createReference( symbol, t.getImage(), t.getOffset() )); references.add( createReference( symbol, t.getImage(), t.getOffset() ));
} }