1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
Fixed Bug 39556 : 'restrict' qualifier is not supported (ANSI C99) 
	Fixed Bug 43126 : ISourceElementRequestor.acceptParameterReference accesses internal class
	Fixed Bug 43062 : Outline is confused on operator methods containing spaces 
	Cleaned up some warnings in the parser. 

TESTS
	Moved ASTFailedTests::testBug39556() to QuickParseASTTests.
	Cleaned up some warnings in parser tests.
This commit is contained in:
John Camelon 2003-09-15 22:50:59 +00:00
parent e563e217c7
commit 61976f1b51
32 changed files with 176 additions and 128 deletions

View file

@ -1,3 +1,7 @@
2003-09-15 John Camelon
Moved ASTFailedTests::testBug39556() to QuickParseASTTests.
Cleaned up some warnings in parser tests.
2003-09-15 Andrew Niefer 2003-09-15 Andrew Niefer
added testGetConditionalOperand_bug43106 to ParserSymbolTableTests added testGetConditionalOperand_bug43106 to ParserSymbolTableTests

View file

@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.tests.BaseASTTest;
*/ */
public class ASTFailedTests extends BaseASTTest public class ASTFailedTests extends BaseASTTest
{ {
private static final boolean debugging = false;
public ASTFailedTests(String name) public ASTFailedTests(String name)
{ {
super(name); super(name);
@ -112,13 +112,6 @@ public class ASTFailedTests extends BaseASTTest
{ {
assertCodeFailsParse("_Pragma(\"foobar\")"); assertCodeFailsParse("_Pragma(\"foobar\")");
} }
public void testBug39556() throws Exception
{
IASTFunction function = (IASTFunction)parse("int *restrict ip_fn (void);").getDeclarations().next();
assertFalse(
"The expected error did not occur.",
function.getReturnType().getPointerOperators().hasNext() );
}
//Here C99-specific section ends //Here C99-specific section ends
//Here GCC-specific section starts //Here GCC-specific section starts
@ -304,6 +297,7 @@ public class ASTFailedTests extends BaseASTTest
{ {
IASTFunction f = (IASTFunction)assertSoleDeclaration("int func2 (void) __attribute__((dllexport));"); IASTFunction f = (IASTFunction)assertSoleDeclaration("int func2 (void) __attribute__((dllexport));");
assertNotReached(); assertNotReached();
assertEquals( f.getName(), "func2");
} catch( ClassCastException cce ) } catch( ClassCastException cce )
{ {
} }

View file

@ -44,16 +44,23 @@ public class BaseASTTest extends TestCase
protected IQuickParseCallback quickParseCallback; protected IQuickParseCallback quickParseCallback;
protected IParser parser; protected IParser parser;
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError ) throws ParserException
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError, ParserLanguage lang ) throws ParserException
{ {
ParserMode mode = quick ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE; ParserMode mode = quick ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
quickParseCallback = ParserFactory.createQuickParseCallback(); quickParseCallback = ParserFactory.createQuickParseCallback();
parser = ParserFactory.createParser( ParserFactory.createScanner( new StringReader( code ), "code", new ScannerInfo(), mode, ParserLanguage.CPP, quickParseCallback), quickParseCallback, mode, ParserLanguage.CPP ); parser = ParserFactory.createParser( ParserFactory.createScanner( new StringReader( code ), "code", new ScannerInfo(), mode, lang, quickParseCallback), quickParseCallback, mode, lang );
if( ! parser.parse() && throwExceptionOnError ) if( ! parser.parse() && throwExceptionOnError )
throw new ParserException("Parse failure"); throw new ParserException("Parse failure");
return quickParseCallback.getCompilationUnit(); return quickParseCallback.getCompilationUnit();
} }
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError ) throws ParserException
{
return parse( code, quick, throwExceptionOnError, ParserLanguage.CPP );
}
protected IASTCompilationUnit parse( String code )throws ParserException protected IASTCompilationUnit parse( String code )throws ParserException
{ {
return parse( code, true, true ); return parse( code, true, true );

View file

@ -22,8 +22,8 @@ import junit.framework.TestCase;
import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
@ -47,6 +47,7 @@ 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.IASTParameterReference;
import org.eclipse.cdt.core.parser.ast.IASTScope; 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;
@ -59,7 +60,6 @@ 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
@ -623,7 +623,7 @@ public class CompleteParseBaseTest extends TestCase
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
*/ */
public void acceptParameterReference(ASTParameterReference reference) public void acceptParameterReference(IASTParameterReference reference)
{ {
references.add( reference ); references.add( reference );
} }

View file

@ -245,7 +245,7 @@ public class ParserSymbolTableTest extends TestCase {
a.addParent( b ); a.addParent( b );
try{ try{
ISymbol look = a.lookup("foo"); a.lookup("foo");
assertTrue( false ); assertTrue( false );
} catch ( ParserSymbolTableException e) { } catch ( ParserSymbolTableException e) {
assertEquals( e.reason, ParserSymbolTableException.r_CircularInheritance ); assertEquals( e.reason, ParserSymbolTableException.r_CircularInheritance );
@ -2331,7 +2331,7 @@ public class ParserSymbolTableTest extends TestCase {
args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, new Integer(2) ) ); args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, new Integer(2) ) );
try{ try{
TemplateInstance a5 = a.instantiate( args ); a.instantiate( args );
} catch ( ParserSymbolTableException e ){ } catch ( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous ); assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
} }

View file

@ -74,7 +74,8 @@ public class PreprocessorTest extends TestCase {
public IPreprocessor setupPreprocessor( String text, List includePaths, Map defns, ISourceElementRequestor rq ) public IPreprocessor setupPreprocessor( String text, List includePaths, Map defns, ISourceElementRequestor rq )
{ {
IPreprocessor p = ParserFactory.createPreprocessor( new StringReader( text ), "test", new ScannerInfo(), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, rq ); IPreprocessor p = ParserFactory.createPreprocessor( new StringReader( text ), "test", new ScannerInfo( defns,
includePaths == null ? null : (String [])includePaths.toArray()), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, rq );
return p; return p;
} }
} }

View file

@ -14,6 +14,7 @@ import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.core.parser.ParserLanguage;
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.ASTPointerOperator;
@ -1119,7 +1120,7 @@ public class QuickParseASTTests extends BaseASTTest
public void testConstructorChain() throws Exception public void testConstructorChain() throws Exception
{ {
Iterator declarations = parse( "TrafficLight_Actor::TrafficLight_Actor( RTController * rtg_rts, RTActorRef * rtg_ref ) : RTActor( rtg_rts, rtg_ref ), myId( 0 ) {}" ).getDeclarations(); Iterator declarations = parse( "TrafficLight_Actor::TrafficLight_Actor( RTController * rtg_rts, RTActorRef * rtg_ref ) : RTActor( rtg_rts, rtg_ref ), myId( 0 ) {}" ).getDeclarations();
IASTDeclaration d = (IASTDeclaration)declarations.next(); // cannot properly do this test now with new callback structure in quickparse mode declarations.next(); // cannot properly do this test now with new callback structure in quickparse mode
} }
public void testBug36237() throws Exception public void testBug36237() throws Exception
@ -1305,7 +1306,7 @@ public class QuickParseASTTests extends BaseASTTest
Iterator pointerOps = f.getReturnType().getPointerOperators(); Iterator pointerOps = f.getReturnType().getPointerOperators();
assertEquals( (ASTPointerOperator)pointerOps.next(), ASTPointerOperator.REFERENCE ); assertEquals( (ASTPointerOperator)pointerOps.next(), ASTPointerOperator.REFERENCE );
assertFalse( pointerOps.hasNext() ); assertFalse( pointerOps.hasNext() );
assertEquals( f.getName(), "A::operator="); assertEquals( f.getName(), "A::operator =");
Iterator parms = f.getParameters(); Iterator parms = f.getParameters();
IASTParameterDeclaration parm = (IASTParameterDeclaration)parms.next(); IASTParameterDeclaration parm = (IASTParameterDeclaration)parms.next();
assertEquals( parm.getName(), "" ); assertEquals( parm.getName(), "" );
@ -1551,7 +1552,7 @@ public class QuickParseASTTests extends BaseASTTest
Writer code = new StringWriter(); Writer code = new StringWriter();
code.write("A ( * const fPtr) (void *); \n"); code.write("A ( * const fPtr) (void *); \n");
code.write("A (* const fPtr2) ( A * ); \n"); code.write("A (* const fPtr2) ( A * ); \n");
Iterator declarations = parse(code.toString()).getDeclarations(); parse(code.toString()).getDeclarations();
} }
// K&R Test hasn't been ported from DOMTests // K&R Test hasn't been ported from DOMTests
@ -1810,5 +1811,9 @@ public class QuickParseASTTests extends BaseASTTest
parse( code.toString() ); parse( code.toString() );
} }
public void testBug39556() throws Exception
{
parse("int *restrict ip_fn (void);", true, true, ParserLanguage.C).getDeclarations().next();
}
} }

View file

@ -687,7 +687,7 @@ public class ScannerTestCase extends BaseScannerTest
try try
{ {
initializeScanner("#if ! 0\n#error Correct!\n#endif"); initializeScanner("#if ! 0\n#error Correct!\n#endif");
IToken t= scanner.nextToken(); scanner.nextToken();
fail(EXPECTED_FAILURE); fail(EXPECTED_FAILURE);
} }
catch (ScannerException se) catch (ScannerException se)

View file

@ -39,6 +39,7 @@ 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.IASTParameterReference;
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;
@ -50,7 +51,6 @@ 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
@ -448,7 +448,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
*/ */
public void acceptParameterReference(ASTParameterReference reference) public void acceptParameterReference(IASTParameterReference reference)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View file

@ -573,7 +573,7 @@ public class CModelBuilder {
parent.addChild( element ); parent.addChild( element );
// hook up the offsets // hook up the offsets
element.setIdPos( functionDeclaration.getNameOffset(), name.length() ); element.setIdPos( functionDeclaration.getNameOffset(), functionDeclaration.getNameEndOffset() - functionDeclaration.getNameOffset() );
if(!isTemplate){ if(!isTemplate){
// set the element position // set the element position
element.setPos(functionDeclaration.getStartingOffset(), functionDeclaration.getEndingOffset() - functionDeclaration.getStartingOffset()); element.setPos(functionDeclaration.getStartingOffset(), functionDeclaration.getEndingOffset() - functionDeclaration.getStartingOffset());

View file

@ -1,3 +1,9 @@
2003-09-15 John Camelon
Fixed Bug 39556 : 'restrict' qualifier is not supported (ANSI C99)
Fixed Bug 43126 : ISourceElementRequestor.acceptParameterReference accesses internal class
Fixed Bug 43062 : Outline is confused on operator methods containing spaces
Cleaned up some warnings in the parser.
2003-09-15 Andrew Niefer 2003-09-15 Andrew Niefer
bug43106 - added getConditionalOperand to ParserSymbolTable bug43106 - added getConditionalOperand to ParserSymbolTable

View file

@ -31,6 +31,7 @@ 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.IASTParameterReference;
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;
@ -40,7 +41,6 @@ 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
@ -91,7 +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 acceptParameterReference(IASTParameterReference reference);
public void exitTemplateDeclaration( IASTTemplateDeclaration declaration ); public void exitTemplateDeclaration( IASTTemplateDeclaration declaration );
public void exitTemplateSpecialization( IASTTemplateSpecialization specialization ); public void exitTemplateSpecialization( IASTTemplateSpecialization specialization );

View file

@ -22,7 +22,7 @@ public class ASTPointerOperator extends Enum
public static final ASTPointerOperator POINTER = new ASTPointerOperator( 1 ); public static final ASTPointerOperator POINTER = new ASTPointerOperator( 1 );
public static final ASTPointerOperator CONST_POINTER = new ASTPointerOperator( 2 ); public static final ASTPointerOperator CONST_POINTER = new ASTPointerOperator( 2 );
public static final ASTPointerOperator VOLATILE_POINTER = new ASTPointerOperator( 3 ); public static final ASTPointerOperator VOLATILE_POINTER = new ASTPointerOperator( 3 );
public static final ASTPointerOperator RESTRICT_POINTER = new ASTPointerOperator( 4 );
/** /**
* @param enumValue * @param enumValue

View file

@ -133,6 +133,7 @@ public interface IASTFactory
public IASTFunction createFunction( public IASTFunction createFunction(
IASTScope scope, IASTScope scope,
String name, String name,
int nameEndOffset,
List parameters, List parameters,
IASTAbstractDeclaration returnType, IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception, IASTExceptionSpecification exception,
@ -146,8 +147,7 @@ public interface IASTFactory
boolean isVolatile, boolean isVolatile,
boolean isVirtual, boolean isVirtual,
boolean isExplicit, boolean isExplicit,
boolean isPureVirtual, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition ) throws ASTSemanticException;
ASTAccessVisibility visibility, List constructorChain, boolean isDefinition ) throws ASTSemanticException;
public IASTAbstractDeclaration createAbstractDeclaration( public IASTAbstractDeclaration createAbstractDeclaration(
boolean isConst, boolean isConst,
boolean isVolatile, boolean isVolatile,
@ -156,6 +156,7 @@ public interface IASTFactory
public IASTMethod createMethod( public IASTMethod createMethod(
IASTScope scope, IASTScope scope,
String name, String name,
int nameEndOffset,
List parameters, List parameters,
IASTAbstractDeclaration returnType, IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception, IASTExceptionSpecification exception,
@ -169,8 +170,7 @@ public interface IASTFactory
boolean isVolatile, boolean isVolatile,
boolean isVirtual, boolean isVirtual,
boolean isExplicit, boolean isExplicit,
boolean isPureVirtual, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition) 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;

View file

@ -35,4 +35,5 @@ public interface IASTFunction extends IASTCodeScope, IASTOffsetableNamedElement,
public boolean previouslyDeclared(); public boolean previouslyDeclared();
public int getNameEndOffset(); // necessary for operator new, etc. which are > 1 token
} }

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.parser;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Set; import java.util.Set;
import java.util.Stack; import java.util.Stack;
@ -118,7 +117,6 @@ public class ContextStack {
int size = undoStack.size(); int size = undoStack.size();
if( size > 0 ) if( size > 0 )
{ {
Iterator iter = undoStack.iterator();
for( int i = size; i > 0; i-- ) for( int i = size; i > 0; i-- )
{ {
push( (IScannerContext) undoStack.removeFirst(), requestor ); push( (IScannerContext) undoStack.removeFirst(), requestor );

View file

@ -38,6 +38,7 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
*/ */
public class DeclarationWrapper implements IDeclaratorOwner public class DeclarationWrapper implements IDeclaratorOwner
{ {
private boolean restrict;
private int endOffset; private int endOffset;
private ITokenDuple name; private ITokenDuple name;
private Type simpleType = private Type simpleType =
@ -418,6 +419,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
.createMethod( .createMethod(
scope, scope,
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
declarator.getNameEndOffset(),
createParameterList(declarator.getParameters()), createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration( astFactory.createAbstractDeclaration(
constt, constt,
@ -435,9 +437,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
declarator.isVolatile(), declarator.isVolatile(),
virtual, virtual,
explicit, explicit,
declarator.isPureVirtual(), declarator.isPureVirtual(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode(),
((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers(), declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody());
declarator.hasFunctionBody());
} }
/** /**
* @param declarator * @param declarator
@ -448,6 +449,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
return astFactory.createFunction( return astFactory.createFunction(
scope, scope,
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
declarator.getNameEndOffset(),
createParameterList(declarator.getParameters()), createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration( astFactory.createAbstractDeclaration(
constt, constt,
@ -467,8 +469,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
explicit, explicit,
declarator.isPureVirtual(), declarator.isPureVirtual(),
ASTAccessVisibility.PUBLIC, ASTAccessVisibility.PUBLIC,
declarator.getConstructorMemberInitializers(), declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody() );
declarator.hasFunctionBody() );
} }
/** /**
* @param declarator * @param declarator
@ -664,5 +665,21 @@ public class DeclarationWrapper implements IDeclaratorOwner
{ {
return endOffset; return endOffset;
} }
/**
* @param b
*/
public void setRestrict(boolean b)
{
restrict = b;
}
/**
* @return
*/
public boolean isRestrict()
{
return restrict;
}
} }

View file

@ -23,6 +23,7 @@ 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.IASTParameterReference;
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;
@ -32,7 +33,6 @@ 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
@ -438,7 +438,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
*/ */
public void acceptParameterReference(ASTParameterReference reference) public void acceptParameterReference(IASTParameterReference reference)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View file

@ -43,7 +43,6 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceAlias;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement; import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
@ -60,6 +59,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.internal.core.model.IDebugLogConstants; import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
import org.eclipse.cdt.internal.core.model.Util; import org.eclipse.cdt.internal.core.model.Util;
/** /**
* This is our first implementation of the IParser interface, serving as a parser for * This is our first implementation of the IParser interface, serving as a parser for
* ANSI C and C++. * ANSI C and C++.
@ -70,7 +70,6 @@ import org.eclipse.cdt.internal.core.model.Util;
*/ */
public class Parser implements IParser public class Parser implements IParser
{ {
private ClassNameType access;
private static int DEFAULT_OFFSET = -1; private static int DEFAULT_OFFSET = -1;
// sentinel initial value for offsets // sentinel initial value for offsets
private int firstErrorOffset = DEFAULT_OFFSET; private int firstErrorOffset = DEFAULT_OFFSET;
@ -552,7 +551,7 @@ public class Parser implements IParser
} }
else if (LT(1) == IToken.t_template) else if (LT(1) == IToken.t_template)
{ {
IToken kind = consume(IToken.t_template); consume(IToken.t_template);
consume(IToken.tLT); consume(IToken.tLT);
List subResult = templateParameterList(scope); List subResult = templateParameterList(scope);
@ -804,11 +803,9 @@ public class Parser implements IParser
ITokenDuple duple = name(); ITokenDuple duple = name();
IASTNamespaceAlias alias = null;
try try
{ {
alias = astFactory.createNamespaceAlias( astFactory.createNamespaceAlias(
scope, identifier.toString(), duple, first.getOffset(), scope, identifier.toString(), duple, first.getOffset(),
identifier.getOffset(), duple.getLastToken().getEndOffset() ); identifier.getOffset(), duple.getLastToken().getEndOffset() );
} }
@ -881,14 +878,11 @@ public class Parser implements IParser
} }
} }
boolean done = false;
boolean hasFunctionBody = false; boolean hasFunctionBody = false;
switch (LT(1)) switch (LT(1))
{ {
case IToken.tSEMI : case IToken.tSEMI :
consume(IToken.tSEMI); consume(IToken.tSEMI);
done = true;
break; break;
case IToken.tCOLON : case IToken.tCOLON :
if (forKR) if (forKR)
@ -1752,6 +1746,15 @@ public class Parser implements IParser
result = consume( IToken.t_volatile ); result = consume( IToken.t_volatile );
if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER); if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER);
break; break;
case IToken.t_restrict :
if( language == ParserLanguage.C )
{
result = consume( IToken.t_restrict );
if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.RESTRICT_POINTER);
break;
}
else
throw backtrack;
default : default :
} }
@ -1805,7 +1808,6 @@ public class Parser implements IParser
{ {
if (LT(1) == IToken.tLBRACE) if (LT(1) == IToken.tLBRACE)
{ {
//TODO - parse this for real
consume(IToken.tLBRACE); consume(IToken.tLBRACE);
if (LT(1) == (IToken.tRBRACE)) if (LT(1) == (IToken.tRBRACE))
{ {
@ -1835,8 +1837,6 @@ public class Parser implements IParser
// assignmentExpression || { initializerList , } || { } // assignmentExpression || { initializerList , } || { }
try try
{ {
IToken marked = mark();
IASTExpression assignmentExpression = IASTExpression assignmentExpression =
assignmentExpression(scope); assignmentExpression(scope);
@ -1847,7 +1847,7 @@ public class Parser implements IParser
} }
catch (Backtrack b) catch (Backtrack b)
{ {
// who cares // do nothing
} }
throw backtrack; throw backtrack;
} }
@ -2859,7 +2859,7 @@ public class Parser implements IParser
IASTExpression assignmentExpression = assignmentExpression(scope); IASTExpression assignmentExpression = assignmentExpression(scope);
while (LT(1) == IToken.tCOMMA) while (LT(1) == IToken.tCOMMA)
{ {
IToken t = consume(); consume();
IASTExpression secondExpression = assignmentExpression(scope); IASTExpression secondExpression = assignmentExpression(scope);
try try
{ {
@ -2960,7 +2960,7 @@ public class Parser implements IParser
IASTExpression.Kind kind, IASTExpression lhs ) IASTExpression.Kind kind, IASTExpression lhs )
throws EndOfFile, Backtrack throws EndOfFile, Backtrack
{ {
IToken t = consume(); consume();
IASTExpression assignmentExpression = assignmentExpression(scope); IASTExpression assignmentExpression = assignmentExpression(scope);
try try
@ -3058,7 +3058,7 @@ public class Parser implements IParser
IASTExpression firstExpression = logicalAndExpression(scope); IASTExpression firstExpression = logicalAndExpression(scope);
while (LT(1) == IToken.tOR) while (LT(1) == IToken.tOR)
{ {
IToken t = consume(); consume();
IASTExpression secondExpression = logicalAndExpression(scope); IASTExpression secondExpression = logicalAndExpression(scope);
try try
@ -3091,7 +3091,7 @@ public class Parser implements IParser
IASTExpression firstExpression = inclusiveOrExpression( scope ); IASTExpression firstExpression = inclusiveOrExpression( scope );
while (LT(1) == IToken.tAND) while (LT(1) == IToken.tAND)
{ {
IToken t = consume(); consume();
IASTExpression secondExpression = inclusiveOrExpression( scope ); IASTExpression secondExpression = inclusiveOrExpression( scope );
try try
{ {
@ -3123,7 +3123,7 @@ public class Parser implements IParser
IASTExpression firstExpression = exclusiveOrExpression(scope); IASTExpression firstExpression = exclusiveOrExpression(scope);
while (LT(1) == IToken.tBITOR) while (LT(1) == IToken.tBITOR)
{ {
IToken t = consume(); consume();
IASTExpression secondExpression = exclusiveOrExpression(scope); IASTExpression secondExpression = exclusiveOrExpression(scope);
try try
@ -3156,7 +3156,7 @@ public class Parser implements IParser
IASTExpression firstExpression = andExpression( scope ); IASTExpression firstExpression = andExpression( scope );
while (LT(1) == IToken.tXOR) while (LT(1) == IToken.tXOR)
{ {
IToken t = consume(); consume();
IASTExpression secondExpression = andExpression( scope ); IASTExpression secondExpression = andExpression( scope );
try try
@ -3188,7 +3188,7 @@ public class Parser implements IParser
IASTExpression firstExpression = equalityExpression(scope); IASTExpression firstExpression = equalityExpression(scope);
while (LT(1) == IToken.tAMPER) while (LT(1) == IToken.tAMPER)
{ {
IToken t = consume(); consume();
IASTExpression secondExpression = equalityExpression(scope); IASTExpression secondExpression = equalityExpression(scope);
try try
@ -3843,8 +3843,7 @@ public class Parser implements IParser
} }
} }
protected IASTExpression unaryOperatorCastExpression( IASTScope scope, protected IASTExpression unaryOperatorCastExpression( IASTScope scope,
IASTExpression.Kind kind, IASTExpression.Kind kind)
IToken consumed)
throws Backtrack throws Backtrack
{ {
IASTExpression castExpression = castExpression(scope); IASTExpression castExpression = castExpression(scope);
@ -3875,37 +3874,37 @@ public class Parser implements IParser
switch (LT(1)) switch (LT(1))
{ {
case IToken.tSTAR : case IToken.tSTAR :
consume();
return unaryOperatorCastExpression(scope, return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION, IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION);
consume());
case IToken.tAMPER : case IToken.tAMPER :
consume();
return unaryOperatorCastExpression(scope, return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION, IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION);
consume());
case IToken.tPLUS : case IToken.tPLUS :
consume();
return unaryOperatorCastExpression(scope, return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION, IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION);
consume());
case IToken.tMINUS : case IToken.tMINUS :
consume();
return unaryOperatorCastExpression(scope, return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION, IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION);
consume());
case IToken.tNOT : case IToken.tNOT :
consume();
return unaryOperatorCastExpression(scope, return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION, IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION);
consume());
case IToken.tCOMPL : case IToken.tCOMPL :
consume();
return unaryOperatorCastExpression(scope, return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION, IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION);
consume());
case IToken.tINCR : case IToken.tINCR :
consume();
return unaryOperatorCastExpression(scope, return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_INCREMENT, IASTExpression.Kind.UNARY_INCREMENT);
consume());
case IToken.tDECR : case IToken.tDECR :
consume();
return unaryOperatorCastExpression(scope, return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_DECREMENT, IASTExpression.Kind.UNARY_DECREMENT);
consume());
case IToken.t_sizeof : case IToken.t_sizeof :
consume(IToken.t_sizeof); consume(IToken.t_sizeof);
IToken mark = LA(1); IToken mark = LA(1);

View file

@ -10,13 +10,9 @@
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.internal.core.parser; package org.eclipse.cdt.internal.core.parser;
import org.eclipse.cdt.core.parser.IToken;
public class ParserException extends Exception { public class ParserException extends Exception {
public ParserException(IToken t) {
}
public ParserException( String msg ) public ParserException( String msg )
{ {
super( msg ); super( msg );

View file

@ -356,8 +356,7 @@ public class Scanner implements IScanner {
private static final String START = "<initial reader>"; private static final String START = "<initial reader>";
private static final String EXPRESSION = "<expression>"; private static final String EXPRESSION = "<expression>";
private static final String PASTING = "<pasting>"; private static final String PASTING = "<pasting>";
private static final String BAD_PP =
"Invalid preprocessor directive encountered at offset ";
private static final String DEFINED = "defined"; private static final String DEFINED = "defined";
private static final String POUND_DEFINE = "#define "; private static final String POUND_DEFINE = "#define ";
@ -624,7 +623,6 @@ public class Scanner implements IScanner {
while (c != NOCHAR) { while (c != NOCHAR) {
if ( ! passOnToClient ) { if ( ! passOnToClient ) {
int state = 0;
while (c != NOCHAR && c != '#' ) while (c != NOCHAR && c != '#' )
{ {
@ -1565,8 +1563,6 @@ public class Scanner implements IScanner {
// string // string
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
int beforePrevious = NOCHAR;
int previous = c;
c = getChar(true); c = getChar(true);
for( ; ; ) for( ; ; )
@ -1574,8 +1570,6 @@ public class Scanner implements IScanner {
if ( c =='"' ) break; if ( c =='"' ) break;
if( c == NOCHAR) break; if( c == NOCHAR) break;
buff.append((char) c); buff.append((char) c);
beforePrevious = previous;
previous = c;
c = getChar(true); c = getChar(true);
} }
@ -2279,7 +2273,6 @@ public class Scanner implements IScanner {
for (int i = 0; i < numberOfTokens; ++i) { for (int i = 0; i < numberOfTokens; ++i) {
t = (Token) tokens.get(i); t = (Token) tokens.get(i);
if (t.type == IToken.tIDENTIFIER) { if (t.type == IToken.tIDENTIFIER) {
String identifierName = t.image;
// is this identifier in the parameterNames // is this identifier in the parameterNames
// list? // list?

View file

@ -88,6 +88,8 @@ public class TokenDuple implements ITokenDuple {
for( ; ; ) for( ; ; )
{ {
buff.append( iter.getImage() ); buff.append( iter.getImage() );
if( iter.getType() == IToken.t_operator )
buff.append( ' ');
if( iter == lastToken ) break; if( iter == lastToken ) break;
iter = iter.getNext(); iter = iter.getNext();
} }

View file

@ -41,6 +41,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
private final ASTQualifiedNamedElement qualifiedName; private final ASTQualifiedNamedElement qualifiedName;
private final List parameters; private final List parameters;
protected final ASTReferenceStore references; protected final ASTReferenceStore references;
private final int nameEndOffset;
/** /**
* @param symbol * @param symbol
@ -52,11 +53,11 @@ public class ASTFunction extends ASTScope implements IASTFunction
* @param ownerTemplate * @param ownerTemplate
* @param references * @param references
*/ */
public ASTFunction(IParameterizedSymbol symbol, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int nameOffset, IASTTemplate ownerTemplate, List references, boolean previouslyDeclared ) public ASTFunction(IParameterizedSymbol symbol, int nameEndOffset, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int nameOffset, IASTTemplate ownerTemplate, List references, boolean previouslyDeclared )
{ {
super( symbol ); super( symbol );
this.parameters = parameters; this.parameters = parameters;
this.nameEndOffset = nameEndOffset;
this.returnType = returnType; this.returnType = returnType;
this.exception = exception; this.exception = exception;
setStartingOffset(startOffset); setStartingOffset(startOffset);
@ -261,4 +262,14 @@ public class ASTFunction extends ASTScope implements IASTFunction
{ {
return previouslyDeclared; return previouslyDeclared;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#getNameEndOffset()
*/
public int getNameEndOffset()
{
// TODO Auto-generated method stub
return 0;
}
} }

View file

@ -45,11 +45,12 @@ public class ASTMethod extends ASTFunction implements IASTMethod
* @param ownerTemplate * @param ownerTemplate
* @param references * @param references
*/ */
public ASTMethod(IParameterizedSymbol symbol, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int nameOffset, IASTTemplate ownerTemplate, List references, boolean previouslyDeclared, public ASTMethod(IParameterizedSymbol symbol, int nameEndOffset, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int nameOffset, IASTTemplate ownerTemplate, List references, boolean previouslyDeclared,
boolean isConstructor, boolean isDestructor, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain ) boolean isConstructor, boolean isDestructor, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain )
{ {
super( super(
symbol, symbol,
nameEndOffset,
parameters, parameters,
returnType, returnType,
exception, exception,

View file

@ -161,6 +161,7 @@ public class ASTParameterDeclaration extends ASTSymbol implements IASTParameterD
{ {
offsets.setEndingOffset(o); offsets.setEndingOffset(o);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset() * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset()
*/ */
@ -168,6 +169,7 @@ public class ASTParameterDeclaration extends ASTSymbol implements IASTParameterD
{ {
return offsets.getStartingOffset(); return offsets.getStartingOffset();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset() * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset()
*/ */
@ -176,8 +178,4 @@ public class ASTParameterDeclaration extends ASTSymbol implements IASTParameterD
return offsets.getEndingOffset(); return offsets.getEndingOffset();
} }
} }

View file

@ -1270,6 +1270,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
public IASTFunction createFunction( public IASTFunction createFunction(
IASTScope scope, IASTScope scope,
String name, String name,
int nameEndOffset,
List parameters, List parameters,
IASTAbstractDeclaration returnType, IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception, IASTExceptionSpecification exception,
@ -1284,8 +1285,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean isVirtual, boolean isVirtual,
boolean isExplicit, boolean isExplicit,
boolean isPureVirtual, boolean isPureVirtual,
ASTAccessVisibility visibility, ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
{ {
List references = new ArrayList(); List references = new ArrayList();
IContainerSymbol ownerScope = scopeToSymbol( scope ); IContainerSymbol ownerScope = scopeToSymbol( scope );
@ -1341,7 +1341,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next(); ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next();
visibility = ((IASTMethod)reference.getReferencedElement()).getVisiblity(); visibility = ((IASTMethod)reference.getReferencedElement()).getVisiblity();
} }
return createMethod(scope, functionName, parameters, returnType, return createMethod(scope, functionName, nameEndOffset, 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, isFunctionDefinition); visibility, constructorChain,parentName, references, isFunctionDefinition);
@ -1387,7 +1387,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{ {
throw new ASTSemanticException(); throw new ASTSemanticException();
} }
ASTFunction function = new ASTFunction( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, previouslyDeclared ); ASTFunction function = new ASTFunction( symbol, nameEndOffset, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, previouslyDeclared );
try try
{ {
attachSymbolExtension(symbol, function); attachSymbolExtension(symbol, function);
@ -1580,6 +1580,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
public IASTMethod createMethod( public IASTMethod createMethod(
IASTScope scope, IASTScope scope,
String name, String name,
int nameEndOffset,
List parameters, List parameters,
IASTAbstractDeclaration returnType, IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception, IASTExceptionSpecification exception,
@ -1594,10 +1595,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean isVirtual, boolean isVirtual,
boolean isExplicit, boolean isExplicit,
boolean isPureVirtual, boolean isPureVirtual,
ASTAccessVisibility visibility, ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
{ {
return createMethod(scope, name, parameters, returnType, return createMethod(scope, name, nameEndOffset, 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, isFunctionDefinition ); visibility, constructorChain,scopeToSymbol(scope).getName(), null, isFunctionDefinition );
@ -1606,6 +1606,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
public IASTMethod createMethod( public IASTMethod createMethod(
IASTScope scope, IASTScope scope,
String name, String name,
int nameEndOffset,
List parameters, List parameters,
IASTAbstractDeclaration returnType, IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception, IASTExceptionSpecification exception,
@ -1669,7 +1670,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean previouslyDeclared = false; boolean previouslyDeclared = false;
//TODO : Hoda - if symbol was previously declared in PST, then set this to true //TODO : Hoda - if symbol was previously declared in PST, then set this to true
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, previouslyDeclared, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain ); ASTMethod method = new ASTMethod( symbol, nameEndOffset, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, previouslyDeclared, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain );
try try
{ {
attachSymbolExtension( symbol, method ); attachSymbolExtension( symbol, method );

View file

@ -34,7 +34,7 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
/** /**
* @param scope * @param scope
*/ */
public ASTFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, public ASTFunction(IASTScope scope, String name, int nameEndOffset, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception,
boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate ) boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate )
{ {
super(ownerTemplate != null ? null : scope ); super(ownerTemplate != null ? null : scope );
@ -51,8 +51,10 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
offsets.setStartingOffset( startOffset ); offsets.setStartingOffset( startOffset );
offsets.setNameOffset( nameOffset ); offsets.setNameOffset( nameOffset );
qualifiedName = new ASTQualifiedNamedElement( scope, name ); qualifiedName = new ASTQualifiedNamedElement( scope, name );
this.nameEndOffset = nameEndOffset;
} }
private final int nameEndOffset;
private boolean hasFunctionBody = false; private boolean hasFunctionBody = false;
private final IASTQualifiedNameElement qualifiedName; private final IASTQualifiedNameElement qualifiedName;
private final IASTTemplate ownerTemplateDeclaration; private final IASTTemplate ownerTemplateDeclaration;
@ -226,4 +228,11 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#getNameEndOffset()
*/
public int getNameEndOffset()
{
return nameEndOffset;
}
} }

View file

@ -54,6 +54,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
public ASTMethod( public ASTMethod(
IASTScope scope, IASTScope scope,
String name, String name,
int nameEndOffset,
List parameters, List parameters,
IASTAbstractDeclaration returnType, IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception, IASTExceptionSpecification exception,
@ -74,6 +75,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
super( super(
scope, scope,
name, name,
nameEndOffset,
parameters, parameters,
returnType, returnType,
exception, exception,

View file

@ -188,17 +188,17 @@ 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, boolean isFunctionDefinition ) public IASTFunction createFunction(IASTScope scope, String name, int nameEndOffset, 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, nameEndOffset, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate );
} }
/* (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, boolean isFunctionDefinition ) public IASTMethod createMethod(IASTScope scope, String name, int nameEndOffset, 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, nameEndOffset, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, false, false, isVirtual, isExplicit, isPureVirtual, visibility, constructorChain);
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -32,8 +32,8 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate; import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
@ -58,6 +58,7 @@ 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.IASTOffsetableNamedElement; import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
import org.eclipse.cdt.core.parser.ast.IASTReference; import org.eclipse.cdt.core.parser.ast.IASTReference;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
@ -76,7 +77,6 @@ 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;
@ -513,7 +513,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
*/ */
public void acceptParameterReference(ASTParameterReference reference) public void acceptParameterReference(IASTParameterReference reference)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View file

@ -1,3 +1,6 @@
2003-09-15 John Camelon
Fixed Bug 43126 : ISourceElementRequestor.acceptParameterReference accesses internal class
2003-09-13 Andrew Niefer 2003-09-13 Andrew Niefer
- bug42836 - prepopulate template classes from Outline View - bug42836 - prepopulate template classes from Outline View
- bug43016 - Search: Cannot find macro declarations - bug43016 - Search: Cannot find macro declarations

View file

@ -34,6 +34,7 @@ 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.IASTParameterReference;
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;
@ -43,7 +44,6 @@ 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;
/** /**
* *
@ -323,7 +323,7 @@ public class SourceElementRequestorAdapter implements ISourceElementRequestor {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
*/ */
public void acceptParameterReference(ASTParameterReference reference) public void acceptParameterReference(IASTParameterReference reference)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }