mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
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.
This commit is contained in:
parent
22e130fbe7
commit
322dcaad49
26 changed files with 473 additions and 108 deletions
|
@ -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
|
2003-09-10 Sean Evoy
|
||||||
Added a test for resetting the value of a configuration to the defaults defined in the
|
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
|
plugin file. Work completed to resolve [Bug 41412] Restore Default in Managed Build
|
||||||
|
|
|
@ -41,18 +41,6 @@ public class ASTFailedTests extends BaseASTTest
|
||||||
{
|
{
|
||||||
assertCodeFailsParse("int y = sizeof(x[0]);");
|
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
|
public void testBug39525() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,11 +10,6 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.failedTests;
|
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;
|
import org.eclipse.cdt.core.parser.tests.CompleteParseBaseTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -713,4 +713,35 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
assertEquals( ((IASTReference)callback.getReferences().get(0)).getReferencedElement(), enumE );
|
assertEquals( ((IASTReference)callback.getReferences().get(0)).getReferencedElement(), enumE );
|
||||||
assertEquals( ((IASTReference)callback.getReferences().get(1)).getReferencedElement(), e1 );
|
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() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -619,6 +620,14 @@ public class CompleteParseBaseTest extends TestCase
|
||||||
references.add( reference );
|
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 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Iterator getNestedScopes( IASTCodeScope scope )
|
protected Iterator getNestedScopes( IASTCodeScope scope )
|
||||||
|
|
|
@ -1156,7 +1156,7 @@ public class QuickParseASTTests extends BaseASTTest
|
||||||
|
|
||||||
assertEquals( i.getName(), "stdio.h");
|
assertEquals( i.getName(), "stdio.h");
|
||||||
assertEquals( i.getStartingOffset(), 0 );
|
assertEquals( i.getStartingOffset(), 0 );
|
||||||
assertEquals( i.getNameOffset(), 9 );
|
assertEquals( i.getNameOffset(), 10 );
|
||||||
assertEquals( i.getEndingOffset(), 19 );
|
assertEquals( i.getEndingOffset(), 19 );
|
||||||
|
|
||||||
|
|
||||||
|
@ -1779,5 +1779,17 @@ public class QuickParseASTTests extends BaseASTTest
|
||||||
parse("namespace bar = foo;");
|
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);");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bgheorgh
|
* @author bgheorgh
|
||||||
|
@ -442,4 +443,12 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
indexer.addEnumeratorReference( (IASTEnumerator)reference.getReferencedElement() );
|
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
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
2003-09-09 Hoda Amer
|
||||||
- Solved the double reference problem
|
- Solved the double reference problem
|
||||||
- solution to bugs #42822, #42823, & #42822B
|
- solution to bugs #42822, #42823, & #42822B
|
||||||
|
|
|
@ -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.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -90,6 +91,7 @@ public interface ISourceElementRequestor {
|
||||||
public void acceptFieldReference( IASTFieldReference reference );
|
public void acceptFieldReference( IASTFieldReference reference );
|
||||||
public void acceptMethodReference( IASTMethodReference reference );
|
public void acceptMethodReference( IASTMethodReference reference );
|
||||||
public void acceptEnumeratorReference( IASTEnumeratorReference reference );
|
public void acceptEnumeratorReference( IASTEnumeratorReference reference );
|
||||||
|
public void acceptParameterReference(ASTParameterReference reference);
|
||||||
|
|
||||||
public void exitTemplateDeclaration( IASTTemplateDeclaration declaration );
|
public void exitTemplateDeclaration( IASTTemplateDeclaration declaration );
|
||||||
public void exitTemplateSpecialization( IASTTemplateSpecialization specialization );
|
public void exitTemplateSpecialization( IASTTemplateSpecialization specialization );
|
||||||
|
|
|
@ -147,7 +147,7 @@ public interface IASTFactory
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
boolean isExplicit,
|
boolean isExplicit,
|
||||||
boolean isPureVirtual,
|
boolean isPureVirtual,
|
||||||
ASTAccessVisibility visibility, List constructorChain) throws ASTSemanticException;
|
ASTAccessVisibility visibility, List constructorChain, boolean isDefinition ) throws ASTSemanticException;
|
||||||
public IASTAbstractDeclaration createAbstractDeclaration(
|
public IASTAbstractDeclaration createAbstractDeclaration(
|
||||||
boolean isConst,
|
boolean isConst,
|
||||||
boolean isVolatile,
|
boolean isVolatile,
|
||||||
|
@ -170,7 +170,7 @@ public interface IASTFactory
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
boolean isExplicit,
|
boolean isExplicit,
|
||||||
boolean isPureVirtual,
|
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,
|
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;
|
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, IASTExpression constructorExpression ) throws ASTSemanticException;
|
||||||
|
|
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
|
@ -435,7 +435,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
virtual,
|
virtual,
|
||||||
explicit,
|
explicit,
|
||||||
declarator.isPureVirtual(),
|
declarator.isPureVirtual(),
|
||||||
((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers());
|
((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers(),
|
||||||
|
declarator.hasFunctionBody());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
|
@ -465,7 +466,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
explicit,
|
explicit,
|
||||||
declarator.isPureVirtual(),
|
declarator.isPureVirtual(),
|
||||||
ASTAccessVisibility.PUBLIC,
|
ASTAccessVisibility.PUBLIC,
|
||||||
declarator.getConstructorMemberInitializers());
|
declarator.getConstructorMemberInitializers(),
|
||||||
|
declarator.hasFunctionBody() );
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
|
|
|
@ -392,4 +392,20 @@ public class Declarator implements IParameterCollection, IDeclaratorOwner
|
||||||
return pointerOperatorNameDuple;
|
return pointerOperatorNameDuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean hasFunctionBody()
|
||||||
|
{
|
||||||
|
return hasFunctionBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param b
|
||||||
|
*/
|
||||||
|
public void setHasFunctionBody(boolean b)
|
||||||
|
{
|
||||||
|
hasFunctionBody = b;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
|
||||||
|
|
||||||
|
|
||||||
public class NullSourceElementRequestor implements ISourceElementRequestor
|
public class NullSourceElementRequestor implements ISourceElementRequestor
|
||||||
|
@ -433,4 +434,13 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
|
||||||
// TODO Auto-generated method stub
|
// 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
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -897,7 +897,7 @@ public class Parser implements IParser
|
||||||
case IToken.tLBRACE :
|
case IToken.tLBRACE :
|
||||||
if (forKR)
|
if (forKR)
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
declarator.hasFunctionBody(true);
|
declarator.setHasFunctionBody(true);
|
||||||
hasFunctionBody = true;
|
hasFunctionBody = true;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
@ -1730,23 +1730,25 @@ public class Parser implements IParser
|
||||||
* @return Returns the same object sent in.
|
* @return Returns the same object sent in.
|
||||||
* @throws Backtrack
|
* @throws Backtrack
|
||||||
*/
|
*/
|
||||||
protected boolean cvQualifier(
|
protected IToken cvQualifier(
|
||||||
Declarator declarator)
|
Declarator declarator)
|
||||||
throws Backtrack
|
throws Backtrack
|
||||||
{
|
{
|
||||||
|
IToken result = null;
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
{
|
{
|
||||||
case IToken.t_const :
|
case IToken.t_const :
|
||||||
consume( IToken.t_const );
|
result = consume( IToken.t_const );
|
||||||
declarator.addPtrOp(ASTPointerOperator.CONST_POINTER);
|
if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.CONST_POINTER);
|
||||||
return true;
|
break;
|
||||||
case IToken.t_volatile :
|
case IToken.t_volatile :
|
||||||
consume( IToken.t_volatile );
|
result = consume( IToken.t_volatile );
|
||||||
declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER);
|
if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER);
|
||||||
return true;
|
break;
|
||||||
default :
|
default :
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Parses the initDeclarator construct of the ANSI C++ spec.
|
* Parses the initDeclarator construct of the ANSI C++ spec.
|
||||||
|
@ -2186,15 +2188,15 @@ public class Parser implements IParser
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// must be a conversion function
|
// must be a conversion function
|
||||||
typeId();
|
toSend = typeId().getLastToken();
|
||||||
toSend = lastToken;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// this ptrOp doesn't belong to the declarator,
|
// this ptrOp doesn't belong to the declarator,
|
||||||
// it's just a part of the name
|
// it's just a part of the name
|
||||||
consumePointerOperators(d, true);
|
IToken temp = consumePointerOperators(d, true);
|
||||||
if( lastToken != null )
|
if( temp != null )
|
||||||
toSend = lastToken;
|
toSend = temp;
|
||||||
}
|
}
|
||||||
catch (Backtrack b)
|
catch (Backtrack b)
|
||||||
{
|
{
|
||||||
|
@ -2220,22 +2222,22 @@ public class Parser implements IParser
|
||||||
* @param owner Declarator that this pointer operator corresponds to.
|
* @param owner Declarator that this pointer operator corresponds to.
|
||||||
* @throws Backtrack request a backtrack
|
* @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( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
int t = LT(1);
|
if (LT(1) == IToken.tAMPER)
|
||||||
if (t == IToken.tAMPER)
|
|
||||||
{
|
{
|
||||||
consume( IToken.tAMPER );
|
result = consume( IToken.tAMPER );
|
||||||
d.addPtrOp(ASTPointerOperator.REFERENCE);
|
if( d != null ) d.addPtrOp(ASTPointerOperator.REFERENCE);
|
||||||
if( consumeOnlyOne ) return;
|
/*if( consumeOnlyOne ) */return result;
|
||||||
continue;
|
/* continue; */
|
||||||
}
|
}
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
IToken tokenType = LA(1);
|
|
||||||
ITokenDuple nameDuple = null;
|
ITokenDuple nameDuple = null;
|
||||||
if (t == IToken.tIDENTIFIER || t == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2244,34 +2246,33 @@ public class Parser implements IParser
|
||||||
catch( Backtrack bt )
|
catch( Backtrack bt )
|
||||||
{
|
{
|
||||||
backup( mark );
|
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 (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
boolean newSuccess = cvQualifier(d);
|
IToken newSuccess = cvQualifier(d);
|
||||||
if( newSuccess ) successful = true;
|
if( newSuccess != null ) successful = newSuccess;
|
||||||
else break;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
backup(mark);
|
backup(mark);
|
||||||
return;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -3520,12 +3521,6 @@ public class Parser implements IParser
|
||||||
if (LT(1) == IToken.t_const)
|
if (LT(1) == IToken.t_const)
|
||||||
consume();
|
consume();
|
||||||
duple = typeId();
|
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);
|
consume(IToken.tRPAREN);
|
||||||
IASTExpression castExpression = castExpression(scope);
|
IASTExpression castExpression = castExpression(scope);
|
||||||
try
|
try
|
||||||
|
@ -3552,17 +3547,20 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
return unaryExpression(scope);
|
return unaryExpression(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Backtrack
|
* @throws Backtrack
|
||||||
*/
|
*/
|
||||||
protected ITokenDuple typeId() throws Backtrack
|
protected ITokenDuple typeId( ) throws Backtrack
|
||||||
{
|
{
|
||||||
IToken begin = LA(1);
|
IToken begin = LA(1);
|
||||||
IToken end = null;
|
IToken end = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ITokenDuple d = name();
|
ITokenDuple d = name();
|
||||||
return d;
|
IToken checkForPtrs = consumePointerOperators(null, false);
|
||||||
|
if( checkForPtrs == null ) return d;
|
||||||
|
return new TokenDuple( d.getFirstToken(), checkForPtrs );
|
||||||
}
|
}
|
||||||
catch (Backtrack b)
|
catch (Backtrack b)
|
||||||
{
|
{
|
||||||
|
@ -3599,7 +3597,8 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
if (end != null)
|
if (end != null)
|
||||||
{
|
{
|
||||||
return new TokenDuple(begin, end);
|
IToken end2 = consumePointerOperators(null, false);
|
||||||
|
return new TokenDuple(begin, end2 == null ? end : end2);
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
LT(1) == IToken.t_typename
|
LT(1) == IToken.t_typename
|
||||||
|
@ -3610,7 +3609,8 @@ public class Parser implements IParser
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
ITokenDuple d = name();
|
ITokenDuple d = name();
|
||||||
return new TokenDuple(begin, d.getLastToken());
|
IToken end2 = consumePointerOperators(null, false);
|
||||||
|
return new TokenDuple(begin, ( (end2 == null) ? d.getLastToken() : end2 ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
@ -4273,7 +4273,7 @@ public class Parser implements IParser
|
||||||
lhs,
|
lhs,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
duple,
|
||||||
"", null);
|
"", null);
|
||||||
}
|
}
|
||||||
catch (ASTSemanticException e)
|
catch (ASTSemanticException e)
|
||||||
|
|
|
@ -1966,8 +1966,9 @@ public class Scanner implements IScanner {
|
||||||
} else if (t.getType() == IToken.tLT) {
|
} else if (t.getType() == IToken.tLT) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startOffset = baseOffset + t.getOffset();
|
|
||||||
t = helperScanner.nextToken(false);
|
t = helperScanner.nextToken(false);
|
||||||
|
startOffset = baseOffset + t.getOffset();
|
||||||
|
|
||||||
while (t.getType() != IToken.tGT) {
|
while (t.getType() != IToken.tGT) {
|
||||||
fileName.append(t.getImage());
|
fileName.append(t.getImage());
|
||||||
|
|
|
@ -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.IASTInclusion;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
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 );
|
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)
|
public IASTInitializerClause createInitializerClause(IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses)
|
||||||
{
|
{
|
||||||
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses );
|
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses );
|
||||||
|
|
|
@ -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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
|
||||||
*/
|
*/
|
||||||
public class ASTSymbolOwner implements ISymbolOwner
|
public class ASTSymbolOwner implements ISymbolOwner
|
||||||
{
|
{
|
||||||
protected final ISymbol symbol;
|
protected ISymbol symbol;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -34,4 +34,10 @@ public class ASTSymbolOwner implements ISymbolOwner
|
||||||
{
|
{
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSymbol( ISymbol symbol )
|
||||||
|
{
|
||||||
|
this.symbol = symbol;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
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.ast.BaseASTFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
|
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.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.TypeInfo;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
|
@ -210,36 +210,18 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
Iterator iter = name.iterator();
|
Iterator iter = name.iterator();
|
||||||
firstSymbol = name.getFirstToken();
|
firstSymbol = name.getFirstToken();
|
||||||
result = startingScope;
|
result = startingScope;
|
||||||
if( firstSymbol.getType() == IToken.tCOLONCOLON )
|
if( firstSymbol.getType() == IToken.tCOLONCOLON )
|
||||||
result = pst.getCompilationUnit();
|
result = pst.getCompilationUnit();
|
||||||
|
|
||||||
while( iter.hasNext() )
|
while( iter.hasNext() )
|
||||||
{
|
{
|
||||||
IToken t = (IToken)iter.next();
|
IToken t = (IToken)iter.next();
|
||||||
if( t.getType() == IToken.tCOLONCOLON ) continue;
|
if( t.getType() == IToken.tCOLONCOLON ) continue;
|
||||||
|
if( t.isPointer() ) break;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( t == name.getLastToken() )
|
if( t == name.getLastToken() )
|
||||||
|
@ -660,6 +642,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
{
|
{
|
||||||
return new ASTFieldReference( offset, string, (IASTField)symbol.getASTExtension().getPrimaryDeclaration());
|
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
|
else
|
||||||
{
|
{
|
||||||
return new ASTVariableReference( offset, string, (IASTVariable)symbol.getASTExtension().getPrimaryDeclaration());
|
return new ASTVariableReference( offset, string, (IASTVariable)symbol.getASTExtension().getPrimaryDeclaration());
|
||||||
|
@ -1149,7 +1138,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
boolean isExplicit,
|
boolean isExplicit,
|
||||||
boolean isPureVirtual,
|
boolean isPureVirtual,
|
||||||
ASTAccessVisibility visibility,
|
ASTAccessVisibility visibility,
|
||||||
List constructorChain) throws ASTSemanticException
|
List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
List references = new ArrayList();
|
List references = new ArrayList();
|
||||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||||
|
@ -1208,7 +1197,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
return createMethod(scope, functionName, parameters, returnType,
|
return createMethod(scope, functionName, parameters, returnType,
|
||||||
exception, isInline, isFriend, isStatic, startOffset, offset,
|
exception, isInline, isFriend, isStatic, startOffset, offset,
|
||||||
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
||||||
visibility, constructorChain,parentName, references);
|
visibility, constructorChain,parentName, references, isFunctionDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,6 +1207,30 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
setParameter( symbol, returnType, false, references );
|
setParameter( symbol, returnType, false, references );
|
||||||
setParameters( symbol, references, parameters.iterator() );
|
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
|
try
|
||||||
{
|
{
|
||||||
ownerScope.addSymbol( symbol );
|
ownerScope.addSymbol( symbol );
|
||||||
|
@ -1362,6 +1375,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
if( newReferences != null )
|
if( newReferences != null )
|
||||||
references.addAll( newReferences );
|
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 isExplicit,
|
||||||
boolean isPureVirtual,
|
boolean isPureVirtual,
|
||||||
ASTAccessVisibility visibility,
|
ASTAccessVisibility visibility,
|
||||||
List constructorChain) throws ASTSemanticException
|
List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
return createMethod(scope, name, parameters, returnType,
|
return createMethod(scope, name, parameters, returnType,
|
||||||
exception, isInline, isFriend, isStatic, startOffset, nameOffset,
|
exception, isInline, isFriend, isStatic, startOffset, nameOffset,
|
||||||
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
||||||
visibility, constructorChain,scopeToSymbol(scope).getName(), null);
|
visibility, constructorChain,scopeToSymbol(scope).getName(), null, isFunctionDefinition );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTMethod createMethod(
|
public IASTMethod createMethod(
|
||||||
|
@ -1442,7 +1468,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
ASTAccessVisibility visibility,
|
ASTAccessVisibility visibility,
|
||||||
List constructorChain,
|
List constructorChain,
|
||||||
String parentName,
|
String parentName,
|
||||||
List references) throws ASTSemanticException
|
List references, boolean isFunctionDefinition ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
boolean isConstructor = false;
|
boolean isConstructor = false;
|
||||||
boolean isDestructor = 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;
|
if( lookupSymbol.isType( TypeInfo.t_type, TypeInfo.t_enumeration ) ) return true;
|
||||||
return false;
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* 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;
|
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.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.ASTAbstractDeclaration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
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.ASTSemanticException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
|
@ -187,7 +188,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
/* (non-Javadoc)
|
/* (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)
|
* @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 );
|
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)
|
/* (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)
|
* @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);
|
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) {
|
public boolean queryIsTypeName(IASTScope scope, ITokenDuple nameInQuestion) {
|
||||||
return true; // we have no information to say that it is not
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ import org.eclipse.cdt.core.search.ICSearchScope;
|
||||||
import org.eclipse.cdt.core.search.IMatch;
|
import org.eclipse.cdt.core.search.IMatch;
|
||||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
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.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -473,5 +474,14 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
System.out.println("(" + Thread.currentThread() + ") " + log);
|
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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2003-09-11 John Camelon
|
||||||
|
Updated SourceElementRequestor callbacks to include IASTParameterReference callbacks.
|
||||||
|
|
||||||
2003-09-11 Bogdan Gheorghe
|
2003-09-11 Bogdan Gheorghe
|
||||||
- Added Search Menu to CView.java
|
- Added Search Menu to CView.java
|
||||||
- Added queryWorkingSets to CSearchScopeFactory to bring up the working
|
- Added queryWorkingSets to CSearchScopeFactory to bring up the working
|
||||||
|
|
|
@ -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.IASTMethodReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
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.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
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.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue