[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] References resolved in qualified method names (complete parse mode)
|
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.
Tests:
Regards,
Hoda Amer
Staff Software Engineer
Rational Software - IBM Software Group
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.132
diff -u -r1.132 ChangeLog
--- ChangeLog 26 Aug 2003 19:15:58 -0000 1.132
+++ ChangeLog 28 Aug 2003 15:26:36 -0000
@@ -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
- Modified start up code to set debug trace options
- Added trace debug statements to CModelBuilder.
@@ -5,11 +15,10 @@
Util.debugLog clients (currently Parser and CModelBuidler)
- Modified Util.java to make use of IDebugLogConstants
-
2003-08-25 Hoda Amer
Modified the IASTFactory to take three expression lists
for the createNewDescriptor() instead of just one.
- They are : newPlacementExpressions, typeIdExpressions, and
+ They are : newPlacementExpressions, newTypeIdExpressions, and
newInitializerExpressions.
2003-08-25 John Camelon
Index: model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.14
diff -u -r1.14 CModelBuilder.java
--- model/org/eclipse/cdt/internal/core/model/CModelBuilder.java 26 Aug 2003 19:15:58 -0000 1.14
+++ model/org/eclipse/cdt/internal/core/model/CModelBuilder.java 28 Aug 2003 15:26:36 -0000
@@ -110,8 +110,8 @@
catch( ParserException e )
{
- System.out.println( "Parse Exception in Outline View" );
- e.printStackTrace();
+ Util.debugLog( "Parse Exception in CModelBuilder", IDebugLogConstants.MODEL );
+ //e.printStackTrace();
}
long startTime = System.currentTimeMillis();
try
@@ -120,8 +120,8 @@
}
catch( NullPointerException npe )
{
- System.out.println( "NullPointer exception generating CModel");
- npe.printStackTrace();
+ Util.debugLog( "NullPointer exception in CModelBuilder", IDebugLogConstants.MODEL);
+ //npe.printStackTrace();
}
// For the debuglog to take place, you have to call
Index: model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java,v
retrieving revision 1.5
diff -u -r1.5 MethodDeclaration.java
--- model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java 25 Aug 2003 04:20:40 -0000 1.5
+++ model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java 28 Aug 2003 15:26:37 -0000
@@ -30,13 +30,13 @@
}
public boolean isConstructor(){
- // Still a problem with the parser
+ // is not implemented in the parser's quick mode
//return isConstructor;
return getElementName().equals(getParent().getElementName());
}
public boolean isDestructor() {
- // still a problem with the parser
+ // is not implemented in the parser's quick mode
//return isDestructor;
return getElementName().startsWith("~");
}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java,v
retrieving revision 1.26
diff -u -r1.26 IASTFactory.java
--- parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 28 Aug 2003 15:02:52 -0000 1.26
+++ parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 28 Aug 2003 15:26:37 -0000
@@ -143,7 +143,13 @@
boolean isStatic,
int startOffset,
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(
boolean isConst,
boolean isVolatile,
@@ -163,8 +169,6 @@
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
- boolean isConstructor,
- boolean isDestructor,
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
@@ -188,5 +192,8 @@
public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset ) throws ASTSemanticException;
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset);
+
+ static final String DOUBLE_COLON = "::";
+ static final String TELTA = "~";
}
Index: parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java,v
retrieving revision 1.15
diff -u -r1.15 DeclarationWrapper.java
--- parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 13 Aug 2003 23:54:05 -0000 1.15
+++ parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 28 Aug 2003 15:26:37 -0000
@@ -15,6 +15,7 @@
import java.util.List;
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.ASTSemanticException;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
@@ -431,13 +432,10 @@
templateDeclaration,
declarator.isConst(),
declarator.isVolatile(),
- false,
- // isConstructor
- false, // isDestructor
- virtual,
- explicit,
- declarator.isPureVirtual(),
- ((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers());
+ virtual,
+ explicit,
+ declarator.isPureVirtual(),
+ ((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers());
}
/**
* @param declarator
@@ -460,7 +458,14 @@
staticc,
startingOffset,
declarator.getNameStartOffset(),
- templateDeclaration);
+ templateDeclaration,
+ declarator.isConst(),
+ declarator.isVolatile(),
+ virtual,
+ explicit,
+ declarator.isPureVirtual(),
+ ASTAccessVisibility.PUBLIC,
+ declarator.getConstructorMemberInitializers());
}
/**
* @param declarator
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java,v
retrieving revision 1.22
diff -u -r1.22 CompleteParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 28 Aug 2003 15:02:52 -0000 1.22
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 28 Aug 2003 15:26:38 -0000
@@ -12,7 +12,9 @@
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
+import java.util.StringTokenizer;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ITokenDuple;
@@ -82,11 +84,47 @@
/**
*
*/
+
public CompleteParseASTFactory()
{
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
{
@@ -833,51 +871,107 @@
}
/* (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)
- */
- 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) throws ASTSemanticException
- {
- IContainerSymbol ownerScope = scopeToSymbol( scope );
- IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
- setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
- List references = new ArrayList();
-
+ * @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(
+ 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
+ {
+ 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 );
setParameters( symbol, references, parameters.iterator() );
-
-
- try
- {
- ownerScope.addSymbol( symbol );
- }
- catch (ParserSymbolTableException e)
- {
- throw new ASTSemanticException();
- }
-
-
- ASTFunction function = new ASTFunction( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references );
- try
- {
- attachSymbolExtension(symbol, function);
- }
- catch (ExtensionException e1)
- {
- throw new ASTSemanticException();
- }
- return function;
- }
+
+ try
+ {
+ ownerScope.addSymbol( symbol );
+ }
+ catch (ParserSymbolTableException e)
+ {
+ throw new ASTSemanticException();
+ }
+ ASTFunction function = new ASTFunction( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references );
+ try
+ {
+ attachSymbolExtension(symbol, function);
+ }
+ catch (ExtensionException e1)
+ {
+ throw new ASTSemanticException();
+ }
+ return function;
+ }
+
protected void setFunctionTypeInfoBits(
boolean isInline,
boolean isFriend,
@@ -1019,6 +1113,33 @@
/* (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)
*/
+
+ 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(
IASTScope scope,
String name,
@@ -1033,18 +1154,23 @@
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
- boolean isConstructor,
- boolean isDestructor,
boolean isVirtual,
boolean isExplicit,
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 );
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
setMethodTypeInfoBits( symbol, isConst, isVolatile, isVirtual, isExplicit );
- List references = new ArrayList();
+ if(references == null)
+ references = new ArrayList();
if( returnType.getTypeSpecifier() != null )
setParameter( symbol, returnType, false, references );
@@ -1058,7 +1184,19 @@
{
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 );
try
{
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java,v
retrieving revision 1.28
diff -u -r1.28 QuickParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 28 Aug 2003 15:02:52 -0000 1.28
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 28 Aug 2003 15:26:38 -0000
@@ -187,7 +187,7 @@
/* (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)
*/
- 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 );
}
@@ -195,9 +195,9 @@
/* (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)
*/
- 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)
- {
- return new ASTMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, isConstructor, isDestructor, isVirtual, isExplicit, isPureVirtual, visibility, 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, false, false, isVirtual, isExplicit, isPureVirtual, visibility, constructorChain);
}
/* (non-Javadoc)
Index: parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java,v
retrieving revision 1.4
diff -u -r1.4 IContainerSymbol.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java 7 Aug 2003 14:46:58 -0000 1.4
+++ parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java 28 Aug 2003 15:26:38 -0000
@@ -46,6 +46,7 @@
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
public IContainerSymbol lookupNestedNameSpecifier( 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 memberFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
public IParameterizedSymbol qualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java,v
retrieving revision 1.13
diff -u -r1.13 ParserSymbolTable.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java 14 Aug 2003 19:49:44 -0000 1.13
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java 28 Aug 2003 15:26:39 -0000
@@ -3021,7 +3021,12 @@
}
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;
ParserSymbolTable.lookup( data, this );
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.69
diff -u -r1.69 ChangeLog
--- ChangeLog 28 Aug 2003 15:02:29 -0000 1.69
+++ ChangeLog 28 Aug 2003 15:31:36 -0000
@@ -1,3 +1,7 @@
+2003-08-28 Hoda Amer
+ - Added to completeParseASTTest testQualifiedNameReferences(),
+ testIsConstructor() and testIsDestructor().
+
2003-08-28 John Camelon
Moved bug39535 from failedTests to quickParse success tests.
Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java,v
retrieving revision 1.17
diff -u -r1.17 CompleteParseASTTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 25 Aug 2003 18:19:48 -0000 1.17
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 28 Aug 2003 15:31:37 -0000
@@ -522,5 +522,39 @@
IASTVariableReference maxRef = (IASTVariableReference) callback.getReferences().get(0);
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());
+ }
}