mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 21:35:40 +02:00
Core :
- Added resolving references in a method's qualified name in Complete parse mode. Example (.cpp file ): The method "A::B::C::aMethod(){};" used to be an IASTFunction, with name = "A::B::C::aMethod". Now is an IASTMethod, with name = "aMethod", and references to class A, class B and class C. - Added the checking for "isConstructor" and "isDestructor" for an IASTMethod in complete parse mode.
This commit is contained in:
parent
cb951980f4
commit
55bd1089ae
11 changed files with 275 additions and 72 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2003-08-28 Hoda Amer
|
||||||
|
- Added to completeParseASTTest testQualifiedNameReferences(),
|
||||||
|
testIsConstructor() and testIsDestructor().
|
||||||
|
|
||||||
2003-08-28 John Camelon
|
2003-08-28 John Camelon
|
||||||
Moved bug39535 from failedTests to quickParse success tests.
|
Moved bug39535 from failedTests to quickParse success tests.
|
||||||
|
|
||||||
|
|
|
@ -522,5 +522,39 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
IASTVariableReference maxRef = (IASTVariableReference) callback.getReferences().get(0);
|
IASTVariableReference maxRef = (IASTVariableReference) callback.getReferences().get(0);
|
||||||
assertEquals( maxRef.getReferencedElement(), max );
|
assertEquals( maxRef.getReferencedElement(), max );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testQualifiedNameReferences() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n" ).getDeclarations();
|
||||||
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
Iterator j = getDeclarations(classA);
|
||||||
|
IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)j.next()).getTypeSpecifier();
|
||||||
|
Iterator k = getDeclarations(classB);
|
||||||
|
IASTClassSpecifier classC = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)k.next()).getTypeSpecifier();
|
||||||
|
|
||||||
|
// Note : this used to be considered a function, not a method
|
||||||
|
IASTMethod method = (IASTMethod)i.next();
|
||||||
|
|
||||||
|
assertEquals( callback.getReferences().size(), 3 );
|
||||||
|
Iterator references = callback.getReferences().iterator();
|
||||||
|
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classA );
|
||||||
|
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classB );
|
||||||
|
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classC );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsConstructor() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "class A{ public: A(); }; \n A::A() {}; \n" ).getDeclarations();
|
||||||
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
IASTMethod method = (IASTMethod)i.next();
|
||||||
|
assertTrue (method.isConstructor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsDestructor() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "class A{ public: A(); }; \n A::~A() {}; \n" ).getDeclarations();
|
||||||
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
IASTMethod method = (IASTMethod)i.next();
|
||||||
|
assertTrue (method.isDestructor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
2003-08-28 Hoda Amer
|
||||||
|
- Added resolving references in a method's qualified name
|
||||||
|
in Complete parse mode.
|
||||||
|
Example (.cpp file ): The method "A::B::C::aMethod(){};"
|
||||||
|
used to be an IASTFunction, with name = "A::B::C::aMethod".
|
||||||
|
Now is an IASTMethod, with name = "aMethod", and references to
|
||||||
|
class A, class B and class C.
|
||||||
|
- Added the checking for "isConstructor" and "isDestructor"
|
||||||
|
for an IASTMethod in complete parse mode.
|
||||||
|
|
||||||
2003-08-26 Bogdan Gheorghe
|
2003-08-26 Bogdan Gheorghe
|
||||||
- Modified start up code to set debug trace options
|
- Modified start up code to set debug trace options
|
||||||
- Added trace debug statements to CModelBuilder.
|
- Added trace debug statements to CModelBuilder.
|
||||||
|
@ -5,11 +15,10 @@
|
||||||
Util.debugLog clients (currently Parser and CModelBuidler)
|
Util.debugLog clients (currently Parser and CModelBuidler)
|
||||||
- Modified Util.java to make use of IDebugLogConstants
|
- Modified Util.java to make use of IDebugLogConstants
|
||||||
|
|
||||||
|
|
||||||
2003-08-25 Hoda Amer
|
2003-08-25 Hoda Amer
|
||||||
Modified the IASTFactory to take three expression lists
|
Modified the IASTFactory to take three expression lists
|
||||||
for the createNewDescriptor() instead of just one.
|
for the createNewDescriptor() instead of just one.
|
||||||
They are : newPlacementExpressions, typeIdExpressions, and
|
They are : newPlacementExpressions, newTypeIdExpressions, and
|
||||||
newInitializerExpressions.
|
newInitializerExpressions.
|
||||||
|
|
||||||
2003-08-25 John Camelon
|
2003-08-25 John Camelon
|
||||||
|
|
|
@ -110,8 +110,8 @@ public class CModelBuilder {
|
||||||
|
|
||||||
catch( ParserException e )
|
catch( ParserException e )
|
||||||
{
|
{
|
||||||
System.out.println( "Parse Exception in Outline View" );
|
Util.debugLog( "Parse Exception in CModelBuilder", IDebugLogConstants.MODEL );
|
||||||
e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
try
|
try
|
||||||
|
@ -120,8 +120,8 @@ public class CModelBuilder {
|
||||||
}
|
}
|
||||||
catch( NullPointerException npe )
|
catch( NullPointerException npe )
|
||||||
{
|
{
|
||||||
System.out.println( "NullPointer exception generating CModel");
|
Util.debugLog( "NullPointer exception in CModelBuilder", IDebugLogConstants.MODEL);
|
||||||
npe.printStackTrace();
|
//npe.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the debuglog to take place, you have to call
|
// For the debuglog to take place, you have to call
|
||||||
|
|
|
@ -30,13 +30,13 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConstructor(){
|
public boolean isConstructor(){
|
||||||
// Still a problem with the parser
|
// is not implemented in the parser's quick mode
|
||||||
//return isConstructor;
|
//return isConstructor;
|
||||||
return getElementName().equals(getParent().getElementName());
|
return getElementName().equals(getParent().getElementName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDestructor() {
|
public boolean isDestructor() {
|
||||||
// still a problem with the parser
|
// is not implemented in the parser's quick mode
|
||||||
//return isDestructor;
|
//return isDestructor;
|
||||||
return getElementName().startsWith("~");
|
return getElementName().startsWith("~");
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,13 @@ public interface IASTFactory
|
||||||
boolean isStatic,
|
boolean isStatic,
|
||||||
int startOffset,
|
int startOffset,
|
||||||
int nameOffset,
|
int nameOffset,
|
||||||
IASTTemplate ownerTemplate) throws ASTSemanticException;
|
IASTTemplate ownerTemplate,
|
||||||
|
boolean isConst,
|
||||||
|
boolean isVolatile,
|
||||||
|
boolean isVirtual,
|
||||||
|
boolean isExplicit,
|
||||||
|
boolean isPureVirtual,
|
||||||
|
ASTAccessVisibility visibility, List constructorChain) throws ASTSemanticException;
|
||||||
public IASTAbstractDeclaration createAbstractDeclaration(
|
public IASTAbstractDeclaration createAbstractDeclaration(
|
||||||
boolean isConst,
|
boolean isConst,
|
||||||
boolean isVolatile,
|
boolean isVolatile,
|
||||||
|
@ -163,8 +169,6 @@ public interface IASTFactory
|
||||||
IASTTemplate ownerTemplate,
|
IASTTemplate ownerTemplate,
|
||||||
boolean isConst,
|
boolean isConst,
|
||||||
boolean isVolatile,
|
boolean isVolatile,
|
||||||
boolean isConstructor,
|
|
||||||
boolean isDestructor,
|
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
boolean isExplicit,
|
boolean isExplicit,
|
||||||
boolean isPureVirtual,
|
boolean isPureVirtual,
|
||||||
|
@ -189,4 +193,7 @@ public interface IASTFactory
|
||||||
|
|
||||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset);
|
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset);
|
||||||
|
|
||||||
|
static final String DOUBLE_COLON = "::";
|
||||||
|
static final String TELTA = "~";
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
|
@ -431,13 +432,10 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
templateDeclaration,
|
templateDeclaration,
|
||||||
declarator.isConst(),
|
declarator.isConst(),
|
||||||
declarator.isVolatile(),
|
declarator.isVolatile(),
|
||||||
false,
|
virtual,
|
||||||
// isConstructor
|
explicit,
|
||||||
false, // isDestructor
|
declarator.isPureVirtual(),
|
||||||
virtual,
|
((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers());
|
||||||
explicit,
|
|
||||||
declarator.isPureVirtual(),
|
|
||||||
((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers());
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
|
@ -460,7 +458,14 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
staticc,
|
staticc,
|
||||||
startingOffset,
|
startingOffset,
|
||||||
declarator.getNameStartOffset(),
|
declarator.getNameStartOffset(),
|
||||||
templateDeclaration);
|
templateDeclaration,
|
||||||
|
declarator.isConst(),
|
||||||
|
declarator.isVolatile(),
|
||||||
|
virtual,
|
||||||
|
explicit,
|
||||||
|
declarator.isPureVirtual(),
|
||||||
|
ASTAccessVisibility.PUBLIC,
|
||||||
|
declarator.getConstructorMemberInitializers());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
|
|
|
@ -12,7 +12,9 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
@ -82,11 +84,47 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CompleteParseASTFactory()
|
public CompleteParseASTFactory()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, int offset, List references, boolean throwOnError ) throws ASTSemanticException
|
||||||
|
{
|
||||||
|
ISymbol result = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( name == null ) throw new ASTSemanticException();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(type == TypeInfo.t_function){
|
||||||
|
// looking for a function
|
||||||
|
result = startingScope.qualifiedFunctionLookup(name, new LinkedList(parameters));
|
||||||
|
}else{
|
||||||
|
// looking for a class
|
||||||
|
result = startingScope.qualifiedLookup(name, type);
|
||||||
|
}
|
||||||
|
if( result != null )
|
||||||
|
references.add( createReference( result, name, offset ));
|
||||||
|
else
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
catch (ParserSymbolTableException e)
|
||||||
|
{
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch( ASTSemanticException se )
|
||||||
|
{
|
||||||
|
if( throwOnError )
|
||||||
|
throw se;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, List references, boolean throwOnError ) throws ASTSemanticException
|
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, List references, boolean throwOnError ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
|
@ -833,51 +871,107 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
|
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate)
|
||||||
*/
|
*/
|
||||||
public IASTFunction createFunction(
|
public IASTFunction createFunction(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String name,
|
String name,
|
||||||
List parameters,
|
List parameters,
|
||||||
IASTAbstractDeclaration returnType,
|
IASTAbstractDeclaration returnType,
|
||||||
IASTExceptionSpecification exception,
|
IASTExceptionSpecification exception,
|
||||||
boolean isInline,
|
boolean isInline,
|
||||||
boolean isFriend,
|
boolean isFriend,
|
||||||
boolean isStatic,
|
boolean isStatic,
|
||||||
int startOffset,
|
int startOffset,
|
||||||
int nameOffset,
|
int nameOffset,
|
||||||
IASTTemplate ownerTemplate) throws ASTSemanticException
|
IASTTemplate ownerTemplate,
|
||||||
{
|
boolean isConst,
|
||||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
boolean isVolatile,
|
||||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
|
boolean isVirtual,
|
||||||
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
boolean isExplicit,
|
||||||
List references = new ArrayList();
|
boolean isPureVirtual,
|
||||||
|
ASTAccessVisibility visibility,
|
||||||
|
List constructorChain) throws ASTSemanticException
|
||||||
|
{
|
||||||
|
List references = new ArrayList();
|
||||||
|
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||||
|
|
||||||
|
// check if this is a method in a body file
|
||||||
|
StringTokenizer tokenizer = new StringTokenizer(name,DOUBLE_COLON);
|
||||||
|
int tokencount = tokenizer.countTokens();
|
||||||
|
if(tokencount > 1){
|
||||||
|
List tokens = new ArrayList();
|
||||||
|
String oneToken = "";
|
||||||
|
// This is NOT a function. This is a method definition
|
||||||
|
while (tokenizer.hasMoreTokens()){
|
||||||
|
oneToken = tokenizer.nextToken();
|
||||||
|
tokens.add(oneToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
String functionName = oneToken;
|
||||||
|
String parentName = name.substring(0, name.lastIndexOf(DOUBLE_COLON));
|
||||||
|
|
||||||
|
int numOfTokens = 1;
|
||||||
|
int offset = nameOffset;
|
||||||
|
IContainerSymbol parentScope = ownerScope;
|
||||||
|
Iterator i = tokens.iterator();
|
||||||
|
while (i.hasNext() && (numOfTokens++) < tokens.size()){
|
||||||
|
String token = (String) i.next();
|
||||||
|
IContainerSymbol parentSymbol =
|
||||||
|
(IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_class, null, offset, references, false);
|
||||||
|
if(parentSymbol == null){
|
||||||
|
parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_namespace, null, offset, references, false);
|
||||||
|
}
|
||||||
|
if(parentSymbol == null)
|
||||||
|
break;
|
||||||
|
else {
|
||||||
|
parentScope = parentSymbol;
|
||||||
|
offset += token.length()+ DOUBLE_COLON.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((parentScope != null) && (parentScope.getType() == TypeInfo.t_class)){
|
||||||
|
// find out the visibility of the method's declaration
|
||||||
|
List functionReferences = new ArrayList();
|
||||||
|
IParameterizedSymbol methodDeclaration =
|
||||||
|
(IParameterizedSymbol) lookupQualifiedName(parentScope, functionName, TypeInfo.t_function, parameters, 0, functionReferences, false);
|
||||||
|
if(methodDeclaration != null){
|
||||||
|
ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next();
|
||||||
|
visibility = ((IASTMethod)reference.getReferencedElement()).getVisiblity();
|
||||||
|
}
|
||||||
|
return createMethod(scope, functionName, parameters, returnType,
|
||||||
|
exception, isInline, isFriend, isStatic, startOffset, offset,
|
||||||
|
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
||||||
|
visibility, constructorChain,parentName, references);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
|
||||||
|
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
||||||
|
|
||||||
setParameter( symbol, returnType, false, references );
|
setParameter( symbol, returnType, false, references );
|
||||||
setParameters( symbol, references, parameters.iterator() );
|
setParameters( symbol, references, parameters.iterator() );
|
||||||
|
|
||||||
|
try
|
||||||
try
|
{
|
||||||
{
|
ownerScope.addSymbol( symbol );
|
||||||
ownerScope.addSymbol( symbol );
|
}
|
||||||
}
|
catch (ParserSymbolTableException e)
|
||||||
catch (ParserSymbolTableException e)
|
{
|
||||||
{
|
throw new ASTSemanticException();
|
||||||
throw new ASTSemanticException();
|
}
|
||||||
}
|
ASTFunction function = new ASTFunction( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references );
|
||||||
|
try
|
||||||
|
{
|
||||||
ASTFunction function = new ASTFunction( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references );
|
attachSymbolExtension(symbol, function);
|
||||||
try
|
}
|
||||||
{
|
catch (ExtensionException e1)
|
||||||
attachSymbolExtension(symbol, function);
|
{
|
||||||
}
|
throw new ASTSemanticException();
|
||||||
catch (ExtensionException e1)
|
}
|
||||||
{
|
return function;
|
||||||
throw new ASTSemanticException();
|
}
|
||||||
}
|
|
||||||
return function;
|
|
||||||
}
|
|
||||||
protected void setFunctionTypeInfoBits(
|
protected void setFunctionTypeInfoBits(
|
||||||
boolean isInline,
|
boolean isInline,
|
||||||
boolean isFriend,
|
boolean isFriend,
|
||||||
|
@ -1019,6 +1113,33 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public IASTMethod createMethod(
|
||||||
|
IASTScope scope,
|
||||||
|
String name,
|
||||||
|
List parameters,
|
||||||
|
IASTAbstractDeclaration returnType,
|
||||||
|
IASTExceptionSpecification exception,
|
||||||
|
boolean isInline,
|
||||||
|
boolean isFriend,
|
||||||
|
boolean isStatic,
|
||||||
|
int startOffset,
|
||||||
|
int nameOffset,
|
||||||
|
IASTTemplate ownerTemplate,
|
||||||
|
boolean isConst,
|
||||||
|
boolean isVolatile,
|
||||||
|
boolean isVirtual,
|
||||||
|
boolean isExplicit,
|
||||||
|
boolean isPureVirtual,
|
||||||
|
ASTAccessVisibility visibility,
|
||||||
|
List constructorChain) throws ASTSemanticException
|
||||||
|
{
|
||||||
|
return createMethod(scope, name, parameters, returnType,
|
||||||
|
exception, isInline, isFriend, isStatic, startOffset, nameOffset,
|
||||||
|
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
||||||
|
visibility, constructorChain,scopeToSymbol(scope).getName(), null);
|
||||||
|
}
|
||||||
|
|
||||||
public IASTMethod createMethod(
|
public IASTMethod createMethod(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String name,
|
String name,
|
||||||
|
@ -1033,18 +1154,23 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IASTTemplate ownerTemplate,
|
IASTTemplate ownerTemplate,
|
||||||
boolean isConst,
|
boolean isConst,
|
||||||
boolean isVolatile,
|
boolean isVolatile,
|
||||||
boolean isConstructor,
|
|
||||||
boolean isDestructor,
|
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
boolean isExplicit,
|
boolean isExplicit,
|
||||||
boolean isPureVirtual,
|
boolean isPureVirtual,
|
||||||
ASTAccessVisibility visibility, List constructorChain) throws ASTSemanticException
|
ASTAccessVisibility visibility,
|
||||||
|
List constructorChain,
|
||||||
|
String parentName,
|
||||||
|
List references) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
|
boolean isConstructor = false;
|
||||||
|
boolean isDestructor = false;
|
||||||
|
|
||||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
|
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
|
||||||
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
||||||
setMethodTypeInfoBits( symbol, isConst, isVolatile, isVirtual, isExplicit );
|
setMethodTypeInfoBits( symbol, isConst, isVolatile, isVirtual, isExplicit );
|
||||||
List references = new ArrayList();
|
if(references == null)
|
||||||
|
references = new ArrayList();
|
||||||
|
|
||||||
if( returnType.getTypeSpecifier() != null )
|
if( returnType.getTypeSpecifier() != null )
|
||||||
setParameter( symbol, returnType, false, references );
|
setParameter( symbol, returnType, false, references );
|
||||||
|
@ -1058,7 +1184,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
{
|
{
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check constructor / destructor if no return type
|
||||||
|
if ( returnType.getTypeSpecifier() == null ){
|
||||||
|
if(parentName.indexOf(DOUBLE_COLON) != -1){
|
||||||
|
parentName = parentName.substring(parentName.lastIndexOf(DOUBLE_COLON) + DOUBLE_COLON.length());
|
||||||
|
}
|
||||||
|
if( parentName.equals(name) ){
|
||||||
|
isConstructor = true;
|
||||||
|
} else if(name.startsWith(TELTA) && parentName.equals(name.substring(1))){
|
||||||
|
isDestructor = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain );
|
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
||||||
*/
|
*/
|
||||||
public IASTFunction createFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate)
|
public IASTFunction createFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain)
|
||||||
{
|
{
|
||||||
return new ASTFunction(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate );
|
return new ASTFunction(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate );
|
||||||
}
|
}
|
||||||
|
@ -195,9 +195,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
||||||
*/
|
*/
|
||||||
public IASTMethod createMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isConstructor, boolean isDestructor, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain)
|
public IASTMethod createMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain)
|
||||||
{
|
{
|
||||||
return new ASTMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, isConstructor, isDestructor, isVirtual, isExplicit, isPureVirtual, visibility, constructorChain);
|
return new ASTMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, false, false, isVirtual, isExplicit, isPureVirtual, visibility, constructorChain);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -46,6 +46,7 @@ public interface IContainerSymbol extends ISymbol {
|
||||||
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
|
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
|
||||||
public IContainerSymbol lookupNestedNameSpecifier( String name ) throws ParserSymbolTableException;
|
public IContainerSymbol lookupNestedNameSpecifier( String name ) throws ParserSymbolTableException;
|
||||||
public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException;
|
public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException;
|
||||||
|
public ISymbol qualifiedLookup( String name, TypeInfo.eType t ) throws ParserSymbolTableException;
|
||||||
public IParameterizedSymbol unqualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
|
public IParameterizedSymbol unqualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
|
||||||
public IParameterizedSymbol memberFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
|
public IParameterizedSymbol memberFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
|
||||||
public IParameterizedSymbol qualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
|
public IParameterizedSymbol qualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
|
||||||
|
|
|
@ -3021,7 +3021,12 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException{
|
public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException{
|
||||||
LookupData data = new LookupData( name, TypeInfo.t_any, getTemplateInstance() );
|
|
||||||
|
return qualifiedLookup(name, TypeInfo.t_any);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISymbol qualifiedLookup( String name, TypeInfo.eType t ) throws ParserSymbolTableException{
|
||||||
|
LookupData data = new LookupData( name, t, getTemplateInstance() );
|
||||||
data.qualified = true;
|
data.qualified = true;
|
||||||
ParserSymbolTable.lookup( data, this );
|
ParserSymbolTable.lookup( data, this );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue