mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
CORE
Added constructor expression support for variables. Added constructor chain x-reference support for methods. TESTS Added testBug41520() to FullParseFailedTests.java. Added testConstructorChain() to CompleteParseASTTest.java
This commit is contained in:
parent
fa8baf0518
commit
80ee3e49e7
24 changed files with 316 additions and 79 deletions
|
@ -1,3 +1,7 @@
|
|||
2003-08-13 John Camelon
|
||||
Added testBug41520() to FullParseFailedTests.java.
|
||||
Added testConstructorChain() to CompleteParseASTTest.java
|
||||
|
||||
2003-08-13 John Camelon
|
||||
Added testSimpleExpression(), testParameterExpressions() &&
|
||||
testNestedNamespaceExpression() to CompleteParseASTTest.java.
|
||||
|
|
|
@ -13,10 +13,13 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.parser.failedTests;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.tests.BaseASTTest;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.tests.CompleteParseASTTest;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -24,7 +27,7 @@ import org.eclipse.cdt.core.parser.tests.BaseASTTest;
|
|||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class FullParseFailedTests extends BaseASTTest {
|
||||
public class FullParseFailedTests extends CompleteParseASTTest {
|
||||
|
||||
/**
|
||||
* @param a
|
||||
|
@ -37,5 +40,27 @@ public class FullParseFailedTests extends BaseASTTest {
|
|||
TestSuite suite = new TestSuite(FullParseFailedTests.class.getName());
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void testBug41520() throws Exception
|
||||
{
|
||||
Iterator i = parse( "int x = 666; int y ( x );").getDeclarations();
|
||||
IASTVariable variableX = (IASTVariable)i.next();
|
||||
try
|
||||
{
|
||||
IASTVariable variableY = (IASTVariable)i.next();
|
||||
failedAsExpected();
|
||||
}catch( ClassCastException cce )
|
||||
{
|
||||
//this is bad
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void failedAsExpected()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -929,4 +929,22 @@ public class CompleteParseASTTest extends TestCase
|
|||
assertFalse( i.hasNext() );
|
||||
assertEquals( callback.getReferences().size(), 2 );
|
||||
}
|
||||
|
||||
public void testConstructorChain() throws Exception
|
||||
{
|
||||
Iterator i = parse( "int x = 5;\n class A \n{ public : \n int a; \n A() : a( x ) { } };").getDeclarations();
|
||||
IASTVariable variableX = (IASTVariable)i.next();
|
||||
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
assertFalse( i.hasNext() );
|
||||
Iterator s = getDeclarations( classA );
|
||||
IASTField fieldA = (IASTField)s.next();
|
||||
IASTMethod methodA = (IASTMethod)s.next();
|
||||
assertFalse( s.hasNext() );
|
||||
assertEquals( callback.getReferences().size(), 2 );
|
||||
IASTFieldReference reference1 = (IASTFieldReference)callback.getReferences().get(0);
|
||||
IASTVariableReference reference2 = (IASTVariableReference)callback.getReferences().get(1);
|
||||
assertEquals( reference1.getReferencedElement(), fieldA );
|
||||
assertEquals( reference2.getReferencedElement(), variableX );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2003-08-13 John Camelon
|
||||
Added constructor expression support for variables.
|
||||
Added constructor chain x-reference support for methods.
|
||||
|
||||
2003-08-13 John Camelon
|
||||
Added Expression x-reference support into Parser.
|
||||
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTConstructorMemberInitializer
|
||||
public interface IASTConstructorMemberInitializer extends ISourceElementCallbackDelegate
|
||||
{
|
||||
public IASTExpression getExpressionList();
|
||||
public String getName();
|
||||
|
|
|
@ -113,8 +113,8 @@ public interface IASTFactory
|
|||
* @return
|
||||
*/
|
||||
public IASTConstructorMemberInitializer createConstructorMemberInitializer(
|
||||
ITokenDuple duple,
|
||||
IASTExpression expressionList);
|
||||
IASTScope scope,
|
||||
ITokenDuple duple, IASTExpression expressionList) throws ASTSemanticException;
|
||||
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(
|
||||
IASTScope scope,
|
||||
IASTSimpleTypeSpecifier.Type kind,
|
||||
|
@ -159,12 +159,12 @@ public interface IASTFactory
|
|||
boolean isVirtual,
|
||||
boolean isExplicit,
|
||||
boolean isPureVirtual,
|
||||
ASTAccessVisibility visibility) throws ASTSemanticException;
|
||||
ASTAccessVisibility visibility, List constructorChain) 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;
|
||||
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, IASTExpression constructorExpression ) throws ASTSemanticException;
|
||||
|
||||
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) throws ASTSemanticException;
|
||||
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, IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException;
|
||||
|
||||
public IASTParameterDeclaration createParameterDeclaration( boolean isConst, boolean isVolatile, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause );
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -27,5 +29,5 @@ public interface IASTMethod extends IASTFunction, IASTMember {
|
|||
public boolean isVolatile();
|
||||
public boolean isPureVirtual();
|
||||
|
||||
|
||||
public Iterator getConstructorChainInitializers();
|
||||
}
|
||||
|
|
|
@ -29,4 +29,5 @@ public interface IASTVariable extends IASTDeclaration, IASTOffsetableNamedEleme
|
|||
|
||||
public boolean isBitfield();
|
||||
public IASTExpression getBitfieldExpression();
|
||||
public IASTExpression getConstructorExpression();
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
name,
|
||||
abs, getStartingOffset(), d.getNameStartOffset() );
|
||||
else
|
||||
return astFactory.createVariable( scope, name, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), d.getNameStartOffset() );
|
||||
return astFactory.createVariable( scope, name, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), d.getNameStartOffset(), d.getConstructorExpression() );
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -437,7 +437,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
virtual,
|
||||
explicit,
|
||||
declarator.isPureVirtual(),
|
||||
((IASTClassSpecifier)scope).getCurrentVisibilityMode());
|
||||
((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers());
|
||||
}
|
||||
/**
|
||||
* @param declarator
|
||||
|
@ -485,7 +485,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
staticc,
|
||||
startingOffset,
|
||||
declarator.getNameStartOffset(),
|
||||
((IASTClassSpecifier)scope).getCurrentVisibilityMode());
|
||||
declarator.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode());
|
||||
}
|
||||
private List createParameterList(List currentParameters)
|
||||
{
|
||||
|
@ -534,7 +534,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
register,
|
||||
staticc,
|
||||
getStartingOffset(),
|
||||
declarator.getNameStartOffset());
|
||||
declarator.getNameStartOffset(), declarator.getConstructorExpression());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -972,10 +972,18 @@ public class Parser implements IParser
|
|||
|
||||
consume(IToken.tRPAREN);
|
||||
|
||||
d.addConstructorMemberInitializer(
|
||||
astFactory.createConstructorMemberInitializer(
|
||||
duple,
|
||||
expressionList));
|
||||
try
|
||||
{
|
||||
d.addConstructorMemberInitializer(
|
||||
astFactory.createConstructorMemberInitializer(
|
||||
d.getDeclarationWrapper().getScope(),
|
||||
duple, expressionList));
|
||||
}
|
||||
catch (ASTSemanticException e)
|
||||
{
|
||||
failParse();
|
||||
throw backtrack;
|
||||
}
|
||||
if (LT(1) == IToken.tLBRACE)
|
||||
break;
|
||||
consume(IToken.tCOMMA);
|
||||
|
|
|
@ -44,35 +44,6 @@ public class ASTInitializerClause implements IASTInitializerClause {
|
|||
return kind;
|
||||
}
|
||||
|
||||
public static class EmptyIterator implements Iterator
|
||||
{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
public boolean hasNext()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
public Object next()
|
||||
{
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
public void remove()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getInitializerList()
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/**********************************************************************
|
||||
* 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.NoSuchElementException;
|
||||
|
||||
|
||||
public class EmptyIterator implements Iterator
|
||||
{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
public boolean hasNext()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
public Object next()
|
||||
{
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
public void remove()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/**********************************************************************
|
||||
* 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.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTConstructorMemberInitializer
|
||||
implements IASTConstructorMemberInitializer
|
||||
{
|
||||
private final String name;
|
||||
private final IASTExpression expression;
|
||||
private final ASTReferenceStore store;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ASTConstructorMemberInitializer( IASTExpression expression, String name, List references )
|
||||
{
|
||||
this.expression = expression;
|
||||
this.name = name;
|
||||
store = new ASTReferenceStore( references );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer#getExpressionList()
|
||||
*/
|
||||
public IASTExpression getExpressionList()
|
||||
{
|
||||
return expression;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void acceptElement(ISourceElementRequestor requestor)
|
||||
{
|
||||
store.processReferences( 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)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -120,8 +120,11 @@ public class ASTExpression implements IASTExpression
|
|||
*/
|
||||
public void acceptElement(ISourceElementRequestor requestor)
|
||||
{
|
||||
ASTReferenceStore store = new ASTReferenceStore( references );
|
||||
store.processReferences(requestor);
|
||||
if( ! references.isEmpty() )
|
||||
{
|
||||
ASTReferenceStore store = new ASTReferenceStore( references );
|
||||
store.processReferences(requestor);
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
|
|
@ -37,9 +37,9 @@ public class ASTField extends ASTVariable implements IASTField
|
|||
* @param references
|
||||
* @param visibility
|
||||
*/
|
||||
public ASTField(ISymbol newSymbol, IASTAbstractDeclaration abstractDeclaration, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, int startingOffset, int nameOffset, List references, ASTAccessVisibility visibility)
|
||||
public ASTField(ISymbol newSymbol, IASTAbstractDeclaration abstractDeclaration, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, int startingOffset, int nameOffset, List references, IASTExpression constructorExpression, ASTAccessVisibility visibility)
|
||||
{
|
||||
super( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references );
|
||||
super( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, constructorExpression );
|
||||
this.visibility = visibility;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,14 +10,17 @@
|
|||
***********************************************************************/
|
||||
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.IASTAbstractDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
||||
|
||||
|
@ -27,6 +30,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
|||
*/
|
||||
public class ASTMethod extends ASTFunction implements IASTMethod
|
||||
{
|
||||
private final List constructorChain;
|
||||
private final boolean isConstructor;
|
||||
private final boolean isPureVirtual;
|
||||
private final ASTAccessVisibility visibility;
|
||||
|
@ -42,7 +46,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
* @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 )
|
||||
boolean isConstructor, boolean isDestructor, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain )
|
||||
{
|
||||
super(
|
||||
symbol,
|
||||
|
@ -57,7 +61,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
this.isConstructor = isConstructor;
|
||||
this.isDestructor = isDestructor;
|
||||
this.isPureVirtual = isPureVirtual;
|
||||
|
||||
this.constructorChain = constructorChain;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVirtual()
|
||||
|
@ -124,6 +128,20 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
requestor.acceptMethodDeclaration(this);
|
||||
references.processReferences(requestor);
|
||||
processParameterInitializers(requestor);
|
||||
processConstructorChain(requestor);
|
||||
}
|
||||
|
||||
protected void processConstructorChain(ISourceElementRequestor requestor)
|
||||
{
|
||||
if( constructorChain != null )
|
||||
{
|
||||
Iterator i = getConstructorChainInitializers();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
IASTConstructorMemberInitializer c = (IASTConstructorMemberInitializer)i.next();
|
||||
c.acceptElement(requestor);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
@ -132,6 +150,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
{
|
||||
requestor.enterMethodBody(this);
|
||||
references.processReferences(requestor);
|
||||
processConstructorChain(requestor);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
@ -140,4 +159,13 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
{
|
||||
requestor.exitMethodBody( this );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#getConstructorChainInitializers()
|
||||
*/
|
||||
public Iterator getConstructorChainInitializers()
|
||||
{
|
||||
if( constructorChain == null )
|
||||
return new EmptyIterator();
|
||||
return constructorChain.iterator();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
|||
*/
|
||||
public class ASTVariable extends ASTSymbol implements IASTVariable
|
||||
{
|
||||
protected final ASTReferenceStore referenceDelegate;
|
||||
private final IASTExpression constructorExpression;
|
||||
protected final ASTReferenceStore referenceDelegate;
|
||||
private final ASTQualifiedNamedElement qualifiedName;
|
||||
private NamedOffsets offsets = new NamedOffsets();
|
||||
private final IASTExpression bitfieldExpression;
|
||||
|
@ -44,12 +45,13 @@ public class ASTVariable extends ASTSymbol implements IASTVariable
|
|||
* @param nameOffset
|
||||
* @param references
|
||||
*/
|
||||
public ASTVariable(ISymbol newSymbol, IASTAbstractDeclaration abstractDeclaration, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, int startingOffset, int nameOffset, List references)
|
||||
public ASTVariable(ISymbol newSymbol, IASTAbstractDeclaration abstractDeclaration, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, int startingOffset, int nameOffset, List references, IASTExpression constructorExpression )
|
||||
{
|
||||
super( newSymbol );
|
||||
this.abstractDeclaration = abstractDeclaration;
|
||||
this.initializerClause = initializerClause;
|
||||
this.bitfieldExpression = bitfieldExpression;
|
||||
this.constructorExpression = constructorExpression;
|
||||
setStartingOffset( startingOffset );
|
||||
setNameOffset( nameOffset );
|
||||
referenceDelegate = new ASTReferenceStore( references );
|
||||
|
@ -162,6 +164,8 @@ public class ASTVariable extends ASTSymbol implements IASTVariable
|
|||
referenceDelegate.processReferences(requestor);
|
||||
if( initializerClause != null )
|
||||
initializerClause.acceptElement(requestor);
|
||||
if( constructorExpression != null )
|
||||
constructorExpression.acceptElement(requestor);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
@ -203,4 +207,11 @@ public class ASTVariable extends ASTSymbol implements IASTVariable
|
|||
{
|
||||
return offsets.getEndingOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#getConstructorExpression()
|
||||
*/
|
||||
public IASTExpression getConstructorExpression()
|
||||
{
|
||||
return constructorExpression;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -704,11 +704,17 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createConstructorMemberInitializer(org.eclipse.cdt.core.parser.ITokenDuple, org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public IASTConstructorMemberInitializer createConstructorMemberInitializer(
|
||||
ITokenDuple duple,
|
||||
IASTExpression expressionList)
|
||||
IASTScope scope,
|
||||
ITokenDuple duple, IASTExpression expressionList) throws ASTSemanticException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
List references = new ArrayList();
|
||||
|
||||
IContainerSymbol scopeSymbol = scopeToSymbol(scope);
|
||||
if( duple != null )
|
||||
lookupQualifiedName( scopeSymbol, duple, references, false );
|
||||
|
||||
getExpressionReferences( expressionList, references );
|
||||
return new ASTConstructorMemberInitializer( expressionList, duple == null ? "" : duple.toString(), references );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSimpleTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type, org.eclipse.cdt.core.parser.ITokenDuple, boolean, boolean, boolean, boolean, boolean)
|
||||
|
@ -1000,7 +1006,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
boolean isVirtual,
|
||||
boolean isExplicit,
|
||||
boolean isPureVirtual,
|
||||
ASTAccessVisibility visibility) throws ASTSemanticException
|
||||
ASTAccessVisibility visibility, List constructorChain) throws ASTSemanticException
|
||||
{
|
||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
|
||||
|
@ -1008,7 +1014,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
setMethodTypeInfoBits( symbol, isConst, isVolatile, isVirtual, isExplicit );
|
||||
List references = new ArrayList();
|
||||
|
||||
setParameter( symbol, returnType, false, references );
|
||||
if( returnType.getTypeSpecifier() != null )
|
||||
setParameter( symbol, returnType, false, references );
|
||||
setParameters( symbol, references, parameters.iterator() );
|
||||
|
||||
try
|
||||
|
@ -1020,9 +1027,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
throw new ASTSemanticException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, isConstructor, isDestructor, isPureVirtual, visibility );
|
||||
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain );
|
||||
try
|
||||
{
|
||||
attachSymbolExtension( symbol, method );
|
||||
|
@ -1066,7 +1071,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
boolean isRegister,
|
||||
boolean isStatic,
|
||||
int startingOffset,
|
||||
int nameOffset) throws ASTSemanticException
|
||||
int nameOffset, IASTExpression constructorExpression) throws ASTSemanticException
|
||||
{
|
||||
List references = new ArrayList();
|
||||
ISymbol newSymbol = cloneSimpleTypeSymbol(name, abstractDeclaration, references);
|
||||
|
@ -1088,7 +1093,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
// TODO Auto-generated catch block
|
||||
}
|
||||
|
||||
ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references );
|
||||
ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, constructorExpression );
|
||||
try
|
||||
{
|
||||
attachSymbolExtension(newSymbol, variable );
|
||||
|
@ -1159,7 +1164,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
boolean isStatic,
|
||||
int startingOffset,
|
||||
int nameOffset,
|
||||
ASTAccessVisibility visibility) throws ASTSemanticException
|
||||
IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException
|
||||
{
|
||||
List references = new ArrayList();
|
||||
ISymbol newSymbol = cloneSimpleTypeSymbol(name, abstractDeclaration, references);
|
||||
|
@ -1182,7 +1187,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
throw new ASTSemanticException();
|
||||
}
|
||||
|
||||
ASTField field = new ASTField( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, visibility );
|
||||
ASTField field = new ASTField( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, constructorExpression, visibility );
|
||||
try
|
||||
{
|
||||
attachSymbolExtension(newSymbol, field );
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
|
||||
|
@ -46,4 +47,22 @@ public class ASTConstructorMemberInitializer
|
|||
{
|
||||
return name;
|
||||
}
|
||||
/* (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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ASTField extends ASTVariable implements IASTField
|
|||
* @param isRegister
|
||||
* @param isStatic
|
||||
*/
|
||||
public ASTField(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)
|
||||
public ASTField(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, ASTAccessVisibility visibility)
|
||||
{
|
||||
super(
|
||||
scope,
|
||||
|
@ -50,7 +50,7 @@ public class ASTField extends ASTVariable implements IASTField
|
|||
isMutable,
|
||||
isExtern,
|
||||
isRegister,
|
||||
isStatic, startingOffset, nameOffset);
|
||||
isStatic, startingOffset, nameOffset, constructorExpression );
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,6 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
|||
public void acceptElement(ISourceElementRequestor requestor)
|
||||
{
|
||||
requestor.acceptFunctionDeclaration(this);
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enter(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* 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.ISourceElementRequestor;
|
||||
|
@ -20,12 +21,14 @@ import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
|||
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.EmptyIterator;
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTMethod extends ASTFunction implements IASTMethod
|
||||
{
|
||||
private final List constructorChainElements;
|
||||
private final boolean isConst;
|
||||
private final boolean isDestructor;
|
||||
private final boolean isConstructor;
|
||||
|
@ -66,7 +69,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
boolean isDestructor,
|
||||
boolean isVirtual,
|
||||
boolean isExplicit,
|
||||
boolean isPureVirtual, ASTAccessVisibility visibility)
|
||||
boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChainElements )
|
||||
{
|
||||
super(
|
||||
scope,
|
||||
|
@ -88,6 +91,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
this.isConst = isConst;
|
||||
this.isVolatile = isVolatile;
|
||||
this.visibility = visibility;
|
||||
this.constructorChainElements = constructorChainElements;
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
@ -173,4 +177,13 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
{
|
||||
requestor.exitMethodBody(this);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#getConstructorChainInitializers()
|
||||
*/
|
||||
public Iterator getConstructorChainInitializers()
|
||||
{
|
||||
if( constructorChainElements == null )
|
||||
return new EmptyIterator();
|
||||
return constructorChainElements.iterator();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
|||
*/
|
||||
public class ASTVariable extends ASTDeclaration implements IASTVariable
|
||||
{
|
||||
private IASTExpression constructorExpression;
|
||||
private final boolean isAuto;
|
||||
private final IASTInitializerClause initializerClause;
|
||||
private final IASTExpression bitfieldExpression;
|
||||
|
@ -40,7 +41,7 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable
|
|||
* @param scope
|
||||
*/
|
||||
public ASTVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression,
|
||||
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset )
|
||||
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, IASTExpression constructorExpression )
|
||||
{
|
||||
super(scope);
|
||||
this.isAuto = isAuto;
|
||||
|
@ -52,6 +53,7 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable
|
|||
this.isRegister = isRegister;
|
||||
this.isStatic = isStatic;
|
||||
this.name = name;
|
||||
this.constructorExpression = constructorExpression;
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name );
|
||||
setStartingOffset(startingOffset);
|
||||
setNameOffset(nameOffset);
|
||||
|
@ -194,6 +196,13 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable
|
|||
public void exitScope(ISourceElementRequestor requestor)
|
||||
{
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#getConstructorExpression()
|
||||
*/
|
||||
public IASTExpression getConstructorExpression()
|
||||
{
|
||||
return constructorExpression;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createConstructorMemberInitializer(org.eclipse.cdt.core.parser.ITokenDuple, org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public IASTConstructorMemberInitializer createConstructorMemberInitializer(ITokenDuple duple, IASTExpression expressionList )
|
||||
public IASTConstructorMemberInitializer createConstructorMemberInitializer(IASTScope scope, ITokenDuple duple, IASTExpression expressionList )
|
||||
{
|
||||
return new ASTConstructorMemberInitializer( duple.toString(), expressionList );
|
||||
}
|
||||
|
@ -203,25 +203,25 @@ 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 isConstructor, boolean isDestructor, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility)
|
||||
public IASTMethod createMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isConstructor, boolean isDestructor, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain)
|
||||
{
|
||||
return new ASTMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, isConstructor, isDestructor, isVirtual, isExplicit, isPureVirtual, visibility);
|
||||
return new ASTMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, isConstructor, isDestructor, isVirtual, isExplicit, isPureVirtual, visibility, constructorChain);
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
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)
|
||||
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)
|
||||
{
|
||||
return new ASTVariable(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, nameOffset);
|
||||
return new ASTVariable(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, nameOffset, constructorExpression);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createField(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, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
||||
*/
|
||||
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)
|
||||
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, IASTExpression constructorExpression, ASTAccessVisibility visibility)
|
||||
{
|
||||
return new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, nameOffset, visibility);
|
||||
return new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, nameOffset, constructorExpression, visibility);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue