Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Camelon2003-09-11 18:06:15 +0000
committerJohn Camelon2003-09-11 18:06:15 +0000
commit322dcaad49939895e0f66cffb7537bc6b968ebd3 (patch)
tree7658e2d88ecbac69142e7587f5e3e9394aea1953 /core/org.eclipse.cdt.core/parser
parent22e130fbe74010db49230abc203d497c8720053a (diff)
downloadorg.eclipse.cdt-322dcaad49939895e0f66cffb7537bc6b968ebd3.tar.gz
org.eclipse.cdt-322dcaad49939895e0f66cffb7537bc6b968ebd3.tar.xz
org.eclipse.cdt-322dcaad49939895e0f66cffb7537bc6b968ebd3.zip
CORE
Fixed Bug 42840 : Search: Cannot find things after double declarations Fixed Bug 42798 : Selected #include <Angled> off by 1 char Fixed Bug 42872 : dynamic cast not parsed properly Partially fixed Bug 39504 : sizeof-expressions are not handled properly Updated SourceElementRequestor callbacks to include IASTParameterReference callbacks. UI Updated SourceElementRequestor callbacks to include IASTParameterReference callbacks. TESTS Added CompleteParseASTTest::testBug42840() & testBug42872(). Moved testBug39504B(), testBug39505A() & testBug39505B() from failed to QuickParse tests.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/ChangeLog7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTParameterReference.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java92
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterDeclaration.java136
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterReference.java65
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbolOwner.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java85
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTParameterDeclaration.java)3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java10
16 files changed, 385 insertions, 89 deletions
diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog
index a026b19f5cb..a9098e48ba1 100644
--- a/core/org.eclipse.cdt.core/parser/ChangeLog
+++ b/core/org.eclipse.cdt.core/parser/ChangeLog
@@ -1,3 +1,10 @@
+2003-09-11 John Camelon
+ Fixed Bug 42840 : Search: Cannot find things after double declarations
+ Fixed Bug 42798 : Selected #include <Angled> off by 1 char
+ Fixed Bug 42872 : dynamic cast not parsed properly
+ Partially fixed Bug 39504 : sizeof-expressions are not handled properly
+ Updated SourceElementRequestor callbacks to include IASTParameterReference callbacks.
+
2003-09-09 Hoda Amer
- Solved the double reference problem
- solution to bugs #42822, #42823, & #42822B
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java
index 04268bcb44b..54d70993015 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java
@@ -40,6 +40,7 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
+import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
/**
* @author jcamelon
@@ -90,6 +91,7 @@ public interface ISourceElementRequestor {
public void acceptFieldReference( IASTFieldReference reference );
public void acceptMethodReference( IASTMethodReference reference );
public void acceptEnumeratorReference( IASTEnumeratorReference reference );
+ public void acceptParameterReference(ASTParameterReference reference);
public void exitTemplateDeclaration( IASTTemplateDeclaration declaration );
public void exitTemplateSpecialization( IASTTemplateSpecialization specialization );
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
index d10e6b0ec06..e9c6ed85910 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
@@ -147,7 +147,7 @@ public interface IASTFactory
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
- ASTAccessVisibility visibility, List constructorChain) throws ASTSemanticException;
+ ASTAccessVisibility visibility, List constructorChain, boolean isDefinition ) throws ASTSemanticException;
public IASTAbstractDeclaration createAbstractDeclaration(
boolean isConst,
boolean isVolatile,
@@ -170,7 +170,7 @@ public interface IASTFactory
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
- ASTAccessVisibility visibility, List constructorChain) throws ASTSemanticException;
+ ASTAccessVisibility visibility, List constructorChain, boolean isDefinition) 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, IASTExpression constructorExpression ) throws ASTSemanticException;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTParameterReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTParameterReference.java
new file mode 100644
index 00000000000..64cf24936fb
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTParameterReference.java
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * 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.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTParameterReference extends IASTReference
+{
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
index d9979c87e5e..5077aa63e0a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
@@ -37,7 +37,7 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
*
*/
public class DeclarationWrapper implements IDeclaratorOwner
-{
+{
private ITokenDuple name;
private Type simpleType =
IASTSimpleTypeSpecifier.Type.UNSPECIFIED;
@@ -435,7 +435,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
virtual,
explicit,
declarator.isPureVirtual(),
- ((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers());
+ ((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers(),
+ declarator.hasFunctionBody());
}
/**
* @param declarator
@@ -465,7 +466,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
explicit,
declarator.isPureVirtual(),
ASTAccessVisibility.PUBLIC,
- declarator.getConstructorMemberInitializers());
+ declarator.getConstructorMemberInitializers(),
+ declarator.hasFunctionBody() );
}
/**
* @param declarator
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java
index e954d3dabe5..8878a3c7cad 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java
@@ -392,4 +392,20 @@ public class Declarator implements IParameterCollection, IDeclaratorOwner
return pointerOperatorNameDuple;
}
+ /**
+ * @return
+ */
+ public boolean hasFunctionBody()
+ {
+ return hasFunctionBody;
+ }
+
+ /**
+ * @param b
+ */
+ public void setHasFunctionBody(boolean b)
+ {
+ hasFunctionBody = b;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java
index f615c3e6eb8..87f3d1c6687 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java
@@ -32,6 +32,7 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
+import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
public class NullSourceElementRequestor implements ISourceElementRequestor
@@ -432,5 +433,14 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
{
// TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
+ */
+ public void acceptParameterReference(ASTParameterReference reference)
+ {
+ // TODO Auto-generated method stub
+
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
index aba339d8f7c..a829fdc50a0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
@@ -897,7 +897,7 @@ public class Parser implements IParser
case IToken.tLBRACE :
if (forKR)
throw backtrack;
- declarator.hasFunctionBody(true);
+ declarator.setHasFunctionBody(true);
hasFunctionBody = true;
break;
default :
@@ -1730,23 +1730,25 @@ public class Parser implements IParser
* @return Returns the same object sent in.
* @throws Backtrack
*/
- protected boolean cvQualifier(
+ protected IToken cvQualifier(
Declarator declarator)
throws Backtrack
{
+ IToken result = null;
switch (LT(1))
{
case IToken.t_const :
- consume( IToken.t_const );
- declarator.addPtrOp(ASTPointerOperator.CONST_POINTER);
- return true;
+ result = consume( IToken.t_const );
+ if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.CONST_POINTER);
+ break;
case IToken.t_volatile :
- consume( IToken.t_volatile );
- declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER);
- return true;
+ result = consume( IToken.t_volatile );
+ if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER);
+ break;
default :
- return false;
+
}
+ return result;
}
/**
* Parses the initDeclarator construct of the ANSI C++ spec.
@@ -2186,15 +2188,15 @@ public class Parser implements IParser
else
{
// must be a conversion function
- typeId();
- toSend = lastToken;
+ toSend = typeId().getLastToken();
+
try
{
// this ptrOp doesn't belong to the declarator,
// it's just a part of the name
- consumePointerOperators(d, true);
- if( lastToken != null )
- toSend = lastToken;
+ IToken temp = consumePointerOperators(d, true);
+ if( temp != null )
+ toSend = temp;
}
catch (Backtrack b)
{
@@ -2220,22 +2222,22 @@ public class Parser implements IParser
* @param owner Declarator that this pointer operator corresponds to.
* @throws Backtrack request a backtrack
*/
- protected void consumePointerOperators(Declarator d, boolean consumeOnlyOne) throws Backtrack
+ protected IToken consumePointerOperators(Declarator d, boolean consumeOnlyOne) throws Backtrack
{
+ IToken result = null;
for( ; ; )
{
- int t = LT(1);
- if (t == IToken.tAMPER)
+ if (LT(1) == IToken.tAMPER)
{
- consume( IToken.tAMPER );
- d.addPtrOp(ASTPointerOperator.REFERENCE);
- if( consumeOnlyOne ) return;
- continue;
+ result = consume( IToken.tAMPER );
+ if( d != null ) d.addPtrOp(ASTPointerOperator.REFERENCE);
+ /*if( consumeOnlyOne ) */return result;
+ /* continue; */
}
IToken mark = mark();
- IToken tokenType = LA(1);
+
ITokenDuple nameDuple = null;
- if (t == IToken.tIDENTIFIER || t == IToken.tCOLONCOLON)
+ if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
{
try
{
@@ -2244,34 +2246,33 @@ public class Parser implements IParser
catch( Backtrack bt )
{
backup( mark );
- return;
+ return null;
}
- t = LT(1);
}
- if (t == IToken.tSTAR)
+ if ( LT(1) == IToken.tSTAR)
{
- tokenType = consume(Token.tSTAR); // tokenType = "*"
+ result = consume(Token.tSTAR); // tokenType = "*"
- d.setPointerOperatorName(nameDuple);
+ if( d != null ) d.setPointerOperatorName(nameDuple);
- boolean successful = false;
+ IToken successful = null;
for (;;)
{
- boolean newSuccess = cvQualifier(d);
- if( newSuccess ) successful = true;
+ IToken newSuccess = cvQualifier(d);
+ if( newSuccess != null ) successful = newSuccess;
else break;
}
- if( !successful )
+ if( successful == null )
{
- d.addPtrOp( ASTPointerOperator.POINTER );
+ if( d != null ) d.addPtrOp( ASTPointerOperator.POINTER );
}
- if( consumeOnlyOne ) return;
+ if( consumeOnlyOne ) return result;
continue;
}
backup(mark);
- return;
+ return result;
}
}
/**
@@ -3520,12 +3521,6 @@ public class Parser implements IParser
if (LT(1) == IToken.t_const)
consume();
duple = typeId();
- while (LT(1) == IToken.tSTAR)
- {
- consume(IToken.tSTAR);
- if (LT(1) == IToken.t_const || LT(1) == IToken.t_volatile)
- consume();
- }
consume(IToken.tRPAREN);
IASTExpression castExpression = castExpression(scope);
try
@@ -3552,17 +3547,20 @@ public class Parser implements IParser
}
return unaryExpression(scope);
}
+
/**
* @throws Backtrack
*/
- protected ITokenDuple typeId() throws Backtrack
+ protected ITokenDuple typeId( ) throws Backtrack
{
IToken begin = LA(1);
IToken end = null;
try
{
ITokenDuple d = name();
- return d;
+ IToken checkForPtrs = consumePointerOperators(null, false);
+ if( checkForPtrs == null ) return d;
+ return new TokenDuple( d.getFirstToken(), checkForPtrs );
}
catch (Backtrack b)
{
@@ -3599,7 +3597,8 @@ public class Parser implements IParser
}
if (end != null)
{
- return new TokenDuple(begin, end);
+ IToken end2 = consumePointerOperators(null, false);
+ return new TokenDuple(begin, end2 == null ? end : end2);
}
else if (
LT(1) == IToken.t_typename
@@ -3610,7 +3609,8 @@ public class Parser implements IParser
{
consume();
ITokenDuple d = name();
- return new TokenDuple(begin, d.getLastToken());
+ IToken end2 = consumePointerOperators(null, false);
+ return new TokenDuple(begin, ( (end2 == null) ? d.getLastToken() : end2 ) );
}
else
throw backtrack;
@@ -4273,7 +4273,7 @@ public class Parser implements IParser
lhs,
null,
null,
- null,
+ duple,
"", null);
}
catch (ASTSemanticException e)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
index 209f047974f..7fda176c769 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
@@ -1966,8 +1966,9 @@ public class Scanner implements IScanner {
} else if (t.getType() == IToken.tLT) {
try {
- startOffset = baseOffset + t.getOffset();
+
t = helperScanner.nextToken(false);
+ startOffset = baseOffset + t.getOffset();
while (t.getType() != IToken.tGT) {
fileName.append(t.getImage());
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
index d75661aa53c..55fb8da35e4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
@@ -19,7 +19,6 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression;
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;
@@ -56,11 +55,6 @@ public class BaseASTFactory {
return new ASTAbstractDeclaration( isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOperator );
}
- public IASTParameterDeclaration createParameterDeclaration(boolean isConst, boolean isVolatile, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause)
- {
- return new ASTParameterDeclaration( isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp, parameterName, initializerClause );
- }
-
public IASTInitializerClause createInitializerClause(IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses)
{
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses );
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterDeclaration.java
new file mode 100644
index 00000000000..d28a149e093
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterDeclaration.java
@@ -0,0 +1,136 @@
+/**********************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
+import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
+import org.eclipse.cdt.internal.core.parser.ast.ASTAbstractDeclaration;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTParameterDeclaration extends ASTSymbol implements IASTParameterDeclaration
+{
+ private final ASTAbstractDeclaration abstractDeclaration;
+ private final String parameterName;
+ private final IASTInitializerClause initializerClause;
+ /**
+ * @param isConst
+ * @param typeSpecifier
+ * @param pointerOperators
+ * @param arrayModifiers
+ * @param parameterName
+ * @param initializerClause
+ */
+ public ASTParameterDeclaration(ISymbol symbol, boolean isConst, boolean isVolatile, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause)
+ {
+ super( symbol );
+ abstractDeclaration = new ASTAbstractDeclaration( isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp );
+ 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 abstractDeclaration.isConst();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isVolatile()
+ */
+ public boolean isVolatile()
+ {
+ return abstractDeclaration.isVolatile();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerOperators()
+ */
+ public Iterator getPointerOperators()
+ {
+ return abstractDeclaration.getPointerOperators();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getArrayModifiers()
+ */
+ public Iterator getArrayModifiers()
+ {
+ return abstractDeclaration.getArrayModifiers();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getParameters()
+ */
+ public Iterator getParameters()
+ {
+ return abstractDeclaration.getParameters();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerToFunctionOperator()
+ */
+ public ASTPointerOperator getPointerToFunctionOperator()
+ {
+ return abstractDeclaration.getPointerToFunctionOperator();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeSpecifierOwner#getTypeSpecifier()
+ */
+ public IASTTypeSpecifier getTypeSpecifier()
+ {
+ return abstractDeclaration.getTypeSpecifier();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void acceptElement(ISourceElementRequestor requestor)
+ {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void enterScope(ISourceElementRequestor requestor)
+ {
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void exitScope(ISourceElementRequestor requestor)
+ {
+
+ }
+
+
+
+
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterReference.java
new file mode 100644
index 00000000000..2c4a78ba15d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTParameterReference.java
@@ -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.IASTParameterDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTParameterReference extends ASTReference implements IASTParameterReference
+{
+ private final IASTParameterDeclaration parm;
+
+ /**
+ * @param offset
+ * @param string
+ * @param declaration
+ */
+ public ASTParameterReference(int offset, String string, IASTParameterDeclaration declaration)
+ {
+ super( offset, string );
+ parm = declaration;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTReference#getReferencedElement()
+ */
+ public ISourceElementCallbackDelegate getReferencedElement()
+ {
+ return parm;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void acceptElement(ISourceElementRequestor requestor)
+ {
+ requestor.acceptParameterReference( 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)
+ {
+
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbolOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbolOwner.java
index 1fd4b68fcf7..e069a7247e3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbolOwner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbolOwner.java
@@ -19,7 +19,7 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
*/
public class ASTSymbolOwner implements ISymbolOwner
{
- protected final ISymbol symbol;
+ protected ISymbol symbol;
/**
*
*/
@@ -34,4 +34,10 @@ public class ASTSymbolOwner implements ISymbolOwner
{
return symbol;
}
+
+ public void setSymbol( ISymbol symbol )
+ {
+ this.symbol = symbol;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
index 278c9e0928b..a350214aa1a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
@@ -63,7 +63,6 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescripto
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.ASTParameterDeclaration;
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
@@ -79,6 +78,7 @@ 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.ISymbolASTExtension.ExtensionException;
+
/**
* @author jcamelon
*
@@ -210,36 +210,18 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
throw new ASTSemanticException();
}
break;
- case 2:
- firstSymbol = name.getFirstToken();
- if( firstSymbol.getType() != IToken.tCOLONCOLON )
- throw new ASTSemanticException();
- try
- {
- if(type == TypeInfo.t_function)
- if(validParameterList(parameters))
- result = pst.getCompilationUnit().unqualifiedFunctionLookup( name.getLastToken().getImage(), new LinkedList(parameters));
- else
- result = null;
- else
- result = pst.getCompilationUnit().lookup( name.getLastToken().getImage() );
- addReference( references, createReference( result, name.getLastToken().getImage(), name.getLastToken().getOffset() ));
- }
- catch( ParserSymbolTableException e)
- {
- throw new ASTSemanticException();
- }
- break;
default:
Iterator iter = name.iterator();
firstSymbol = name.getFirstToken();
result = startingScope;
if( firstSymbol.getType() == IToken.tCOLONCOLON )
result = pst.getCompilationUnit();
+
while( iter.hasNext() )
{
IToken t = (IToken)iter.next();
if( t.getType() == IToken.tCOLONCOLON ) continue;
+ if( t.isPointer() ) break;
try
{
if( t == name.getLastToken() )
@@ -660,6 +642,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
return new ASTFieldReference( offset, string, (IASTField)symbol.getASTExtension().getPrimaryDeclaration());
}
+ else if( symbol.getContainingSymbol().getType() == TypeInfo.t_function &&
+ symbol.getContainingSymbol() instanceof IParameterizedSymbol &&
+ ((IParameterizedSymbol)symbol.getContainingSymbol()).getParameterList() != null &&
+ ((IParameterizedSymbol)symbol.getContainingSymbol()).getParameterList().contains( symbol ) )
+ {
+ return new ASTParameterReference( offset, string, (IASTParameterDeclaration)symbol.getASTExtension().getPrimaryDeclaration() );
+ }
else
{
return new ASTVariableReference( offset, string, (IASTVariable)symbol.getASTExtension().getPrimaryDeclaration());
@@ -1149,7 +1138,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility,
- List constructorChain) throws ASTSemanticException
+ List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
{
List references = new ArrayList();
IContainerSymbol ownerScope = scopeToSymbol( scope );
@@ -1208,7 +1197,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return createMethod(scope, functionName, parameters, returnType,
exception, isInline, isFriend, isStatic, startOffset, offset,
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
- visibility, constructorChain,parentName, references);
+ visibility, constructorChain,parentName, references, isFunctionDefinition);
}
}
@@ -1217,7 +1206,31 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
setParameter( symbol, returnType, false, references );
setParameters( symbol, references, parameters.iterator() );
-
+
+ symbol.setIsForwardDeclaration(!isFunctionDefinition);
+
+ if( isFunctionDefinition )
+ {
+ List functionParameters = new LinkedList();
+ // the lookup requires a list of type infos
+ // instead of a list of IASTParameterDeclaration
+ Iterator p = parameters.iterator();
+ while (p.hasNext()){
+ ASTParameterDeclaration param = (ASTParameterDeclaration)p.next();
+ functionParameters.add(getParameterTypeInfo(param));
+ }
+
+ IParameterizedSymbol functionDeclaration = null;
+
+ functionDeclaration =
+ (IParameterizedSymbol) lookupQualifiedName(ownerScope, name, TypeInfo.t_function, functionParameters, 0, new ArrayList(), false);
+
+ if( functionDeclaration != null )
+ {
+ functionDeclaration.setTypeSymbol( symbol );
+ }
+ }
+
try
{
ownerScope.addSymbol( symbol );
@@ -1362,6 +1375,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( newReferences != null )
references.addAll( newReferences );
+ if( absDecl instanceof ASTParameterDeclaration )
+ {
+ ASTParameterDeclaration parm = (ASTParameterDeclaration)absDecl;
+ parm.setSymbol( paramSymbol );
+ try
+ {
+ attachSymbolExtension( paramSymbol, parm );
+ }
+ catch (ExtensionException e)
+ {
+ throw new ASTSemanticException();
+ }
+ }
}
/**
@@ -1414,12 +1440,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility,
- List constructorChain) throws ASTSemanticException
+ List constructorChain, boolean isFunctionDefinition ) 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);
+ visibility, constructorChain,scopeToSymbol(scope).getName(), null, isFunctionDefinition );
}
public IASTMethod createMethod(
@@ -1442,7 +1468,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ASTAccessVisibility visibility,
List constructorChain,
String parentName,
- List references) throws ASTSemanticException
+ List references, boolean isFunctionDefinition ) throws ASTSemanticException
{
boolean isConstructor = false;
boolean isDestructor = false;
@@ -1902,4 +1928,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( lookupSymbol.isType( TypeInfo.t_type, TypeInfo.t_enumeration ) ) return true;
return false;
}
+
+ public IASTParameterDeclaration createParameterDeclaration(boolean isConst, boolean isVolatile, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause)
+ {
+ return new ASTParameterDeclaration( null, isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp, parameterName, initializerClause );
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java
index 2fe06b391b8..ee3f2d1e605 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTParameterDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.quick;
import java.util.List;
@@ -16,6 +16,7 @@ import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
+import org.eclipse.cdt.internal.core.parser.ast.ASTAbstractDeclaration;
/**
* @author jcamelon
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
index 8f19d2aa4ba..68a2623660b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
@@ -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.ASTClassKind;
+import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
@@ -187,7 +188,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
/* (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, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain)
+ 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, boolean isFunctionDefinition )
{
return new ASTFunction(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate );
}
@@ -195,7 +196,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
/* (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 isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain)
+ public IASTMethod createMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition )
{
return new ASTMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, false, false, isVirtual, isExplicit, isPureVirtual, visibility, constructorChain);
}
@@ -290,4 +291,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
public boolean queryIsTypeName(IASTScope scope, ITokenDuple nameInQuestion) {
return true; // we have no information to say that it is not
}
+
+ public IASTParameterDeclaration createParameterDeclaration(boolean isConst, boolean isVolatile, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause)
+ {
+ return new ASTParameterDeclaration( isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp, parameterName, initializerClause );
+ }
}

Back to the top