mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
This patch is the start of parsing templates. Template uses that don't require a template-id should work.
This commit is contained in:
parent
0fe0020d9f
commit
5a0369683c
35 changed files with 2260 additions and 754 deletions
|
@ -1,3 +1,14 @@
|
|||
2004-03-15 Andrew Niefer
|
||||
Added CompleteParseASTTest.testTemplateClassDeclaration
|
||||
CompleteParseASTTest.testTemplateFunction
|
||||
CompleteParseASTTest.testTemplateFunctionDefinition
|
||||
CompleteParseASTTest.testClassMemberTemplate
|
||||
started CompleteParseASTTest.testOverloadedFunctionTemplates
|
||||
Updated CompleteParseBaseTest to handle templates
|
||||
updated ParserSymbolTableTemplateTests to reflect changes to ITemplateFactory
|
||||
Commented out a couple of ParserSymbolTableTemplateTests until I figure out how the parser will
|
||||
handle those cases
|
||||
|
||||
2004-03-12 Sean Evoy
|
||||
Commit for Jeremiah Lott.
|
||||
Allows the managed build system to resolve "forward references" within its
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
@ -332,4 +333,5 @@ public class CompleteParseASTSymbolIteratorTest extends CompleteParseBaseTest {
|
|||
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
|
@ -1282,6 +1284,178 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
public void testTemplateClassDeclaration() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "template < class T > class A { T t; }; " );
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
|
||||
Iterator params = template.getTemplateParameters();
|
||||
|
||||
IASTTemplateParameter T = (IASTTemplateParameter) params.next();
|
||||
assertEquals( T.getIdentifier(), "T" );
|
||||
assertFalse( params.hasNext() );
|
||||
assertFalse( i.hasNext() );
|
||||
|
||||
i = getDeclarations( template );
|
||||
|
||||
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
assertEquals( classA.getName(), "A" );
|
||||
|
||||
assertFalse( i.hasNext() );
|
||||
|
||||
i = getDeclarations( classA );
|
||||
|
||||
IASTField t = (IASTField) i.next();
|
||||
assertEquals( t.getName(), "t" );
|
||||
|
||||
IASTSimpleTypeSpecifier specifier = (IASTSimpleTypeSpecifier) t.getAbstractDeclaration().getTypeSpecifier();
|
||||
assertEquals( specifier.getTypename(), "T" );
|
||||
//assertEquals( specifier.getTypeSpecifier(), T ); //TODO uncomment when bug 54029 is fixed
|
||||
}
|
||||
|
||||
public void testTemplateFunction() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "template < class T > void f( T t ){} " );
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
|
||||
|
||||
Iterator params = template.getTemplateParameters();
|
||||
|
||||
IASTTemplateParameter T = (IASTTemplateParameter) params.next();
|
||||
assertEquals( T.getIdentifier(), "T" );
|
||||
assertFalse( params.hasNext() );
|
||||
assertFalse( i.hasNext() );
|
||||
|
||||
i = getDeclarations( template );
|
||||
IASTFunction f = (IASTFunction) i.next();
|
||||
assertEquals( f.getName(), "f" );
|
||||
|
||||
params = f.getParameters();
|
||||
IASTParameterDeclaration t = (IASTParameterDeclaration) params.next();
|
||||
assertEquals( t.getName(), "t" );
|
||||
IASTSimpleTypeSpecifier typeSpec = (IASTSimpleTypeSpecifier) t.getTypeSpecifier();
|
||||
assertEquals( typeSpec.getTypename(), "T" );
|
||||
//assertEquals( typeSpec.getTypeSpecifier(), T ); //TODO uncomment when bug 54029 is fixed
|
||||
}
|
||||
|
||||
public void testTemplateFunctionDefinition() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "template <class T> void f( T t );" );
|
||||
writer.write( "template <class U> void f( U u ) { }" );
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
|
||||
|
||||
Iterator params = template.getTemplateParameters();
|
||||
|
||||
IASTTemplateParameter T = (IASTTemplateParameter) params.next();
|
||||
assertEquals( T.getIdentifier(), "T" );
|
||||
assertFalse( params.hasNext() );
|
||||
|
||||
Iterator tempDecls = getDeclarations( template );
|
||||
IASTFunction f = (IASTFunction) tempDecls.next();
|
||||
assertEquals( f.getName(), "f" );
|
||||
assertFalse( f.hasFunctionBody() );
|
||||
assertFalse( tempDecls.hasNext() );
|
||||
|
||||
params = f.getParameters();
|
||||
IASTParameterDeclaration t = (IASTParameterDeclaration) params.next();
|
||||
assertEquals( t.getName(), "t" );
|
||||
IASTSimpleTypeSpecifier typeSpec = (IASTSimpleTypeSpecifier) t.getTypeSpecifier();
|
||||
assertEquals( typeSpec.getTypename(), "T" );
|
||||
//assertEquals( typeSpec.getTypeSpecifier(), T ); //TODO uncomment when bug 54029 is fixed
|
||||
|
||||
IASTTemplateDeclaration template2 = (IASTTemplateDeclaration) i.next();
|
||||
|
||||
params = template2.getTemplateParameters();
|
||||
|
||||
IASTTemplateParameter U = (IASTTemplateParameter) params.next();
|
||||
assertEquals( U.getIdentifier(), "U" );
|
||||
assertFalse( params.hasNext() );
|
||||
|
||||
tempDecls = getDeclarations( template2 );
|
||||
IASTFunction f2 = (IASTFunction) tempDecls.next();
|
||||
assertEquals( f2.getName(), "f" );
|
||||
assertTrue( f2.previouslyDeclared() );
|
||||
|
||||
params = f2.getParameters();
|
||||
IASTParameterDeclaration u = (IASTParameterDeclaration) params.next();
|
||||
assertEquals( u.getName(), "u" );
|
||||
typeSpec = (IASTSimpleTypeSpecifier) u.getTypeSpecifier();
|
||||
assertEquals( typeSpec.getTypename(), "U" );
|
||||
//assertEquals( typeSpec.getTypeSpecifier(), U ); //TODO uncomment when bug 54029 is fixed
|
||||
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
public void testClassMemberTemplate() throws Exception{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "namespace N { " );
|
||||
writer.write( " class A { " );
|
||||
writer.write( " template < class T > T f();" );
|
||||
writer.write( " }; " );
|
||||
writer.write( "}" );
|
||||
writer.write( "template <class U> U N::A::f() {} " );
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTNamespaceDefinition N = (IASTNamespaceDefinition) i.next();
|
||||
|
||||
Iterator i2 = getDeclarations( N );
|
||||
|
||||
IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i2.next()).getTypeSpecifier();
|
||||
assertFalse( i2.hasNext() );
|
||||
|
||||
i2 = getDeclarations( A );
|
||||
|
||||
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i2.next();
|
||||
Iterator params = template.getTemplateParameters();
|
||||
IASTTemplateParameter T = (IASTTemplateParameter) params.next();
|
||||
assertFalse( params.hasNext() );
|
||||
assertFalse( i2.hasNext() );
|
||||
|
||||
i2 = getDeclarations( template );
|
||||
|
||||
IASTMethod f = (IASTMethod) i2.next();
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)f.getReturnType().getTypeSpecifier()).getTypename(), "T" );
|
||||
assertFalse( i2.hasNext() );
|
||||
|
||||
IASTTemplateDeclaration template2 = (IASTTemplateDeclaration) i.next();
|
||||
params = template.getTemplateParameters();
|
||||
IASTTemplateParameter U = (IASTTemplateParameter) params.next();
|
||||
assertFalse( params.hasNext() );
|
||||
assertFalse( i.hasNext() );
|
||||
|
||||
i2 = getDeclarations( template2 );
|
||||
|
||||
IASTMethod f2 = (IASTMethod) i2.next();
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)f2.getReturnType().getTypeSpecifier()).getTypename(), "U" );
|
||||
assertQualifiedName( f2.getFullyQualifiedName(), new String [] { "N", "A", "f" } );
|
||||
assertTrue( f2.previouslyDeclared() );
|
||||
assertFalse( i2.hasNext() );
|
||||
}
|
||||
|
||||
public void testOverloadedFunctionTemplates() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( " template < class T > void f ( T ) {} " );
|
||||
writer.write( " template < class T > void f ( T * ) {} " );
|
||||
writer.write( " int * p;" );
|
||||
writer.write( " void main () {" );
|
||||
writer.write( " f( p );" );
|
||||
writer.write( " f( *p );" );
|
||||
writer.write( " }" );
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
}
|
||||
public void testBug54639() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.eclipse.cdt.core.parser.ast.IASTReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
|
||||
|
@ -347,7 +348,7 @@ public class CompleteParseBaseTest extends TestCase
|
|||
*/
|
||||
public void enterTemplateDeclaration(IASTTemplateDeclaration declaration)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
pushScope( declaration );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -408,8 +409,8 @@ public class CompleteParseBaseTest extends TestCase
|
|||
*/
|
||||
public void exitTemplateDeclaration(IASTTemplateDeclaration declaration)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
popScope();
|
||||
getCurrentScope().addDeclaration( declaration );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -680,6 +681,14 @@ public class CompleteParseBaseTest extends TestCase
|
|||
public Reader createReader(String finalPath) {
|
||||
return ParserUtil.createReader(finalPath);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTemplateParameterReference(org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference)
|
||||
*/
|
||||
public void acceptTemplateParameterReference(IASTTemplateParameterReference reference) {
|
||||
processReference( reference );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,6 @@
|
|||
2004-03-15 Andrew Niefer
|
||||
updated SourceIndexerRequestor with acceptTemplateParameterReference
|
||||
|
||||
2004-03-04 Bogdan Gheorghe
|
||||
Modified SourceIndexer to use BufferedReaders instead of passing in a char array.
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
|
@ -464,6 +465,12 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
|||
|
||||
}
|
||||
|
||||
public void acceptTemplateParameterReference( IASTTemplateParameterReference reference ){
|
||||
if( reference.getReferencedElement() instanceof IASTTemplateParameterReference ){
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
|
||||
private void pushInclude( IASTInclusion inclusion ){
|
||||
includeStack.addFirst( currentInclude );
|
||||
currentInclude = inclusion;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
2004-03-15 Andrew Niefer
|
||||
Templates:
|
||||
- added ISourceElementRequestor.acceptTemplateParameterReference
|
||||
- added throws ASTSemanticException to IASTFactory.createTemplateDeclaration & createTemplateParameter
|
||||
- IASTTemplateDeclaration extends IASTScope, IASTTemplateParameter extends ISourceElementCallbackDelegate
|
||||
- modified DeclarationWrapper.createASTNode & createMethodASTNode to handle member templates
|
||||
- Add functionality to ASTTemplateDeclaration
|
||||
- implemented CompleteParseASTFactory.createTemplateDeclaration & createTemplateParameter
|
||||
- changes to symbol table to make it easier for the parser to use
|
||||
|
||||
2004-03-12 Andrew Niefer
|
||||
handle case causing NPE in CompleteParseASTFactory.createElaboratedTypeSpecifier
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
|
||||
|
@ -94,6 +95,7 @@ public interface ISourceElementRequestor {
|
|||
public void acceptMethodReference( IASTMethodReference reference );
|
||||
public void acceptEnumeratorReference( IASTEnumeratorReference reference );
|
||||
public void acceptParameterReference(IASTParameterReference reference);
|
||||
public void acceptTemplateParameterReference( IASTTemplateParameterReference reference );
|
||||
|
||||
public void exitTemplateDeclaration( IASTTemplateDeclaration declaration );
|
||||
public void exitTemplateSpecialization( IASTTemplateSpecialization specialization );
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
|
||||
|
@ -458,5 +459,14 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
|
|||
*/
|
||||
public Reader createReader(String finalPath) {
|
||||
return InternalParserUtil.createFileReader( finalPath );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTemplateParameterReference(org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference)
|
||||
*/
|
||||
public void acceptTemplateParameterReference(IASTTemplateParameterReference reference)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,9 +208,9 @@ public interface IASTFactory
|
|||
|
||||
public IASTParameterDeclaration createParameterDeclaration( boolean isConst, boolean isVolatile, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endingLine ) ;
|
||||
|
||||
public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset, int startingLine ) ;
|
||||
public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset, int startingLine ) throws ASTSemanticException;
|
||||
|
||||
public IASTTemplateParameter createTemplateParameter( IASTTemplateParameter.ParamKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms ) ;
|
||||
public IASTTemplateParameter createTemplateParameter( IASTTemplateParameter.ParamKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms ) throws ASTSemanticException;
|
||||
|
||||
public IASTTemplateInstantiation createTemplateInstantiation(IASTScope scope, int startingOffset, int startingLine);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTTemplateDeclaration extends IASTDeclaration, IASTTemplate, IASTTemplateParameterList, IASTOffsetableElement {
|
||||
public interface IASTTemplateDeclaration extends IASTDeclaration, IASTTemplate, IASTTemplateParameterList, IASTScope, IASTOffsetableElement {
|
||||
|
||||
public boolean isExported();
|
||||
|
||||
|
|
|
@ -11,12 +11,13 @@
|
|||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
import org.eclipse.cdt.core.parser.Enum;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTTemplateParameter extends IASTTemplateParameterList {
|
||||
public interface IASTTemplateParameter extends IASTTemplateParameterList, ISourceElementCallbackDelegate {
|
||||
|
||||
public class ParamKind extends Enum
|
||||
{
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Created on Mar 8, 2004
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public interface IASTTemplateParameterReference extends IASTReference {
|
||||
}
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
|
@ -322,7 +323,15 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
*/
|
||||
private IASTDeclaration createASTNode(Declarator declarator) throws ASTSemanticException, BacktrackException
|
||||
{
|
||||
boolean isWithinClass = (getScope() instanceof IASTClassSpecifier); //TODO fix this for COMPLETE_PARSE
|
||||
IASTScope scope = getScope();
|
||||
|
||||
boolean isWithinClass = false;//(getScope() instanceof IASTClassSpecifier); //TODO fix this for COMPLETE_PARSE
|
||||
if( scope instanceof IASTClassSpecifier ){
|
||||
isWithinClass = true;
|
||||
} else if ( scope instanceof IASTTemplateDeclaration ){
|
||||
isWithinClass = (((IASTTemplateDeclaration)scope).getOwnerScope() instanceof IASTClassSpecifier);
|
||||
}
|
||||
|
||||
boolean isFunction = declarator.isFunction();
|
||||
boolean hasInnerDeclarator = ( declarator.getOwnedDeclarator() != null );
|
||||
|
||||
|
@ -430,6 +439,10 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
*/
|
||||
private IASTMethod createMethodASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
|
||||
{
|
||||
IASTScope classifierScope = getScope();
|
||||
if( classifierScope instanceof IASTTemplateDeclaration ){
|
||||
classifierScope = ((IASTTemplateDeclaration)classifierScope).getOwnerScope();
|
||||
}
|
||||
return astFactory.createMethod(scope, nested ? declarator
|
||||
.getOwnedDeclarator().getNameDuple() : declarator
|
||||
.getNameDuple(),
|
||||
|
@ -443,7 +456,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
.getNameStartOffset(), declarator.getNameEndOffset(),
|
||||
declarator.getNameLine(), templateDeclaration, declarator
|
||||
.isConst(), declarator.isVolatile(), virtual, explicit,
|
||||
declarator.isPureVirtual(), ((IASTClassSpecifier) scope)
|
||||
declarator.isPureVirtual(), ((IASTClassSpecifier) classifierScope)
|
||||
.getCurrentVisibilityMode(), declarator
|
||||
.getConstructorMemberInitializers(), declarator
|
||||
.hasFunctionBody(), declarator.hasFunctionTryBlock(),
|
||||
|
|
|
@ -495,11 +495,15 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
templateDecl.enterScope( requestor );
|
||||
declaration(scope, templateDecl, null );
|
||||
templateDecl.setEndingOffsetAndLineNumber(
|
||||
lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||
try{
|
||||
declaration(templateDecl, templateDecl, null );
|
||||
} catch( EndOfFileException e ){
|
||||
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||
templateDecl.exitScope( requestor );
|
||||
throw e;
|
||||
}
|
||||
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||
templateDecl.exitScope( requestor );
|
||||
|
||||
}
|
||||
catch (BacktrackException bt)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScopedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -43,7 +44,13 @@ public class ASTQualifiedNamedElement implements IASTQualifiedNameElement
|
|||
if( parent instanceof IASTScopedElement )
|
||||
parent = ((IASTScopedElement)parent).getOwnerScope();
|
||||
}
|
||||
else
|
||||
else if( parent instanceof IASTTemplateDeclaration )
|
||||
{
|
||||
if( parent instanceof IASTScopedElement )
|
||||
parent = ((IASTScopedElement)parent).getOwnerScope();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (names.size() != 0)
|
||||
|
|
|
@ -11,26 +11,62 @@
|
|||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTTemplateDeclaration extends ASTNode implements IASTTemplateDeclaration
|
||||
public class ASTTemplateDeclaration extends ASTSymbol implements IASTTemplateDeclaration
|
||||
{
|
||||
final private List templateParameters;
|
||||
|
||||
private IASTScope ownerScope;
|
||||
private ITemplateFactory factory;
|
||||
private NamedOffsets offsets = new NamedOffsets();
|
||||
|
||||
private ITemplateSymbol getTemplateSymbol(){
|
||||
ISymbol symbol = getSymbol();
|
||||
return (ITemplateSymbol) (( symbol instanceof ITemplateSymbol ) ? symbol : null);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ASTTemplateDeclaration()
|
||||
public ASTTemplateDeclaration( ITemplateSymbol template, IASTScope scope, List parameters )
|
||||
{
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
super( template );
|
||||
|
||||
IContainerSymbol container = ((ASTScope)scope).getContainerSymbol();
|
||||
if( container instanceof ITemplateFactory ){
|
||||
factory = (ITemplateFactory) container;
|
||||
} else {
|
||||
factory = template.getSymbolTable().newTemplateFactory();
|
||||
factory.setContainingSymbol( container );
|
||||
factory.setASTExtension( new StandardSymbolExtension(factory, this ) );
|
||||
}
|
||||
|
||||
factory.pushTemplate( template );
|
||||
|
||||
templateParameters = parameters;
|
||||
ownerScope = scope;
|
||||
}
|
||||
|
||||
public IASTScope getOwnerScope(){
|
||||
return ownerScope;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration#isExported()
|
||||
*/
|
||||
|
@ -44,62 +80,61 @@ public class ASTTemplateDeclaration extends ASTNode implements IASTTemplateDecla
|
|||
*/
|
||||
public IASTDeclaration getOwnedDeclaration()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
IContainerSymbol owned = getTemplateSymbol().getTemplatedSymbol();
|
||||
if( owned != null && owned.getASTExtension() != null ){
|
||||
return owned.getASTExtension().getPrimaryDeclaration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplate#setOwnedDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void setOwnedDeclaration(IASTDeclaration declaration)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void releaseFactory(){
|
||||
factory = null;
|
||||
}
|
||||
|
||||
public IContainerSymbol getContainerSymbol()
|
||||
{
|
||||
return factory != null ? (IContainerSymbol) factory : getTemplateSymbol();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameterList#getTemplateParameters()
|
||||
*/
|
||||
public Iterator getTemplateParameters()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return templateParameters.iterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||
*/
|
||||
public void setStartingOffsetAndLineNumber(int offset, int lineNumber)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
offsets.setStartingOffsetAndLineNumber(offset, lineNumber);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||
*/
|
||||
public void setEndingOffsetAndLineNumber(int offset, int lineNumber)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
offsets.setEndingOffsetAndLineNumber( offset, lineNumber );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset()
|
||||
*/
|
||||
public int getStartingOffset()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return offsets.getStartingOffset();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset()
|
||||
*/
|
||||
public int getEndingOffset()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTScopedElement#getOwnerScope()
|
||||
*/
|
||||
public IASTScope getOwnerScope()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return offsets.getEndingOffset();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
|
@ -112,28 +147,55 @@ public class ASTTemplateDeclaration extends ASTNode implements IASTTemplateDecla
|
|||
*/
|
||||
public void enterScope(ISourceElementRequestor requestor)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
try
|
||||
{
|
||||
requestor.enterTemplateDeclaration(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void exitScope(ISourceElementRequestor requestor)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
try
|
||||
{
|
||||
requestor.exitTemplateDeclaration(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingLine()
|
||||
*/
|
||||
public int getStartingLine() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return offsets.getStartingLine();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingLine()
|
||||
*/
|
||||
public int getEndingLine() {
|
||||
return offsets.getEndingLine();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplate#setOwnedDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void setOwnedDeclaration(IASTDeclaration declaration) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
||||
*/
|
||||
public Iterator getDeclarations() throws ASTNotImplementedException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Created on Mar 3, 2004
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class ASTTemplateParameter extends ASTSymbol implements IASTTemplateParameter, IASTOffsetableNamedElement {
|
||||
|
||||
// private ParamKind kind;
|
||||
// private String identifier;
|
||||
//private ISymbol symbol;
|
||||
private String defaultValue;
|
||||
private ASTParameterDeclaration parameter;
|
||||
private List parms;
|
||||
private final NamedOffsets offsets = new NamedOffsets();
|
||||
|
||||
/**
|
||||
* @param symbol
|
||||
* @param defaultValue2
|
||||
* @param parameter2
|
||||
* @param parms2
|
||||
*/
|
||||
public ASTTemplateParameter(ISymbol sym, String defVal, IASTParameterDeclaration param, List parms ) {
|
||||
super( sym );
|
||||
symbol = sym;
|
||||
defaultValue = defVal;
|
||||
parameter = (ASTParameterDeclaration) param;
|
||||
this.parms = parms;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getTemplateParameterKind()
|
||||
*/
|
||||
public ParamKind getTemplateParameterKind() {
|
||||
TypeInfo.eType type = symbol.getTypeInfo().getTemplateParameterType();
|
||||
if( type == TypeInfo.t_typeName )
|
||||
//TODO: difference between class & typename?
|
||||
return ParamKind.TYPENAME;
|
||||
else if( type == TypeInfo.t_template )
|
||||
return ParamKind.TEMPLATE_LIST;
|
||||
else
|
||||
return ParamKind.PARAMETER;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getIdentifier()
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return symbol.getName();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getDefaultValueIdExpression()
|
||||
*/
|
||||
public String getDefaultValueIdExpression() {
|
||||
return defaultValue;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getParameterDeclaration()
|
||||
*/
|
||||
public IASTParameterDeclaration getParameterDeclaration() {
|
||||
return parameter;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameterList#getTemplateParameters()
|
||||
*/
|
||||
public Iterator getTemplateParameters() {
|
||||
return parms.iterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void acceptElement(ISourceElementRequestor requestor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void enterScope(ISourceElementRequestor requestor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void exitScope(ISourceElementRequestor requestor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return symbol.getName();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameOffset()
|
||||
*/
|
||||
public int getNameOffset() {
|
||||
return offsets.getNameOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o) {
|
||||
offsets.setNameOffset( o );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameEndOffset()
|
||||
*/
|
||||
public int getNameEndOffset() {
|
||||
return offsets.getNameEndOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameEndOffsetAndLineNumber(int, int)
|
||||
*/
|
||||
public void setNameEndOffsetAndLineNumber(int offset, int lineNumber) {
|
||||
offsets.setNameEndOffsetAndLineNumber( offset, lineNumber );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameLineNumber()
|
||||
*/
|
||||
public int getNameLineNumber() {
|
||||
return offsets.getNameLineNumber();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffsetAndLineNumber(int, int)
|
||||
*/
|
||||
public void setStartingOffsetAndLineNumber(int offset, int lineNumber) {
|
||||
offsets.setStartingOffsetAndLineNumber( offset, lineNumber );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffsetAndLineNumber(int, int)
|
||||
*/
|
||||
public void setEndingOffsetAndLineNumber(int offset, int lineNumber) {
|
||||
offsets.setEndingOffsetAndLineNumber( offset, lineNumber );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset()
|
||||
*/
|
||||
public int getStartingOffset() {
|
||||
return offsets.getStartingOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset()
|
||||
*/
|
||||
public int getEndingOffset() {
|
||||
return offsets.getEndingOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingLine()
|
||||
*/
|
||||
public int getStartingLine() {
|
||||
return offsets.getStartingLine();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingLine()
|
||||
*/
|
||||
public int getEndingLine() {
|
||||
return offsets.getEndingLine();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Created on Mar 8, 2004
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class ASTTemplateParameterReference extends ASTReference implements IASTTemplateParameterReference {
|
||||
private final IASTTemplateParameter parameter;
|
||||
/**
|
||||
* @param offset
|
||||
* @param name
|
||||
*/
|
||||
public ASTTemplateParameterReference(int offset, String name, IASTTemplateParameter param) {
|
||||
super(offset, name);
|
||||
parameter = param;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTReference#getReferencedElement()
|
||||
*/
|
||||
public ISourceElementCallbackDelegate getReferencedElement() {
|
||||
return parameter;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void acceptElement(ISourceElementRequestor requestor)
|
||||
{
|
||||
try
|
||||
{
|
||||
requestor.acceptTemplateParameterReference( this );
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void enterScope(ISourceElementRequestor requestor) {
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void exitScope(ISourceElementRequestor requestor) {
|
||||
}
|
||||
}
|
|
@ -83,6 +83,8 @@ import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
|||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IUsingDeclarationSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IUsingDirectiveSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.NamespaceSymbolExtension;
|
||||
|
@ -119,6 +121,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
public static final LookupType UNQUALIFIED = new LookupType( 2 );
|
||||
public static final LookupType FORDEFINITION = new LookupType( 3 );
|
||||
public static final LookupType FORFRIENDSHIP = new LookupType( 4 );
|
||||
public static final LookupType FORPARENTSCOPE = new LookupType( 5 );
|
||||
|
||||
private LookupType( int constant)
|
||||
{
|
||||
|
@ -187,7 +190,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
else {
|
||||
if( lookupType == LookupType.QUALIFIED )
|
||||
result = startingScope.qualifiedFunctionLookup(name, new LinkedList(parameters));
|
||||
else if( lookupType == LookupType.UNQUALIFIED )
|
||||
else if( lookupType == LookupType.UNQUALIFIED || lookupType == LookupType.FORPARENTSCOPE)
|
||||
result = startingScope.unqualifiedFunctionLookup( name, new LinkedList( parameters ) );
|
||||
else if( lookupType == LookupType.FORDEFINITION )
|
||||
result = startingScope.lookupMethodForDefinition( name, new LinkedList( parameters ) );
|
||||
|
@ -201,7 +204,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
// looking for something else
|
||||
if( lookupType == LookupType.QUALIFIED )
|
||||
result = startingScope.qualifiedLookup(name, type);
|
||||
else if( lookupType == LookupType.UNQUALIFIED )
|
||||
else if( lookupType == LookupType.UNQUALIFIED || lookupType == LookupType.FORPARENTSCOPE )
|
||||
result = startingScope.elaboratedLookup( type, name );
|
||||
else if( lookupType == LookupType.FORDEFINITION )
|
||||
result = startingScope.lookupMemberForDefinition( name );
|
||||
|
@ -271,8 +274,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
case 1:
|
||||
firstSymbol = name.getFirstToken();
|
||||
result = lookupElement(startingScope, firstSymbol.getImage(), type, parameters, lookup );
|
||||
if( result != null )
|
||||
if( result != null )
|
||||
{
|
||||
if( lookup == LookupType.FORPARENTSCOPE && startingScope instanceof ITemplateFactory ){
|
||||
((ITemplateFactory)startingScope).pushSymbol( result );
|
||||
}
|
||||
addReference( references, createReference( result, firstSymbol.getImage(), firstSymbol.getOffset() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
if( startingScope.getASTExtension().getPrimaryDeclaration() instanceof IASTCodeScope )
|
||||
|
@ -307,8 +315,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
result = lookupElement((IContainerSymbol)result, t.getImage(), type, parameters, ( lookup == LookupType.FORDEFINITION ) ? lookup : LookupType.QUALIFIED );
|
||||
else
|
||||
result = ((IContainerSymbol)result).lookupNestedNameSpecifier( t.getImage() );
|
||||
if( result != null )
|
||||
if( result != null ){
|
||||
if( lookup == LookupType.FORPARENTSCOPE && startingScope instanceof ITemplateFactory ){
|
||||
((ITemplateFactory)startingScope).pushSymbol( result );
|
||||
}
|
||||
addReference( references, createReference( result, t.getImage(), t.getOffset() ));
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
@ -369,6 +381,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
{
|
||||
if( currentScope instanceof ASTScope )
|
||||
return ((ASTScope)currentScope).getContainerSymbol();
|
||||
else if ( currentScope instanceof ASTTemplateDeclaration )
|
||||
return ((ASTTemplateDeclaration)currentScope).getContainerSymbol();
|
||||
else
|
||||
return scopeToSymbol(((ASTAnonymousDeclaration)currentScope).getOwnerScope());
|
||||
}
|
||||
|
@ -706,10 +720,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return new ASTEnumeratorReference( offset, referenceElementName, (IASTEnumerator)symbol.getASTExtension().getPrimaryDeclaration() );
|
||||
else if(( symbol.getType() == TypeInfo.t_function ) || (symbol.getType() == TypeInfo.t_constructor))
|
||||
{
|
||||
if( symbol.getContainingSymbol().getTypeInfo().isType( TypeInfo.t_class, TypeInfo.t_union ) )
|
||||
return new ASTMethodReference( offset, referenceElementName, (IASTMethod)symbol.getASTExtension().getPrimaryDeclaration() );
|
||||
ASTSymbol referenced = symbol.getASTExtension().getPrimaryDeclaration();
|
||||
if( referenced instanceof IASTMethod )
|
||||
return new ASTMethodReference( offset, referenceElementName, (IASTMethod)referenced );
|
||||
else
|
||||
return new ASTFunctionReference( offset, referenceElementName, (IASTFunction)symbol.getASTExtension().getPrimaryDeclaration() );
|
||||
return new ASTFunctionReference( offset, referenceElementName, (IASTFunction)referenced );
|
||||
}
|
||||
else if( ( symbol.getType() == TypeInfo.t_type ) ||
|
||||
( symbol.getType() == TypeInfo.t_bool )||
|
||||
|
@ -719,7 +734,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
( symbol.getType() == TypeInfo.t_float )||
|
||||
( symbol.getType() == TypeInfo.t_double ) ||
|
||||
( symbol.getType() == TypeInfo.t_void ) ||
|
||||
( symbol.getType() == TypeInfo.t__Bool) )
|
||||
( symbol.getType() == TypeInfo.t__Bool) ||
|
||||
( symbol.getType() == TypeInfo.t_templateParameter ) )
|
||||
|
||||
{
|
||||
if( symbol.getContainingSymbol().getType() == TypeInfo.t_class ||
|
||||
|
@ -743,6 +759,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return new ASTVariableReference( offset, referenceElementName, (IASTVariable)s);
|
||||
else if (s instanceof IASTParameterDeclaration)
|
||||
return new ASTParameterReference( offset, referenceElementName, (IASTParameterDeclaration)s);
|
||||
else if (s instanceof IASTTemplateParameter )
|
||||
return new ASTTemplateParameterReference( offset, referenceElementName, (IASTTemplateParameter)s );
|
||||
}
|
||||
}
|
||||
// assert false : "Unreachable code : createReference()";
|
||||
|
@ -1625,7 +1643,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ownerScope,
|
||||
name.getSubrange( 0, name.findLastTokenType( IToken.tCOLONCOLON ) - 1),
|
||||
references,
|
||||
false );
|
||||
false,
|
||||
LookupType.FORPARENTSCOPE );
|
||||
|
||||
|
||||
if((parentScope != null) &&
|
||||
|
@ -1963,7 +1982,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
boolean isConstructor = false;
|
||||
boolean isDestructor = false;
|
||||
|
||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||
IContainerSymbol ownerScope = scopeToSymbol( ownerTemplate != null ? (IASTScope) ownerTemplate : scope );
|
||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( nameDuple.toString(), TypeInfo.t_function );
|
||||
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
||||
setMethodTypeInfoBits( symbol, isConst, isVolatile, isVirtual, isExplicit );
|
||||
|
@ -1976,7 +1995,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
setParameter( symbol, returnType, false, references );
|
||||
setParameters( symbol, references, parameters.iterator() );
|
||||
|
||||
String parentName = ((IASTClassSpecifier)scope).getName();
|
||||
IASTClassSpecifier classifier = null;
|
||||
if( scope instanceof IASTTemplateDeclaration ){
|
||||
classifier = (IASTClassSpecifier) ((IASTTemplateDeclaration)scope).getOwnerScope();
|
||||
} else {
|
||||
classifier = (IASTClassSpecifier) scope;
|
||||
}
|
||||
String parentName = classifier.getName();
|
||||
|
||||
// check constructor / destructor if no return type
|
||||
if ( returnType.getTypeSpecifier() == null ){
|
||||
|
@ -2434,10 +2459,28 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
IASTScope scope,
|
||||
List templateParameters,
|
||||
boolean exported,
|
||||
int startingOffset, int startingLine)
|
||||
int startingOffset, int startingLine) throws ASTSemanticException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return new ASTTemplateDeclaration();
|
||||
ITemplateSymbol template = pst.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||
|
||||
List functionParameters = new LinkedList();
|
||||
// the lookup requires a list of type infos
|
||||
// instead of a list of IASTParameterDeclaration
|
||||
Iterator iter = templateParameters.iterator();
|
||||
while (iter.hasNext()){
|
||||
ASTTemplateParameter param = (ASTTemplateParameter)iter.next();
|
||||
try {
|
||||
template.addTemplateParameter( param.getSymbol() );
|
||||
} catch (ParserSymbolTableException e) {
|
||||
handleProblem( e.createProblemID(), "", startingOffset, -1, startingLine );
|
||||
}
|
||||
}
|
||||
|
||||
ASTTemplateDeclaration ast = new ASTTemplateDeclaration( template, scope, templateParameters);
|
||||
|
||||
attachSymbolExtension( template, ast, false );
|
||||
|
||||
return ast;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateParameter(org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind, java.lang.String, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration, java.util.List)
|
||||
|
@ -2447,10 +2490,25 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
String identifier,
|
||||
String defaultValue,
|
||||
IASTParameterDeclaration parameter,
|
||||
List parms)
|
||||
List parms ) throws ASTSemanticException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
ISymbol symbol = ( kind != ParamKind.PARAMETER ) ? pst.newSymbol( identifier, TypeInfo.t_templateParameter ) : null;
|
||||
if( kind == ParamKind.CLASS || kind == ParamKind.TYPENAME ){
|
||||
symbol.getTypeInfo().setTemplateParameterType( TypeInfo.t_typeName );
|
||||
} else if ( kind == ParamKind.TEMPLATE_LIST ){
|
||||
symbol.getTypeInfo().setTemplateParameterType( TypeInfo.t_template );
|
||||
} else /*ParamKind.PARAMETER*/ {
|
||||
symbol = ((ASTParameterDeclaration)parameter).getSymbol();
|
||||
symbol.getTypeInfo().setTemplateParameterType( symbol.getType() );
|
||||
symbol.setType( TypeInfo.t_templateParameter );
|
||||
}
|
||||
|
||||
ASTTemplateParameter ast = new ASTTemplateParameter( symbol, defaultValue, parameter, parms );
|
||||
|
||||
//TODO what if the symbol was ParamKind.PARAMETER?
|
||||
attachSymbolExtension( symbol, ast, false );
|
||||
|
||||
return ast;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateInstantiation(org.eclipse.cdt.core.parser.ast.IASTScope, int)
|
||||
|
@ -2669,7 +2727,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
// won't get thrown
|
||||
}
|
||||
if( lookupSymbol == null ) return false;
|
||||
if( lookupSymbol.isType( TypeInfo.t_type, TypeInfo.t_enumeration ) ) return true;
|
||||
if( lookupSymbol.isType( TypeInfo.t_type, TypeInfo.t_enumeration ) ||
|
||||
( lookupSymbol.isType( TypeInfo.t_templateParameter ) &&
|
||||
lookupSymbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
|
@ -150,5 +152,14 @@ public class ASTTemplateDeclaration extends ASTDeclaration implements IASTTempla
|
|||
public int getEndingLine() {
|
||||
return offsets.getEndingLine();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
||||
*/
|
||||
public Iterator getDeclarations() throws ASTNotImplementedException {
|
||||
List decls = new LinkedList();
|
||||
decls.add( getOwnedDeclaration() );
|
||||
return decls.iterator();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.ast.quick;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
|
||||
|
||||
|
@ -76,4 +77,21 @@ public class ASTTemplateParameter implements IASTTemplateParameter
|
|||
{
|
||||
return parameter;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void acceptElement(ISourceElementRequestor requestor) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void enterScope(ISourceElementRequestor requestor) {
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void exitScope(ISourceElementRequestor requestor) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -719,7 +719,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#templateLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public ISymbol lookupTemplate( String name, List arguments ) throws ParserSymbolTableException
|
||||
public ISymbol lookupTemplateId( String name, List arguments ) throws ParserSymbolTableException
|
||||
{
|
||||
LookupData data = new LookupData( name, TypeInfo.t_any );
|
||||
|
||||
|
@ -737,48 +737,56 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
return null;
|
||||
}
|
||||
|
||||
public ITemplateFactory lookupTemplateForMemberDefinition( String name, List parameters, List arguments ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name, TypeInfo.t_any );
|
||||
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
|
||||
Object look = null;
|
||||
try{
|
||||
look = ParserSymbolTable.resolveAmbiguities( data );
|
||||
} catch ( ParserSymbolTableException e ){
|
||||
if( e.reason != ParserSymbolTableException.r_UnableToResolveFunction ){
|
||||
throw e;
|
||||
}
|
||||
if( !data.foundItems.isEmpty() ){
|
||||
look = data.foundItems.get( name );
|
||||
if(!( look instanceof List ) ){
|
||||
throw new ParserSymbolTableError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ITemplateSymbol template = (ITemplateSymbol) (( look instanceof ITemplateSymbol ) ? look : null);
|
||||
if( template == null ){
|
||||
if( look instanceof ISymbol ){
|
||||
ISymbol symbol = (ISymbol) look;
|
||||
if( symbol.isTemplateMember() && symbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
||||
template = (ITemplateSymbol) symbol.getContainingSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if( template != null ){
|
||||
template = TemplateEngine.selectTemplateOrSpecialization( template, parameters, arguments );
|
||||
if( template != null ){
|
||||
return new TemplateFactory( template, parameters, arguments );
|
||||
}
|
||||
} else if ( look instanceof List ){
|
||||
return new TemplateFactory( new HashSet( (List)look ), parameters, arguments );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupTemplateIdForDefinition(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IContainerSymbol lookupTemplateIdForDefinition(String name, List arguments) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
// public ITemplateFactory lookupTemplateForMemberDefinition( String name, List parameters, List arguments ) throws ParserSymbolTableException{
|
||||
// LookupData data = new LookupData( name, TypeInfo.t_any );
|
||||
//
|
||||
// ParserSymbolTable.lookup( data, this );
|
||||
//
|
||||
// Object look = null;
|
||||
// try{
|
||||
// look = ParserSymbolTable.resolveAmbiguities( data );
|
||||
// } catch ( ParserSymbolTableException e ){
|
||||
// if( e.reason != ParserSymbolTableException.r_UnableToResolveFunction ){
|
||||
// throw e;
|
||||
// }
|
||||
// if( !data.foundItems.isEmpty() ){
|
||||
// look = data.foundItems.get( name );
|
||||
// if(!( look instanceof List ) ){
|
||||
// throw new ParserSymbolTableError();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ITemplateSymbol template = (ITemplateSymbol) (( look instanceof ITemplateSymbol ) ? look : null);
|
||||
// if( template == null ){
|
||||
// if( look instanceof ISymbol ){
|
||||
// ISymbol symbol = (ISymbol) look;
|
||||
// if( symbol.isTemplateMember() && symbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
||||
// template = (ITemplateSymbol) symbol.getContainingSymbol();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if( template != null ){
|
||||
// template = TemplateEngine.selectTemplateOrSpecialization( template, parameters, arguments );
|
||||
// if( template != null ){
|
||||
// return new TemplateFactory( template, parameters, arguments );
|
||||
// }
|
||||
// } else if ( look instanceof List ){
|
||||
// return new TemplateFactory( new HashSet( (List)look ), parameters, arguments );
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
public List prefixLookup( TypeFilter filter, String prefix, boolean qualified ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( prefix, filter );
|
||||
|
@ -1056,4 +1064,5 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
private LinkedList _usingDirectives; //collection of nominated namespaces
|
||||
private Map _containedSymbols; //declarations contained by us.
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -116,7 +116,9 @@ public interface IContainerSymbol extends ISymbol {
|
|||
* r_Ambiguous if (14.5.4.1) more than one specialization can be used and none is more specializaed than all the others
|
||||
* r_BadTemplateArgument if (14.3.1, 14.3.2) a template argument is invalid
|
||||
*/
|
||||
public ISymbol lookupTemplate( String name, List arguments ) throws ParserSymbolTableException;
|
||||
public ISymbol lookupTemplateId( String name, List arguments ) throws ParserSymbolTableException;
|
||||
|
||||
public IContainerSymbol lookupTemplateIdForDefinition( String name, List arguments ) throws ParserSymbolTableException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -129,8 +131,8 @@ public interface IContainerSymbol extends ISymbol {
|
|||
* r_BadTemplateParameter if (14.5.1-3) the parameters provided can't be matched up to a template declaration
|
||||
* r_BadTemplate if the parameter and argument list can't be resolved to either the template or a specialization
|
||||
*/
|
||||
public ITemplateFactory lookupTemplateForMemberDefinition( String name, List templateParameters,
|
||||
List templateArguments ) throws ParserSymbolTableException;
|
||||
// public ITemplateFactory lookupTemplateForMemberDefinition( String name, List templateParameters,
|
||||
// List templateArguments ) throws ParserSymbolTableException;
|
||||
|
||||
public boolean isVisible( ISymbol symbol, IContainerSymbol qualifyingSymbol );
|
||||
|
||||
|
|
|
@ -16,16 +16,10 @@ import java.util.List;
|
|||
* @author aniefer
|
||||
**/
|
||||
|
||||
public interface ITemplateFactory {
|
||||
|
||||
public void addSymbol( ISymbol symbol ) throws ParserSymbolTableException;
|
||||
|
||||
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol lookupMemberFunctionForDefinition( String name, List params ) throws ParserSymbolTableException;
|
||||
|
||||
public ITemplateFactory lookupTemplateForMemberDefinition( String name, List templateParameters,
|
||||
List templateArguments ) throws ParserSymbolTableException;
|
||||
public interface ITemplateFactory extends IDerivableContainerSymbol {
|
||||
public ITemplateSymbol getPrimaryTemplate();
|
||||
|
||||
public ISymbol lookupParam( String name ) throws ParserSymbolTableException;
|
||||
public void pushTemplate( ITemplateSymbol template );
|
||||
public void pushSymbol( ISymbol symbol );
|
||||
public void pushTemplateId( ISymbol symbol, List args );
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
int size = ( getParameterList() == null ) ? 0 : getParameterList().size();
|
||||
int fsize = ( function.getParameterList() == null ) ? 0 : function.getParameterList().size();
|
||||
if( fsize != size ){
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
if( fsize == 0 )
|
||||
return true;
|
||||
|
@ -205,8 +205,11 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
TypeInfo fInfo = null;
|
||||
|
||||
for( int i = size; i > 0; i-- ){
|
||||
info = ((BasicSymbol)iter.next()).getTypeInfo();
|
||||
fInfo = ((BasicSymbol) fIter.next()).getTypeInfo();
|
||||
ISymbol p = (ISymbol) iter.next();
|
||||
ISymbol pf = (ISymbol) fIter.next();
|
||||
|
||||
info = p.getTypeInfo();
|
||||
fInfo = pf.getTypeInfo();
|
||||
|
||||
//parameters that differ only in the use of equivalent typedef types are equivalent.
|
||||
info = ParserSymbolTable.getFlatTypeInfo( info );
|
||||
|
@ -259,6 +262,8 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
*/
|
||||
public void setReturnType( ISymbol type ){
|
||||
_returnType = type;
|
||||
_returnType.setContainingSymbol( this );
|
||||
_returnType.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -89,6 +89,11 @@ public class ParserSymbolTable {
|
|||
public ISpecializedSymbol newSpecializedSymbol( String name ){
|
||||
return new SpecializedSymbol( this, name );
|
||||
}
|
||||
|
||||
public ITemplateFactory newTemplateFactory(){
|
||||
return new TemplateFactory( this );
|
||||
}
|
||||
|
||||
// public ISpecializedSymbol newSpecializedSymbol( String name, TypeInfo.eType type ){
|
||||
// return new Declaration( this, name, type );
|
||||
// }
|
||||
|
@ -461,7 +466,9 @@ public class ParserSymbolTable {
|
|||
foundSymbol = symbol;
|
||||
|
||||
if( foundSymbol.isType( TypeInfo.t_function ) ){
|
||||
if( foundSymbol.isForwardDeclaration() && foundSymbol.getTypeSymbol() != null ){
|
||||
if( foundSymbol.isForwardDeclaration() && foundSymbol.getTypeSymbol() != null &&
|
||||
foundSymbol.getTypeSymbol().getContainingSymbol() == foundSymbol.getContainingSymbol() )
|
||||
{
|
||||
foundSymbol = foundSymbol.getTypeSymbol();
|
||||
}
|
||||
if( foundSymbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
||||
|
@ -555,7 +562,7 @@ public class ParserSymbolTable {
|
|||
}
|
||||
|
||||
if( numTemplateFunctions > 0 ){
|
||||
if( data.parameters != null ){
|
||||
if( data.parameters != null && !data.exactFunctionsOnly ){
|
||||
List fns = TemplateEngine.selectTemplateFunctions( templateFunctionSet, data.parameters );
|
||||
functionSet.addAll( fns );
|
||||
numFunctions = functionSet.size();
|
||||
|
@ -940,6 +947,16 @@ public class ParserSymbolTable {
|
|||
|
||||
reduceToViable( data, functions );
|
||||
|
||||
if( data.exactFunctionsOnly ){
|
||||
if( functions.size() == 1 ){
|
||||
return (IParameterizedSymbol) functions.get( 0 );
|
||||
} else if( functions.size() == 0 ){
|
||||
return null;
|
||||
} else {
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
||||
}
|
||||
}
|
||||
|
||||
int numSourceParams = ( data.parameters == null ) ? 0 : data.parameters.size();
|
||||
int numFns = functions.size();
|
||||
|
||||
|
@ -1932,7 +1949,9 @@ public class ParserSymbolTable {
|
|||
returnInfo.setTypeSymbol( null );
|
||||
returnInfo.addPtrOperator( info.getPtrOperators() );
|
||||
}
|
||||
|
||||
if( returnInfo.isType( TypeInfo.t_templateParameter ) ){
|
||||
returnInfo.setTypeSymbol( typeSymbol );
|
||||
}
|
||||
returnInfo.applyOperatorExpressions( topInfo.getOperatorExpressions() );
|
||||
|
||||
if( topInfo.hasPtrOperators() ){
|
||||
|
@ -2034,6 +2053,7 @@ public class ParserSymbolTable {
|
|||
public HashSet inheritanceChain; //used to detect circular inheritance
|
||||
|
||||
public List parameters; //parameter info for resolving functions
|
||||
public List templateParameters; //template parameters
|
||||
public HashSet associated; //associated namespaces for argument dependant lookup
|
||||
public ISymbol stopAt; //stop looking along the stack once we hit this declaration
|
||||
public TypeFilter filter = null;
|
||||
|
|
|
@ -1217,4 +1217,27 @@ public final class TemplateEngine {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
static protected boolean templateParametersAreEquivalent( ISymbol p1, ISymbol p2 ){
|
||||
if( !p1.isType( TypeInfo.t_templateParameter ) || !p2.isType( TypeInfo.t_templateParameter ) ||
|
||||
p1.getTypeInfo().getTemplateParameterType() != p2.getTypeInfo().getTemplateParameterType() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ITemplateSymbol t1 = (ITemplateSymbol) p1.getContainingSymbol();
|
||||
ITemplateSymbol t2 = (ITemplateSymbol) p2.getContainingSymbol();
|
||||
|
||||
if( p1.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName )
|
||||
{
|
||||
List l1 = t1.getParameterList(), l2 = t2.getParameterList();
|
||||
return ( l1 != null && l2 != null && l1.indexOf( p1 ) == l2.indexOf( p2 ) );
|
||||
} else if( p1.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){
|
||||
ITemplateSymbol pt1 = (ITemplateSymbol)p1.getTypeSymbol();
|
||||
ITemplateSymbol pt2 = (ITemplateSymbol)p2.getTypeSymbol();
|
||||
return checkTemplateParameterListsAreEquivalent( pt1.getParameterList(), pt2.getParameterList() );
|
||||
} else {
|
||||
return p1.getTypeInfo().equals( p2.getTypeInfo() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,120 +14,208 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.LookupData;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class TemplateFactory implements ITemplateFactory {
|
||||
public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactory {
|
||||
|
||||
protected TemplateFactory( ITemplateSymbol primary, List params, List args ){
|
||||
templatesList = new LinkedList();
|
||||
templatesList.add( primary );
|
||||
|
||||
parametersList = new LinkedList();
|
||||
parametersList.add( new LinkedList( params ) );
|
||||
|
||||
argumentsList = new LinkedList();
|
||||
argumentsList.add( args != null ? new LinkedList( args ) : new LinkedList() );
|
||||
private IContainerSymbol lastSymbol;
|
||||
|
||||
private List templates = new LinkedList();
|
||||
private List symbols = new LinkedList();
|
||||
private Map argMap = new HashMap();
|
||||
|
||||
protected TemplateFactory( ParserSymbolTable table ){
|
||||
super( table );
|
||||
}
|
||||
|
||||
protected TemplateFactory( List templates, List params, List args ){
|
||||
templatesList = templates;
|
||||
parametersList = params;
|
||||
argumentsList = args;
|
||||
public void pushTemplate(ITemplateSymbol template ) {
|
||||
templates.add( template );
|
||||
}
|
||||
|
||||
public void pushSymbol(ISymbol symbol) {
|
||||
symbols.add( symbol );
|
||||
}
|
||||
|
||||
protected TemplateFactory( Set functions, List params, List args ){
|
||||
templatesList = new LinkedList();
|
||||
templateFunctions = functions;
|
||||
|
||||
parametersList = new LinkedList();
|
||||
parametersList.add( new LinkedList( params ) );
|
||||
|
||||
argumentsList = new LinkedList();
|
||||
argumentsList.add( args != null ? new LinkedList( args ) : new LinkedList() );
|
||||
public void pushTemplateId(ISymbol symbol, List args) {
|
||||
symbols.add( symbol );
|
||||
argMap.put( symbol, new LinkedList( args ) );
|
||||
}
|
||||
|
||||
public ITemplateFactory lookupTemplateForMemberDefinition( String name, List parameters, List arguments ) throws ParserSymbolTableException{
|
||||
if( templatesList == null || templatesList.isEmpty() ){
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addSymbol(ISymbol symbol) throws ParserSymbolTableException {
|
||||
lastSymbol = (IContainerSymbol) (( symbols.size() > 0 ) ? symbols.get( symbols.size() - 1) : null);
|
||||
|
||||
ITemplateSymbol template = (ITemplateSymbol) templatesList.get( 0 );
|
||||
IContainerSymbol symbol = template.getTemplatedSymbol();
|
||||
LookupData data = new LookupData( name, TypeInfo.t_any ); //, null );
|
||||
Iterator iter = symbols.iterator();
|
||||
ListIterator tIter = templates.listIterator();
|
||||
|
||||
ParserSymbolTable.lookup( data, symbol );
|
||||
|
||||
ISymbol look = ParserSymbolTable.resolveAmbiguities( data );
|
||||
|
||||
if( look.getContainingSymbol() instanceof ITemplateSymbol ){
|
||||
template = TemplateEngine.selectTemplateOrSpecialization( (ITemplateSymbol) look.getContainingSymbol(), parameters, arguments );
|
||||
if( template != null ){
|
||||
List newTemplatesList = new LinkedList( templatesList );
|
||||
List newParamsList = new LinkedList( parametersList );
|
||||
List newArgsList = new LinkedList( argumentsList );
|
||||
|
||||
newTemplatesList.add( template );
|
||||
newParamsList.add( new LinkedList( parameters ) );
|
||||
newArgsList.add( arguments != null ? new LinkedList( arguments ) : new LinkedList() );
|
||||
|
||||
return new TemplateFactory( newTemplatesList, newParamsList, newArgsList );
|
||||
ISymbol sym = null;
|
||||
while( iter.hasNext() ){
|
||||
sym = (ISymbol) iter.next();
|
||||
if( !sym.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
||||
iter.remove();
|
||||
} else if( tIter.hasNext() ) {
|
||||
// ITemplateSymbol template = (ITemplateSymbol) tIter.next();
|
||||
// List args = (List) argMap.get( sym );
|
||||
// template = TemplateEngine.selectTemplateOrSpecialization( (ITemplateSymbol) sym.getContainingSymbol(), template.getParameterList(), args );
|
||||
// tIter.set( template );
|
||||
} else {
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory#addSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public void addSymbol( ISymbol symbol ) throws ParserSymbolTableException {
|
||||
if( ((List)getParametersList().get( 0 )).isEmpty() ){
|
||||
addExplicitSpecialization( symbol );
|
||||
int numTemplates = templates.size();
|
||||
int numSymbols = symbols.size();
|
||||
|
||||
if( numTemplates == numSymbols + 1 ){
|
||||
//basic template declaration or Definition
|
||||
basicTemplateDeclaration( symbol );
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator templatesIter = getTemplatesList().iterator();
|
||||
Iterator parametersIter = getParametersList().iterator();
|
||||
|
||||
while( templatesIter.hasNext() ){
|
||||
Map defnMap = new HashMap();
|
||||
|
||||
ITemplateSymbol template = (ITemplateSymbol) templatesIter.next();
|
||||
|
||||
Iterator tempIter = template.getParameterList().iterator();
|
||||
|
||||
if( !parametersIter.hasNext() ){
|
||||
throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
|
||||
}
|
||||
|
||||
List params = (List) parametersIter.next();
|
||||
Iterator iter = params.iterator();
|
||||
|
||||
while( iter.hasNext() ){
|
||||
ISymbol param = (ISymbol) iter.next();
|
||||
ISymbol tempParam = (ISymbol) tempIter.next();
|
||||
defnMap.put( param, tempParam );
|
||||
}
|
||||
|
||||
template.getDefinitionParameterMap().put( symbol, defnMap );
|
||||
}
|
||||
|
||||
ITemplateSymbol template = (ITemplateSymbol) getTemplatesList().get( getTemplatesList().size() - 1 );
|
||||
IContainerSymbol container = template.getTemplatedSymbol();
|
||||
|
||||
if( container.isForwardDeclaration() && container.getTypeSymbol() == symbol ){
|
||||
template.addSymbol( symbol );
|
||||
} else {
|
||||
container.addSymbol( symbol );
|
||||
if( numTemplates == numSymbols ){
|
||||
//all of the templates were matched to a symbol, we are doing a member
|
||||
memberDeclaration( symbol );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ISymbol findPreviousSymbol( ISymbol symbol ) throws ParserSymbolTableException{
|
||||
ISymbol previous = null;
|
||||
|
||||
List argList = null;
|
||||
if( symbol instanceof IParameterizedSymbol ){
|
||||
argList = new LinkedList();
|
||||
Iterator i = ((IParameterizedSymbol)symbol).getParameterList().iterator();
|
||||
while( i.hasNext() ){
|
||||
ISymbol param = (ISymbol) i.next();
|
||||
argList.add( param.getTypeInfo() );
|
||||
}
|
||||
}
|
||||
|
||||
if( symbol.isType( TypeInfo.t_function ) ){
|
||||
previous = lookupMethodForDefinition( symbol.getName(), argList );
|
||||
} else if ( symbol.isType( TypeInfo.t_constructor ) ){
|
||||
previous = lookupConstructor( argList );
|
||||
} else {
|
||||
previous = lookupMemberForDefinition( symbol.getName() );
|
||||
}
|
||||
return previous;
|
||||
}
|
||||
|
||||
private void basicTemplateDeclaration( ISymbol symbol ) throws ParserSymbolTableException{
|
||||
ITemplateSymbol template = (ITemplateSymbol)templates.get( 0 );
|
||||
if( template.getParameterList().size() == 0 ){
|
||||
//explicit specialization
|
||||
} else {
|
||||
ISymbol previous = findPreviousSymbol( symbol );
|
||||
|
||||
if( previous == null ){
|
||||
//new template
|
||||
template.setName( symbol.getName () );
|
||||
template.addSymbol( symbol );
|
||||
getContainingSymbol().addSymbol( template );
|
||||
if( getASTExtension() != null ){
|
||||
ASTTemplateDeclaration templateDecl = (ASTTemplateDeclaration) getASTExtension().getPrimaryDeclaration();
|
||||
templateDecl.releaseFactory();
|
||||
}
|
||||
} else {
|
||||
//definition for something declared already
|
||||
ITemplateSymbol originalTemplate = null;
|
||||
ISymbol originalSymbol = null;
|
||||
|
||||
if( previous instanceof ITemplateSymbol ){
|
||||
originalTemplate = (ITemplateSymbol) previous;
|
||||
originalSymbol = originalTemplate.getTemplatedSymbol();
|
||||
} else {
|
||||
if( previous.getContainingSymbol() instanceof ITemplateSymbol ){
|
||||
originalTemplate = (ITemplateSymbol) previous.getContainingSymbol();
|
||||
originalSymbol = previous;
|
||||
} else {
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
}
|
||||
}
|
||||
|
||||
if( originalSymbol.isForwardDeclaration() ){
|
||||
|
||||
if( originalTemplate.getParameterList().size() != template.getParameterList().size() ){
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
}
|
||||
|
||||
symbols.add( originalSymbol );
|
||||
doDefinitionParameterMaps( symbol );
|
||||
|
||||
originalTemplate.addSymbol( symbol );
|
||||
|
||||
if( getASTExtension() != null ){
|
||||
ASTTemplateDeclaration templateDecl = (ASTTemplateDeclaration) getASTExtension().getPrimaryDeclaration();
|
||||
templateDecl.releaseFactory();
|
||||
}
|
||||
} else {
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidOverload );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void memberDeclaration( ISymbol symbol ) throws ParserSymbolTableException{
|
||||
ISymbol previous = findPreviousSymbol( symbol );
|
||||
if( previous == null ) {
|
||||
//??
|
||||
} else {
|
||||
IContainerSymbol originalContainer = previous.getContainingSymbol();
|
||||
|
||||
if( previous.isForwardDeclaration() ){
|
||||
doDefinitionParameterMaps( symbol );
|
||||
|
||||
originalContainer.addSymbol( symbol );
|
||||
|
||||
if( getASTExtension() != null ){
|
||||
ASTTemplateDeclaration templateDecl = (ASTTemplateDeclaration) getASTExtension().getPrimaryDeclaration();
|
||||
templateDecl.releaseFactory();
|
||||
}
|
||||
} else {
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidOverload );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void doDefinitionParameterMaps( ISymbol newSymbol ) throws ParserSymbolTableException {
|
||||
if( templates.size() != symbols.size() ){
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
}
|
||||
|
||||
Iterator tempIter = templates.iterator();
|
||||
Iterator symIter = symbols.iterator();
|
||||
|
||||
while( tempIter.hasNext() ){
|
||||
Map defnMap = new HashMap();
|
||||
|
||||
ITemplateSymbol template = (ITemplateSymbol) tempIter.next();
|
||||
ITemplateSymbol origTemplate = (ITemplateSymbol) ((ISymbol)symIter.next()).getContainingSymbol();
|
||||
|
||||
Iterator params = template.getParameterList().iterator();
|
||||
Iterator origParams = origTemplate.getParameterList().iterator();
|
||||
|
||||
while( params.hasNext() ){
|
||||
ISymbol param = (ISymbol) params.next();
|
||||
ISymbol origParam = (ISymbol) origParams.next();
|
||||
defnMap.put( param, origParam );
|
||||
}
|
||||
|
||||
origTemplate.getDefinitionParameterMap().put( newSymbol, defnMap );
|
||||
}
|
||||
}
|
||||
|
||||
private void addExplicitSpecialization( ISymbol symbol ) throws ParserSymbolTableException {
|
||||
Iterator templatesIter = getTemplatesList().iterator();
|
||||
Iterator argsIter = getArgumentsList().iterator();
|
||||
|
@ -153,27 +241,18 @@ public class TemplateFactory implements ITemplateFactory {
|
|||
* @see org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory#lookupMemberForDefinition(java.lang.String)
|
||||
*/
|
||||
public ISymbol lookupMemberForDefinition(String name) throws ParserSymbolTableException {
|
||||
if( getTemplateFunctions() != null ){
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
||||
ISymbol look = null;
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
look = ((IContainerSymbol)symbol).lookupMemberForDefinition( name );
|
||||
} else {
|
||||
look = getContainingSymbol().lookupMemberForDefinition( name );
|
||||
}
|
||||
Set keys = getPrimaryTemplate().getContainedSymbols().keySet();
|
||||
IContainerSymbol symbol = (IContainerSymbol) getPrimaryTemplate().getContainedSymbols().get( keys.iterator().next() );
|
||||
|
||||
return symbol.lookupMemberForDefinition( name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory#lookupMemberFunctionForDefinition(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol lookupMemberFunctionForDefinition( String name, List params) throws ParserSymbolTableException {
|
||||
if( getTemplateFunctions() != null ){
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
||||
if( look instanceof ITemplateSymbol ){
|
||||
return ((ITemplateSymbol)look).getTemplatedSymbol();
|
||||
} else {
|
||||
return look;
|
||||
}
|
||||
|
||||
Set keys = getPrimaryTemplate().getContainedSymbols().keySet();
|
||||
IContainerSymbol symbol = (IContainerSymbol) getPrimaryTemplate().getContainedSymbols().get( keys.iterator().next() );
|
||||
|
||||
return symbol.lookupMethodForDefinition( name, params );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -183,24 +262,6 @@ public class TemplateFactory implements ITemplateFactory {
|
|||
return (ITemplateSymbol) templatesList.get( 0 );
|
||||
}
|
||||
|
||||
public ISymbol lookupParam( String name ) throws ParserSymbolTableException{
|
||||
Iterator iter = getParametersList().iterator();
|
||||
|
||||
while( iter.hasNext() ){
|
||||
List list = (List) iter.next();
|
||||
Iterator params = list.iterator();
|
||||
while( params.hasNext() ){
|
||||
ISymbol p = (ISymbol) params.next();
|
||||
if( p.getName().equals( name ) ){
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getPrimaryTemplate().lookup( name );
|
||||
}
|
||||
|
||||
|
||||
protected List getTemplatesList() {
|
||||
return templatesList;
|
||||
}
|
||||
|
@ -218,4 +279,529 @@ public class TemplateFactory implements ITemplateFactory {
|
|||
private List templatesList;
|
||||
private List parametersList;
|
||||
private List argumentsList;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#removeSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public boolean removeSymbol(ISymbol symbol) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#hasUsingDirectives()
|
||||
*/
|
||||
public boolean hasUsingDirectives() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#getUsingDirectives()
|
||||
*/
|
||||
public List getUsingDirectives() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDirective(org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
||||
*/
|
||||
public IUsingDirectiveSymbol addUsingDirective(IContainerSymbol namespace) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String)
|
||||
*/
|
||||
public IUsingDeclarationSymbol addUsingDeclaration(String name) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
||||
*/
|
||||
public IUsingDeclarationSymbol addUsingDeclaration(String name, IContainerSymbol declContext) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#getContainedSymbols()
|
||||
*/
|
||||
public Map getContainedSymbols() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#prefixLookup(org.eclipse.cdt.internal.core.parser.pst.TypeFilter, java.lang.String, boolean)
|
||||
*/
|
||||
public List prefixLookup(TypeFilter filter, String prefix, boolean qualified) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#elaboratedLookup(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, java.lang.String)
|
||||
*/
|
||||
public ISymbol elaboratedLookup(eType type, String name) throws ParserSymbolTableException {
|
||||
ListIterator iter = templates.listIterator( templates.size() );
|
||||
while( iter.hasPrevious() ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) iter.previous();
|
||||
|
||||
ISymbol look = template.lookupMemberForDefinition( name );
|
||||
if( look != null && look.isType( type ) ){
|
||||
return look;
|
||||
}
|
||||
}
|
||||
|
||||
return getContainingSymbol().elaboratedLookup( type, name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookup(java.lang.String)
|
||||
*/
|
||||
public ISymbol lookup(String name) throws ParserSymbolTableException {
|
||||
ListIterator iter = templates.listIterator( templates.size() );
|
||||
while( iter.hasPrevious() ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) iter.previous();
|
||||
|
||||
ISymbol look = template.lookupMemberForDefinition( name );
|
||||
if( look != null ){
|
||||
return look;
|
||||
}
|
||||
}
|
||||
|
||||
return getContainingSymbol().lookup( name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupMethodForDefinition(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol lookupMethodForDefinition(String name, List parameters) throws ParserSymbolTableException {
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
IParameterizedSymbol found = ((IContainerSymbol)symbol).lookupMethodForDefinition( name, parameters );
|
||||
if( found != null ){
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return getContainingSymbol().lookupMethodForDefinition( name, parameters );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupNestedNameSpecifier(java.lang.String)
|
||||
*/
|
||||
public IContainerSymbol lookupNestedNameSpecifier(String name) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().lookupNestedNameSpecifier( name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String)
|
||||
*/
|
||||
public ISymbol qualifiedLookup(String name) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().qualifiedLookup( name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||
*/
|
||||
public ISymbol qualifiedLookup(String name, eType t) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().qualifiedLookup( name, t );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#unqualifiedFunctionLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol unqualifiedFunctionLookup(String name, List parameters) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().unqualifiedFunctionLookup( name, parameters );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#memberFunctionLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol memberFunctionLookup(String name, List parameters) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().memberFunctionLookup( name, parameters );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedFunctionLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol qualifiedFunctionLookup(String name, List parameters) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().qualifiedFunctionLookup( name, parameters );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupTemplate(java.lang.String, java.util.List)
|
||||
*/
|
||||
public ISymbol lookupTemplateId(String name, List arguments) throws ParserSymbolTableException {
|
||||
ISymbol look = null;
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
look = ((IContainerSymbol)symbol).lookupTemplateId( name, arguments );
|
||||
} else {
|
||||
look = getContainingSymbol().lookupTemplateId( name, arguments );
|
||||
}
|
||||
return look;
|
||||
}
|
||||
|
||||
public IContainerSymbol lookupTemplateIdForDefinition(String name, List arguments) throws ParserSymbolTableException {
|
||||
ISymbol look = null;
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
look = ((IContainerSymbol)symbol).lookupMemberForDefinition( name );
|
||||
} else {
|
||||
look = getContainingSymbol().lookupMemberForDefinition( name );
|
||||
}
|
||||
|
||||
if( look instanceof ITemplateSymbol ){
|
||||
ITemplateSymbol t = TemplateEngine.selectTemplateOrSpecialization( (ITemplateSymbol) look, getNextAvailableTemplate().getParameterList(), arguments );
|
||||
look = ((ITemplateSymbol) look).getTemplatedSymbol();
|
||||
}
|
||||
return (IContainerSymbol) (( look instanceof IContainerSymbol) ? look : null);
|
||||
}
|
||||
|
||||
private ITemplateSymbol getNextAvailableTemplate() throws ParserSymbolTableException{
|
||||
Iterator tIter = templates.iterator();
|
||||
Iterator sIter = symbols.iterator();
|
||||
|
||||
while( sIter.hasNext() ){
|
||||
ISymbol symbol = (ISymbol) sIter.next();
|
||||
if( symbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
||||
if( tIter.hasNext() )
|
||||
tIter.next();
|
||||
else
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( !tIter.hasNext() )
|
||||
return null;
|
||||
else
|
||||
return (ITemplateSymbol) tIter.next();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#isVisible(org.eclipse.cdt.internal.core.parser.pst.ISymbol, org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
||||
*/
|
||||
public boolean isVisible(ISymbol symbol, IContainerSymbol qualifyingSymbol) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#getContentsIterator()
|
||||
*/
|
||||
public Iterator getContentsIterator() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#clone()
|
||||
*/
|
||||
public Object clone() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#instantiate(org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol, java.util.Map)
|
||||
*/
|
||||
public ISymbol instantiate(ITemplateSymbol template, Map argMap) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||
*/
|
||||
public boolean isType(eType type) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||
*/
|
||||
public boolean isType(eType type, eType upperType) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getType()
|
||||
*/
|
||||
public eType getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||
*/
|
||||
public void setType(eType t) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getTypeInfo()
|
||||
*/
|
||||
public TypeInfo getTypeInfo() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setTypeInfo(org.eclipse.cdt.internal.core.parser.pst.TypeInfo)
|
||||
*/
|
||||
public void setTypeInfo(TypeInfo info) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getTypeSymbol()
|
||||
*/
|
||||
public ISymbol getTypeSymbol() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setTypeSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public void setTypeSymbol(ISymbol type) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isForwardDeclaration()
|
||||
*/
|
||||
public boolean isForwardDeclaration() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsForwardDeclaration(boolean)
|
||||
*/
|
||||
public void setIsForwardDeclaration(boolean forward) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#compareCVQualifiersTo(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public int compareCVQualifiersTo(ISymbol symbol) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getPtrOperators()
|
||||
*/
|
||||
public List getPtrOperators() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#addPtrOperator(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp)
|
||||
*/
|
||||
public void addPtrOperator(PtrOp ptrOp) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isTemplateInstance()
|
||||
*/
|
||||
public boolean isTemplateInstance() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getInstantiatedSymbol()
|
||||
*/
|
||||
public ISymbol getInstantiatedSymbol() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setInstantiatedSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public void setInstantiatedSymbol(ISymbol symbol) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isTemplateMember()
|
||||
*/
|
||||
public boolean isTemplateMember() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsTemplateMember(boolean)
|
||||
*/
|
||||
public void setIsTemplateMember(boolean isMember) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getDepth()
|
||||
*/
|
||||
public int getDepth() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getIsInvisible()
|
||||
*/
|
||||
public boolean getIsInvisible() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsInvisible(boolean)
|
||||
*/
|
||||
public void setIsInvisible(boolean invisible) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addParent(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public void addParent(ISymbol parent) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addParent(org.eclipse.cdt.internal.core.parser.pst.ISymbol, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, java.util.List)
|
||||
*/
|
||||
public void addParent(ISymbol parent, boolean virtual, ASTAccessVisibility visibility, int offset, List references) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#getParents()
|
||||
*/
|
||||
public List getParents() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#hasParents()
|
||||
*/
|
||||
public boolean hasParents() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addConstructor(org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol)
|
||||
*/
|
||||
public void addConstructor(IParameterizedSymbol constructor) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addCopyConstructor()
|
||||
*/
|
||||
public void addCopyConstructor() throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupConstructor(java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol lookupConstructor(List parameters) throws ParserSymbolTableException {
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
if( symbol instanceof IDerivableContainerSymbol ){
|
||||
IParameterizedSymbol found = ((IDerivableContainerSymbol)symbol).lookupConstructor( parameters );
|
||||
if( found != null )
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return ((IDerivableContainerSymbol) getContainingSymbol()).lookupConstructor( parameters );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#getConstructors()
|
||||
*/
|
||||
public List getConstructors() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addFriend(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public void addFriend(ISymbol friend) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupForFriendship(java.lang.String)
|
||||
*/
|
||||
public ISymbol lookupForFriendship(String name) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupFunctionForFriendship(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol lookupFunctionForFriendship(String name, List parameters) throws ParserSymbolTableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#getFriends()
|
||||
*/
|
||||
public List getFriends() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -470,24 +470,30 @@ public class TypeInfo {
|
|||
boolean result = ( _typeInfo == type._typeInfo );
|
||||
result &= ( _type == type._type );
|
||||
|
||||
if( _typeDeclaration != null && type._typeDeclaration != null &&
|
||||
_typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) &&
|
||||
type._typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
|
||||
{
|
||||
//if typeDeclaration is a basic type, then only need the types the same
|
||||
result &= ( _typeDeclaration.getType() == type._typeDeclaration.getType() );
|
||||
} else if( _typeDeclaration != null && type._typeDeclaration != null &&
|
||||
_typeDeclaration.isType( TypeInfo.t_function ) &&
|
||||
type._typeDeclaration.isType( TypeInfo.t_function ) )
|
||||
{
|
||||
//function pointers... functions must have same parameter lists and return types
|
||||
IParameterizedSymbol f1 = (IParameterizedSymbol) _typeDeclaration;
|
||||
IParameterizedSymbol f2 = (IParameterizedSymbol) type._typeDeclaration;
|
||||
|
||||
result &= f1.hasSameParameters( f2 );
|
||||
result &= f1.getReturnType().getTypeInfo().equals( f2.getReturnType().getTypeInfo() );
|
||||
if( _typeDeclaration != null && type._typeDeclaration != null ){
|
||||
if( _typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) &&
|
||||
type._typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
|
||||
{
|
||||
//if typeDeclaration is a basic type, then only need the types the same
|
||||
result &= ( _typeDeclaration.getType() == type._typeDeclaration.getType() );
|
||||
} else if( _typeDeclaration.isType( TypeInfo.t_function ) &&
|
||||
type._typeDeclaration.isType( TypeInfo.t_function ) )
|
||||
{
|
||||
//function pointers... functions must have same parameter lists and return types
|
||||
IParameterizedSymbol f1 = (IParameterizedSymbol) _typeDeclaration;
|
||||
IParameterizedSymbol f2 = (IParameterizedSymbol) type._typeDeclaration;
|
||||
|
||||
result &= f1.hasSameParameters( f2 );
|
||||
result &= f1.getReturnType().getTypeInfo().equals( f2.getReturnType().getTypeInfo() );
|
||||
} else if( _typeDeclaration.isType( TypeInfo.t_templateParameter ) &&
|
||||
type._typeDeclaration.isType( TypeInfo.t_templateParameter ) ){
|
||||
//template parameters
|
||||
result &= TemplateEngine.templateParametersAreEquivalent( _typeDeclaration, type._typeDeclaration );
|
||||
} else {
|
||||
//otherwise, its a user defined type, need the decls the same
|
||||
result &= ( _typeDeclaration == type._typeDeclaration );
|
||||
}
|
||||
} else {
|
||||
//otherwise, its a user defined type, need the decls the same
|
||||
result &= ( _typeDeclaration == type._typeDeclaration );
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.parser.ast.IASTField;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.internal.core.CharOperation;
|
||||
|
@ -68,8 +69,12 @@ public class FieldDeclarationPattern extends CSearchPattern {
|
|||
} else if( node instanceof IASTParameterDeclaration ){
|
||||
if( searchFor != VAR || !canAccept( limit ) )
|
||||
return IMPOSSIBLE_MATCH;
|
||||
} else if( node instanceof IASTTemplateParameter ){
|
||||
if( searchFor != VAR || !canAccept( limit ) )
|
||||
return IMPOSSIBLE_MATCH;
|
||||
} else return IMPOSSIBLE_MATCH;
|
||||
|
||||
|
||||
String nodeName = ((IASTOffsetableNamedElement)node).getName();
|
||||
|
||||
//check name, if simpleName == null, its treated the same as "*"
|
||||
|
|
|
@ -69,6 +69,7 @@ import org.eclipse.cdt.core.parser.ast.IASTReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
|
||||
|
@ -148,6 +149,12 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
check( REFERENCES, reference );
|
||||
}
|
||||
|
||||
|
||||
public void acceptTemplateParameterReference(IASTTemplateParameterReference reference)
|
||||
{
|
||||
check( REFERENCES, reference );
|
||||
}
|
||||
|
||||
public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef){
|
||||
lastDeclaration = typedef;
|
||||
check( DECLARATIONS, typedef );
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-03-15 Andrew Niefer
|
||||
updated internal.ui.compare.SourceElementRequestorAdapter with acceptTemplateParameterReference
|
||||
|
||||
2004-03-12 David Inglis
|
||||
|
||||
Implemented new build console using the Eclipse 3 generic console, supporting multiple
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
|
||||
|
@ -341,4 +342,12 @@ public class SourceElementRequestorAdapter implements ISourceElementRequestor {
|
|||
return ParserUtil.createReader(finalPath);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTemplateParameterReference(org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference)
|
||||
*/
|
||||
public void acceptTemplateParameterReference(IASTTemplateParameterReference reference) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue