[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied [HEAD] Parser - Method/Function COMPLETE_PARSE support
|
CORE
Added COMPLETE_PARSE support for Method and Field declarations and
cross-references.
Fixed some small ParserSymbolTable bugs.
Added support for linkage specification under COMPLETE_PARSE.
TESTS
Updated CompleteParseASTTests for Method/Field updates.
Fixed TortureTest's parser mode switch (was always QuickParsing).
JohnC
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.85
diff -u -r1.85 ChangeLog
--- parser/ChangeLog 24 Jul 2003 13:47:18 -0000 1.85
+++ parser/ChangeLog 25 Jul 2003 00:34:41 -0000
@@ -1,4 +1,9 @@
2003-07-24 John Camelon
+ Added COMPLETE_PARSE support for Method and Field declarations and cross-references.
+ Fixed some small ParserSymbolTable bugs.
+ Added support for linkage specification under COMPLETE_PARSE.
+
+2003-07-24 John Camelon
Added CompleteParse - UsingDirective & UsingDeclarations w/namespace/class/field variable references.
Added CompleteParse support for enumeration specifiers and references in variables & fields.
Stubbed out other Scopes/Declarations for COMPLETE_PARSE mode to allow indexer team to switch over ASAP.
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.17
diff -u -r1.17 IASTFactory.java
--- parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 24 Jul 2003 13:47:18 -0000 1.17
+++ parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 25 Jul 2003 00:34:41 -0000
@@ -134,7 +134,7 @@
boolean isStatic,
int startOffset,
int nameOffset,
- IASTTemplate ownerTemplate);
+ IASTTemplate ownerTemplate) throws ASTSemanticException;
public IASTAbstractDeclaration createAbstractDeclaration(
boolean isConst,
IASTTypeSpecifier typeSpecifier,
@@ -159,7 +159,7 @@
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
- ASTAccessVisibility visibility);
+ ASTAccessVisibility visibility) throws ASTSemanticException;
public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression,
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset ) throws ASTSemanticException;
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.11
diff -u -r1.11 DeclarationWrapper.java
--- parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 24 Jul 2003 13:47:18 -0000 1.11
+++ parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 25 Jul 2003 00:34:41 -0000
@@ -363,7 +363,7 @@
* @param declarator
* @return
*/
- private IASTMethod createMethodASTNode(Declarator declarator)
+ private IASTMethod createMethodASTNode(Declarator declarator) throws ASTSemanticException
{
return astFactory
.createMethod(
@@ -396,7 +396,7 @@
* @param declarator
* @return
*/
- private IASTFunction createFunctionASTNode(Declarator declarator)
+ private IASTFunction createFunctionASTNode(Declarator declarator) throws ASTSemanticException
{
return astFactory.createFunction(
scope,
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.79
diff -u -r1.79 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java 24 Jul 2003 14:47:32 -0000 1.79
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java 25 Jul 2003 00:34:43 -0000
@@ -897,7 +897,7 @@
}
protected void handleFunctionBody(Declarator d) throws Backtrack, EndOfFile
{
- if (mode == ParserMode.QUICK_PARSE)
+ if ( true ) // TODO - Enable parsing within function bodies i.e. mode == ParserMode.QUICK_PARSE)
{
// speed up the parser by skiping the body
// simply look for matching brace and return
Index: parser/org/eclipse/cdt/internal/core/parser/ast/ASTParameterDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/ASTParameterDeclaration.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/ASTParameterDeclaration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/ASTParameterDeclaration.java 25 Jul 2003 00:34:43 -0000
@@ -0,0 +1,91 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTParameterDeclaration implements IASTParameterDeclaration
+{
+ private final boolean isConst;
+ private final IASTTypeSpecifier typeSpecifier;
+ private final List pointerOperators;
+ private final List arrayModifiers;
+ private final String parameterName;
+ private final IASTInitializerClause initializerClause;
+ /**
+ * @param isConst
+ * @param typeSpecifier
+ * @param pointerOperators
+ * @param arrayModifiers
+ * @param parameterName
+ * @param initializerClause
+ */
+ public ASTParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause)
+ {
+ this.isConst = isConst;
+ this.typeSpecifier = typeSpecifier;
+ this.pointerOperators = pointerOperators;
+ this.arrayModifiers = arrayModifiers;
+ this.parameterName = parameterName;
+ this.initializerClause = initializerClause;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getName()
+ */
+ public String getName()
+ {
+ return parameterName;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getDefaultValue()
+ */
+ public IASTInitializerClause getDefaultValue()
+ {
+ return initializerClause;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isConst()
+ */
+ public boolean isConst()
+ {
+ return isConst;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getTypeSpecifier()
+ */
+ public IASTTypeSpecifier getTypeSpecifier()
+ {
+ return typeSpecifier;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerOperators()
+ */
+ public Iterator getPointerOperators()
+ {
+ return pointerOperators.iterator();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getArrayModifiers()
+ */
+ public Iterator getArrayModifiers()
+ {
+ return arrayModifiers.iterator();
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java,v
retrieving revision 1.4
diff -u -r1.4 BaseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java 21 Jul 2003 17:29:54 -0000 1.4
+++ parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java 25 Jul 2003 00:34:43 -0000
@@ -10,8 +10,14 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTMacro;
+import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
/**
@@ -41,6 +47,16 @@
inclusion.setNameOffset( nameOffset );
return inclusion;
}
+
+ public IASTAbstractDeclaration createAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers)
+ {
+ return new ASTAbstractDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers );
+ }
+
+ public IASTParameterDeclaration createParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause)
+ {
+ return new ASTParameterDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers, parameterName, initializerClause );
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java,v
retrieving revision 1.1
diff -u -r1.1 ASTFunction.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java 24 Jul 2003 13:47:18 -0000 1.1
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java 25 Jul 2003 00:34:43 -0000
@@ -11,196 +11,200 @@
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.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
import org.eclipse.cdt.core.parser.ast.IASTFunction;
-import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
+import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
+import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
+import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
/**
* @author jcamelon
*
*/
-public class ASTFunction implements IASTFunction
+public class ASTFunction extends ASTScope implements IASTFunction
{
+ private boolean hasFunctionBody = false;
+ private final IASTTemplate ownerTemplate;
+ private final IASTAbstractDeclaration returnType;
+ private final IASTExceptionSpecification exception;
+ private NamedOffsets offsets = new NamedOffsets();
+ private final ASTQualifiedNamedElement qualifiedName;
+ private final List parameters;
+ protected final ASTReferenceStore references;
+
/**
- *
- */
- public ASTFunction()
- {
- super();
- // TODO Auto-generated constructor stub
+ * @param symbol
+ * @param parameters
+ * @param returnType
+ * @param exception
+ * @param startOffset
+ * @param nameOffset
+ * @param ownerTemplate
+ * @param references
+ */
+ public ASTFunction(IParameterizedSymbol symbol, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int nameOffset, IASTTemplate ownerTemplate, List references)
+ {
+ super( symbol );
+ this.parameters = parameters;
+
+ this.returnType = returnType;
+ this.exception = exception;
+ setStartingOffset(startOffset);
+ setNameOffset(nameOffset);
+ this.ownerTemplate = ownerTemplate;
+ this.references = new ASTReferenceStore( references );
+ qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), symbol.getName() );
}
+
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#isInline()
*/
public boolean isInline()
{
- // TODO Auto-generated method stub
- return false;
+ return symbol.getTypeInfo().checkBit( TypeInfo.isInline );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#isFriend()
*/
public boolean isFriend()
{
- // TODO Auto-generated method stub
- return false;
+ return symbol.getTypeInfo().checkBit( TypeInfo.isFriend );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#isStatic()
*/
public boolean isStatic()
{
- // TODO Auto-generated method stub
- return false;
+ return symbol.getTypeInfo().checkBit( TypeInfo.isStatic );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
*/
public String getName()
{
- // TODO Auto-generated method stub
- return null;
+ return symbol.getName();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#getReturnType()
*/
public IASTAbstractDeclaration getReturnType()
{
- // TODO Auto-generated method stub
- return null;
+ return returnType;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#getParameters()
*/
public Iterator getParameters()
{
- // TODO Auto-generated method stub
- return null;
+ return parameters.iterator();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#getExceptionSpec()
*/
public IASTExceptionSpecification getExceptionSpec()
{
- // TODO Auto-generated method stub
- return null;
+ return exception;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#setHasFunctionBody(boolean)
*/
public void setHasFunctionBody(boolean b)
{
- // TODO Auto-generated method stub
+ hasFunctionBody = true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#hasFunctionBody()
*/
public boolean hasFunctionBody()
{
- // TODO Auto-generated method stub
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
- */
- public Iterator getDeclarations() throws ASTNotImplementedException
- {
- // TODO Auto-generated method stub
- return null;
+ return hasFunctionBody;
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameOffset()
*/
public int getNameOffset()
{
- // TODO Auto-generated method stub
- return 0;
+ return offsets.getNameOffset();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
*/
public void setNameOffset(int o)
{
- // TODO Auto-generated method stub
+ offsets.setNameOffset(o);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTTemplatedDeclaration#getOwnerTemplateDeclaration()
*/
public IASTTemplate getOwnerTemplateDeclaration()
{
- // TODO Auto-generated method stub
- return null;
+ return ownerTemplate;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
*/
public String[] getFullyQualifiedName()
{
- // TODO Auto-generated method stub
- return null;
+ return qualifiedName.getFullyQualifiedName();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
*/
public void setStartingOffset(int o)
{
- // TODO Auto-generated method stub
+ offsets.setStartingOffset(o);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
*/
public void setEndingOffset(int o)
{
- // TODO Auto-generated method stub
+ offsets.setEndingOffset(o);
}
/* (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)
*/
public void acceptElement(ISourceElementRequestor requestor)
{
- // TODO Auto-generated method stub
+ requestor.acceptFunctionDeclaration(this);
+ references.processReferences(requestor);
}
/* (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
+ requestor.enterFunctionBody( this );
+ references.processReferences(requestor);
}
/* (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
+ requestor.exitFunctionBody( this );
}
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunctionReference.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunctionReference.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunctionReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunctionReference.java 25 Jul 2003 00:34:43 -0000
@@ -0,0 +1,65 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+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.IASTFunction;
+import org.eclipse.cdt.core.parser.ast.IASTFunctionReference;
+import org.eclipse.cdt.core.parser.ast.IASTReference;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTFunctionReference
+ extends ASTReference
+ implements IASTReference, IASTFunctionReference
+{
+ private final IASTFunction declaration;
+ /**
+ * @param offset
+ * @param name
+ */
+ public ASTFunctionReference(int offset, String name, IASTFunction referencedDeclaration )
+ {
+ super(offset, name);
+ this.declaration = referencedDeclaration;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTReference#getReferencedElement()
+ */
+ public ISourceElementCallbackDelegate getReferencedElement()
+ {
+ return declaration;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void acceptElement(ISourceElementRequestor requestor)
+ {
+ requestor.acceptFunctionReference( this );
+ }
+ /* (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)
+ {
+
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTLinkageSpecification.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTLinkageSpecification.java,v
retrieving revision 1.1
diff -u -r1.1 ASTLinkageSpecification.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTLinkageSpecification.java 24 Jul 2003 13:47:18 -0000 1.1
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTLinkageSpecification.java 25 Jul 2003 00:34:43 -0000
@@ -15,95 +15,87 @@
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
-import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.internal.core.parser.ast.Offsets;
+import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
/**
* @author jcamelon
*
*/
-public class ASTLinkageSpecification implements IASTLinkageSpecification
+public class ASTLinkageSpecification extends ASTAnonymousDeclaration implements IASTLinkageSpecification
{
+ private final String linkageString;
+ private Offsets offsets = new Offsets();
/**
*
*/
- public ASTLinkageSpecification()
+ public ASTLinkageSpecification( IContainerSymbol scope, String linkageString, int startingOffset )
{
- super();
- // TODO Auto-generated constructor stub
+ super( scope );
+ this.linkageString = linkageString;
+ setStartingOffset(startingOffset);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification#getLinkageString()
*/
public String getLinkageString()
{
- // TODO Auto-generated method stub
- return null;
+ return linkageString;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
*/
public Iterator getDeclarations() throws ASTNotImplementedException
{
- // TODO Auto-generated method stub
- return null;
+ throw new ASTNotImplementedException();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
*/
public void setStartingOffset(int o)
{
- // TODO Auto-generated method stub
+ offsets.setStartingOffset(o);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
*/
public void setEndingOffset(int o)
{
- // TODO Auto-generated method stub
+ offsets.setEndingOffset(o);
}
/* (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)
*/
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
+ requestor.enterLinkageSpecification(this);
}
/* (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
+ requestor.exitLinkageSpecification(this);
}
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java,v
retrieving revision 1.1
diff -u -r1.1 ASTMethod.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java 24 Jul 2003 13:47:18 -0000 1.1
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java 25 Jul 2003 00:34:43 -0000
@@ -10,262 +10,133 @@
***********************************************************************/
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.ASTAccessVisibility;
-import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
import org.eclipse.cdt.core.parser.ast.IASTMethod;
-import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
+import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
/**
* @author jcamelon
*
*/
-public class ASTMethod implements IASTMethod
+public class ASTMethod extends ASTFunction implements IASTMethod
{
+ private final boolean isConstructor;
+ private final boolean isPureVirtual;
+ private final ASTAccessVisibility visibility;
+ private final boolean isDestructor;
/**
- *
- */
- public ASTMethod()
- {
- super();
- // TODO Auto-generated constructor stub
+ * @param symbol
+ * @param parameters
+ * @param returnType
+ * @param exception
+ * @param startOffset
+ * @param nameOffset
+ * @param ownerTemplate
+ * @param references
+ */
+ public ASTMethod(IParameterizedSymbol symbol, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int nameOffset, IASTTemplate ownerTemplate, List references,
+ boolean isConstructor, boolean isDestructor, boolean isPureVirtual, ASTAccessVisibility visibility )
+ {
+ super(
+ symbol,
+ parameters,
+ returnType,
+ exception,
+ startOffset,
+ nameOffset,
+ ownerTemplate,
+ references);
+ this.visibility = visibility;
+ this.isConstructor = isConstructor;
+ this.isDestructor = isDestructor;
+ this.isPureVirtual = isPureVirtual;
+
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVirtual()
*/
public boolean isVirtual()
{
- // TODO Auto-generated method stub
- return false;
+ return symbol.getTypeInfo().checkBit( TypeInfo.isVirtual );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isExplicit()
*/
public boolean isExplicit()
{
- // TODO Auto-generated method stub
- return false;
+ return symbol.getTypeInfo().checkBit( TypeInfo.isExplicit);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isConstructor()
*/
public boolean isConstructor()
{
- // TODO Auto-generated method stub
- return false;
+ return isConstructor;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isDestructor()
*/
public boolean isDestructor()
{
- // TODO Auto-generated method stub
- return false;
+ return isDestructor;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isConst()
*/
public boolean isConst()
{
- // TODO Auto-generated method stub
- return false;
+ return symbol.getTypeInfo().checkBit( TypeInfo.isConst);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVolatile()
*/
public boolean isVolatile()
{
- // TODO Auto-generated method stub
- return false;
+ return symbol.getTypeInfo().checkBit( TypeInfo.isVolatile );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isPureVirtual()
*/
public boolean isPureVirtual()
{
- // TODO Auto-generated method stub
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFunction#isInline()
- */
- public boolean isInline()
- {
- // TODO Auto-generated method stub
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFunction#isFriend()
- */
- public boolean isFriend()
- {
- // TODO Auto-generated method stub
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFunction#isStatic()
- */
- public boolean isStatic()
- {
- // TODO Auto-generated method stub
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
- */
- public String getName()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFunction#getReturnType()
- */
- public IASTAbstractDeclaration getReturnType()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFunction#getParameters()
- */
- public Iterator getParameters()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFunction#getExceptionSpec()
- */
- public IASTExceptionSpecification getExceptionSpec()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFunction#setHasFunctionBody(boolean)
- */
- public void setHasFunctionBody(boolean b)
- {
- // TODO Auto-generated method stub
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFunction#hasFunctionBody()
- */
- public boolean hasFunctionBody()
- {
- // TODO Auto-generated method stub
- return false;
+ return isPureVirtual;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTMember#getVisiblity()
*/
public ASTAccessVisibility getVisiblity()
{
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
- */
- public Iterator getDeclarations() throws ASTNotImplementedException
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameOffset()
- */
- public int getNameOffset()
- {
- // TODO Auto-generated method stub
- return 0;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
- */
- public void setNameOffset(int o)
- {
- // TODO Auto-generated method stub
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTTemplatedDeclaration#getOwnerTemplateDeclaration()
- */
- public IASTTemplate getOwnerTemplateDeclaration()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
- */
- public String[] getFullyQualifiedName()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
- */
- public void setStartingOffset(int o)
- {
- // TODO Auto-generated method stub
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
- */
- public void setEndingOffset(int o)
- {
- // TODO Auto-generated method stub
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset()
- */
- public int getStartingOffset()
- {
- // TODO Auto-generated method stub
- return 0;
- }
- /* (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 visibility;
}
+
/* (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
+ requestor.acceptMethodDeclaration(this);
+ references.processReferences(requestor);
}
/* (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
+ requestor.enterMethodBody(this);
+ references.processReferences(requestor);
}
/* (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
+ requestor.exitMethodBody( this );
}
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethodReference.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethodReference.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethodReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethodReference.java 25 Jul 2003 00:34:43 -0000
@@ -0,0 +1,62 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+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.IASTMethod;
+import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTMethodReference
+ extends ASTReference
+ implements IASTMethodReference
+{
+ private final IASTMethod method;
+ /**
+ * @param offset
+ * @param name
+ */
+ public ASTMethodReference(int offset, String name, IASTMethod method )
+ {
+ super(offset, name);
+ this.method = method;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTReference#getReferencedElement()
+ */
+ public ISourceElementCallbackDelegate getReferencedElement()
+ {
+ return method;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void acceptElement(ISourceElementRequestor requestor)
+ {
+ requestor.acceptMethodReference( this );
+ }
+ /* (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)
+ {
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterDeclaration.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterDeclaration.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterDeclaration.java 24 Jul 2003 13:47:18 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,81 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast.complete;
-
-import java.util.Iterator;
-
-import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
-import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
-
-/**
- * @author jcamelon
- *
- */
-public class ASTParameterDeclaration implements IASTParameterDeclaration
-{
- /**
- *
- */
- public ASTParameterDeclaration()
- {
- super();
- // TODO Auto-generated constructor stub
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getName()
- */
- public String getName()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getDefaultValue()
- */
- public IASTInitializerClause getDefaultValue()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isConst()
- */
- public boolean isConst()
- {
- // TODO Auto-generated method stub
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerOperators()
- */
- public Iterator getPointerOperators()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getArrayModifiers()
- */
- public Iterator getArrayModifiers()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTTypeSpecifierOwner#getTypeSpecifier()
- */
- public IASTTypeSpecifier getTypeSpecifier()
- {
- // TODO Auto-generated method stub
- return null;
- }
-}
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.5
diff -u -r1.5 CompleteParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 24 Jul 2003 13:47:18 -0000 1.5
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 25 Jul 2003 00:34:44 -0000
@@ -58,12 +58,12 @@
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
-import org.eclipse.cdt.internal.core.parser.ast.ASTAbstractDeclaration;
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
+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;
@@ -150,7 +150,10 @@
}
protected IContainerSymbol scopeToSymbol(IASTScope currentScope)
{
- return ((ASTScope)currentScope).getContainerSymbol();
+ if( currentScope instanceof ASTScope )
+ return ((ASTScope)currentScope).getContainerSymbol();
+ else
+ return scopeToSymbol(((ASTAnonymousDeclaration)currentScope).getOwnerScope());
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.core.parser.ITokenDuple, int, int)
@@ -319,8 +322,7 @@
String spec,
int startingOffset)
{
- // TODO FIX THIS
- return new ASTLinkageSpecification();
+ return new ASTLinkageSpecification( scopeToSymbol( scope ), spec, startingOffset );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, org.eclipse.cdt.core.parser.ast.ASTClassKind, org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, org.eclipse.cdt.core.parser.ast.IASTTemplate, int, int)
@@ -414,6 +416,9 @@
*/
protected IASTReference createReference(ISymbol symbol, String string, int offset ) throws ASTSemanticException
{
+ if( symbol == null )
+ throw new ASTSemanticException();
+
if( symbol.getType() == TypeInfo.t_namespace )
{
return new ASTNamespaceReference( offset, string, (IASTNamespaceDefinition)symbol.getASTExtension().getPrimaryDeclaration());
@@ -426,6 +431,13 @@
}
else if( symbol.getType() == TypeInfo.t_enumeration )
return new ASTEnumerationReference( offset, string, (IASTEnumerationSpecifier)symbol.getASTExtension().getPrimaryDeclaration() );
+ else if( symbol.getType() == TypeInfo.t_function )
+ {
+ if( symbol.getContainingSymbol().getTypeInfo().isType( TypeInfo.t_class, TypeInfo.t_union ) )
+ return new ASTMethodReference( offset, string, (IASTMethod)symbol.getASTExtension().getPrimaryDeclaration() );
+ else
+ return new ASTFunctionReference( offset, string, (IASTFunction)symbol.getASTExtension().getPrimaryDeclaration() );
+ }
else if( ( symbol.getType() == TypeInfo.t_type ) ||
( symbol.getType() == TypeInfo.t_bool )||
( symbol.getType() == TypeInfo.t_char ) ||
@@ -645,17 +657,8 @@
Iterator i = typeName.iterator();
IToken first = typeName.getFirstToken();
- ISymbol typeSymbol = null;
- if( first.getType() == IToken.tCOLONCOLON )
- {
- typeSymbol = pst.getCompilationUnit();
- i.next(); // waste this token
- }
- else
- {
- typeSymbol = scopeToSymbol( scope );
- }
-
+ ISymbol typeSymbol = getScopeToSearchUpon( scope, first, i );
+
while( i.hasNext() )
{
IToken current = (IToken)i.next();
@@ -700,22 +703,171 @@
boolean isStatic,
int startOffset,
int nameOffset,
- IASTTemplate ownerTemplate)
+ IASTTemplate ownerTemplate) throws ASTSemanticException
{
- // TODO Auto-generated method stub
- return new ASTFunction();
+ IContainerSymbol ownerScope = scopeToSymbol( scope );
+ IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
+ setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
+ List references = new ArrayList();
+
+ try
+ {
+ ownerScope.addSymbol( symbol );
+ }
+ catch (ParserSymbolTableException e)
+ {
+ throw new ASTSemanticException();
+ }
+
+ setParameter( symbol, returnType, false, references );
+ setParameters( symbol, references, parameters.iterator() );
+
+ ASTFunction function = new ASTFunction( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references );
+ try
+ {
+ attachSymbolExtension(symbol, function);
+ }
+ catch (ExtensionException e1)
+ {
+ throw new ASTSemanticException();
+ }
+ return function;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createAbstractDeclaration(boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List)
+ protected void setFunctionTypeInfoBits(
+ boolean isInline,
+ boolean isFriend,
+ boolean isStatic,
+ IParameterizedSymbol symbol)
+ {
+ symbol.getTypeInfo().setBit( isInline, TypeInfo.isInline );
+ symbol.getTypeInfo().setBit( isFriend, TypeInfo.isFriend );
+ symbol.getTypeInfo().setBit( isStatic, TypeInfo.isStatic );
+ }
+
+ /**
+ * @param symbol
+ * @param iterator
*/
- public IASTAbstractDeclaration createAbstractDeclaration(
- boolean isConst,
- IASTTypeSpecifier typeSpecifier,
- List pointerOperators,
- List arrayModifiers)
+ protected void setParameters(IParameterizedSymbol symbol, List references, Iterator iterator) throws ASTSemanticException
{
- return new ASTAbstractDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers );
+ while( iterator.hasNext() )
+ {
+ setParameter( symbol, (IASTParameterDeclaration)iterator.next(), true, references );
+ }
}
+
+ /**
+ * @param symbol
+ * @param returnType
+ */
+ protected void setParameter(IParameterizedSymbol symbol, IASTAbstractDeclaration absDecl, boolean isParameter, List references) throws ASTSemanticException
+ {
+ TypeInfo.eType type = null;
+ ISymbol xrefSymbol = null;
+ List newReferences = null;
+ if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
+ {
+ IASTSimpleTypeSpecifier.Type kind = ((IASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getType();
+ if( kind == IASTSimpleTypeSpecifier.Type.BOOL )
+ type = TypeInfo.t_bool;
+ else if( kind == IASTSimpleTypeSpecifier.Type.CHAR )
+ type = TypeInfo.t_char;
+ else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE )
+ type = TypeInfo.t_double;
+ else if( kind == IASTSimpleTypeSpecifier.Type.FLOAT )
+ type = TypeInfo.t_float;
+ else if( kind == IASTSimpleTypeSpecifier.Type.INT )
+ type = TypeInfo.t_int;
+ else if( kind == IASTSimpleTypeSpecifier.Type.VOID )
+ type = TypeInfo.t_void;
+ else if( kind == IASTSimpleTypeSpecifier.Type.WCHAR_T)
+ type = TypeInfo.t_wchar_t;
+ else if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
+ {
+ type = TypeInfo.t_type;
+ xrefSymbol = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getSymbol();
+ newReferences = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getReferences();
+ }
+ else
+ throw new ASTSemanticException();
+ }
+ else if( absDecl.getTypeSpecifier() instanceof IASTClassSpecifier )
+ {
+ ASTClassKind kind = ((IASTClassSpecifier)absDecl.getTypeSpecifier()).getClassKind();
+ if( kind == ASTClassKind.CLASS )
+ type = TypeInfo.t_class;
+ else if( kind == ASTClassKind.STRUCT )
+ type = TypeInfo.t_struct;
+ else if( kind == ASTClassKind.UNION )
+ type = TypeInfo.t_union;
+ else
+ throw new ASTSemanticException();
+ }
+ else if( absDecl.getTypeSpecifier() instanceof IASTEnumerationSpecifier )
+ {
+ type = TypeInfo.t_enumeration;
+ }
+ else if( absDecl.getTypeSpecifier() instanceof IASTElaboratedTypeSpecifier )
+ {
+ ASTClassKind kind = ((IASTElaboratedTypeSpecifier)absDecl.getTypeSpecifier()).getClassKind();
+ if( kind == ASTClassKind.CLASS )
+ type = TypeInfo.t_class;
+ else if( kind == ASTClassKind.STRUCT )
+ type = TypeInfo.t_struct;
+ else if( kind == ASTClassKind.UNION )
+ type = TypeInfo.t_union;
+ else if( kind == ASTClassKind.ENUM )
+ type = TypeInfo.t_enumeration;
+ else
+ throw new ASTSemanticException();
+ }
+ else
+ throw new ASTSemanticException();
+
+ ISymbol paramSymbol = pst.newSymbol( "", type );
+ if( xrefSymbol != null )
+ paramSymbol.setTypeSymbol( xrefSymbol );
+
+ setPointerOperators( paramSymbol, absDecl.getPointerOperators(), absDecl.getArrayModifiers() );
+
+ if( isParameter)
+ symbol.addParameter( paramSymbol );
+ else
+ symbol.setReturnType( paramSymbol );
+
+ if( newReferences != null )
+ references.addAll( newReferences );
+
+ }
+
+ /**
+ * @param paramSymbol
+ * @param iterator
+ */
+ protected void setPointerOperators(ISymbol symbol, Iterator pointerOpsIterator, Iterator arrayModsIterator) throws ASTSemanticException
+ {
+ while( pointerOpsIterator.hasNext() )
+ {
+ ASTPointerOperator pointerOperator = (ASTPointerOperator)pointerOpsIterator.next();
+ if( pointerOperator == ASTPointerOperator.REFERENCE )
+ symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_reference ));
+ else if( pointerOperator == ASTPointerOperator.POINTER )
+ symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer ));
+ else if( pointerOperator == ASTPointerOperator.CONST_POINTER )
+ symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer, true, false ));
+ else if( pointerOperator == ASTPointerOperator.VOLATILE_POINTER )
+ symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer, false, true));
+ else
+ throw new ASTSemanticException();
+ }
+
+ while( arrayModsIterator.hasNext() )
+ {
+ IASTArrayModifier astArrayModifier = (IASTArrayModifier)arrayModsIterator.next();
+ symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_array ));
+ }
+ }
+
/* (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)
*/
@@ -738,11 +890,55 @@
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
- ASTAccessVisibility visibility)
+ ASTAccessVisibility visibility) throws ASTSemanticException
{
- // TODO Auto-generated method stub
- return new ASTMethod();
+ 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();
+
+ try
+ {
+ ownerScope.addSymbol( symbol );
+ }
+ catch (ParserSymbolTableException e)
+ {
+ throw new ASTSemanticException();
+ }
+
+ setParameter( symbol, returnType, false, references );
+ setParameters( symbol, references, parameters.iterator() );
+
+ ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, isConstructor, isDestructor, isPureVirtual, visibility );
+ try
+ {
+ attachSymbolExtension( symbol, method );
+ }
+ catch (ExtensionException e1)
+ {
+ throw new ASTSemanticException();
+ }
+ return method;
+ }
+ /**
+ * @param symbol
+ * @param isConst
+ * @param isVolatile
+ * @param isConstructor
+ * @param isDestructor
+ * @param isVirtual
+ * @param isExplicit
+ * @param isPureVirtual
+ */
+ protected void setMethodTypeInfoBits(IParameterizedSymbol symbol, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit)
+ {
+ symbol.getTypeInfo().setBit( isConst, TypeInfo.isConst );
+ symbol.getTypeInfo().setBit( isVolatile, TypeInfo.isConst );
+ symbol.getTypeInfo().setBit( isVirtual, TypeInfo.isVirtual );
+ symbol.getTypeInfo().setBit( isExplicit, TypeInfo.isExplicit );
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createVariable(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, boolean, org.eclipse.cdt.core.parser.ast.IASTInitializerClause, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean, boolean, boolean, boolean, int, int)
*/
@@ -761,8 +957,8 @@
int nameOffset) throws ASTSemanticException
{
List references = new ArrayList();
- ISymbol newSymbol = cloneSimpleTypeSymbol(scope, name, abstractDeclaration, references);
- setSymbolBits(
+ ISymbol newSymbol = cloneSimpleTypeSymbol(name, abstractDeclaration, references);
+ setVariableTypeInfoBits(
isAuto,
abstractDeclaration,
isMutable,
@@ -770,6 +966,15 @@
isRegister,
isStatic,
newSymbol);
+ setPointerOperators( newSymbol, abstractDeclaration.getPointerOperators(), abstractDeclaration.getArrayModifiers() );
+ try
+ {
+ scopeToSymbol(scope).addSymbol( newSymbol );
+ }
+ catch (ParserSymbolTableException e)
+ {
+ // TODO Auto-generated catch block
+ }
ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references );
try
@@ -782,7 +987,7 @@
}
return variable;
}
- private void setSymbolBits(
+ protected void setVariableTypeInfoBits(
boolean isAuto,
IASTAbstractDeclaration abstractDeclaration,
boolean isMutable,
@@ -799,7 +1004,6 @@
newSymbol.getTypeInfo().setBit( abstractDeclaration.isConst(), TypeInfo.isConst );
}
protected ISymbol cloneSimpleTypeSymbol(
- IASTScope scope,
String name,
IASTAbstractDeclaration abstractDeclaration,
List references)
@@ -810,15 +1014,6 @@
ISymbol symbolToBeCloned = ((ASTSimpleTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol();
newSymbol = (ISymbol)symbolToBeCloned.clone();
newSymbol.setName( name );
- IContainerSymbol containerSymbol = scopeToSymbol(scope);
- try
- {
- containerSymbol.addSymbol( newSymbol );
- }
- catch (ParserSymbolTableException e)
- {
- // TODO Auto-generated catch block
- }
references.addAll( ((ASTSimpleTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getReferences() );
}
return newSymbol;
@@ -842,8 +1037,8 @@
ASTAccessVisibility visibility) throws ASTSemanticException
{
List references = new ArrayList();
- ISymbol newSymbol = cloneSimpleTypeSymbol(scope, name, abstractDeclaration, references);
- setSymbolBits(
+ ISymbol newSymbol = cloneSimpleTypeSymbol(name, abstractDeclaration, references);
+ setVariableTypeInfoBits(
isAuto,
abstractDeclaration,
isMutable,
@@ -851,6 +1046,16 @@
isRegister,
isStatic,
newSymbol);
+ setPointerOperators( newSymbol, abstractDeclaration.getPointerOperators(), abstractDeclaration.getArrayModifiers() );
+
+ try
+ {
+ scopeToSymbol(scope).addSymbol( newSymbol );
+ }
+ catch (ParserSymbolTableException e)
+ {
+ // TODO Auto-generated catch block
+ }
ASTField field = new ASTField( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, visibility );
try
{
@@ -864,20 +1069,7 @@
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createParameterDeclaration(boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTInitializerClause)
- */
- public IASTParameterDeclaration createParameterDeclaration(
- boolean isConst,
- IASTTypeSpecifier getTypeSpecifier,
- List pointerOperators,
- List arrayModifiers,
- String parameterName,
- IASTInitializerClause initializerClause)
- {
- // TODO Auto-generated method stub
- return new ASTParameterDeclaration();
- }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, java.util.List, boolean, int)
*/
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java 9 Jul 2003 00:47:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast.quick;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
-import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
-
-/**
- * @author jcamelon
- *
- */
-public class ASTParameterDeclaration implements IASTParameterDeclaration
-{
- private final boolean isConst;
- private final IASTTypeSpecifier typeSpecifier;
- private final List pointerOperators;
- private final List arrayModifiers;
- private final String parameterName;
- private final IASTInitializerClause initializerClause;
- /**
- * @param isConst
- * @param typeSpecifier
- * @param pointerOperators
- * @param arrayModifiers
- * @param parameterName
- * @param initializerClause
- */
- public ASTParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause)
- {
- this.isConst = isConst;
- this.typeSpecifier = typeSpecifier;
- this.pointerOperators = pointerOperators;
- this.arrayModifiers = arrayModifiers;
- this.parameterName = parameterName;
- this.initializerClause = initializerClause;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getName()
- */
- public String getName()
- {
- return parameterName;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getDefaultValue()
- */
- public IASTInitializerClause getDefaultValue()
- {
- return initializerClause;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isConst()
- */
- public boolean isConst()
- {
- return isConst;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getTypeSpecifier()
- */
- public IASTTypeSpecifier getTypeSpecifier()
- {
- return typeSpecifier;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerOperators()
- */
- public Iterator getPointerOperators()
- {
- return pointerOperators.iterator();
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getArrayModifiers()
- */
- public Iterator getArrayModifiers()
- {
- return arrayModifiers.iterator();
- }
-}
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.17
diff -u -r1.17 QuickParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 24 Jul 2003 13:47:18 -0000 1.17
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 25 Jul 2003 00:34:44 -0000
@@ -55,7 +55,6 @@
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
-import org.eclipse.cdt.internal.core.parser.ast.*;
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
@@ -218,14 +217,6 @@
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createAbstractDeclaration(boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List)
- */
- public IASTAbstractDeclaration createAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers)
- {
- return new ASTAbstractDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers );
- }
-
- /* (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)
@@ -247,14 +238,6 @@
public IASTField createField(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, ASTAccessVisibility visibility)
{
return new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, nameOffset, visibility);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createParameterDeclaration(boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTInitializerClause)
- */
- public IASTParameterDeclaration createParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause)
- {
- return new ASTParameterDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers, parameterName, initializerClause );
}
/* (non-Javadoc)
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.8
diff -u -r1.8 ParserSymbolTable.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java 22 Jul 2003 22:02:20 -0000 1.8
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java 25 Jul 2003 00:34:45 -0000
@@ -2117,7 +2117,10 @@
if( size != size2 ){
return size2 - size;
- } else {
+ } else if( size == 0 )
+ return 0;
+ else {
+
Iterator iter1 = symbol.getTypeInfo().getPtrOperators().iterator();
Iterator iter2 = getTypeInfo().getPtrOperators().iterator();
@@ -2560,7 +2563,9 @@
throw new ParserSymbolTableException();
}
- if( unnamed || ((origList == null) ? isValidOverload( origDecl, obj ) : isValidOverload( origList, obj ) )){
+ boolean validOverride = ((origList == null) ? isValidOverload( origDecl, obj ) : isValidOverload( origList, obj ) );
+ if( unnamed || validOverride )
+ {
if( origList == null ){
origList = new LinkedList();
origList.add( origDecl );
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.33
diff -u -r1.33 ChangeLog
--- ChangeLog 24 Jul 2003 21:47:13 -0000 1.33
+++ ChangeLog 25 Jul 2003 00:35:00 -0000
@@ -1,3 +1,7 @@
+2003-07-24 John Camelon
+ Updated CompleteParseASTTests for Method/Field updates.
+ Fixed TortureTest's parser mode switch (was always QuickParsing).
+
2003-07-24 Hoda Amer
Moved part of the CModelElementsTest (Templates of Variables ) to the failed tests.
Moved the same test (Templates of Variables) from ITemplateTests to failed 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.4
diff -u -r1.4 CompleteParseASTTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 24 Jul 2003 13:47:20 -0000 1.4
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 25 Jul 2003 00:35:00 -0000
@@ -48,6 +48,7 @@
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
+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;
@@ -705,6 +706,65 @@
assertEquals( ((IASTSimpleTypeSpecifier)varE.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), enumE );
}
+ public void testSimpleFunction() throws Exception
+ {
+ Iterator declarations = parse( "void foo( void );").getDeclarations();
+ IASTFunction function = (IASTFunction)declarations.next();
+ assertEquals( function.getName(), "foo" );
+ assertEquals( callback.getReferences().size(), 0 );
+ }
+
+ public void testSimpleFunctionWithTypes() throws Exception
+ {
+ Iterator declarations = parse( "class A { public: \n class B { }; }; const A::B & foo( A * myParam );").getDeclarations();
+ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
+ IASTFunction function = (IASTFunction)declarations.next();
+ assertEquals( callback.getReferences().size(), 3 );
+ }
+
+ public void testSimpleMethod() throws Exception
+ {
+ Iterator declarations = parse( "class A { void foo(); };").getDeclarations();
+ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
+ IASTMethod method = (IASTMethod)getDeclarations( classA ).next();
+ assertEquals( method.getName(), "foo" );
+ }
+
+ public void testSimpleMethodWithTypes() throws Exception
+ {
+ Iterator declarations = parse( "class U { }; class A { U foo( U areDumb ); };").getDeclarations();
+ IASTClassSpecifier classU = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
+ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
+ IASTMethod method = (IASTMethod)getDeclarations( classA ).next();
+ assertEquals( method.getName(), "foo" );
+ assertEquals( callback.getReferences().size(), 2 );
+ }
+
+ public void testUsingDeclarationWithFunctionsAndMethods() throws Exception
+ {
+ Iterator declarations = parse( "namespace N { int foo(void); } class A { static int bar(void); }; using N::foo; using ::A::bar;" ).getDeclarations();
+ IASTNamespaceDefinition namespaceN = (IASTNamespaceDefinition)declarations.next();
+ IASTFunction fooFunction = (IASTFunction)(getDeclarations(namespaceN).next());
+ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
+ IASTMethod methodM = (IASTMethod)(getDeclarations(classA).next());
+ IASTUsingDeclaration using1 = (IASTUsingDeclaration)declarations.next();
+ IASTUsingDeclaration using2 = (IASTUsingDeclaration)declarations.next();
+ assertEquals( callback.getReferences().size(), 4 );
+ Iterator references = callback.getReferences().iterator();
+ assertEquals( ((IASTReference)references.next()).getReferencedElement(), namespaceN );
+ assertEquals( ((IASTReference)references.next()).getReferencedElement(), fooFunction );
+ assertEquals( ((IASTReference)references.next()).getReferencedElement(), classA );
+ assertEquals( ((IASTReference)references.next()).getReferencedElement(), methodM );
+ }
+
+ public void testLinkageSpec() throws Exception
+ {
+ IASTLinkageSpecification linkage = (IASTLinkageSpecification)parse( "extern \"C\" { int foo(); }").getDeclarations().next();
+ Iterator i = getDeclarations( linkage );
+ IASTFunction f = (IASTFunction)i.next();
+ assertEquals( f.getName(),"foo");
+ }
+
protected void assertQualifiedName(String [] fromAST, String [] theTruth)
{
assertNotNull( fromAST );
@@ -715,4 +775,6 @@
assertEquals( fromAST[i], theTruth[i]);
}
}
+
+
}
Index: parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java,v
retrieving revision 1.10
diff -u -r1.10 ParserSymbolTableTest.java
--- parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java 22 Jul 2003 22:02:24 -0000 1.10
+++ parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java 25 Jul 2003 00:35:01 -0000
@@ -18,7 +18,6 @@
import junit.framework.TestCase;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
@@ -26,6 +25,7 @@
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
+import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension;
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Mark;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance;
@@ -102,52 +102,12 @@
assertEquals( look, null );
}
- protected class NullSymbolExtension implements ISymbolASTExtension
- {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getPrimaryDeclaration()
- */
- public ASTSymbol getPrimaryDeclaration()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getAllDefinitions()
- */
- public Iterator getAllDefinitions()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#addDefinition(org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol)
- */
- public void addDefinition(ASTSymbol definition) throws ExtensionException
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner#getSymbol()
- */
- public ISymbol getSymbol()
- {
- // TODO Auto-generated method stub
- return null;
- }
- }
-
public void testSimpleSetGetObject() throws Exception{
newTable();
IContainerSymbol x = table.new Declaration("x");
- ISymbolASTExtension extension = new NullSymbolExtension ();
+ ISymbolASTExtension extension = new StandardSymbolExtension(x,null);
x.setASTExtension( extension );
Index: parser/org/eclipse/cdt/core/parser/tests/TortureTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java,v
retrieving revision 1.7
diff -u -r1.7 TortureTest.java
--- parser/org/eclipse/cdt/core/parser/tests/TortureTest.java 22 Jul 2003 00:44:16 -0000 1.7
+++ parser/org/eclipse/cdt/core/parser/tests/TortureTest.java 25 Jul 2003 00:35:01 -0000
@@ -277,9 +277,10 @@
public void run(){
try {
- DOMBuilder domBuilder = new DOMBuilder();
+ DOMBuilder domBuilder = new DOMBuilder();
+ ParserMode parserMode = quickParse ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
parser = ParserFactory.createParser(
- ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE, nullCallback ), nullCallback, ParserMode.QUICK_PARSE);
+ ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), parserMode, nullCallback ), nullCallback, parserMode);
parser.setCppNature(cppNature);
mapping = ParserFactory.createLineOffsetReconciler( new StringReader( code ) );