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

report references for symbols used in template-ids

This commit is contained in:
Andrew Niefer 2004-03-26 15:50:31 +00:00
parent 6475a7ac01
commit bb598c9a99
4 changed files with 54 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2003-04-26 Andrew Niefer
test references to symbols in template-ids
- modified parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testOverloadedFunctionTemplates_2()
- modified parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testTemplateParameterAsBaseClause()
- modified parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testTypedefedTemplate_2()
- modified parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testInstantiatingDeferredInstances()
- modified parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testClassTemplateStaticMemberDefinition()
2003-04-25 Andrew Niefer 2003-04-25 Andrew Niefer
-added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testClassTemplateStaticMemberDefinition() -added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testClassTemplateStaticMemberDefinition()
-modified parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.testPointersToMemberFunctions -modified parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.testPointersToMemberFunctions

View file

@ -1516,8 +1516,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertEquals( ((IASTSimpleTypeSpecifier)z.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), A ); assertEquals( ((IASTSimpleTypeSpecifier)z.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), A );
assertEquals( ((IASTSimpleTypeSpecifier)z2.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), A ); assertEquals( ((IASTSimpleTypeSpecifier)z2.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), A );
assertAllReferences( 8 /*9*/, createTaskList( new Task( T2 ), assertAllReferences( 9, createTaskList( new Task( T2 ),
//new Task( T3 ), new Task( T3 ),
new Task( A, 3 ), new Task( A, 3 ),
new Task( z ), new Task( z ),
new Task( z2 ), new Task( z2 ),
@ -1665,12 +1665,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
iter = getDeclarations( main ); iter = getDeclarations( main );
IASTVariable a = (IASTVariable) iter.next(); IASTVariable a = (IASTVariable) iter.next();
assertAllReferences( 4 /*5*/, createTaskList( new Task( T ), assertAllReferences( 5, createTaskList( new Task( T ), new Task( A ), new Task( B ), new Task( a ), new Task( i ) ) );
new Task( A ),
//new Task( B ),
new Task( a ),
new Task( i ) ) );
} }
@ -1759,9 +1754,9 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
IASTVariable au = (IASTVariable) getDeclarations( g ).next(); IASTVariable au = (IASTVariable) getDeclarations( g ).next();
IASTVariable b = (IASTVariable) getDeclarations( h ).next(); IASTVariable b = (IASTVariable) getDeclarations( h ).next();
assertAllReferences( 12, createTaskList( new Task( A ), assertAllReferences( 13, createTaskList( new Task( A ),
new Task( T ), new Task( T ),
new Task( U ), new Task( U, 2 ),
new Task( AU, 2 ), new Task( AU, 2 ),
new Task( au ), new Task( au ),
new Task( x, 2 ), new Task( x, 2 ),
@ -1777,6 +1772,14 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
writer.write( "A< int > a; \n" ); writer.write( "A< int > a; \n" );
Iterator i = parse( writer.toString() ).getDeclarations(); Iterator i = parse( writer.toString() ).getDeclarations();
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
IASTTemplateParameter T = (IASTTemplateParameter) template.getTemplateParameters().next();
IASTClassSpecifier A = (IASTClassSpecifier) template.getOwnedDeclaration();
IASTField next = (IASTField) getDeclarations( A ).next();
IASTVariable a = (IASTVariable) i.next();
assertAllReferences( 3, createTaskList( new Task( A, 2 ), new Task( T ) ) );
} }
public void testTemplateArgumentDeduction() throws Exception{ public void testTemplateArgumentDeduction() throws Exception{
@ -1845,9 +1848,14 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
Iterator i = parse( writer.toString() ).getDeclarations(); Iterator i = parse( writer.toString() ).getDeclarations();
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next(); IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
IASTTemplateParameter T1 = (IASTTemplateParameter) template.getTemplateParameters().next();
IASTTemplateDeclaration template2 = (IASTTemplateDeclaration) i.next(); IASTTemplateDeclaration template2 = (IASTTemplateDeclaration) i.next();
IASTTemplateParameter T2 = (IASTTemplateParameter) template2.getTemplateParameters().next();
IASTField member = (IASTField) getDeclarations( template2 ).next(); IASTField member = (IASTField) getDeclarations( template2 ).next();
assertEquals( member.getName(), "member" ); assertEquals( member.getName(), "member" );
assertReferenceTask( new Task( T1, 2, false, false ) );
assertReferenceTask( new Task( T2, 2, false, false ) );
} }
} }

View file

@ -1,3 +1,6 @@
2004-03-26 Andrew Niefer
-report references to symbols used in a template-id.
2004-03-25 Andrew Niefer 2004-03-25 Andrew Niefer
-modify IASTFactory.createField & .createVariable to take ITokenDuple's for the name -modify IASTFactory.createField & .createVariable to take ITokenDuple's for the name
-modify ITokenDuple to support manipulating TokenDuples that have template arguments in them -modify ITokenDuple to support manipulating TokenDuples that have template arguments in them

View file

@ -160,6 +160,23 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
references.add(reference); references.add(reference);
} }
protected void addTemplateIdReferences( List references, List templateArgs ){
if( templateArgs == null )
return;
Iterator i = templateArgs.iterator();
while( i.hasNext() ){
ASTExpression exp = (ASTExpression) i.next();
Iterator j = null;
if( exp.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPEID_TYPEID )
j = ((ASTTypeId) exp.getTypeId()).getReferences().iterator();
else
j = exp.getReferences().iterator();
while( j.hasNext() ){
addReference( references, (IASTReference) j.next() );
}
}
}
/* /*
* Test if the provided list is a valid parameter list * Test if the provided list is a valid parameter list
* Parameters are list of TypeInfos * Parameters are list of TypeInfos
@ -356,6 +373,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
((ITemplateFactory)startingScope).pushSymbol( result ); ((ITemplateFactory)startingScope).pushSymbol( result );
} }
addReference( references, createReference( result, image, offset )); addReference( references, createReference( result, image, offset ));
if( templateArgLists != null && templateArgLists[idx] != null )
addTemplateIdReferences( references, templateArgLists[idx] );
} }
else else
break; break;
@ -1727,8 +1746,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
typeSymbol = ((IContainerSymbol)typeSymbol).lookup( image ); typeSymbol = ((IContainerSymbol)typeSymbol).lookup( image );
if( typeSymbol != null ) if( typeSymbol != null )
{
addReference( references, createReference( typeSymbol, image, offset )); addReference( references, createReference( typeSymbol, image, offset ));
else if( argLists != null && argLists[idx] != null )
addTemplateIdReferences( references, argLists[idx] );
}
else
handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, image ); handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, image );
} }
catch (ParserSymbolTableException e) catch (ParserSymbolTableException e)