1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

org.eclipse.cdt.core

Restructured Parser implementation to allow for better support of Selection Search.
	Restructured Parser implementation to allow for separation between parsing expressions (Scanner) and complete C/C++ source.

org.eclipse.cdt.core.tests
	Updated tests to accommodate for new Parser class hierarchy and factories.
This commit is contained in:
John Camelon 2004-02-11 23:14:24 +00:00
parent d3531f1429
commit 7f57c34082
23 changed files with 3812 additions and 2733 deletions

View file

@ -1,3 +1,6 @@
2004-02-11 John Camelon
Updated tests to accommodate for new Parser class hierarchy and factories.
2004-02-10 Andrew Niefer
Added new File: ParserSymbolTableTemplateTests.java (contains 30 new tests)
Added new File: FailingTemplateTests.java (contains 5 test stubs for failing cases)

View file

@ -6,14 +6,14 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.NullLogService;
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
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.ScannerInfo;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.internal.core.parser.IExpressionParser;
import org.eclipse.cdt.internal.core.parser.InternalParserFactory;
public class ExprEvalTest extends TestCase {
@ -28,7 +28,7 @@ public class ExprEvalTest extends TestCase {
public void runTest(String code, int expectedValue) throws Exception {
final NullSourceElementRequestor nullCallback = new NullSourceElementRequestor();
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, new NullLogService() ), nullCallback, ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
IExpressionParser parser = InternalParserFactory.createExpressionParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, new NullLogService() ), ParserLanguage.CPP, null );
IASTExpression expression = parser.expression(null);
assertEquals(expectedValue, expression.evaluateExpression());
}

View file

@ -53,7 +53,7 @@ public class SelectionParseTest extends CompleteParseBaseTest {
}
public void testBaseCase_Variable() throws Exception
public void testBaseCase_VariableReference() throws Exception
{
String code = "int x; x=3;";
int offset1 = code.indexOf( "x=" );
@ -63,9 +63,9 @@ public class SelectionParseTest extends CompleteParseBaseTest {
assertEquals( ((IASTVariable)node).getName(), "x" );
}
public void testBaseCase_Function() throws Exception
public void testBaseCase_FunctionReference() throws Exception
{
String code = "int x(); x( );";
String code = "int x(){x( );}";
int offset1 = code.indexOf( "x( " );
int offset2 = code.indexOf( "( )");
IASTNode node = parse( code, offset1, offset2 );
@ -75,11 +75,31 @@ public class SelectionParseTest extends CompleteParseBaseTest {
public void testBaseCase_Error() throws Exception
{
String code = "int x(); y( );";
String code = "int x() { y( ) }";
int offset1 = code.indexOf( "y( " );
int offset2 = code.indexOf( "( )");
assertNull( parse( code, offset1, offset2 ));
}
// public void testBaseCase_FunctionDeclaration() throws Exception
// {
// String code = "int x(); x( );";
// int offset1 = code.indexOf( "x()" );
// int offset2 = code.indexOf( "()");
// IASTNode node = parse( code, offset1, offset2 );
// assertTrue( node instanceof IASTFunction );
// assertEquals( ((IASTFunction)node).getName(), "x" );
// }
//
// public void testBaseCase_VariableDeclaration() throws Exception
// {
// String code = "int x = 3;";
// int offset1 = code.indexOf( "x" );
// int offset2 = code.indexOf( " =");
// IASTNode node = parse( code, offset1, offset2 );
// assertTrue( node instanceof IASTVariable );
// assertEquals( ((IASTVariable)node).getName(), "x" );
// }
}

View file

@ -1,3 +1,7 @@
2004-02-11 John Camelon
Restructured Parser implementation to allow for better support of Selection Search.
Restructured Parser implementation to allow for separation between parsing expressions (Scanner) and complete C/C++ source.
2004-02-10 John Camelon
Workaround for Bug 51502 - Parser spins on particular file (Scalability)

View file

@ -11,9 +11,7 @@
package org.eclipse.cdt.core.parser;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTNode;
import org.eclipse.cdt.core.parser.ast.IASTScope;
@ -23,7 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
*
* @author jcamelon
*/
public interface IParser {
public interface IParser {
/**
@ -47,18 +45,6 @@ public interface IParser {
*/
public IASTNode parse( int startingOffset, int endingOffset ) throws ParseError;
/**
* Request a parse from a pre-configured parser to parse an expression.
*
* @param expression Optional parameter representing an expression object that
* your particular IParserCallback instance would appreciate
*
* @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid
* expression
*/
public IASTExpression expression(IASTScope scope) throws BacktrackException, EndOfFileException;
/**
* If an error was encountered, give us the offset of the token that caused the error.
*

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.internal.core.parser.SelectionParser;
import org.eclipse.cdt.internal.core.parser.StructuralParseCallback;
import org.eclipse.cdt.internal.core.parser.StructuralParser;
import org.eclipse.cdt.internal.core.parser.ast.complete.CompleteParseASTFactory;
import org.eclipse.cdt.internal.core.parser.ast.expression.ExpressionParseASTFactory;
import org.eclipse.cdt.internal.core.parser.ast.quick.QuickParseASTFactory;
import org.eclipse.cdt.internal.core.parser.scanner.LineOffsetReconciler;
import org.eclipse.cdt.internal.core.parser.scanner.Preprocessor;
@ -41,7 +42,9 @@ public class ParserFactory {
public static IASTFactory createASTFactory( ParserMode mode, ParserLanguage language )
{
if( mode == ParserMode.QUICK_PARSE )
return new QuickParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.QUICK_PARSE ) );
return new QuickParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.QUICK_PARSE ) );
else if( mode == ParserMode.EXPRESSION_PARSE )
return new ExpressionParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.EXPRESSION_PARSE ) );
else
return new CompleteParseASTFactory( language, mode, extensionFactory.createASTExtensionFactory( ParserMode.COMPLETE_PARSE ) );
}

View file

@ -16,14 +16,16 @@ package org.eclipse.cdt.core.parser;
*/
public class ParserMode extends Enum {
// follow inclusions, parse function/method bodies
public static final ParserMode COMPLETE_PARSE = new ParserMode( 1 );
// follow inclusions, do not parse function/method bodies
public static final ParserMode STRUCTURAL_PARSE = new ParserMode( 2 );
public static final ParserMode EXPRESSION_PARSE = new ParserMode( 0 );
// do not follow inclusions, do not parse function/method bodies
public static final ParserMode QUICK_PARSE = new ParserMode( 3 );
public static final ParserMode QUICK_PARSE = new ParserMode( 1 );
//follow inclusions, do not parse function/method bodies
public static final ParserMode STRUCTURAL_PARSE = new ParserMode( 2 );
// follow inclusions, parse function/method bodies
public static final ParserMode COMPLETE_PARSE = new ParserMode( 3 );
// follow inclusions, parse function/method bodies, stop at particular offset
// provide optimized lookup capability for querying symbols

View file

@ -37,8 +37,6 @@ public class CompleteParser extends Parser {
*/
public CompleteParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log) {
super(scanner, callback, language, log);
astFactory = ParserFactory.createASTFactory( ParserMode.COMPLETE_PARSE, language);
scanner.setASTFactory(astFactory);
}
protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException
@ -67,4 +65,12 @@ public class CompleteParser extends Parser {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
*/
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
astFactory = ParserFactory.createASTFactory( ParserMode.COMPLETE_PARSE, language);
scanner.setASTFactory(astFactory);
}
}

View file

@ -29,27 +29,17 @@ import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTNode;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.Token;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
/**
* @author jcamelon
*/
public class CompletionParser extends CompleteParser implements IParser {
public class CompletionParser extends ContextualParser implements IParser {
protected CompletionKind kind;
protected IASTNode context;
protected IToken finalToken;
private Set keywordSet;
protected IASTScope scope;
/**
* @param scanner
* @param callback
@ -58,8 +48,6 @@ public class CompletionParser extends CompleteParser implements IParser {
*/
public CompletionParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log) {
super(scanner, callback, language, log);
astFactory = ParserFactory.createASTFactory( ParserMode.COMPLETION_PARSE, language);
scanner.setASTFactory(astFactory);
}
/* (non-Javadoc)
@ -98,38 +86,6 @@ public class CompletionParser extends CompleteParser implements IParser {
return keywordSet;
}
/**
* @return
*/
protected String getCompletionPrefix() {
return ( finalToken == null ? "" : finalToken.getImage() );
}
/**
* @return
*/
protected IASTNode getCompletionContext() {
return context;
}
/**
* @return
*/
protected IASTCompletionNode.CompletionKind getCompletionKind() {
return kind;
}
protected void setCompletionContext( IASTNode node )
{
this.context = node;
}
protected void setCompletionKind( IASTCompletionNode.CompletionKind kind )
{
this.kind = kind;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#handleOffsetLimitException()
*/
@ -149,91 +105,12 @@ public class CompletionParser extends CompleteParser implements IParser {
throw exception;
}
/**
* @param compilationUnit
* @param kind2
* @param set
* @param object
* @param string
*/
protected void setCompletionValues(CompletionKind kind, Set keywordSet, String prefix ) {
setCompletionScope(compilationUnit);
this.keywordSet = keywordSet;
setCompletionKind(kind);
setCompletionContext(null);
setCompletionToken( new Token( IToken.tIDENTIFIER, prefix ) );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionKeywords(java.lang.String[])
*/
protected void setCompletionKeywords(KeywordSets.Key key) {
this.keywordSet = KeywordSets.getKeywords( key, language );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionToken(org.eclipse.cdt.core.parser.IToken)
*/
protected void setCompletionToken(IToken token) {
finalToken = token;
}
protected IToken getCompletionToken()
{
return finalToken;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionContextForExpression(org.eclipse.cdt.core.parser.ast.IASTExpression, boolean)
*/
protected IASTNode getCompletionContextForExpression(
IASTExpression firstExpression,
boolean isTemplate) {
return astFactory.getCompletionContext( (isTemplate
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION),
firstExpression ) ;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTNode, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key, java.lang.String)
*/
protected void setCompletionValues(
IASTScope scope,
CompletionKind kind,
Key key,
IASTNode node, String prefix) throws EndOfFileException {
setCompletionToken( new Token( IToken.tIDENTIFIER, prefix ) );
setCompletionValues(scope, kind, key, node );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTNode, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key)
*/
protected void setCompletionValues(
IASTScope scope,
CompletionKind kind,
Key key ) throws EndOfFileException {
setCompletionValues(scope, kind, key, null );
}
protected void setCompletionValues(
IASTScope scope,
CompletionKind kind,
Key key,
IASTNode node ) throws EndOfFileException
{
setCompletionScope(scope);
setCompletionKeywords(key);
setCompletionKind(kind);
setCompletionContext(node);
checkEndOfFile();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#getCompletionKindForDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope)
*/
@ -250,18 +127,6 @@ public class CompletionParser extends CompleteParser implements IParser {
return kind;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key, org.eclipse.cdt.core.parser.ast.IASTExpression, boolean)
*/
protected void setCompletionValues(
IASTScope scope,
CompletionKind kind,
Key key,
IASTExpression firstExpression,
boolean isTemplate) throws EndOfFileException {
setCompletionValues(scope,kind,key, getCompletionContextForExpression(firstExpression,isTemplate) );
}
protected void catchHandlerSequence(IASTScope scope)
throws EndOfFileException, BacktrackException {
if( LT(1) != IToken.t_catch )
@ -269,36 +134,34 @@ public class CompletionParser extends CompleteParser implements IParser {
while (LT(1) == IToken.t_catch)
{
consume(IToken.t_catch);
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY);
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY );
consume(IToken.tLPAREN);
setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,Key.DECL_SPECIFIER_SEQUENCE );
setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,Key.DECL_SPECIFIER_SEQUENCE);
if( LT(1) == IToken.tELLIPSIS )
consume( IToken.tELLIPSIS );
else
declaration(scope, null, CompletionKind.EXCEPTION_REFERENCE); // was exceptionDeclaration
simpleDeclarationStrategyUnion( scope, null, CompletionKind.EXCEPTION_REFERENCE); // was exceptionDeclaration
consume(IToken.tRPAREN);
catchBlockCompoundStatement(scope);
}
}
/**
* @return
*/
protected IASTScope getCompletionScope() {
return scope;
}
public IASTNode parse(int startingOffset, int endingOffset) {
throw new ParseError( ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED );
}
protected void setCompletionScope(IASTScope scope) {
this.scope = scope;
}
public boolean parse() {
throw new ParseError( ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
*/
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
astFactory = ParserFactory.createASTFactory( ParserMode.COMPLETION_PARSE, language);
scanner.setASTFactory(astFactory);
}
}

View file

@ -0,0 +1,148 @@
/*******************************************************************************
* Copyright (c) 2000 - 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
import java.util.Set;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IParserLogService;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTNode;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.Token;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
/**
* @author jcamelon
*/
public class ContextualParser extends CompleteParser {
/**
* @param scanner
* @param callback
* @param language
* @param log
*/
public ContextualParser(
IScanner scanner,
ISourceElementRequestor callback,
ParserLanguage language,
IParserLogService log) {
super(scanner, callback, language, log);
}
protected IASTScope scope;
/**
* @return
*/
protected IASTScope getCompletionScope() {
return scope;
}
protected CompletionKind kind;
/**
* @return
*/
protected IASTCompletionNode.CompletionKind getCompletionKind() {
return kind;
}
protected IASTNode context;
protected IToken finalToken;
protected Set keywordSet;
/**
* @return
*/
protected String getCompletionPrefix() {
return ( finalToken == null ? "" : finalToken.getImage() );
}
/**
* @return
*/
protected IASTNode getCompletionContext() {
return context;
}
protected void setCompletionContext(IASTNode node) {
this.context = node;
}
protected void setCompletionKind(IASTCompletionNode.CompletionKind kind) {
this.kind = kind;
}
/**
* @param compilationUnit
* @param kind2
* @param set
* @param object
* @param string
*/
protected void setCompletionValues(CompletionKind kind, Set keywordSet, String prefix) {
setCompletionScope(compilationUnit);
this.keywordSet = keywordSet;
setCompletionKind(kind);
setCompletionContext(null);
setCompletionToken( new Token( IToken.tIDENTIFIER, prefix ) );
}
protected void setCompletionKeywords(KeywordSets.Key key) {
this.keywordSet = KeywordSets.getKeywords( key, language );
}
protected void setCompletionToken(IToken token) {
finalToken = token;
}
protected IASTNode getCompletionContextForExpression(IASTExpression firstExpression, boolean isTemplate) {
return astFactory.getCompletionContext( (isTemplate
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION),
firstExpression ) ;
}
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTNode node, String prefix) throws EndOfFileException {
setCompletionToken( new Token( IToken.tIDENTIFIER, prefix ) );
setCompletionValues(scope, kind, key, node );
}
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException {
setCompletionValues(scope, kind, key, null );
}
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTNode node) throws EndOfFileException {
setCompletionScope(scope);
setCompletionKeywords(key);
setCompletionKind(kind);
setCompletionContext(node);
checkEndOfFile();
}
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, boolean isTemplate) throws EndOfFileException {
setCompletionValues(scope,kind,key, getCompletionContextForExpression(firstExpression,isTemplate) );
}
protected void setCompletionScope(IASTScope scope) {
this.scope = scope;
}
}

View file

@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2000 - 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
import org.eclipse.cdt.core.parser.BacktrackException;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTScope;
/**
* @author jcamelon
*/
public interface IExpressionParser {
/**
* Request a parse from a pre-configured parser to parse an expression.
*
* @param expression Optional parameter representing an expression object that
* your particular IParserCallback instance would appreciate
*
* @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid
* expression
*/
public IASTExpression expression(IASTScope scope) throws BacktrackException, EndOfFileException;
}

View file

@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2000 - 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
import org.eclipse.cdt.core.parser.IParserLogService;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserFactoryError;
import org.eclipse.cdt.core.parser.ParserLanguage;
/**
* @author jcamelon
*/
public class InternalParserFactory extends ParserFactory {
public static IExpressionParser createExpressionParser( IScanner scanner, ParserLanguage language, IParserLogService log ) throws ParserFactoryError
{
if( scanner == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_SCANNER );
if( language == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_LANGUAGE );
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
return new ExpressionParser( scanner, language, logService );
}
}

View file

@ -51,7 +51,7 @@ public class ParserExtensionFactory implements IParserExtensionFactory {
public IASTExtensionFactory createASTExtensionFactory(ParserMode mode) throws ParserFactoryError {
if( dialect == ExtensionDialect.GCC )
{
if( mode == ParserMode.QUICK_PARSE )
if( mode == ParserMode.QUICK_PARSE || mode == ParserMode.EXPRESSION_PARSE )
return new QuickParseASTExtensionFactory();
return new CompleteParseASTExtensionFactory();
}

View file

@ -38,8 +38,6 @@ public class QuickParser extends Parser {
*/
public QuickParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log) {
super(scanner, callback, language, log);
astFactory = ParserFactory.createASTFactory( ParserMode.QUICK_PARSE, language);
scanner.setASTFactory(astFactory);
}
protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException
@ -65,5 +63,15 @@ public class QuickParser extends Parser {
public IASTNode parse(int startingOffset, int endingOffset) throws ParseError {
throw new ParseError( ParseErrorKind.METHOD_NOT_IMPLEMENTED );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
*/
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
astFactory = ParserFactory.createASTFactory( ParserMode.QUICK_PARSE, language);
scanner.setASTFactory(astFactory);
}
}

View file

@ -26,7 +26,7 @@ import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
/**
* @author jcamelon
*/
public class SelectionParser extends CompletionParser {
public class SelectionParser extends ContextualParser {
private OffsetDuple offsetRange;
private IToken firstTokenOfDuple = null, lastTokenOfDuple = null;
@ -34,16 +34,13 @@ public class SelectionParser extends CompletionParser {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#handleNewToken(org.eclipse.cdt.core.parser.IToken)
*/
protected void handleNewToken(IToken value) throws EndOfFileException {
protected void handleNewToken(IToken value) {
if( value != null )
{
if( value.getOffset() == offsetRange.getFloorOffset() )
firstTokenOfDuple = value;
if( value.getEndOffset() == offsetRange.getCeilingOffset() )
{
lastTokenOfDuple = value;
throw new EndOfFileException();
}
}
}
@ -63,7 +60,7 @@ public class SelectionParser extends CompletionParser {
* @see org.eclipse.cdt.core.parser.IParser#parse(int, int)
*/
public IASTNode parse(int startingOffset, int endingOffset) {
scanner.setOffsetBoundary(endingOffset);
// scanner.setOffsetBoundary(endingOffset);
offsetRange = new OffsetDuple( startingOffset, endingOffset );
translationUnit();
return reconcileTokenDuple();
@ -88,5 +85,15 @@ public class SelectionParser extends CompletionParser {
*/
public IASTCompletionNode parse(int offset) {
throw new ParseError( ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#checkEndOfFile()
*/
protected void checkEndOfFile() throws EndOfFileException {
if( lastToken != null && lastToken.getEndOffset() >= offsetRange.getCeilingOffset() )
throw new EndOfFileException();
}
}

View file

@ -4,7 +4,7 @@
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.eclipse.cdt.internal.core.parser.ast.quick;
package org.eclipse.cdt.internal.core.parser.ast.expression;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;

View file

@ -0,0 +1,917 @@
/*******************************************************************************
* Copyright (c) 2000 - 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.expression;
import java.util.List;
import org.eclipse.cdt.core.parser.IMacroDescriptor;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTField;
import org.eclipse.cdt.core.parser.ast.IASTFunction;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTMacro;
import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceAlias;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNode;
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
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.IASTClassSpecifier.ClassNameType;
import org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind;
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
/**
* @author jcamelon
*/
public class ExpressionParseASTFactory implements IASTFactory {
private final IASTExtensionFactory extensionFactory;
/**
* @param factory
*/
public ExpressionParseASTFactory(IASTExtensionFactory factory) {
this.extensionFactory = factory;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createMacro(java.lang.String,
* int, int, int, int, int, int, int,
* org.eclipse.cdt.core.parser.IMacroDescriptor)
*/
public IASTMacro createMacro(
String name,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine,
int endingOffset,
int endingLine,
IMacroDescriptor info) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createInclusion(java.lang.String,
* java.lang.String, boolean, int, int, int, int, int, int, int)
*/
public IASTInclusion createInclusion(
String name,
String fileName,
boolean local,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine,
int endingOffset,
int endingLine) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDirective(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ITokenDuple, int, int, int, int)
*/
public IASTUsingDirective createUsingDirective(
IASTScope scope,
ITokenDuple duple,
int startingOffset,
int startingLine,
int endingOffset,
int endingLine)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope,
* boolean, org.eclipse.cdt.core.parser.ITokenDuple, int, int, int,
* int)
*/
public IASTUsingDeclaration createUsingDeclaration(
IASTScope scope,
boolean isTypeName,
ITokenDuple name,
int startingOffset,
int startingLine,
int endingOffset,
int endingLine)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createASMDefinition(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.lang.String, int, int, int, int)
*/
public IASTASMDefinition createASMDefinition(
IASTScope scope,
String assembly,
int startingOffset,
int startingLine,
int endingOffset,
int endingLine) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.lang.String, int, int, int, int, int)
*/
public IASTNamespaceDefinition createNamespaceDefinition(
IASTScope scope,
String identifier,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLineNumber)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNamespaceAlias(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.lang.String, org.eclipse.cdt.core.parser.ITokenDuple, int,
* int, int, int, int, int, int)
*/
public IASTNamespaceAlias createNamespaceAlias(
IASTScope scope,
String identifier,
ITokenDuple alias,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine,
int endOffset,
int endingLine)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createCompilationUnit()
*/
public IASTCompilationUnit createCompilationUnit() {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.lang.String, int, int)
*/
public IASTLinkageSpecification createLinkageSpecification(
IASTScope scope,
String spec,
int startingOffset,
int startingLine) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ITokenDuple,
* org.eclipse.cdt.core.parser.ast.ASTClassKind,
* org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType,
* org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, int, int,
* int, int)
*/
public IASTClassSpecifier createClassSpecifier(
IASTScope scope,
ITokenDuple name,
ASTClassKind kind,
ClassNameType type,
ASTAccessVisibility access,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier,
* boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility,
* org.eclipse.cdt.core.parser.ITokenDuple)
*/
public void addBaseSpecifier(
IASTClassSpecifier astClassSpec,
boolean isVirtual,
ASTAccessVisibility visibility,
ITokenDuple parentClassName)
throws ASTSemanticException {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createElaboratedTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ast.ASTClassKind,
* org.eclipse.cdt.core.parser.ITokenDuple, int, int, int, int,
* boolean, boolean)
*/
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(
IASTScope scope,
ASTClassKind elaboratedClassKind,
ITokenDuple typeName,
int startingOffset,
int startingLine,
int endOffset,
int endingLine,
boolean isForewardDecl,
boolean isFriend)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.lang.String, int, int, int, int, int)
*/
public IASTEnumerationSpecifier createEnumerationSpecifier(
IASTScope scope,
String name,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier,
* java.lang.String, int, int, int, int, int, int, int,
* org.eclipse.cdt.core.parser.ast.IASTExpression)
*/
public void addEnumerator(
IASTEnumerationSpecifier enumeration,
String string,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine,
int endingOffset,
int endLine,
IASTExpression initialValue)
throws ASTSemanticException {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createExpression(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ast.IASTExpression.Kind,
* org.eclipse.cdt.core.parser.ast.IASTExpression,
* org.eclipse.cdt.core.parser.ast.IASTExpression,
* org.eclipse.cdt.core.parser.ast.IASTExpression,
* org.eclipse.cdt.core.parser.ast.IASTTypeId,
* org.eclipse.cdt.core.parser.ITokenDuple, java.lang.String,
* org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor)
*/
public IASTExpression createExpression(
IASTScope scope,
Kind kind,
IASTExpression lhs,
IASTExpression rhs,
IASTExpression thirdExpression,
IASTTypeId typeId,
ITokenDuple idExpression,
String literal,
IASTNewExpressionDescriptor newDescriptor)
throws ASTSemanticException {
try {
return new ASTExpression(
kind,
lhs,
rhs,
thirdExpression,
typeId,
idExpression == null ? "" : idExpression.toString(),
literal,
newDescriptor,
extensionFactory.createExpressionExtension());
} catch (ASTNotImplementedException e) {
return new ASTExpression(
kind,
lhs,
rhs,
thirdExpression,
typeId,
idExpression == null ? "" : idExpression.toString(),
literal,
newDescriptor,
new IASTExpressionExtension() {
public void setExpression(IASTExpression expression) {
}
public int evaluateExpression()
throws ASTExpressionEvaluationException {
throw new ASTExpressionEvaluationException();
}
});
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNewDescriptor(java.util.List,
* java.util.List, java.util.List)
*/
public IASTNewExpressionDescriptor createNewDescriptor(
List newPlacementExpressions,
List newTypeIdExpressions,
List newInitializerExpressions) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createInitializerClause(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ast.IASTInitializerClause.Kind,
* org.eclipse.cdt.core.parser.ast.IASTExpression, java.util.List,
* java.util.List)
*/
public IASTInitializerClause createInitializerClause(
IASTScope scope,
org.eclipse.cdt.core.parser.ast.IASTInitializerClause.Kind kind,
IASTExpression assignmentExpression,
List initializerClauses,
List designators) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createExceptionSpecification(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.util.List)
*/
public IASTExceptionSpecification createExceptionSpecification(
IASTScope scope,
List typeIds)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createArrayModifier(org.eclipse.cdt.core.parser.ast.IASTExpression)
*/
public IASTArrayModifier createArrayModifier(IASTExpression exp) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createConstructorMemberInitializer(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ITokenDuple,
* org.eclipse.cdt.core.parser.ast.IASTExpression)
*/
public IASTConstructorMemberInitializer createConstructorMemberInitializer(
IASTScope scope,
ITokenDuple duple,
IASTExpression expressionList)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSimpleTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type,
* org.eclipse.cdt.core.parser.ITokenDuple, boolean, boolean, boolean,
* boolean, boolean, boolean, boolean)
*/
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(
IASTScope scope,
Type kind,
ITokenDuple typeName,
boolean isShort,
boolean isLong,
boolean isSigned,
boolean isUnsigned,
boolean isTypename,
boolean isComplex,
boolean isImaginary)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ITokenDuple, java.util.List,
* org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration,
* org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification,
* boolean, boolean, boolean, int, int, int, int, int,
* org.eclipse.cdt.core.parser.ast.IASTTemplate, boolean, boolean,
* boolean, boolean, boolean, java.util.List, boolean, boolean,
* boolean)
*/
public IASTFunction createFunction(
IASTScope scope,
ITokenDuple name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
boolean isInline,
boolean isFriend,
boolean isStatic,
int startOffset,
int startLine,
int nameOffset,
int nameEndOffset,
int nameLine,
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
List constructorChain,
boolean isDefinition,
boolean hasFunctionTryBlock,
boolean hasVariableArguments)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createAbstractDeclaration(boolean,
* boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier,
* java.util.List, java.util.List, java.util.List,
* org.eclipse.cdt.core.parser.ast.ASTPointerOperator)
*/
public IASTAbstractDeclaration createAbstractDeclaration(
boolean isConst,
boolean isVolatile,
IASTTypeSpecifier typeSpecifier,
List pointerOperators,
List arrayModifiers,
List parameters,
ASTPointerOperator pointerOperator) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createMethod(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ITokenDuple, java.util.List,
* org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration,
* org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification,
* boolean, boolean, boolean, int, int, int, int, int,
* org.eclipse.cdt.core.parser.ast.IASTTemplate, boolean, boolean,
* boolean, boolean, boolean,
* org.eclipse.cdt.core.parser.ast.ASTAccessVisibility,
* java.util.List, boolean, boolean, boolean)
*/
public IASTMethod createMethod(
IASTScope scope,
ITokenDuple name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
boolean isInline,
boolean isFriend,
boolean isStatic,
int startOffset,
int startLine,
int nameOffset,
int nameEndOffset,
int nameLine,
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility,
List constructorChain,
boolean isDefinition,
boolean hasFunctionTryBlock,
boolean hasVariableArguments)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createVariable(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.lang.String, boolean,
* org.eclipse.cdt.core.parser.ast.IASTInitializerClause,
* org.eclipse.cdt.core.parser.ast.IASTExpression,
* org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean,
* boolean, boolean, boolean, int, int, int, int, int,
* org.eclipse.cdt.core.parser.ast.IASTExpression)
*/
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 startingLine,
int nameOffset,
int nameEndOffset,
int nameLine,
IASTExpression constructorExpression)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createField(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.lang.String, boolean,
* org.eclipse.cdt.core.parser.ast.IASTInitializerClause,
* org.eclipse.cdt.core.parser.ast.IASTExpression,
* org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean,
* boolean, boolean, boolean, int, int, int, int, int,
* org.eclipse.cdt.core.parser.ast.IASTExpression,
* org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
*/
public IASTField createField(
IASTScope scope,
String name,
boolean isAuto,
IASTInitializerClause initializerClause,
IASTExpression bitfieldExpression,
IASTAbstractDeclaration abstractDeclaration,
boolean isMutable,
boolean isExtern,
boolean isRegister,
boolean isStatic,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine,
IASTExpression constructorExpression,
ASTAccessVisibility visibility)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createDesignator(org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind,
* org.eclipse.cdt.core.parser.ast.IASTExpression,
* org.eclipse.cdt.core.parser.IToken)
*/
public IASTDesignator createDesignator(
DesignatorKind kind,
IASTExpression constantExpression,
IToken fieldIdentifier) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createParameterDeclaration(boolean,
* boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier,
* java.util.List, java.util.List, java.util.List,
* org.eclipse.cdt.core.parser.ast.ASTPointerOperator,
* java.lang.String,
* org.eclipse.cdt.core.parser.ast.IASTInitializerClause, int, int,
* int, int, int, int, int)
*/
public IASTParameterDeclaration createParameterDeclaration(
boolean isConst,
boolean isVolatile,
IASTTypeSpecifier getTypeSpecifier,
List pointerOperators,
List arrayModifiers,
List parameters,
ASTPointerOperator pointerOp,
String parameterName,
IASTInitializerClause initializerClause,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine,
int endingOffset,
int endingLine) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.util.List, boolean, int, int)
*/
public IASTTemplateDeclaration createTemplateDeclaration(
IASTScope scope,
List templateParameters,
boolean exported,
int startingOffset,
int startingLine) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateParameter(org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind,
* java.lang.String, java.lang.String,
* org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration,
* java.util.List)
*/
public IASTTemplateParameter createTemplateParameter(
ParamKind kind,
String identifier,
String defaultValue,
IASTParameterDeclaration parameter,
List parms) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateInstantiation(org.eclipse.cdt.core.parser.ast.IASTScope,
* int, int)
*/
public IASTTemplateInstantiation createTemplateInstantiation(
IASTScope scope,
int startingOffset,
int startingLine) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTScope,
* int, int)
*/
public IASTTemplateSpecialization createTemplateSpecialization(
IASTScope scope,
int startingOffset,
int startingLine) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypedef(org.eclipse.cdt.core.parser.ast.IASTScope,
* java.lang.String,
* org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, int, int,
* int, int, int)
*/
public IASTTypedefDeclaration createTypedef(
IASTScope scope,
String name,
IASTAbstractDeclaration mapping,
int startingOffset,
int startingLine,
int nameOffset,
int nameEndOffset,
int nameLine)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier,
* org.eclipse.cdt.core.parser.ast.IASTTemplate, int, int, int, int)
*/
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration(
IASTScope scope,
IASTTypeSpecifier typeSpecifier,
IASTTemplate template,
int startingOffset,
int startingLine,
int endingOffset,
int endingLine) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#queryIsTypeName(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ITokenDuple)
*/
public boolean queryIsTypeName(
IASTScope scope,
ITokenDuple nameInQuestion) {
// TODO Auto-generated method stub
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNewCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
*/
public IASTCodeScope createNewCodeBlock(IASTScope scope) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypeId(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type,
* boolean, boolean, boolean, boolean, boolean, boolean, boolean,
* org.eclipse.cdt.core.parser.ITokenDuple, java.util.List,
* java.util.List)
*/
public IASTTypeId createTypeId(
IASTScope scope,
Type kind,
boolean isConst,
boolean isVolatile,
boolean isShort,
boolean isLong,
boolean isSigned,
boolean isUnsigned,
boolean isTypename,
ITokenDuple name,
List pointerOps,
List arrayMods)
throws ASTSemanticException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#signalEndOfClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
*/
public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier) {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#getCompletionContext(org.eclipse.cdt.core.parser.ast.IASTExpression.Kind,
* org.eclipse.cdt.core.parser.ast.IASTExpression)
*/
public IASTNode getCompletionContext(
Kind kind,
IASTExpression expression) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#lookupSymbolInContext(org.eclipse.cdt.core.parser.ast.IASTScope,
* org.eclipse.cdt.core.parser.ITokenDuple)
*/
public IASTNode lookupSymbolInContext(IASTScope scope, ITokenDuple duple)
throws ASTNotImplementedException {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -61,6 +61,7 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
import org.eclipse.cdt.internal.core.parser.ast.expression.ASTExpression;
/**
@ -69,6 +70,7 @@ import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
*/
public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory {
private static final boolean CREATE_EXCESS_CONSTRUCTS = true;
private final IASTExtensionFactory extensionFactory;
public QuickParseASTFactory( IASTExtensionFactory extensionFactory )
@ -159,25 +161,31 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createExpression(org.eclipse.cdt.core.parser.ast.IASTExpression.ExpressionKind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, java.lang.String, java.lang.String, java.lang.String)
*/
public IASTExpression createExpression(IASTScope scope, Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) {
try {
return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor, extensionFactory.createExpressionExtension() );
} catch (ASTNotImplementedException e) {
return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor, new IASTExpressionExtension() {
public void setExpression(IASTExpression expression) {
}
public int evaluateExpression() throws ASTExpressionEvaluationException {
throw new ASTExpressionEvaluationException();
} } );
if( CREATE_EXCESS_CONSTRUCTS )
{
try {
return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor, extensionFactory.createExpressionExtension() );
} catch (ASTNotImplementedException e) {
return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor, new IASTExpressionExtension() {
public void setExpression(IASTExpression expression) {
}
public int evaluateExpression() throws ASTExpressionEvaluationException {
throw new ASTExpressionEvaluationException();
} } );
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNewDescriptor()
*/
public IASTNewExpressionDescriptor createNewDescriptor(List newPlacementEpressions, List newTypeIdExpressions, List newInitializerExpressions) {
return new ASTNewDescriptor();
if( CREATE_EXCESS_CONSTRUCTS )
return new ASTNewDescriptor();
return null;
}
/* (non-Javadoc)
@ -193,7 +201,8 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
*/
public IASTConstructorMemberInitializer createConstructorMemberInitializer(IASTScope scope, ITokenDuple duple, IASTExpression expressionList )
{
return new ASTConstructorMemberInitializer( duple.toString(), expressionList );
// return new ASTConstructorMemberInitializer( duple.toString(), expressionList );
return null;
}
/* (non-Javadoc)
@ -233,8 +242,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
*/
public IASTField createField(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression, ASTAccessVisibility visibility)
{
final ASTField field = new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, constructorExpression, visibility);
return field;
return new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, constructorExpression, visibility);
}
/* (non-Javadoc)
@ -336,7 +344,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
public IASTInitializerClause createInitializerClause(IASTScope scope, IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses, List designators)
{
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses, designators );
if( CREATE_EXCESS_CONSTRUCTS )
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses, designators );
return null;
}
/* (non-Javadoc)

View file

@ -498,7 +498,7 @@ public final class TemplateEngine {
List pPtrs = p.getPtrOperators();
if( pPtrs.size() != 0 ){
PtrOp op = (PtrOp) pPtrs.iterator().next();;
PtrOp op = (PtrOp) pPtrs.iterator().next();
if( op.getType() == PtrOp.t_memberPointer ){
TypeInfo info = new TypeInfo( TypeInfo.t_type, 0, aFunction.getContainingSymbol() );
if( !deduceTemplateArgument( map, op.getMemberOf(), info ) ){
@ -657,7 +657,6 @@ public final class TemplateEngine {
Iterator pIter = pList.iterator();
Iterator aIter = arguments.iterator();
ISymbol aSymbol = null;
while( pIter.hasNext() ){
if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), (TypeInfo) aIter.next() ) ){
return null;
@ -887,7 +886,7 @@ public final class TemplateEngine {
* @throws ParserSymbolTableException
*/
static protected ITemplateSymbol selectTemplateOrSpecialization( ITemplateSymbol template, List parameters, List arguments ) throws ParserSymbolTableException {
if( template != null && template instanceof ITemplateSymbol ){
if( template != null ){
//primary definition or specialization?
boolean forPrimary = true;
@ -908,7 +907,7 @@ public final class TemplateEngine {
}
}
ITemplateSymbol primary = (ITemplateSymbol) template;
ITemplateSymbol primary = template;
if( forPrimary ){
//make sure parameters match up with found template
@ -1085,7 +1084,7 @@ public final class TemplateEngine {
ISpecializedSymbol spec = (ISpecializedSymbol) symbol;
instance = spec.deferredInstance( spec.getArgumentList() );
} else {
ITemplateSymbol template = (ITemplateSymbol) symbol;
ITemplateSymbol template = symbol;
Iterator iter = template.getParameterList().iterator();
List args = new LinkedList();
while( iter.hasNext() ){

View file

@ -97,7 +97,7 @@ public class TemplateFactory implements ITemplateFactory {
}
ITemplateSymbol template = (ITemplateSymbol) getTemplatesList().get( getTemplatesList().size() - 1 );
IContainerSymbol container = (IContainerSymbol) template.getTemplatedSymbol();
IContainerSymbol container = template.getTemplatedSymbol();
if( container.isForwardDeclaration() && container.getTypeSymbol() == symbol ){
template.addSymbol( symbol );
@ -113,7 +113,7 @@ public class TemplateFactory implements ITemplateFactory {
Set keys = getPrimaryTemplate().getContainedSymbols().keySet();
IContainerSymbol symbol = (IContainerSymbol) getPrimaryTemplate().getContainedSymbols().get( keys.iterator().next() );
return (ISymbol) symbol.lookupMemberForDefinition( name );
return symbol.lookupMemberForDefinition( name );
}
/* (non-Javadoc)
@ -123,7 +123,7 @@ public class TemplateFactory implements ITemplateFactory {
Set keys = getPrimaryTemplate().getContainedSymbols().keySet();
IContainerSymbol symbol = (IContainerSymbol) getPrimaryTemplate().getContainedSymbols().get( keys.iterator().next() );
return (IParameterizedSymbol) symbol.lookupMethodForDefinition( name, params );
return symbol.lookupMethodForDefinition( name, params );
}
/* (non-Javadoc)

View file

@ -31,7 +31,6 @@ import org.eclipse.cdt.core.parser.BacktrackException;
import org.eclipse.cdt.core.parser.Directives;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IMacroDescriptor;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IParserLogService;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.IScanner;
@ -55,6 +54,8 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
import org.eclipse.cdt.core.parser.extension.IScannerExtension;
import org.eclipse.cdt.internal.core.parser.*;
import org.eclipse.cdt.internal.core.parser.InternalParserFactory;
import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.Token;
@ -2255,12 +2256,12 @@ public class Scanner implements IScanner {
{
if( expression.trim().equals( "0" ) )
return false;
return true;
}
else
{
final NullSourceElementRequestor nullCallback = new NullSourceElementRequestor();
IParser parser = null;
IExpressionParser parser = null;
StringBuffer expressionBuffer = new StringBuffer( expression );
expressionBuffer.append( ';');
try
@ -2270,8 +2271,8 @@ public class Scanner implements IScanner {
new StringReader(expressionBuffer.toString()),
EXPRESSION,
new ScannerInfo( scannerData.getDefinitions(), scannerData.getOriginalConfig().getIncludePaths()),
ParserMode.QUICK_PARSE, scannerData.getLanguage(), nullCallback, nullLogService );
parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, scannerData.getLanguage(), nullLogService);
ParserMode.QUICK_PARSE, scannerData.getLanguage(), new NullSourceElementRequestor(), nullLogService );
parser = InternalParserFactory.createExpressionParser(trial, scannerData.getLanguage(), nullLogService);
} catch( ParserFactoryError pfe )
{
handleInternalError();