1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
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.
This commit is contained in:
John Camelon 2003-09-11 18:06:15 +00:00
parent 22e130fbe7
commit 322dcaad49
26 changed files with 473 additions and 108 deletions

View file

@ -1,3 +1,7 @@
2003-09-11 John Camelon
Added CompleteParseASTTest::testBug42840() & testBug42872().
Moved testBug39504B(), testBug39505A() & testBug39505B() from failed to QuickParse tests.
2003-09-10 Sean Evoy
Added a test for resetting the value of a configuration to the defaults defined in the
plugin file. Work completed to resolve [Bug 41412] Restore Default in Managed Build

View file

@ -41,18 +41,6 @@ public class ASTFailedTests extends BaseASTTest
{
assertCodeFailsParse("int y = sizeof(x[0]);");
}
public void testBug39504B() throws Exception
{
assertCodeFailsParse("int y = sizeof (int*);");
}
public void testBug39505A() throws Exception
{
assertCodeFailsParse("int AD::* gp_down = static_cast<int AD::*>(gp_stat);");
}
public void testBug39505B() throws Exception
{
assertCodeFailsParse("int* gp_down = static_cast<int*>(gp_stat);");
}
public void testBug39525() throws Exception
{

View file

@ -10,11 +10,6 @@
***********************************************************************/
package org.eclipse.cdt.core.parser.failedTests;
import java.util.Iterator;
import org.eclipse.cdt.core.parser.ast.IASTFunction;
import org.eclipse.cdt.core.parser.ast.IASTReference;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.tests.CompleteParseBaseTest;
/**

View file

@ -713,4 +713,35 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertEquals( ((IASTReference)callback.getReferences().get(0)).getReferencedElement(), enumE );
assertEquals( ((IASTReference)callback.getReferences().get(1)).getReferencedElement(), e1 );
}
public void testBug42840() throws Exception
{
Iterator i = parse( "void foo(); void foo() { } class SearchMe { };").getDeclarations();
IASTFunction fooDeclaration = (IASTFunction)i.next();
IASTFunction fooDefinition = (IASTFunction)i.next();
IASTClassSpecifier classSpec = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
assertFalse( i.hasNext() );
assertTrue( callback.getReferences().isEmpty());
i = parse( "class A { void f ( A ); }; void A::f( A ){ return; }" ).getDeclarations();
classSpec = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTMethod fooMethodDefinition = (IASTMethod)i.next();
assertFalse( i.hasNext() );
Iterator subIterator = getDeclarations( classSpec );
IASTMethod fooMethodDeclaration = (IASTMethod)subIterator.next();
assertFalse( subIterator.hasNext());
assertEquals( callback.getReferences().size(), 3 );
for( int j = 0; j < 3; ++j)
assertEquals( ((IASTReference)callback.getReferences().get( j )).getReferencedElement(), classSpec );
}
public void testBug42872() throws Exception
{
Iterator i = parse( "struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }" ).getDeclarations();
IASTClassSpecifier structB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTClassSpecifier structD = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTFunction foo = (IASTFunction)i.next();
assertFalse( i.hasNext() );
}
}

View file

@ -59,6 +59,7 @@ import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
/**
* @author jcamelon
@ -618,6 +619,14 @@ public class CompleteParseBaseTest extends TestCase
{
references.add( reference );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
*/
public void acceptParameterReference(ASTParameterReference reference)
{
references.add( reference );
}
}

View file

@ -1156,7 +1156,7 @@ public class QuickParseASTTests extends BaseASTTest
assertEquals( i.getName(), "stdio.h");
assertEquals( i.getStartingOffset(), 0 );
assertEquals( i.getNameOffset(), 9 );
assertEquals( i.getNameOffset(), 10 );
assertEquals( i.getEndingOffset(), 19 );
@ -1779,5 +1779,17 @@ public class QuickParseASTTests extends BaseASTTest
parse("namespace bar = foo;");
}
public void testBug39504B() throws Exception
{
parse("int y = sizeof (int*);");
}
public void testBug39505A() throws Exception
{
parse("int AD::* gp_down = static_cast<int AD::*>(gp_stat);");
}
public void testBug39505B() throws Exception
{
parse("int* gp_down = static_cast<int*>(gp_stat);");
}
}

View file

@ -50,6 +50,7 @@ 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.index.IDocument;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
/**
* @author bgheorgh
@ -442,4 +443,12 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
indexer.addEnumeratorReference( (IASTEnumerator)reference.getReferencedElement() );
}
/* (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
}
}

View file

@ -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

View file

@ -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 );

View file

@ -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;

View file

@ -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
{
}

View file

@ -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

View file

@ -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;
}
}

View file

@ -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
}
}

View file

@ -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)

View file

@ -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());

View file

@ -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 );

View file

@ -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)
{
}
}

View file

@ -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)
{
}
}

View file

@ -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;
}
}

View file

@ -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 );
}
}

View file

@ -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

View file

@ -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 );
}
}

View file

@ -75,6 +75,7 @@ import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -473,5 +474,14 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
System.out.println("(" + Thread.currentThread() + ") " + log);
}
/* (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
}
}

View file

@ -1,3 +1,6 @@
2003-09-11 John Camelon
Updated SourceElementRequestor callbacks to include IASTParameterReference callbacks.
2003-09-11 Bogdan Gheorghe
- Added Search Menu to CView.java
- Added queryWorkingSets to CSearchScopeFactory to bring up the working

View file

@ -34,7 +34,6 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
@ -44,6 +43,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;
/**
*
@ -320,4 +320,12 @@ public class SourceElementRequestorAdapter implements ISourceElementRequestor {
}
/* (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
}
}