Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAndrew Niefer2004-03-26 10:50:31 -0500
committerAndrew Niefer2004-03-26 10:50:31 -0500
commitbb598c9a999061e2183615092d89dcd1803c9e52 (patch)
tree8d2fa6e27bebe3287ed507963cf59faeef581ee9 /core
parent6475a7ac01032574a959a73e2b8f9c20b3978e1a (diff)
downloadorg.eclipse.cdt-bb598c9a999061e2183615092d89dcd1803c9e52.tar.gz
org.eclipse.cdt-bb598c9a999061e2183615092d89dcd1803c9e52.tar.xz
org.eclipse.cdt-bb598c9a999061e2183615092d89dcd1803c9e52.zip
report references for symbols used in template-ids
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/ChangeLog8
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java28
-rw-r--r--core/org.eclipse.cdt.core/parser/ChangeLog-parser3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java27
4 files changed, 54 insertions, 12 deletions
diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog
index ea2153c6e6..0420314e26 100644
--- a/core/org.eclipse.cdt.core.tests/ChangeLog
+++ b/core/org.eclipse.cdt.core.tests/ChangeLog
@@ -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
-added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testClassTemplateStaticMemberDefinition()
-modified parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.testPointersToMemberFunctions
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 4c636a0d20..66cc44e52e 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
@@ -1516,8 +1516,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertEquals( ((IASTSimpleTypeSpecifier)z.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), A );
assertEquals( ((IASTSimpleTypeSpecifier)z2.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), A );
- assertAllReferences( 8 /*9*/, createTaskList( new Task( T2 ),
- //new Task( T3 ),
+ assertAllReferences( 9, createTaskList( new Task( T2 ),
+ new Task( T3 ),
new Task( A, 3 ),
new Task( z ),
new Task( z2 ),
@@ -1665,12 +1665,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
iter = getDeclarations( main );
IASTVariable a = (IASTVariable) iter.next();
- assertAllReferences( 4 /*5*/, createTaskList( new Task( T ),
- new Task( A ),
- //new Task( B ),
- new Task( a ),
- new Task( i ) ) );
-
+ assertAllReferences( 5, createTaskList( new Task( T ), 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 b = (IASTVariable) getDeclarations( h ).next();
- assertAllReferences( 12, createTaskList( new Task( A ),
+ assertAllReferences( 13, createTaskList( new Task( A ),
new Task( T ),
- new Task( U ),
+ new Task( U, 2 ),
new Task( AU, 2 ),
new Task( au ),
new Task( x, 2 ),
@@ -1777,6 +1772,14 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
writer.write( "A< int > a; \n" );
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{
@@ -1845,9 +1848,14 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
Iterator i = parse( writer.toString() ).getDeclarations();
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
+ IASTTemplateParameter T1 = (IASTTemplateParameter) template.getTemplateParameters().next();
IASTTemplateDeclaration template2 = (IASTTemplateDeclaration) i.next();
+ IASTTemplateParameter T2 = (IASTTemplateParameter) template2.getTemplateParameters().next();
IASTField member = (IASTField) getDeclarations( template2 ).next();
assertEquals( member.getName(), "member" );
+
+ assertReferenceTask( new Task( T1, 2, false, false ) );
+ assertReferenceTask( new Task( T2, 2, false, false ) );
}
}
diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser
index 82281758a2..0e54c2d9a5 100644
--- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser
+++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser
@@ -1,3 +1,6 @@
+2004-03-26 Andrew Niefer
+ -report references to symbols used in a template-id.
+
2004-03-25 Andrew Niefer
-modify IASTFactory.createField & .createVariable to take ITokenDuple's for the name
-modify ITokenDuple to support manipulating TokenDuples that have template arguments in them
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 53a38c696e..27d9922f49 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
@@ -160,6 +160,23 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
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
* Parameters are list of TypeInfos
@@ -356,6 +373,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
((ITemplateFactory)startingScope).pushSymbol( result );
}
addReference( references, createReference( result, image, offset ));
+ if( templateArgLists != null && templateArgLists[idx] != null )
+ addTemplateIdReferences( references, templateArgLists[idx] );
}
else
break;
@@ -1726,9 +1745,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
else
typeSymbol = ((IContainerSymbol)typeSymbol).lookup( image );
- if( typeSymbol != null )
+ if( typeSymbol != null )
+ {
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 );
}
catch (ParserSymbolTableException e)

Back to the top