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
added testGetConditionalOperand_bug43106 to ParserSymbolTableTests

View file

@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.tests.BaseASTTest;
*/
public class ASTFailedTests extends BaseASTTest
{
private static final boolean debugging = false;
public ASTFailedTests(String name)
{
super(name);
@ -112,13 +112,6 @@ public class ASTFailedTests extends BaseASTTest
{
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 GCC-specific section starts
@ -304,6 +297,7 @@ public class ASTFailedTests extends BaseASTTest
{
IASTFunction f = (IASTFunction)assertSoleDeclaration("int func2 (void) __attribute__((dllexport));");
assertNotReached();
assertEquals( f.getName(), "func2");
} catch( ClassCastException cce )
{
}

View file

@ -44,16 +44,23 @@ public class BaseASTTest extends TestCase
protected IQuickParseCallback quickParseCallback;
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;
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 )
throw new ParserException("Parse failure");
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
{
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.IProblem;
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.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
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.IASTNamespaceDefinition;
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.IASTTemplateDeclaration;
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.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
/**
* @author jcamelon
@ -623,7 +623,7 @@ public class CompleteParseBaseTest extends TestCase
/* (non-Javadoc)
* @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 );
}

View file

@ -245,7 +245,7 @@ public class ParserSymbolTableTest extends TestCase {
a.addParent( b );
try{
ISymbol look = a.lookup("foo");
a.lookup("foo");
assertTrue( false );
} catch ( ParserSymbolTableException e) {
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) ) );
try{
TemplateInstance a5 = a.instantiate( args );
a.instantiate( args );
} catch ( ParserSymbolTableException e ){
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 )
{
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;
}
}

View file

@ -14,6 +14,7 @@ import java.io.StringWriter;
import java.io.Writer;
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.ASTClassKind;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
@ -1119,7 +1120,7 @@ public class QuickParseASTTests extends BaseASTTest
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();
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
@ -1305,7 +1306,7 @@ public class QuickParseASTTests extends BaseASTTest
Iterator pointerOps = f.getReturnType().getPointerOperators();
assertEquals( (ASTPointerOperator)pointerOps.next(), ASTPointerOperator.REFERENCE );
assertFalse( pointerOps.hasNext() );
assertEquals( f.getName(), "A::operator=");
assertEquals( f.getName(), "A::operator =");
Iterator parms = f.getParameters();
IASTParameterDeclaration parm = (IASTParameterDeclaration)parms.next();
assertEquals( parm.getName(), "" );
@ -1551,7 +1552,7 @@ public class QuickParseASTTests extends BaseASTTest
Writer code = new StringWriter();
code.write("A ( * const fPtr) (void *); \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
@ -1810,5 +1811,9 @@ public class QuickParseASTTests extends BaseASTTest
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
{
initializeScanner("#if ! 0\n#error Correct!\n#endif");
IToken t= scanner.nextToken();
scanner.nextToken();
fail(EXPECTED_FAILURE);
}
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.IASTNamespaceDefinition;
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.IASTTemplateInstantiation;
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.IASTVariableReference;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
/**
* @author bgheorgh
@ -448,7 +448,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
/* (non-Javadoc)
* @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

View file

@ -573,7 +573,7 @@ public class CModelBuilder {
parent.addChild( element );
// hook up the offsets
element.setIdPos( functionDeclaration.getNameOffset(), name.length() );
element.setIdPos( functionDeclaration.getNameOffset(), functionDeclaration.getNameEndOffset() - functionDeclaration.getNameOffset() );
if(!isTemplate){
// set the element position
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
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.IASTNamespaceDefinition;
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.IASTTemplateInstantiation;
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.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
/**
* @author jcamelon
@ -91,7 +91,7 @@ public interface ISourceElementRequestor {
public void acceptFieldReference( IASTFieldReference reference );
public void acceptMethodReference( IASTMethodReference reference );
public void acceptEnumeratorReference( IASTEnumeratorReference reference );
public void acceptParameterReference(ASTParameterReference reference);
public void acceptParameterReference(IASTParameterReference reference);
public void exitTemplateDeclaration( IASTTemplateDeclaration declaration );
public void exitTemplateSpecialization( IASTTemplateSpecialization specialization );

View file

@ -18,11 +18,11 @@ import org.eclipse.cdt.core.parser.Enum;
*/
public class ASTPointerOperator extends Enum
{
public static final ASTPointerOperator REFERENCE = new ASTPointerOperator( 0 );
public static final ASTPointerOperator REFERENCE = new ASTPointerOperator( 0 );
public static final ASTPointerOperator POINTER = new ASTPointerOperator( 1 );
public static final ASTPointerOperator CONST_POINTER = new ASTPointerOperator( 2 );
public static final ASTPointerOperator VOLATILE_POINTER = new ASTPointerOperator( 3 );
public static final ASTPointerOperator RESTRICT_POINTER = new ASTPointerOperator( 4 );
/**
* @param enumValue

View file

@ -133,6 +133,7 @@ public interface IASTFactory
public IASTFunction createFunction(
IASTScope scope,
String name,
int nameEndOffset,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@ -141,13 +142,12 @@ public interface IASTFactory
boolean isStatic,
int startOffset,
int nameOffset,
IASTTemplate ownerTemplate,
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility, List constructorChain, boolean isDefinition ) throws ASTSemanticException;
boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition ) throws ASTSemanticException;
public IASTAbstractDeclaration createAbstractDeclaration(
boolean isConst,
boolean isVolatile,
@ -156,6 +156,7 @@ public interface IASTFactory
public IASTMethod createMethod(
IASTScope scope,
String name,
int nameEndOffset,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@ -169,8 +170,7 @@ public interface IASTFactory
boolean isVolatile,
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility, List constructorChain, boolean isDefinition) throws ASTSemanticException;
boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition) throws ASTSemanticException;
public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression,
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, IASTExpression constructorExpression ) throws ASTSemanticException;

View file

@ -35,4 +35,5 @@ public interface IASTFunction extends IASTCodeScope, IASTOffsetableNamedElement,
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.Reader;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
import java.util.Stack;
@ -118,7 +117,6 @@ public class ContextStack {
int size = undoStack.size();
if( size > 0 )
{
Iterator iter = undoStack.iterator();
for( int i = size; i > 0; i-- )
{
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
{
private boolean restrict;
private int endOffset;
private ITokenDuple name;
private Type simpleType =
@ -418,6 +419,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
.createMethod(
scope,
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
declarator.getNameEndOffset(),
createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration(
constt,
@ -432,12 +434,11 @@ public class DeclarationWrapper implements IDeclaratorOwner
declarator.getNameStartOffset(),
templateDeclaration,
declarator.isConst(),
declarator.isVolatile(),
virtual,
declarator.isVolatile(),
virtual,
explicit,
declarator.isPureVirtual(),
((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers(),
declarator.hasFunctionBody());
declarator.isPureVirtual(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode(),
declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody());
}
/**
* @param declarator
@ -448,6 +449,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
return astFactory.createFunction(
scope,
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
declarator.getNameEndOffset(),
createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration(
constt,
@ -460,15 +462,14 @@ public class DeclarationWrapper implements IDeclaratorOwner
staticc,
startingOffset,
declarator.getNameStartOffset(),
templateDeclaration,
templateDeclaration,
declarator.isConst(),
declarator.isVolatile(),
virtual,
explicit,
declarator.isPureVirtual(),
ASTAccessVisibility.PUBLIC,
declarator.getConstructorMemberInitializers(),
declarator.hasFunctionBody() );
declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody() );
}
/**
* @param declarator
@ -664,5 +665,21 @@ public class DeclarationWrapper implements IDeclaratorOwner
{
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.IASTNamespaceDefinition;
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.IASTTemplateInstantiation;
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.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
public class NullSourceElementRequestor implements ISourceElementRequestor
@ -438,7 +438,7 @@ public class NullSourceElementRequestor 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)
public void acceptParameterReference(IASTParameterReference reference)
{
// 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.IASTInitializerClause;
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.IASTOffsetableElement;
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.internal.core.model.IDebugLogConstants;
import org.eclipse.cdt.internal.core.model.Util;
/**
* This is our first implementation of the IParser interface, serving as a parser for
* ANSI C and C++.
@ -70,7 +70,6 @@ import org.eclipse.cdt.internal.core.model.Util;
*/
public class Parser implements IParser
{
private ClassNameType access;
private static int DEFAULT_OFFSET = -1;
// sentinel initial value for offsets
private int firstErrorOffset = DEFAULT_OFFSET;
@ -552,7 +551,7 @@ public class Parser implements IParser
}
else if (LT(1) == IToken.t_template)
{
IToken kind = consume(IToken.t_template);
consume(IToken.t_template);
consume(IToken.tLT);
List subResult = templateParameterList(scope);
@ -804,11 +803,9 @@ public class Parser implements IParser
ITokenDuple duple = name();
IASTNamespaceAlias alias = null;
try
{
alias = astFactory.createNamespaceAlias(
astFactory.createNamespaceAlias(
scope, identifier.toString(), duple, first.getOffset(),
identifier.getOffset(), duple.getLastToken().getEndOffset() );
}
@ -881,14 +878,11 @@ public class Parser implements IParser
}
}
boolean done = false;
boolean hasFunctionBody = false;
switch (LT(1))
{
case IToken.tSEMI :
consume(IToken.tSEMI);
done = true;
break;
case IToken.tCOLON :
if (forKR)
@ -1752,6 +1746,15 @@ public class Parser implements IParser
result = consume( IToken.t_volatile );
if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER);
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 :
}
@ -1805,7 +1808,6 @@ public class Parser implements IParser
{
if (LT(1) == IToken.tLBRACE)
{
//TODO - parse this for real
consume(IToken.tLBRACE);
if (LT(1) == (IToken.tRBRACE))
{
@ -1835,8 +1837,6 @@ public class Parser implements IParser
// assignmentExpression || { initializerList , } || { }
try
{
IToken marked = mark();
IASTExpression assignmentExpression =
assignmentExpression(scope);
@ -1847,7 +1847,7 @@ public class Parser implements IParser
}
catch (Backtrack b)
{
// who cares
// do nothing
}
throw backtrack;
}
@ -2859,7 +2859,7 @@ public class Parser implements IParser
IASTExpression assignmentExpression = assignmentExpression(scope);
while (LT(1) == IToken.tCOMMA)
{
IToken t = consume();
consume();
IASTExpression secondExpression = assignmentExpression(scope);
try
{
@ -2960,7 +2960,7 @@ public class Parser implements IParser
IASTExpression.Kind kind, IASTExpression lhs )
throws EndOfFile, Backtrack
{
IToken t = consume();
consume();
IASTExpression assignmentExpression = assignmentExpression(scope);
try
@ -3058,7 +3058,7 @@ public class Parser implements IParser
IASTExpression firstExpression = logicalAndExpression(scope);
while (LT(1) == IToken.tOR)
{
IToken t = consume();
consume();
IASTExpression secondExpression = logicalAndExpression(scope);
try
@ -3091,7 +3091,7 @@ public class Parser implements IParser
IASTExpression firstExpression = inclusiveOrExpression( scope );
while (LT(1) == IToken.tAND)
{
IToken t = consume();
consume();
IASTExpression secondExpression = inclusiveOrExpression( scope );
try
{
@ -3123,7 +3123,7 @@ public class Parser implements IParser
IASTExpression firstExpression = exclusiveOrExpression(scope);
while (LT(1) == IToken.tBITOR)
{
IToken t = consume();
consume();
IASTExpression secondExpression = exclusiveOrExpression(scope);
try
@ -3156,7 +3156,7 @@ public class Parser implements IParser
IASTExpression firstExpression = andExpression( scope );
while (LT(1) == IToken.tXOR)
{
IToken t = consume();
consume();
IASTExpression secondExpression = andExpression( scope );
try
@ -3188,7 +3188,7 @@ public class Parser implements IParser
IASTExpression firstExpression = equalityExpression(scope);
while (LT(1) == IToken.tAMPER)
{
IToken t = consume();
consume();
IASTExpression secondExpression = equalityExpression(scope);
try
@ -3843,8 +3843,7 @@ public class Parser implements IParser
}
}
protected IASTExpression unaryOperatorCastExpression( IASTScope scope,
IASTExpression.Kind kind,
IToken consumed)
IASTExpression.Kind kind)
throws Backtrack
{
IASTExpression castExpression = castExpression(scope);
@ -3875,37 +3874,37 @@ public class Parser implements IParser
switch (LT(1))
{
case IToken.tSTAR :
consume();
return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION,
consume());
IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION);
case IToken.tAMPER :
consume();
return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION,
consume());
IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION);
case IToken.tPLUS :
consume();
return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION,
consume());
IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION);
case IToken.tMINUS :
consume();
return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION,
consume());
IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION);
case IToken.tNOT :
consume();
return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION,
consume());
IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION);
case IToken.tCOMPL :
consume();
return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION,
consume());
IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION);
case IToken.tINCR :
consume();
return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_INCREMENT,
consume());
IASTExpression.Kind.UNARY_INCREMENT);
case IToken.tDECR :
consume();
return unaryOperatorCastExpression(scope,
IASTExpression.Kind.UNARY_DECREMENT,
consume());
IASTExpression.Kind.UNARY_DECREMENT);
case IToken.t_sizeof :
consume(IToken.t_sizeof);
IToken mark = LA(1);

View file

@ -10,13 +10,9 @@
******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
import org.eclipse.cdt.core.parser.IToken;
public class ParserException extends Exception {
public ParserException(IToken t) {
}
public ParserException( String 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 EXPRESSION = "<expression>";
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 POUND_DEFINE = "#define ";
@ -624,7 +623,6 @@ public class Scanner implements IScanner {
while (c != NOCHAR) {
if ( ! passOnToClient ) {
int state = 0;
while (c != NOCHAR && c != '#' )
{
@ -1565,8 +1563,6 @@ public class Scanner implements IScanner {
// string
StringBuffer buff = new StringBuffer();
int beforePrevious = NOCHAR;
int previous = c;
c = getChar(true);
for( ; ; )
@ -1574,8 +1570,6 @@ public class Scanner implements IScanner {
if ( c =='"' ) break;
if( c == NOCHAR) break;
buff.append((char) c);
beforePrevious = previous;
previous = c;
c = getChar(true);
}
@ -2279,7 +2273,6 @@ public class Scanner implements IScanner {
for (int i = 0; i < numberOfTokens; ++i) {
t = (Token) tokens.get(i);
if (t.type == IToken.tIDENTIFIER) {
String identifierName = t.image;
// is this identifier in the parameterNames
// list?

View file

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

View file

@ -41,6 +41,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
private final ASTQualifiedNamedElement qualifiedName;
private final List parameters;
protected final ASTReferenceStore references;
private final int nameEndOffset;
/**
* @param symbol
@ -52,11 +53,11 @@ public class ASTFunction extends ASTScope implements IASTFunction
* @param ownerTemplate
* @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 );
this.parameters = parameters;
this.nameEndOffset = nameEndOffset;
this.returnType = returnType;
this.exception = exception;
setStartingOffset(startOffset);
@ -261,4 +262,14 @@ public class ASTFunction extends ASTScope implements IASTFunction
{
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 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 )
{
super(
symbol,
nameEndOffset,
parameters,
returnType,
exception,

View file

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

View file

@ -1270,6 +1270,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
public IASTFunction createFunction(
IASTScope scope,
String name,
int nameEndOffset,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@ -1278,14 +1279,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean isStatic,
int startOffset,
int nameOffset,
IASTTemplate ownerTemplate,
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility,
List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
{
List references = new ArrayList();
IContainerSymbol ownerScope = scopeToSymbol( scope );
@ -1341,7 +1341,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next();
visibility = ((IASTMethod)reference.getReferencedElement()).getVisiblity();
}
return createMethod(scope, functionName, parameters, returnType,
return createMethod(scope, functionName, nameEndOffset, parameters, returnType,
exception, isInline, isFriend, isStatic, startOffset, offset,
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
visibility, constructorChain,parentName, references, isFunctionDefinition);
@ -1387,7 +1387,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
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
{
attachSymbolExtension(symbol, function);
@ -1580,6 +1580,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
public IASTMethod createMethod(
IASTScope scope,
String name,
int nameEndOffset,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@ -1594,10 +1595,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility,
List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
ASTAccessVisibility visibility, 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,
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
visibility, constructorChain,scopeToSymbol(scope).getName(), null, isFunctionDefinition );
@ -1606,6 +1606,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
public IASTMethod createMethod(
IASTScope scope,
String name,
int nameEndOffset,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@ -1669,7 +1670,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean previouslyDeclared = false;
//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
{
attachSymbolExtension( symbol, method );

View file

@ -34,7 +34,7 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
/**
* @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 )
{
super(ownerTemplate != null ? null : scope );
@ -51,8 +51,10 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
offsets.setStartingOffset( startOffset );
offsets.setNameOffset( nameOffset );
qualifiedName = new ASTQualifiedNamedElement( scope, name );
this.nameEndOffset = nameEndOffset;
}
private final int nameEndOffset;
private boolean hasFunctionBody = false;
private final IASTQualifiedNameElement qualifiedName;
private final IASTTemplate ownerTemplateDeclaration;
@ -226,4 +228,11 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
// TODO Auto-generated method stub
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(
IASTScope scope,
String name,
int nameEndOffset,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@ -74,6 +75,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
super(
scope,
name,
nameEndOffset,
parameters,
returnType,
exception,

View file

@ -188,17 +188,17 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
*/
public IASTFunction createFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, 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)
* @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)

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.ISourceElementCallbackDelegate;
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.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
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.IASTNamespaceReference;
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.IASTScope;
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.internal.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -513,7 +513,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
/* (non-Javadoc)
* @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

View file

@ -1,3 +1,6 @@
2003-09-15 John Camelon
Fixed Bug 43126 : ISourceElementRequestor.acceptParameterReference accesses internal class
2003-09-13 Andrew Niefer
- bug42836 - prepopulate template classes from Outline View
- 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.IASTNamespaceDefinition;
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.IASTTemplateInstantiation;
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.IASTVariable;
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)
* @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
}