1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
Moved KeywordSets.Key to its own class and thus removing the dependency between the Scanner/Parser to the static Keyword Set tables (improves footprint).  <BR>
Updated CompletionEngine to not set the parser timeout if the value entered is <= 0 (to allow for easier debugging and profiling).
This commit is contained in:
John Camelon 2004-06-02 23:14:20 +00:00
parent 37e64d553e
commit fb57293d47
13 changed files with 314 additions and 212 deletions

View file

@ -29,6 +29,8 @@ import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult; import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind; import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
/** /**
* @author jcamelon * @author jcamelon
@ -1146,4 +1148,52 @@ public class CompletionParseTest extends CompletionParseBaseTest {
assertNotNull( result ); assertNotNull( result );
assertEquals( result.getResultsSize(), 3 ); assertEquals( result.getResultsSize(), 3 );
} }
public void testBug52988() throws Exception
{
for( int i = 0; i < 2; ++i )
{
ParserLanguage language = ( i == 0 ) ? ParserLanguage.C : ParserLanguage.CPP;
String code = "void foo() { "; //$NON-NLS-1$
Set kset = KeywordSets.getKeywords( KeywordSetKey.STATEMENT, language );
validateAllKeywordsAndPrefixes( code, kset, language );
}
}
/**
* @param startingCode
* @param keywordsToTry
* @param language
* @throws Exception
*/
private void validateAllKeywordsAndPrefixes(String startingCode, Set keywordsToTry, ParserLanguage language) throws Exception {
Iterator keywordIterator = keywordsToTry.iterator();
while( keywordIterator.hasNext() )
{
String keyword = (String) keywordIterator.next();
for( int i = 0; i < keyword.length(); ++i )
{
String substring = keyword.subSequence( 0, i ).toString();
String totalCode = (startingCode + substring);
IASTCompletionNode node = parse( totalCode, totalCode.length() - 1, language );
assertNotNull( node );
assertTrue( "Failure on keyword=" + keyword + " prefix=" + substring, setContainsKeyword( node.getKeywords(), keyword )); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
/**
* @param keywords
* @param keyword
* @return
*/
private boolean setContainsKeyword(Iterator keywords, String keyword) {
while( keywords.hasNext() )
{
if( keywords.next().equals( keyword )) return true;
}
return false;
}
} }

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.internal.core.parser.DeclarationWrapper; import org.eclipse.cdt.internal.core.parser.DeclarationWrapper;
import org.eclipse.cdt.internal.core.parser.IParserData; import org.eclipse.cdt.internal.core.parser.IParserData;
import org.eclipse.cdt.internal.core.parser.Parser; import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key; import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
/** /**
@ -32,10 +32,10 @@ public interface IParserExtension {
public ASTPointerOperator getPointerOperator( ParserLanguage language, int tokenType ); public ASTPointerOperator getPointerOperator( ParserLanguage language, int tokenType );
public boolean isValidUnaryExpressionStart( int tokenType ); public boolean isValidUnaryExpressionStart( int tokenType );
public IASTExpression parseUnaryExpression( IASTScope scope, IParserData data, CompletionKind kind, Key key ); public IASTExpression parseUnaryExpression( IASTScope scope, IParserData data, CompletionKind kind, KeywordSetKey key );
public boolean isValidRelationalExpressionStart( ParserLanguage language, int tokenType ); public boolean isValidRelationalExpressionStart( ParserLanguage language, int tokenType );
public IASTExpression parseRelationalExpression( IASTScope scope, IParserData data, CompletionKind kind, Key key, IASTExpression lhsExpression ); public IASTExpression parseRelationalExpression( IASTScope scope, IParserData data, CompletionKind kind, KeywordSetKey key, IASTExpression lhsExpression );
/** /**
* @param i * @param i
* @return * @return
@ -55,7 +55,7 @@ public interface IParserExtension {
* @param key TODO * @param key TODO
* @return TODO * @return TODO
*/ */
public IDeclSpecifierExtensionResult parseDeclSpecifierSequence(IParserData parser, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind, Key key ); public IDeclSpecifierExtensionResult parseDeclSpecifierSequence(IParserData parser, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind, KeywordSetKey key );
/** /**
* @param i * @param i
* @return * @return

View file

@ -33,7 +33,7 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.core.parser.extension.IParserExtension; import org.eclipse.cdt.core.parser.extension.IParserExtension;
import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode; import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key; import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
/** /**
* @author jcamelon * @author jcamelon
@ -135,13 +135,13 @@ public class CompletionParser extends ContextualParser implements IParser {
while (LT(1) == IToken.t_catch) while (LT(1) == IToken.t_catch)
{ {
consume(IToken.t_catch); consume(IToken.t_catch);
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY ); setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY );
consume(IToken.tLPAREN); consume(IToken.tLPAREN);
setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,Key.DECL_SPECIFIER_SEQUENCE); setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,KeywordSetKey.DECL_SPECIFIER_SEQUENCE);
if( LT(1) == IToken.tELLIPSIS ) if( LT(1) == IToken.tELLIPSIS )
consume( IToken.tELLIPSIS ); consume( IToken.tELLIPSIS );
else else
simpleDeclarationStrategyUnion( scope, null, CompletionKind.EXCEPTION_REFERENCE, Key.DECLARATION); // was exceptionDeclaration simpleDeclarationStrategyUnion( scope, null, CompletionKind.EXCEPTION_REFERENCE, KeywordSetKey.DECLARATION); // was exceptionDeclaration
consume(IToken.tRPAREN); consume(IToken.tRPAREN);
catchBlockCompoundStatement(scope); catchBlockCompoundStatement(scope);

View file

@ -28,9 +28,9 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.core.parser.extension.IParserExtension; import org.eclipse.cdt.core.parser.extension.IParserExtension;
import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets; import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.TokenFactory; import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
/** /**
* @author jcamelon * @author jcamelon
@ -120,7 +120,7 @@ public class ContextualParser extends CompleteParser {
protected void setCompletionKeywords(KeywordSets.Key key) { protected void setCompletionKeywords(KeywordSetKey key) {
this.keywordSet = KeywordSets.getKeywords( key, language ); this.keywordSet = KeywordSets.getKeywords( key, language );
} }
@ -128,18 +128,18 @@ public class ContextualParser extends CompleteParser {
finalToken = token; finalToken = token;
} }
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTNode node, String prefix) throws EndOfFileException { protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTNode node, String prefix) throws EndOfFileException {
setCompletionToken( TokenFactory.createStandAloneToken( IToken.tIDENTIFIER, prefix ) ); setCompletionToken( TokenFactory.createStandAloneToken( IToken.tIDENTIFIER, prefix ) );
setCompletionValues(scope, kind, key, node ); setCompletionValues(scope, kind, key, node );
} }
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException { protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException {
setCompletionValues(scope, kind, key, null ); setCompletionValues(scope, kind, key, null );
} }
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTNode node) throws EndOfFileException { protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTNode node) throws EndOfFileException {
setCompletionScope(scope); setCompletionScope(scope);
setCompletionKeywords(key); setCompletionKeywords(key);
setCompletionKind(kind); setCompletionKind(kind);
@ -150,7 +150,7 @@ public class ContextualParser extends CompleteParser {
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last, Key key ) throws EndOfFileException{ protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last, KeywordSetKey key ) throws EndOfFileException{
setCompletionScope( scope ); setCompletionScope( scope );
setCompletionKind( kind ); setCompletionKind( kind );
setCompletionKeywords(key); setCompletionKeywords(key);
@ -167,7 +167,7 @@ public class ContextualParser extends CompleteParser {
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, Kind expressionKind) throws EndOfFileException { protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTExpression firstExpression, Kind expressionKind) throws EndOfFileException {
IASTNode node = astFactory.expressionToMostPreciseASTNode( scope, firstExpression ); IASTNode node = astFactory.expressionToMostPreciseASTNode( scope, firstExpression );
if( kind == CompletionKind.MEMBER_REFERENCE ) if( kind == CompletionKind.MEMBER_REFERENCE )
{ {
@ -250,7 +250,7 @@ public class ContextualParser extends CompleteParser {
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCompletionValuesNoContext(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key) * @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCompletionValuesNoContext(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key)
*/ */
protected void setCompletionValuesNoContext(IASTScope scope, protected void setCompletionValuesNoContext(IASTScope scope,
CompletionKind kind, Key key) throws EndOfFileException { CompletionKind kind, KeywordSetKey key) throws EndOfFileException {
setCompletionScope(scope); setCompletionScope(scope);
setCompletionKeywords(key); setCompletionKeywords(key);
setCompletionKind(kind); setCompletionKind(kind);

View file

@ -40,9 +40,8 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.core.parser.extension.IParserExtension; import org.eclipse.cdt.core.parser.extension.IParserExtension;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets; import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
import org.eclipse.cdt.internal.core.parser.token.TokenFactory; import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
import org.eclipse.cdt.internal.core.parser.util.TraceUtil; import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
/** /**
@ -308,7 +307,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
if( ! completedArg ){ if( ! completedArg ){
try{ try{
expression = assignmentExpression( scope, CompletionKind.VARIABLE_TYPE, Key.EXPRESSION ); expression = assignmentExpression( scope, CompletionKind.VARIABLE_TYPE, KeywordSetKey.EXPRESSION );
if( expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY ){ if( expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY ){
throw backtrack; throw backtrack;
} }
@ -320,7 +319,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
} }
if( !completedArg ){ if( !completedArg ){
try{ try{
ITokenDuple nameDuple = name( scope, null, Key.EMPTY ); ITokenDuple nameDuple = name( scope, null, KeywordSetKey.EMPTY );
expression = astFactory.createExpression( scope, IASTExpression.Kind.ID_EXPRESSION, expression = astFactory.createExpression( scope, IASTExpression.Kind.ID_EXPRESSION,
null, null, null, null, nameDuple, EMPTY_STRING, null); null, null, null, null, nameDuple, EMPTY_STRING, null);
list.add( expression ); list.add( expression );
@ -371,7 +370,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @throws BacktrackException request a backtrack * @throws BacktrackException request a backtrack
*/ */
protected IToken templateId(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException { protected IToken templateId(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
ITokenDuple duple = name(scope, kind, Key.EMPTY ); ITokenDuple duple = name(scope, kind, KeywordSetKey.EMPTY );
//IToken last = consumeTemplateParameters(duple.getLastToken()); //IToken last = consumeTemplateParameters(duple.getLastToken());
return duple.getLastToken();//last; return duple.getLastToken();//last;
} }
@ -389,7 +388,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param key TODO * @param key TODO
* @throws BacktrackException request a backtrack * @throws BacktrackException request a backtrack
*/ */
protected ITokenDuple name(IASTScope scope, IASTCompletionNode.CompletionKind kind, Key key ) throws BacktrackException, EndOfFileException { protected ITokenDuple name(IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSetKey key ) throws BacktrackException, EndOfFileException {
TemplateParameterManager argumentList = TemplateParameterManager.getInstance(); TemplateParameterManager argumentList = TemplateParameterManager.getInstance();
@ -406,7 +405,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
if (LT(1) == IToken.tCOLONCOLON){ if (LT(1) == IToken.tCOLONCOLON){
argumentList.addSegment( null ); argumentList.addSegment( null );
last = consume( IToken.tCOLONCOLON ); last = consume( IToken.tCOLONCOLON );
setCompletionValues( scope, kind, Key.EMPTY, getCompliationUnit() ); setCompletionValues( scope, kind, KeywordSetKey.EMPTY, getCompliationUnit() );
startsWithColonColon = true; startsWithColonColon = true;
} }
@ -421,7 +420,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
if( startsWithColonColon ) if( startsWithColonColon )
setCompletionValues( scope, kind, getCompliationUnit() ); setCompletionValues( scope, kind, getCompliationUnit() );
else if( prev != null ) else if( prev != null )
setCompletionValues(scope, kind, first, prev, Key.EMPTY ); setCompletionValues(scope, kind, first, prev, KeywordSetKey.EMPTY );
else else
setCompletionValuesNoContext(scope, kind, key ); setCompletionValuesNoContext(scope, kind, key );
@ -439,7 +438,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
{ {
IToken prev = last; IToken prev = last;
last = consume(IToken.tCOLONCOLON); last = consume(IToken.tCOLONCOLON);
setCompletionValues( scope, kind, first, prev, Key.EMPTY ); setCompletionValues( scope, kind, first, prev, KeywordSetKey.EMPTY );
if (queryLookaheadCapability() && LT(1) == IToken.t_template) if (queryLookaheadCapability() && LT(1) == IToken.t_template)
consume(); consume();
@ -455,7 +454,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
case IToken.tIDENTIFIER : case IToken.tIDENTIFIER :
prev = last; prev = last;
last = consume(); last = consume();
setCompletionValues( scope, kind, first, prev, Key.EMPTY ); setCompletionValues( scope, kind, first, prev, KeywordSetKey.EMPTY );
last = consumeTemplateArguments(scope, last, argumentList, kind); last = consumeTemplateArguments(scope, last, argumentList, kind);
if( last.getType() == IToken.tGT ) if( last.getType() == IToken.tGT )
hasTemplateId = true; hasTemplateId = true;
@ -478,7 +477,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param kind * @param kind
* @param key * @param key
*/ */
protected void setCompletionValuesNoContext(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException { protected void setCompletionValuesNoContext(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException {
} }
/** /**
* @param tokenDuple * @param tokenDuple
@ -514,7 +513,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param key * @param key
* @param node * @param node
*/ */
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTNode node) throws EndOfFileException protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTNode node) throws EndOfFileException
{ {
} }
@ -604,7 +603,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
IASTExpression exp = null; IASTExpression exp = null;
if (LT(1) != IToken.tRBRACKET) if (LT(1) != IToken.tRBRACKET)
{ {
exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION ); exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
} }
consume(IToken.tRBRACKET); consume(IToken.tRBRACKET);
IASTArrayModifier arrayMod; IASTArrayModifier arrayMod;
@ -719,7 +718,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
{ {
try try
{ {
nameDuple = name(d.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EMPTY ); nameDuple = name(d.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EMPTY );
} }
catch( OffsetLimitReachedException olre ) catch( OffsetLimitReachedException olre )
{ {
@ -765,11 +764,11 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression constantExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression constantExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
return conditionalExpression(scope,kind,key); return conditionalExpression(scope,kind,key);
} }
public IASTExpression expression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { public IASTExpression expression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression assignmentExpression = assignmentExpression(scope,kind,key); IASTExpression assignmentExpression = assignmentExpression(scope,kind,key);
while (LT(1) == IToken.tCOMMA) while (LT(1) == IToken.tCOMMA)
{ {
@ -810,8 +809,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression assignmentExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression assignmentExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
setCompletionValues(scope, kind, Key.EXPRESSION ); setCompletionValues(scope, kind, key );
if (LT(1) == IToken.t_throw) { if (LT(1) == IToken.t_throw) {
return throwExpression(scope,key); return throwExpression(scope,key);
} }
@ -885,9 +884,9 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression throwExpression(IASTScope scope, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression throwExpression(IASTScope scope, KeywordSetKey key) throws EndOfFileException, BacktrackException {
consume(IToken.t_throw); consume(IToken.t_throw);
setCompletionValues( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION ); setCompletionValues( scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
IASTExpression throwExpression = null; IASTExpression throwExpression = null;
try try
{ {
@ -922,7 +921,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @return * @return
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression conditionalExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression conditionalExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = logicalOrExpression(scope,kind,key); IASTExpression firstExpression = logicalOrExpression(scope,kind,key);
if (LT(1) == IToken.tQUESTION) if (LT(1) == IToken.tQUESTION)
{ {
@ -957,7 +956,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression logicalOrExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression logicalOrExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = logicalAndExpression(scope,kind,key); IASTExpression firstExpression = logicalAndExpression(scope,kind,key);
while (LT(1) == IToken.tOR) while (LT(1) == IToken.tOR)
{ {
@ -992,7 +991,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression logicalAndExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression logicalAndExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = inclusiveOrExpression( scope,kind,key ); IASTExpression firstExpression = inclusiveOrExpression( scope,kind,key );
while (LT(1) == IToken.tAND) while (LT(1) == IToken.tAND)
{ {
@ -1026,7 +1025,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression inclusiveOrExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression inclusiveOrExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = exclusiveOrExpression(scope,kind,key); IASTExpression firstExpression = exclusiveOrExpression(scope,kind,key);
while (LT(1) == IToken.tBITOR) while (LT(1) == IToken.tBITOR)
{ {
@ -1061,7 +1060,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression exclusiveOrExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression exclusiveOrExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = andExpression( scope,kind, key ); IASTExpression firstExpression = andExpression( scope,kind, key );
while (LT(1) == IToken.tXOR) while (LT(1) == IToken.tXOR)
{ {
@ -1097,7 +1096,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression andExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression andExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
IASTExpression firstExpression = equalityExpression(scope,kind, key); IASTExpression firstExpression = equalityExpression(scope,kind, key);
while (LT(1) == IToken.tAMPER) while (LT(1) == IToken.tAMPER)
{ {
@ -1153,7 +1152,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression equalityExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression equalityExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
IASTExpression firstExpression = relationalExpression(scope,kind,key); IASTExpression firstExpression = relationalExpression(scope,kind,key);
for (;;) for (;;)
{ {
@ -1198,7 +1197,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression relationalExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression relationalExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = shiftExpression(scope,kind, key); IASTExpression firstExpression = shiftExpression(scope,kind, key);
for (;;) for (;;)
{ {
@ -1280,7 +1279,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = additiveExpression(scope,kind,key); IASTExpression firstExpression = additiveExpression(scope,kind,key);
for (;;) for (;;)
{ {
@ -1324,7 +1323,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression additiveExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression additiveExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = multiplicativeExpression( scope, kind, key ); IASTExpression firstExpression = multiplicativeExpression( scope, kind, key );
for (;;) for (;;)
{ {
@ -1368,7 +1367,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression multiplicativeExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression multiplicativeExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = pmExpression(scope,kind,key); IASTExpression firstExpression = pmExpression(scope,kind,key);
for (;;) for (;;)
{ {
@ -1424,7 +1423,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression pmExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression pmExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
IASTExpression firstExpression = castExpression(scope,kind,key); IASTExpression firstExpression = castExpression(scope,kind,key);
for (;;) for (;;)
{ {
@ -1469,7 +1468,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* : unaryExpression * : unaryExpression
* | "(" typeId ")" castExpression * | "(" typeId ")" castExpression
*/ */
protected IASTExpression castExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression castExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
// TO DO: we need proper symbol checkint to ensure type name // TO DO: we need proper symbol checkint to ensure type name
if (LT(1) == IToken.tLPAREN) if (LT(1) == IToken.tLPAREN)
{ {
@ -1552,7 +1551,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
{ {
try try
{ {
name = name(scope, completionKind, Key.DECL_SPECIFIER_SEQUENCE ); name = name(scope, completionKind, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME; kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
break; break;
} }
@ -1599,7 +1598,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
case IToken.tIDENTIFIER : case IToken.tIDENTIFIER :
if( encounteredType ) break simpleMods; if( encounteredType ) break simpleMods;
encounteredType = true; encounteredType = true;
name = name(scope, completionKind, Key.EMPTY ); name = name(scope, completionKind, KeywordSetKey.EMPTY );
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME; kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
break; break;
@ -1683,7 +1682,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
consume(); consume();
try try
{ {
name = name(scope, completionKind, Key.EMPTY ); name = name(scope, completionKind, KeywordSetKey.EMPTY );
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME; kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
} catch( BacktrackException b ) } catch( BacktrackException b )
{ {
@ -1744,7 +1743,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression deleteExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression deleteExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
if (LT(1) == IToken.tCOLONCOLON) if (LT(1) == IToken.tCOLONCOLON)
{ {
// global scope // global scope
@ -1801,8 +1800,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* directnewdeclarator [ constantexpression ] * directnewdeclarator [ constantexpression ]
* newinitializer: ( expressionlist? ) * newinitializer: ( expressionlist? )
*/ */
protected IASTExpression newExpression(IASTScope scope, Key key) throws BacktrackException, EndOfFileException { protected IASTExpression newExpression(IASTScope scope, KeywordSetKey key) throws BacktrackException, EndOfFileException {
setCompletionValues(scope, CompletionKind.NEW_TYPE_REFERENCE, Key.EMPTY); setCompletionValues(scope, CompletionKind.NEW_TYPE_REFERENCE, KeywordSetKey.EMPTY);
if (LT(1) == IToken.tCOLONCOLON) if (LT(1) == IToken.tCOLONCOLON)
{ {
// global scope // global scope
@ -1913,7 +1912,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
// new-expression ends here. // new-expression ends here.
try try
{ {
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, Key.EMPTY); setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.EMPTY);
return astFactory.createExpression( return astFactory.createExpression(
scope, IASTExpression.Kind.NEW_TYPEID, scope, IASTExpression.Kind.NEW_TYPEID,
null, null, null, typeId, null, null, null, null, typeId, null,
@ -1973,7 +1972,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
consume(IToken.tRPAREN); consume(IToken.tRPAREN);
if( templateIdScopes != null ){ templateIdScopes.pop(); } if( templateIdScopes != null ){ templateIdScopes.pop(); }
} }
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, Key.EMPTY); setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.EMPTY);
try try
{ {
return astFactory.createExpression( return astFactory.createExpression(
@ -2002,7 +2001,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
switch (LT(1)) switch (LT(1))
{ {
case IToken.tSTAR : case IToken.tSTAR :
@ -2130,16 +2129,16 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression postfixExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression postfixExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
IASTExpression firstExpression = null; IASTExpression firstExpression = null;
boolean isTemplate = false; boolean isTemplate = false;
setCompletionValues( scope, kind, Key.EXPRESSION ); setCompletionValues( scope, kind, key );
switch (LT(1)) switch (LT(1))
{ {
case IToken.t_typename : case IToken.t_typename :
consume(IToken.t_typename); consume(IToken.t_typename);
ITokenDuple nestedName = name(scope, CompletionKind.TYPE_REFERENCE, Key.EMPTY); ITokenDuple nestedName = name(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.EMPTY);
boolean templateTokenConsumed = false; boolean templateTokenConsumed = false;
if( LT(1) == IToken.t_template ) if( LT(1) == IToken.t_template )
{ {
@ -2440,7 +2439,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS ? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION); : IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION);
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, memberCompletionKind ); setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSetKey.EMPTY, firstExpression, memberCompletionKind );
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE, key); secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE, key);
if( secondExpression != null && secondExpression.getExpressionKind() == Kind.ID_EXPRESSION && secondExpression.getIdExpression().indexOf( '~') != -1 ) if( secondExpression != null && secondExpression.getExpressionKind() == Kind.ID_EXPRESSION && secondExpression.getIdExpression().indexOf( '~') != -1 )
memberCompletionKind = Kind.POSTFIX_DOT_DESTRUCTOR; memberCompletionKind = Kind.POSTFIX_DOT_DESTRUCTOR;
@ -2482,7 +2481,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
? IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP ? IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP
: IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION); : IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION);
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, arrowCompletionKind ); setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSetKey.EMPTY, firstExpression, arrowCompletionKind );
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE, key); secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE, key);
if( secondExpression != null && secondExpression.getExpressionKind() == Kind.ID_EXPRESSION && secondExpression.getIdExpression().indexOf( '~') != -1 ) if( secondExpression != null && secondExpression.getExpressionKind() == Kind.ID_EXPRESSION && secondExpression.getIdExpression().indexOf( '~') != -1 )
@ -2541,7 +2540,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
LA(1); LA(1);
} }
protected IASTExpression simpleTypeConstructorExpression(IASTScope scope, Kind type, Key key ) throws EndOfFileException, BacktrackException { protected IASTExpression simpleTypeConstructorExpression(IASTScope scope, Kind type, KeywordSetKey key ) throws EndOfFileException, BacktrackException {
String typeName = consume().getImage(); String typeName = consume().getImage();
consume(IToken.tLPAREN); consume(IToken.tLPAREN);
setCurrentFunctionName( typeName ); setCurrentFunctionName( typeName );
@ -2574,7 +2573,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
* @param expression * @param expression
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression primaryExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression primaryExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
IToken t = null; IToken t = null;
switch (LT(1)) switch (LT(1))
{ {
@ -2857,7 +2856,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
throw new EndOfFileException(); throw new EndOfFileException();
} }
protected IASTExpression assignmentOperatorExpression(IASTScope scope, IASTExpression.Kind kind, IASTExpression lhs, CompletionKind completionKind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression assignmentOperatorExpression(IASTScope scope, IASTExpression.Kind kind, IASTExpression lhs, CompletionKind completionKind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
consume(); consume();
IASTExpression assignmentExpression = assignmentExpression(scope,completionKind, key); IASTExpression assignmentExpression = assignmentExpression(scope,completionKind, key);
@ -2882,20 +2881,20 @@ public class ExpressionParser implements IExpressionParser, IParserData {
} }
} }
protected void setCompletionValues(IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSets.Key key) throws EndOfFileException { protected void setCompletionValues(IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSetKey key) throws EndOfFileException {
} }
protected void setCompletionValues(IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSets.Key key, IASTNode node, String prefix) throws EndOfFileException { protected void setCompletionValues(IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSetKey key, IASTNode node, String prefix) throws EndOfFileException {
} }
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, Kind expressionKind) throws EndOfFileException { protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTExpression firstExpression, Kind expressionKind) throws EndOfFileException {
} }
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last, Key key ) throws EndOfFileException { protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last, KeywordSetKey key ) throws EndOfFileException {
} }
protected IASTExpression unaryOperatorCastExpression(IASTScope scope, IASTExpression.Kind kind, CompletionKind completionKind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression unaryOperatorCastExpression(IASTScope scope, IASTExpression.Kind kind, CompletionKind completionKind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
IASTExpression castExpression = castExpression(scope,completionKind,key); IASTExpression castExpression = castExpression(scope,completionKind,key);
try try
{ {
@ -2918,7 +2917,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
} }
} }
protected IASTExpression specialCastExpression(IASTScope scope, IASTExpression.Kind kind, Key key) throws EndOfFileException, BacktrackException { protected IASTExpression specialCastExpression(IASTScope scope, IASTExpression.Kind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
consume(); consume();
consume(IToken.tLT); consume(IToken.tLT);
IASTTypeId duple = typeId(scope, false, CompletionKind.TYPE_REFERENCE); IASTTypeId duple = typeId(scope, false, CompletionKind.TYPE_REFERENCE);

View file

@ -32,8 +32,7 @@ import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.extension.IParserExtension; import org.eclipse.cdt.core.parser.extension.IParserExtension;
import org.eclipse.cdt.internal.core.parser.Parser.Flags; import org.eclipse.cdt.internal.core.parser.Parser.Flags;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets; import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
/** /**
@ -78,7 +77,7 @@ public class GCCParserExtension implements IParserExtension {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseUnaryExpression(org.eclipse.cdt.internal.core.parser.IParserData) * @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseUnaryExpression(org.eclipse.cdt.internal.core.parser.IParserData)
*/ */
public IASTExpression parseUnaryExpression(IASTScope scope, IParserData data, IASTCompletionNode.CompletionKind kind, KeywordSets.Key key) { public IASTExpression parseUnaryExpression(IASTScope scope, IParserData data, IASTCompletionNode.CompletionKind kind, KeywordSetKey key) {
try { try {
switch( data.LT(1)) switch( data.LT(1))
{ {
@ -117,7 +116,7 @@ public class GCCParserExtension implements IParserExtension {
* @param type TODO * @param type TODO
* @return * @return
*/ */
protected IASTExpression performUnaryExpression(IParserData data, IASTScope scope, CompletionKind kind, KeywordSets.Key key, UnaryExpressionKind type) { protected IASTExpression performUnaryExpression(IParserData data, IASTScope scope, CompletionKind kind, KeywordSetKey key, UnaryExpressionKind type) {
IToken startingPoint = null; IToken startingPoint = null;
try try
{ {
@ -241,7 +240,7 @@ public class GCCParserExtension implements IParserExtension {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#handleDeclSpecifierSequence(org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.model.Flags, org.eclipse.cdt.internal.core.parser.DeclarationWrapper) * @see org.eclipse.cdt.core.parser.extension.IParserExtension#handleDeclSpecifierSequence(org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.model.Flags, org.eclipse.cdt.internal.core.parser.DeclarationWrapper)
*/ */
public IDeclSpecifierExtensionResult parseDeclSpecifierSequence(IParserData data, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind, Key key) { public IDeclSpecifierExtensionResult parseDeclSpecifierSequence(IParserData data, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind, KeywordSetKey key) {
IToken startingPoint = null; IToken startingPoint = null;
try try
{ {
@ -336,7 +335,7 @@ public class GCCParserExtension implements IParserExtension {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseRelationalExpression(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind) * @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseRelationalExpression(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind)
*/ */
public IASTExpression parseRelationalExpression(IASTScope scope, IParserData data, CompletionKind kind, KeywordSets.Key key, IASTExpression lhsExpression) { public IASTExpression parseRelationalExpression(IASTScope scope, IParserData data, CompletionKind kind, KeywordSetKey key, IASTExpression lhsExpression) {
if( data.getParserLanguage() == ParserLanguage.C ) return null; if( data.getParserLanguage() == ParserLanguage.C ) return null;
IToken mark = null; IToken mark = null;
try { try {
@ -429,9 +428,9 @@ public class GCCParserExtension implements IParserExtension {
if( parserData.LT(1) == IToken.tLBRACKET ) if( parserData.LT(1) == IToken.tLBRACKET )
{ {
parserData.consume( IToken.tLBRACKET ); parserData.consume( IToken.tLBRACKET );
IASTExpression constantExpression1 = parserData.expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION ); IASTExpression constantExpression1 = parserData.expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
parserData.consume( IToken.tELLIPSIS ); parserData.consume( IToken.tELLIPSIS );
IASTExpression constantExpression2 = parserData.expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION ); IASTExpression constantExpression2 = parserData.expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
parserData.consume(IToken.tRBRACKET ); parserData.consume(IToken.tRBRACKET );
Map extensionParms = new Hashtable(); Map extensionParms = new Hashtable();
extensionParms.put( IASTGCCDesignator.SECOND_EXRESSION, constantExpression2 ); extensionParms.put( IASTGCCDesignator.SECOND_EXRESSION, constantExpression2 );

View file

@ -16,7 +16,7 @@ import org.eclipse.cdt.core.parser.IFilenameProvider;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key; import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
/** /**
* @author jcamelon * @author jcamelon
@ -32,6 +32,6 @@ public interface IExpressionParser extends IFilenameProvider {
* @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid * @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid
* expression * expression
*/ */
public IASTExpression expression(IASTScope scope, IASTCompletionNode.CompletionKind kind, Key key) throws BacktrackException, EndOfFileException; public IASTExpression expression(IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException;
} }

View file

@ -18,8 +18,7 @@ import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTypeId; import org.eclipse.cdt.core.parser.ast.IASTTypeId;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; 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.KeywordSetKey;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
/** /**
* @author jcamelon * @author jcamelon
* *
@ -97,7 +96,7 @@ public interface IParserData extends IExpressionParser {
* @param key TODO * @param key TODO
* @return * @return
*/ */
public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind, KeywordSets.Key key) throws EndOfFileException, BacktrackException; public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException;
/** /**
* @return * @return
*/ */
@ -112,7 +111,7 @@ public interface IParserData extends IExpressionParser {
* @param key TODO * @param key TODO
* @return * @return
*/ */
public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException; public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws BacktrackException, EndOfFileException;
public IToken identifier() throws EndOfFileException, BacktrackException; public IToken identifier() throws EndOfFileException, BacktrackException;
} }

View file

@ -59,9 +59,8 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.core.parser.extension.IParserExtension; import org.eclipse.cdt.core.parser.extension.IParserExtension;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets; import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
import org.eclipse.cdt.internal.core.parser.token.TokenFactory; import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
/** /**
* This is our first implementation of the IParser interface, serving as a parser for * This is our first implementation of the IParser interface, serving as a parser for
@ -134,7 +133,7 @@ public abstract class Parser extends ExpressionParser implements IParser
compilationUnit.enterScope( requestor, astFactory.getReferenceManager() ); compilationUnit.enterScope( requestor, astFactory.getReferenceManager() );
try { try {
setCompletionValues(compilationUnit, CompletionKind.VARIABLE_TYPE, Key.DECLARATION ); setCompletionValues(compilationUnit, CompletionKind.VARIABLE_TYPE, KeywordSetKey.DECLARATION );
} catch (EndOfFileException e1) { } catch (EndOfFileException e1) {
compilationUnit.exitScope( requestor, astFactory.getReferenceManager() ); compilationUnit.exitScope( requestor, astFactory.getReferenceManager() );
return; return;
@ -147,7 +146,7 @@ public abstract class Parser extends ExpressionParser implements IParser
try try
{ {
int checkOffset = LA(1).hashCode(); int checkOffset = LA(1).hashCode();
declaration(compilationUnit, null, null); declaration(compilationUnit, null, null, KeywordSetKey.DECLARATION);
if (LA(1).hashCode() == checkOffset) if (LA(1).hashCode() == checkOffset)
errorHandling(); errorHandling();
} }
@ -235,18 +234,18 @@ public abstract class Parser extends ExpressionParser implements IParser
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
IToken firstToken = consume(IToken.t_using); IToken firstToken = consume(IToken.t_using);
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.POST_USING ); setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.POST_USING );
if (LT(1) == IToken.t_namespace) if (LT(1) == IToken.t_namespace)
{ {
// using-directive // using-directive
consume(IToken.t_namespace); consume(IToken.t_namespace);
setCompletionValues(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY ); setCompletionValues(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY );
// optional :: and nested classes handled in name // optional :: and nested classes handled in name
ITokenDuple duple = null; ITokenDuple duple = null;
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY); duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY);
else else
throw backtrack; throw backtrack;
if (LT(1) == IToken.tSEMI) if (LT(1) == IToken.tSEMI)
@ -269,7 +268,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack; throw backtrack;
} }
boolean typeName = false; boolean typeName = false;
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.POST_USING ); setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.POST_USING );
if (LT(1) == IToken.t_typename) if (LT(1) == IToken.t_typename)
{ {
@ -277,12 +276,12 @@ public abstract class Parser extends ExpressionParser implements IParser
consume(IToken.t_typename); consume(IToken.t_typename);
} }
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.NAMESPACE_ONLY ); setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.NAMESPACE_ONLY );
ITokenDuple name = null; ITokenDuple name = null;
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
{ {
// optional :: and nested classes handled in name // optional :: and nested classes handled in name
name = name(scope, CompletionKind.TYPE_REFERENCE, Key.EMPTY); name = name(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.POST_USING);
} }
else else
{ {
@ -308,7 +307,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack; throw backtrack;
} }
declaration.acceptElement( requestor, astFactory.getReferenceManager() ); declaration.acceptElement( requestor, astFactory.getReferenceManager() );
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), Key.DECLARATION ); setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), KeywordSetKey.DECLARATION );
return declaration; return declaration;
} }
throw backtrack; throw backtrack;
@ -363,7 +362,7 @@ public abstract class Parser extends ExpressionParser implements IParser
default : default :
try try
{ {
declaration(linkage, null, null); declaration(linkage, null, null, KeywordSetKey.DECLARATION);
} }
catch (BacktrackException bt) catch (BacktrackException bt)
{ {
@ -398,7 +397,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack; throw backtrack;
} }
linkage.enterScope( requestor, astFactory.getReferenceManager() ); linkage.enterScope( requestor, astFactory.getReferenceManager() );
declaration(linkage, null, null); declaration(linkage, null, null, KeywordSetKey.DECLARATION);
linkage.exitScope( requestor, astFactory.getReferenceManager() ); linkage.exitScope( requestor, astFactory.getReferenceManager() );
return linkage; return linkage;
@ -448,7 +447,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack; throw backtrack;
} }
templateInstantiation.enterScope( requestor, astFactory.getReferenceManager() ); templateInstantiation.enterScope( requestor, astFactory.getReferenceManager() );
declaration(templateInstantiation, templateInstantiation, null); declaration(templateInstantiation, templateInstantiation, null, KeywordSetKey.DECLARATION);
templateInstantiation.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber()); templateInstantiation.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber());
templateInstantiation.exitScope( requestor, astFactory.getReferenceManager() ); templateInstantiation.exitScope( requestor, astFactory.getReferenceManager() );
@ -475,7 +474,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack; throw backtrack;
} }
templateSpecialization.enterScope(requestor, astFactory.getReferenceManager()); templateSpecialization.enterScope(requestor, astFactory.getReferenceManager());
declaration(templateSpecialization, templateSpecialization, null); declaration(templateSpecialization, templateSpecialization, null, KeywordSetKey.DECLARATION);
templateSpecialization.setEndingOffsetAndLineNumber( templateSpecialization.setEndingOffsetAndLineNumber(
lastToken.getEndOffset(), lastToken.getLineNumber()); lastToken.getEndOffset(), lastToken.getLineNumber());
templateSpecialization.exitScope(requestor, astFactory.getReferenceManager()); templateSpecialization.exitScope(requestor, astFactory.getReferenceManager());
@ -504,7 +503,7 @@ public abstract class Parser extends ExpressionParser implements IParser
} }
templateDecl.enterScope( requestor, astFactory.getReferenceManager() ); templateDecl.enterScope( requestor, astFactory.getReferenceManager() );
try{ try{
declaration(templateDecl, templateDecl, null ); declaration(templateDecl, templateDecl, null, KeywordSetKey.DECLARATION );
} catch( EndOfFileException e ){ } catch( EndOfFileException e ){
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() ); templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
templateDecl.exitScope( requestor, astFactory.getReferenceManager() ); templateDecl.exitScope( requestor, astFactory.getReferenceManager() );
@ -717,24 +716,25 @@ public abstract class Parser extends ExpressionParser implements IParser
* - usingDirective into usingDeclaration * - usingDirective into usingDeclaration
* - explicitInstantiation and explicitSpecialization into * - explicitInstantiation and explicitSpecialization into
* templateDeclaration * templateDeclaration
* * @param overideKey TODO
* @param container IParserCallback object which serves as the owner scope for this declaration. * @param container IParserCallback object which serves as the owner scope for this declaration.
*
* @throws BacktrackException request a backtrack * @throws BacktrackException request a backtrack
*/ */
protected void declaration( protected void declaration(
IASTScope scope, IASTScope scope,
IASTTemplate ownerTemplate, CompletionKind overideKind) IASTTemplate ownerTemplate, CompletionKind overideKind, KeywordSetKey overideKey)
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, overideKind); IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, overideKind);
setCompletionValues(scope, kind, Key.DECLARATION ); setCompletionValues(scope, kind, overideKey);
IASTDeclaration resultDeclaration = null; IASTDeclaration resultDeclaration = null;
switch (LT(1)) switch (LT(1))
{ {
case IToken.t_asm : case IToken.t_asm :
IToken first = consume(IToken.t_asm); IToken first = consume(IToken.t_asm);
setCompletionValues( scope, CompletionKind.NO_SUCH_KIND, Key.EMPTY ); setCompletionValues( scope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.EMPTY );
consume(IToken.tLPAREN); consume(IToken.tLPAREN);
String assembly = consume(IToken.tSTRING).getImage(); String assembly = consume(IToken.tSTRING).getImage();
consume(IToken.tRPAREN); consume(IToken.tRPAREN);
@ -757,7 +757,7 @@ public abstract class Parser extends ExpressionParser implements IParser
// if we made it this far, then we have all we need // if we made it this far, then we have all we need
// do the callback // do the callback
resultDeclaration.acceptElement(requestor, astFactory.getReferenceManager()); resultDeclaration.acceptElement(requestor, astFactory.getReferenceManager());
setCompletionValues(scope, kind, Key.DECLARATION ); setCompletionValues(scope, kind, KeywordSetKey.DECLARATION );
break; break;
case IToken.t_namespace : case IToken.t_namespace :
resultDeclaration = namespaceDefinition(scope); resultDeclaration = namespaceDefinition(scope);
@ -776,9 +776,9 @@ public abstract class Parser extends ExpressionParser implements IParser
break; break;
} }
default : default :
resultDeclaration = simpleDeclarationStrategyUnion(scope, ownerTemplate, overideKind, Key.DECLARATION ); resultDeclaration = simpleDeclarationStrategyUnion(scope, ownerTemplate, overideKind, overideKey);
} }
setCompletionValues(scope, kind, Key.DECLARATION ); setCompletionValues(scope, kind, KeywordSetKey.DECLARATION );
endDeclaration( resultDeclaration ); endDeclaration( resultDeclaration );
} }
@ -792,7 +792,7 @@ public abstract class Parser extends ExpressionParser implements IParser
protected IASTDeclaration simpleDeclarationStrategyUnion( protected IASTDeclaration simpleDeclarationStrategyUnion(
IASTScope scope, IASTScope scope,
IASTTemplate ownerTemplate, CompletionKind overrideKind, Key overrideKey) IASTTemplate ownerTemplate, CompletionKind overrideKind, KeywordSetKey overrideKey)
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
simpleDeclarationMark = mark(); simpleDeclarationMark = mark();
@ -859,7 +859,7 @@ public abstract class Parser extends ExpressionParser implements IParser
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, null); IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, null);
setCompletionValues(scope,CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY ); setCompletionValues(scope,CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY );
IToken identifier = null; IToken identifier = null;
// optional name // optional name
if (LT(1) == IToken.tIDENTIFIER) if (LT(1) == IToken.tIDENTIFIER)
@ -887,7 +887,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack; throw backtrack;
} }
namespaceDefinition.enterScope( requestor, astFactory.getReferenceManager() ); namespaceDefinition.enterScope( requestor, astFactory.getReferenceManager() );
setCompletionValues(scope,CompletionKind.VARIABLE_TYPE, Key.DECLARATION ); setCompletionValues(scope,CompletionKind.VARIABLE_TYPE, KeywordSetKey.DECLARATION );
namespaceDeclarationLoop : while (LT(1) != IToken.tRBRACE) namespaceDeclarationLoop : while (LT(1) != IToken.tRBRACE)
{ {
int checkToken = LA(1).hashCode(); int checkToken = LA(1).hashCode();
@ -899,7 +899,7 @@ public abstract class Parser extends ExpressionParser implements IParser
default : default :
try try
{ {
declaration(namespaceDefinition, null, null); declaration(namespaceDefinition, null, null, KeywordSetKey.DECLARATION);
} }
catch (BacktrackException bt) catch (BacktrackException bt)
{ {
@ -911,27 +911,27 @@ public abstract class Parser extends ExpressionParser implements IParser
if (checkToken == LA(1).hashCode()) if (checkToken == LA(1).hashCode())
errorHandling(); errorHandling();
} }
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,Key.EMPTY ); setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY );
// consume the } // consume the }
IToken last = consume(IToken.tRBRACE); IToken last = consume(IToken.tRBRACE);
namespaceDefinition.setEndingOffsetAndLineNumber( namespaceDefinition.setEndingOffsetAndLineNumber(
last.getOffset() + last.getLength(), last.getLineNumber()); last.getOffset() + last.getLength(), last.getLineNumber());
setCompletionValues(scope, kind, Key.DECLARATION ); setCompletionValues(scope, kind, KeywordSetKey.DECLARATION );
namespaceDefinition.exitScope( requestor, astFactory.getReferenceManager() ); namespaceDefinition.exitScope( requestor, astFactory.getReferenceManager() );
return namespaceDefinition; return namespaceDefinition;
} }
else if( LT(1) == IToken.tASSIGN ) else if( LT(1) == IToken.tASSIGN )
{ {
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,Key.EMPTY); setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY);
consume( IToken.tASSIGN ); consume( IToken.tASSIGN );
if( identifier == null ) if( identifier == null )
throw backtrack; throw backtrack;
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY); ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY);
consume( IToken.tSEMI ); consume( IToken.tSEMI );
setCompletionValues(scope, kind, Key.DECLARATION ); setCompletionValues(scope, kind, KeywordSetKey.DECLARATION );
IASTNamespaceAlias alias = null; IASTNamespaceAlias alias = null;
try try
{ {
@ -972,7 +972,7 @@ public abstract class Parser extends ExpressionParser implements IParser
protected IASTDeclaration simpleDeclaration( protected IASTDeclaration simpleDeclaration(
SimpleDeclarationStrategy strategy, SimpleDeclarationStrategy strategy,
IASTScope scope, IASTScope scope,
IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler, Key overrideKey) IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler, KeywordSetKey overrideKey)
throws BacktrackException, EndOfFileException throws BacktrackException, EndOfFileException
{ {
IToken firstToken = LA(1); IToken firstToken = LA(1);
@ -982,7 +982,7 @@ public abstract class Parser extends ExpressionParser implements IParser
firstToken = null; // necessary for scalability firstToken = null; // necessary for scalability
CompletionKind completionKindForDeclaration = getCompletionKindForDeclaration(scope, overideKind); CompletionKind completionKindForDeclaration = getCompletionKindForDeclaration(scope, overideKind);
setCompletionValues( scope, completionKindForDeclaration, Key.DECL_SPECIFIER_SEQUENCE ); setCompletionValues( scope, completionKindForDeclaration, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, completionKindForDeclaration, overrideKey ); declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, completionKindForDeclaration, overrideKey );
IASTSimpleTypeSpecifier simpleTypeSpecifier = null; IASTSimpleTypeSpecifier simpleTypeSpecifier = null;
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED ) if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED )
@ -1209,12 +1209,12 @@ public abstract class Parser extends ExpressionParser implements IParser
break; break;
ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EMPTY ); ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EMPTY );
consume(IToken.tLPAREN); consume(IToken.tLPAREN);
IASTExpression expressionList = null; IASTExpression expressionList = null;
expressionList = expression(d.getDeclarationWrapper().getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION); expressionList = expression(d.getDeclarationWrapper().getScope(), CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
consume(IToken.tRPAREN); consume(IToken.tRPAREN);
@ -1259,7 +1259,7 @@ public abstract class Parser extends ExpressionParser implements IParser
DeclarationWrapper sdw = DeclarationWrapper sdw =
new DeclarationWrapper(scope, current.getOffset(), current.getLineNumber(), null); new DeclarationWrapper(scope, current.getOffset(), current.getLineNumber(), null);
declSpecifierSeq(sdw, true, false, CompletionKind.ARGUMENT_TYPE, Key.DECL_SPECIFIER_SEQUENCE ); declSpecifierSeq(sdw, true, false, CompletionKind.ARGUMENT_TYPE, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
if (sdw.getTypeSpecifier() == null if (sdw.getTypeSpecifier() == null
&& sdw.getSimpleType() && sdw.getSimpleType()
!= IASTSimpleTypeSpecifier.Type.UNSPECIFIED) != IASTSimpleTypeSpecifier.Type.UNSPECIFIED)
@ -1289,7 +1289,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack; throw backtrack;
} }
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY ); setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY );
if (LT(1) != IToken.tSEMI) if (LT(1) != IToken.tSEMI)
initDeclarator(sdw, SimpleDeclarationStrategy.TRY_FUNCTION, CompletionKind.VARIABLE_TYPE, constructInitializersInParameters ); initDeclarator(sdw, SimpleDeclarationStrategy.TRY_FUNCTION, CompletionKind.VARIABLE_TYPE, constructInitializersInParameters );
@ -1482,7 +1482,7 @@ public abstract class Parser extends ExpressionParser implements IParser
protected void declSpecifierSeq( protected void declSpecifierSeq(
DeclarationWrapper sdw, DeclarationWrapper sdw,
boolean parm, boolean parm,
boolean tryConstructor, CompletionKind kind, Key key ) boolean tryConstructor, CompletionKind kind, KeywordSetKey key )
throws BacktrackException, EndOfFileException throws BacktrackException, EndOfFileException
{ {
Flags flags = new Flags(parm, tryConstructor); Flags flags = new Flags(parm, tryConstructor);
@ -1661,7 +1661,7 @@ public abstract class Parser extends ExpressionParser implements IParser
consume(IToken.t_typename ); consume(IToken.t_typename );
IToken first = LA(1); IToken first = LA(1);
IToken last = null; IToken last = null;
last = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE, Key.EMPTY).getLastToken(); last = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE, KeywordSetKey.EMPTY).getLastToken();
if (LT(1) == IToken.t_template) if (LT(1) == IToken.t_template)
{ {
consume(IToken.t_template); consume(IToken.t_template);
@ -1806,7 +1806,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack; throw backtrack;
} }
ITokenDuple d = name(sdw.getScope(), completionKind, Key.EMPTY); ITokenDuple d = name(sdw.getScope(), completionKind, KeywordSetKey.EMPTY);
IASTTypeSpecifier elaboratedTypeSpec = null; IASTTypeSpecifier elaboratedTypeSpec = null;
final boolean isForewardDecl = ( LT(1) == IToken.tSEMI ); final boolean isForewardDecl = ( LT(1) == IToken.tSEMI );
@ -1872,24 +1872,24 @@ public abstract class Parser extends ExpressionParser implements IParser
{ {
// handle initializer // handle initializer
final IASTScope scope = d.getDeclarationWrapper().getScope(); final IASTScope scope = d.getDeclarationWrapper().getScope();
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY); setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY);
if (LT(1) == IToken.tASSIGN) if (LT(1) == IToken.tASSIGN)
{ {
consume(IToken.tASSIGN); consume(IToken.tASSIGN);
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY); setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY);
throwAwayMarksForInitializerClause(d); throwAwayMarksForInitializerClause(d);
IASTInitializerClause clause = initializerClause(scope,constructInitializers); IASTInitializerClause clause = initializerClause(scope,constructInitializers);
d.setInitializerClause(clause); d.setInitializerClause(clause);
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY); setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY);
} }
else if (LT(1) == IToken.tLPAREN ) else if (LT(1) == IToken.tLPAREN )
{ {
// initializer in constructor // initializer in constructor
consume(IToken.tLPAREN); // EAT IT! consume(IToken.tLPAREN); // EAT IT!
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY); setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY);
IASTExpression astExpression = null; IASTExpression astExpression = null;
astExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION); astExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY); setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY);
consume(IToken.tRPAREN); consume(IToken.tRPAREN);
d.setConstructorExpression(astExpression); d.setConstructorExpression(astExpression);
} }
@ -1910,14 +1910,14 @@ public abstract class Parser extends ExpressionParser implements IParser
protected void optionalCInitializer( Declarator d, boolean constructInitializers ) throws EndOfFileException, BacktrackException protected void optionalCInitializer( Declarator d, boolean constructInitializers ) throws EndOfFileException, BacktrackException
{ {
final IASTScope scope = d.getDeclarationWrapper().getScope(); final IASTScope scope = d.getDeclarationWrapper().getScope();
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY); setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY);
if( LT(1) == IToken.tASSIGN ) if( LT(1) == IToken.tASSIGN )
{ {
consume( IToken.tASSIGN ); consume( IToken.tASSIGN );
throwAwayMarksForInitializerClause(d); throwAwayMarksForInitializerClause(d);
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY); setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY);
d.setInitializerClause( cInitializerClause(scope, Collections.EMPTY_LIST, constructInitializers ) ); d.setInitializerClause( cInitializerClause(scope, Collections.EMPTY_LIST, constructInitializers ) );
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY); setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY);
} }
} }
/** /**
@ -1973,7 +1973,7 @@ public abstract class Parser extends ExpressionParser implements IParser
// assignmentExpression // assignmentExpression
try try
{ {
IASTExpression assignmentExpression = assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION); IASTExpression assignmentExpression = assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
try try
{ {
return createInitializerClause( return createInitializerClause(
@ -2058,7 +2058,7 @@ public abstract class Parser extends ExpressionParser implements IParser
try try
{ {
IASTExpression assignmentExpression = IASTExpression assignmentExpression =
assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION); assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
try try
{ {
@ -2118,7 +2118,7 @@ public abstract class Parser extends ExpressionParser implements IParser
else if( LT(1) == IToken.tLBRACKET ) else if( LT(1) == IToken.tLBRACKET )
{ {
IToken mark = consume( IToken.tLBRACKET ); IToken mark = consume( IToken.tLBRACKET );
constantExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION ); constantExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
if( LT(1) != IToken.tRBRACKET ) if( LT(1) != IToken.tRBRACKET )
{ {
backup( mark ); backup( mark );
@ -2223,7 +2223,7 @@ public abstract class Parser extends ExpressionParser implements IParser
{ {
try try
{ {
queryName = name(parameterScope, CompletionKind.TYPE_REFERENCE, Key.EMPTY ); queryName = name(parameterScope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.EMPTY );
if( ! astFactory.queryIsTypeName( parameterScope, queryName ) ) if( ! astFactory.queryIsTypeName( parameterScope, queryName ) )
failed = true; failed = true;
} }
@ -2248,7 +2248,7 @@ public abstract class Parser extends ExpressionParser implements IParser
d.setIsFunction(true); d.setIsFunction(true);
// TODO need to create a temporary scope object here // TODO need to create a temporary scope object here
consume(IToken.tLPAREN); consume(IToken.tLPAREN);
setCompletionValues( scope, CompletionKind.ARGUMENT_TYPE, Key.DECL_SPECIFIER_SEQUENCE ); setCompletionValues( scope, CompletionKind.ARGUMENT_TYPE, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
boolean seenParameter = false; boolean seenParameter = false;
parameterDeclarationLoop : for (;;) parameterDeclarationLoop : for (;;)
{ {
@ -2256,7 +2256,7 @@ public abstract class Parser extends ExpressionParser implements IParser
{ {
case IToken.tRPAREN : case IToken.tRPAREN :
consume(); consume();
setCompletionValues( parameterScope, CompletionKind.NO_SUCH_KIND, KeywordSets.Key.FUNCTION_MODIFIER ); setCompletionValues( parameterScope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.FUNCTION_MODIFIER );
break parameterDeclarationLoop; break parameterDeclarationLoop;
case IToken.tELLIPSIS : case IToken.tELLIPSIS :
consume(); consume();
@ -2264,7 +2264,7 @@ public abstract class Parser extends ExpressionParser implements IParser
break; break;
case IToken.tCOMMA : case IToken.tCOMMA :
consume(); consume();
setCompletionValues( parameterScope, CompletionKind.ARGUMENT_TYPE, Key.DECL_SPECIFIER_SEQUENCE ); setCompletionValues( parameterScope, CompletionKind.ARGUMENT_TYPE, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
seenParameter = false; seenParameter = false;
break; break;
default : default :
@ -2381,7 +2381,7 @@ public abstract class Parser extends ExpressionParser implements IParser
continue; continue;
case IToken.tCOLON : case IToken.tCOLON :
consume(IToken.tCOLON); consume(IToken.tCOLON);
IASTExpression exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION ); IASTExpression exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
d.setBitFieldExpression(exp); d.setBitFieldExpression(exp);
default : default :
break; break;
@ -2410,7 +2410,7 @@ public abstract class Parser extends ExpressionParser implements IParser
{ {
try try
{ {
ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), kind, Key.EMPTY ); ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), kind, KeywordSetKey.EMPTY );
d.setName(duple); d.setName(duple);
} }
@ -2531,7 +2531,7 @@ public abstract class Parser extends ExpressionParser implements IParser
if (LT(1) == IToken.tASSIGN) if (LT(1) == IToken.tASSIGN)
{ {
consume(IToken.tASSIGN); consume(IToken.tASSIGN);
initialValue = constantExpression(sdw.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION); initialValue = constantExpression(sdw.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
} }
IASTEnumerator enumerator = null; IASTEnumerator enumerator = null;
if (LT(1) == IToken.tRBRACE) if (LT(1) == IToken.tRBRACE)
@ -2643,10 +2643,10 @@ public abstract class Parser extends ExpressionParser implements IParser
ITokenDuple duple = null; ITokenDuple duple = null;
setCompletionValues(sdw.getScope(), completionKind, Key.EMPTY ); setCompletionValues(sdw.getScope(), completionKind, KeywordSetKey.EMPTY );
// class name // class name
if (LT(1) == IToken.tIDENTIFIER) if (LT(1) == IToken.tIDENTIFIER)
duple = name( sdw.getScope(), completionKind, Key.EMPTY ); duple = name( sdw.getScope(), completionKind, KeywordSetKey.EMPTY );
if (duple != null && !duple.isIdentifier()) if (duple != null && !duple.isIdentifier())
nameType = ClassNameType.TEMPLATE; nameType = ClassNameType.TEMPLATE;
if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE)
@ -2690,7 +2690,7 @@ public abstract class Parser extends ExpressionParser implements IParser
if (LT(1) == IToken.tLBRACE) if (LT(1) == IToken.tLBRACE)
{ {
consume(IToken.tLBRACE); consume(IToken.tLBRACE);
setCompletionValues(astClassSpecifier, CompletionKind.FIELD_TYPE, Key.DECLARATION ); setCompletionValues(astClassSpecifier, CompletionKind.FIELD_TYPE, KeywordSetKey.MEMBER );
astClassSpecifier.enterScope( requestor, astFactory.getReferenceManager() ); astClassSpecifier.enterScope( requestor, astFactory.getReferenceManager() );
handleClassSpecifier( astClassSpecifier ); handleClassSpecifier( astClassSpecifier );
memberDeclarationLoop : while (LT(1) != IToken.tRBRACE) memberDeclarationLoop : while (LT(1) != IToken.tRBRACE)
@ -2720,7 +2720,7 @@ public abstract class Parser extends ExpressionParser implements IParser
default : default :
try try
{ {
declaration(astClassSpecifier, null, null); declaration(astClassSpecifier, null, null, KeywordSetKey.MEMBER);
} }
catch (BacktrackException bt) catch (BacktrackException bt)
{ {
@ -2770,7 +2770,7 @@ public abstract class Parser extends ExpressionParser implements IParser
{ {
consume(IToken.tCOLON); consume(IToken.tCOLON);
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.BASE_SPECIFIER ); setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER );
boolean isVirtual = false; boolean isVirtual = false;
ASTAccessVisibility visibility = ASTAccessVisibility.PUBLIC; ASTAccessVisibility visibility = ASTAccessVisibility.PUBLIC;
ITokenDuple nameDuple = null; ITokenDuple nameDuple = null;
@ -2781,26 +2781,26 @@ public abstract class Parser extends ExpressionParser implements IParser
{ {
case IToken.t_virtual : case IToken.t_virtual :
consume(IToken.t_virtual); consume(IToken.t_virtual);
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.EMPTY ); setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY );
isVirtual = true; isVirtual = true;
break; break;
case IToken.t_public : case IToken.t_public :
consume(); consume();
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.EMPTY ); setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY );
break; break;
case IToken.t_protected : case IToken.t_protected :
consume(); consume();
visibility = ASTAccessVisibility.PROTECTED; visibility = ASTAccessVisibility.PROTECTED;
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.EMPTY ); setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY );
break; break;
case IToken.t_private : case IToken.t_private :
visibility = ASTAccessVisibility.PRIVATE; visibility = ASTAccessVisibility.PRIVATE;
consume(); consume();
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.EMPTY ); setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY );
break; break;
case IToken.tCOLONCOLON : case IToken.tCOLONCOLON :
case IToken.tIDENTIFIER : case IToken.tIDENTIFIER :
nameDuple = name(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, Key.BASE_SPECIFIER ); nameDuple = name(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER );
break; break;
case IToken.tCOMMA : case IToken.tCOMMA :
try try
@ -2824,7 +2824,7 @@ public abstract class Parser extends ExpressionParser implements IParser
visibility = ASTAccessVisibility.PUBLIC; visibility = ASTAccessVisibility.PUBLIC;
nameDuple = null; nameDuple = null;
consume(); consume();
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.BASE_SPECIFIER ); setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER );
continue baseSpecifierLoop; continue baseSpecifierLoop;
default : default :
break baseSpecifierLoop; break baseSpecifierLoop;
@ -2866,13 +2866,13 @@ public abstract class Parser extends ExpressionParser implements IParser
protected void statement(IASTCodeScope scope) throws EndOfFileException, BacktrackException protected void statement(IASTCodeScope scope) throws EndOfFileException, BacktrackException
{ {
setCompletionValues(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT); setCompletionValues(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.STATEMENT);
switch (LT(1)) switch (LT(1))
{ {
case IToken.t_case : case IToken.t_case :
consume(IToken.t_case); consume(IToken.t_case);
IASTExpression constant_expression = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION ); IASTExpression constant_expression = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
constant_expression.acceptElement(requestor, astFactory.getReferenceManager()); constant_expression.acceptElement(requestor, astFactory.getReferenceManager());
endExpression(constant_expression); endExpression(constant_expression);
consume(IToken.tCOLON); consume(IToken.tCOLON);
@ -2952,7 +2952,7 @@ public abstract class Parser extends ExpressionParser implements IParser
consume(IToken.tSEMI); consume(IToken.tSEMI);
if (LT(1) != IToken.tRPAREN) if (LT(1) != IToken.tRPAREN)
{ {
IASTExpression finalExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.DECLARATION); IASTExpression finalExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.DECLARATION);
finalExpression.acceptElement(requestor, astFactory.getReferenceManager()); finalExpression.acceptElement(requestor, astFactory.getReferenceManager());
endExpression(finalExpression); endExpression(finalExpression);
} }
@ -2974,7 +2974,7 @@ public abstract class Parser extends ExpressionParser implements IParser
consume(); consume();
if (LT(1) != IToken.tSEMI) if (LT(1) != IToken.tSEMI)
{ {
IASTExpression retVal = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION); IASTExpression retVal = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
retVal.acceptElement(requestor, astFactory.getReferenceManager()); retVal.acceptElement(requestor, astFactory.getReferenceManager());
endExpression(retVal); endExpression(retVal);
} }
@ -3016,7 +3016,7 @@ public abstract class Parser extends ExpressionParser implements IParser
IASTExpression expressionStatement = null; IASTExpression expressionStatement = null;
try try
{ {
expressionStatement = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT); expressionStatement = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.STATEMENT);
consume(IToken.tSEMI); consume(IToken.tSEMI);
expressionStatement.acceptElement( requestor, astFactory.getReferenceManager() ); expressionStatement.acceptElement( requestor, astFactory.getReferenceManager() );
endExpression(expressionStatement); endExpression(expressionStatement);
@ -3030,7 +3030,7 @@ public abstract class Parser extends ExpressionParser implements IParser
} }
// declarationStatement // declarationStatement
declaration(scope, null, null); declaration(scope, null, null, KeywordSetKey.STATEMENT);
} }
} }
@ -3045,7 +3045,7 @@ public abstract class Parser extends ExpressionParser implements IParser
if( LT(1) == IToken.tELLIPSIS ) if( LT(1) == IToken.tELLIPSIS )
consume( IToken.tELLIPSIS ); consume( IToken.tELLIPSIS );
else else
simpleDeclaration( SimpleDeclarationStrategy.TRY_VARIABLE, scope, null, CompletionKind.EXCEPTION_REFERENCE, true, Key.DECL_SPECIFIER_SEQUENCE ); simpleDeclaration( SimpleDeclarationStrategy.TRY_VARIABLE, scope, null, CompletionKind.EXCEPTION_REFERENCE, true, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
consume(IToken.tRPAREN); consume(IToken.tRPAREN);
catchBlockCompoundStatement(scope); catchBlockCompoundStatement(scope);
@ -3083,7 +3083,7 @@ public abstract class Parser extends ExpressionParser implements IParser
*/ */
protected void condition( IASTScope scope ) throws BacktrackException, EndOfFileException protected void condition( IASTScope scope ) throws BacktrackException, EndOfFileException
{ {
IASTExpression someExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION ); IASTExpression someExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
someExpression.acceptElement(requestor, astFactory.getReferenceManager()); someExpression.acceptElement(requestor, astFactory.getReferenceManager());
endExpression(someExpression); endExpression(someExpression);
@ -3097,7 +3097,7 @@ public abstract class Parser extends ExpressionParser implements IParser
IToken mark = mark(); IToken mark = mark();
try try
{ {
IASTExpression e = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.DECLARATION ); IASTExpression e = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.DECLARATION );
consume( IToken.tSEMI ); consume( IToken.tSEMI );
e.acceptElement(requestor, astFactory.getReferenceManager()); e.acceptElement(requestor, astFactory.getReferenceManager());
@ -3143,7 +3143,7 @@ public abstract class Parser extends ExpressionParser implements IParser
setCompletionValues( setCompletionValues(
(createNewScope ? newScope : scope ), (createNewScope ? newScope : scope ),
CompletionKind.SINGLE_NAME_REFERENCE, CompletionKind.SINGLE_NAME_REFERENCE,
KeywordSets.Key.STATEMENT ); KeywordSetKey.STATEMENT );
while (LT(1) != IToken.tRBRACE) while (LT(1) != IToken.tRBRACE)
{ {
@ -3159,7 +3159,7 @@ public abstract class Parser extends ExpressionParser implements IParser
errorHandling(); errorHandling();
} }
setCompletionValues(((createNewScope ? newScope : scope )), CompletionKind.SINGLE_NAME_REFERENCE, setCompletionValues(((createNewScope ? newScope : scope )), CompletionKind.SINGLE_NAME_REFERENCE,
KeywordSets.Key.STATEMENT ); KeywordSetKey.STATEMENT );
} }
consume(IToken.tRBRACE); consume(IToken.tRBRACE);

View file

@ -60,6 +60,7 @@ import org.eclipse.cdt.internal.core.parser.InternalParserUtil;
import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode; import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator; import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory; import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets; import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.SimpleToken; import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
import org.eclipse.cdt.internal.core.parser.token.TokenFactory; import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
@ -2116,7 +2117,7 @@ public final class Scanner implements IScanner, IScannerData {
*/ */
protected void handleCompletionOnDefinition(String definition) throws EndOfFileException { protected void handleCompletionOnDefinition(String definition) throws EndOfFileException {
IASTCompletionNode node = new ASTCompletionNode( IASTCompletionNode.CompletionKind.MACRO_REFERENCE, IASTCompletionNode node = new ASTCompletionNode( IASTCompletionNode.CompletionKind.MACRO_REFERENCE,
null, null, definition, KeywordSets.getKeywords(KeywordSets.Key.EMPTY, language), EMPTY_STRING, null ); null, null, definition, KeywordSets.getKeywords(KeywordSetKey.EMPTY, language), EMPTY_STRING, null );
throwEOF( node ); throwEOF( node );
} }
@ -2175,7 +2176,7 @@ public final class Scanner implements IScanner, IScannerData {
IASTCompletionNode node = new ASTCompletionNode( kind, IASTCompletionNode node = new ASTCompletionNode( kind,
null, null, prefix, null, null, prefix,
KeywordSets.getKeywords(((kind == IASTCompletionNode.CompletionKind.NO_SUCH_KIND )? KeywordSets.Key.EMPTY : KeywordSets.Key.MACRO), language), EMPTY_STRING, null ); KeywordSets.getKeywords(((kind == IASTCompletionNode.CompletionKind.NO_SUCH_KIND )? KeywordSetKey.EMPTY : KeywordSetKey.MACRO), language), EMPTY_STRING, null );
throwEOF( node ); throwEOF( node );
} }
@ -2190,12 +2191,12 @@ public final class Scanner implements IScanner, IScannerData {
protected void handleInvalidCompletion() throws EndOfFileException protected void handleInvalidCompletion() throws EndOfFileException
{ {
throwEOF( new ASTCompletionNode( IASTCompletionNode.CompletionKind.UNREACHABLE_CODE, null, null, EMPTY_STRING, KeywordSets.getKeywords(KeywordSets.Key.EMPTY, language ) , EMPTY_STRING, null)); throwEOF( new ASTCompletionNode( IASTCompletionNode.CompletionKind.UNREACHABLE_CODE, null, null, EMPTY_STRING, KeywordSets.getKeywords(KeywordSetKey.EMPTY, language ) , EMPTY_STRING, null));
} }
protected void handleCompletionOnPreprocessorDirective( String prefix ) throws EndOfFileException protected void handleCompletionOnPreprocessorDirective( String prefix ) throws EndOfFileException
{ {
throwEOF( new ASTCompletionNode( IASTCompletionNode.CompletionKind.NO_SUCH_KIND, null, null, prefix, KeywordSets.getKeywords(KeywordSets.Key.PP_DIRECTIVE, language ), EMPTY_STRING, null)); throwEOF( new ASTCompletionNode( IASTCompletionNode.CompletionKind.NO_SUCH_KIND, null, null, prefix, KeywordSets.getKeywords(KeywordSetKey.PP_DIRECTIVE, language ), EMPTY_STRING, null));
} }
/** /**
* @param key * @param key

View file

@ -0,0 +1,37 @@
/**********************************************************************
* Copyright (c) 2002-2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.token;
import org.eclipse.cdt.core.parser.Enum;
public class KeywordSetKey extends Enum
{
public static final KeywordSetKey EMPTY = new KeywordSetKey( 0 );
public static final KeywordSetKey DECL_SPECIFIER_SEQUENCE = new KeywordSetKey( 1 );
public static final KeywordSetKey DECLARATION = new KeywordSetKey( 2 );
public static final KeywordSetKey STATEMENT = new KeywordSetKey(3);
public static final KeywordSetKey BASE_SPECIFIER = new KeywordSetKey(4);
public static final KeywordSetKey POST_USING = new KeywordSetKey( 5 );
public static final KeywordSetKey FUNCTION_MODIFIER = new KeywordSetKey( 6 );
public static final KeywordSetKey NAMESPACE_ONLY = new KeywordSetKey(6);
public static final KeywordSetKey MACRO = new KeywordSetKey( 7 );
public static final KeywordSetKey PP_DIRECTIVE = new KeywordSetKey( 8 );
public static final KeywordSetKey EXPRESSION = new KeywordSetKey( 9 );
public static final KeywordSetKey MEMBER = new KeywordSetKey(10);
/**
* @param enumValue
*/
protected KeywordSetKey(int enumValue) {
super(enumValue);
}
}

View file

@ -16,7 +16,6 @@ import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import org.eclipse.cdt.core.parser.Directives; import org.eclipse.cdt.core.parser.Directives;
import org.eclipse.cdt.core.parser.Enum;
import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
@ -26,51 +25,35 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
public class KeywordSets { public class KeywordSets {
public static class Key extends Enum public static Set getKeywords( KeywordSetKey kind, ParserLanguage language )
{ {
public static final Key EMPTY = new Key( 0 ); if( kind == KeywordSetKey.EMPTY )
public static final Key DECL_SPECIFIER_SEQUENCE = new Key( 1 );
public static final Key DECLARATION = new Key( 2 );
public static final Key STATEMENT = new Key(3);
public static final Key BASE_SPECIFIER = new Key(4);
public static final Key POST_USING = new Key( 5 );
public static final Key FUNCTION_MODIFIER = new Key( 6 );
public static final Key NAMESPACE_ONLY = new Key(6);
public static final Key MACRO = new Key( 7 );
public static final Key PP_DIRECTIVE = new Key( 8 );
public static final Key EXPRESSION = new Key( 9 );
/**
* @param enumValue
*/
protected Key(int enumValue) {
super(enumValue);
}
}
public static Set getKeywords( Key kind, ParserLanguage language )
{
if( kind == Key.EMPTY )
return EMPTY_TABLE; return EMPTY_TABLE;
if( kind == Key.DECL_SPECIFIER_SEQUENCE ) if( kind == KeywordSetKey.DECL_SPECIFIER_SEQUENCE )
return (Set) DECL_SPECIFIER_SEQUENCE_TABLE.get( language ); return (Set) DECL_SPECIFIER_SEQUENCE_TABLE.get( language );
if( kind == Key.DECLARATION ) if( kind == KeywordSetKey.DECLARATION )
return (Set) DECLARATION_TABLE.get( language ); return (Set) DECLARATION_TABLE.get( language );
if( kind == Key.STATEMENT ) if( kind == KeywordSetKey.STATEMENT )
return (Set) STATEMENT_TABLE.get( language ); return (Set) STATEMENT_TABLE.get( language );
if( kind == Key.BASE_SPECIFIER ) if( kind == KeywordSetKey.BASE_SPECIFIER )
return BASE_SPECIFIER_CPP; return BASE_SPECIFIER_CPP;
if( kind == Key.POST_USING ) if( kind == KeywordSetKey.MEMBER )
{
if( language == ParserLanguage.CPP )
return CLASS_MEMBER;
return EMPTY_TABLE;
}
if( kind == KeywordSetKey.POST_USING )
return POST_USING_CPP; return POST_USING_CPP;
if( kind == Key.FUNCTION_MODIFIER ) if( kind == KeywordSetKey.FUNCTION_MODIFIER )
return (Set) FUNCTION_MODIFIER_TABLE.get( language ); return (Set) FUNCTION_MODIFIER_TABLE.get( language );
if( kind == Key.NAMESPACE_ONLY ) if( kind == KeywordSetKey.NAMESPACE_ONLY )
return NAMESPACE_ONLY_SET; return NAMESPACE_ONLY_SET;
if( kind == Key.MACRO ) if( kind == KeywordSetKey.MACRO )
return MACRO_ONLY; return MACRO_ONLY;
if( kind == Key.PP_DIRECTIVE ) if( kind == KeywordSetKey.PP_DIRECTIVE )
return PP_DIRECTIVES; return PP_DIRECTIVES;
if( kind == Key.EXPRESSION ) if( kind == KeywordSetKey.EXPRESSION )
return (Set) EXPRESSION_TABLE.get( language ); return (Set) EXPRESSION_TABLE.get( language );
//TODO finish this //TODO finish this
return null; return null;
@ -157,7 +140,10 @@ public class KeywordSets {
DECLARATION_CPP = new TreeSet(); DECLARATION_CPP = new TreeSet();
DECLARATION_CPP.addAll( DECL_SPECIFIER_SEQUENCE_CPP ); DECLARATION_CPP.addAll( DECL_SPECIFIER_SEQUENCE_CPP );
DECLARATION_CPP.add( Keywords.ASM ); DECLARATION_CPP.add( Keywords.ASM );
// more to come DECLARATION_CPP.add( Keywords.TEMPLATE );
DECLARATION_CPP.add( Keywords.USING );
DECLARATION_CPP.add( Keywords.NAMESPACE );
DECLARATION_CPP.add( Keywords.EXPORT );
} }
private static final Set DECLARATION_C; private static final Set DECLARATION_C;
@ -166,7 +152,6 @@ public class KeywordSets {
DECLARATION_C = new TreeSet(); DECLARATION_C = new TreeSet();
DECLARATION_C.addAll(DECL_SPECIFIER_SEQUENCE_C ); DECLARATION_C.addAll(DECL_SPECIFIER_SEQUENCE_C );
DECLARATION_C.add(Keywords.ASM ); DECLARATION_C.add(Keywords.ASM );
// more to come
} }
private static final Hashtable DECLARATION_TABLE; private static final Hashtable DECLARATION_TABLE;
@ -229,7 +214,17 @@ public class KeywordSets {
STATEMENT_C.addAll( DECLARATION_C ); STATEMENT_C.addAll( DECLARATION_C );
STATEMENT_C.addAll( EXPRESSION_C ); STATEMENT_C.addAll( EXPRESSION_C );
STATEMENT_C.add( Keywords.FOR ); STATEMENT_C.add( Keywords.FOR );
// more to come STATEMENT_C.add( Keywords.BREAK );
STATEMENT_C.add( Keywords.CASE );
STATEMENT_C.add( Keywords.GOTO );
STATEMENT_C.add( Keywords.SWITCH );
STATEMENT_C.add( Keywords.WHILE );
STATEMENT_C.add( Keywords.IF);
STATEMENT_C.add( Keywords.CONTINUE);
STATEMENT_C.add( Keywords.DEFAULT);
STATEMENT_C.add( Keywords.RETURN);
STATEMENT_C.add( Keywords.ELSE);
STATEMENT_C.add( Keywords.DO);
} }
private static final Set STATEMENT_CPP; private static final Set STATEMENT_CPP;
@ -238,7 +233,19 @@ public class KeywordSets {
STATEMENT_CPP = new TreeSet( DECLARATION_CPP ); STATEMENT_CPP = new TreeSet( DECLARATION_CPP );
STATEMENT_CPP.addAll( EXPRESSION_CPP ); STATEMENT_CPP.addAll( EXPRESSION_CPP );
STATEMENT_CPP.add( Keywords.TRY ); STATEMENT_CPP.add( Keywords.TRY );
//TODO finish this STATEMENT_CPP.add( Keywords.FOR );
STATEMENT_CPP.add( Keywords.BREAK );
STATEMENT_CPP.add( Keywords.CASE );
STATEMENT_CPP.add( Keywords.CATCH );
STATEMENT_CPP.add( Keywords.GOTO );
STATEMENT_CPP.add( Keywords.SWITCH );
STATEMENT_CPP.add( Keywords.WHILE );
STATEMENT_CPP.add( Keywords.IF);
STATEMENT_CPP.add( Keywords.CONTINUE);
STATEMENT_CPP.add( Keywords.DEFAULT);
STATEMENT_CPP.add( Keywords.RETURN);
STATEMENT_CPP.add( Keywords.ELSE);
STATEMENT_CPP.add( Keywords.DO);
} }
private static final Hashtable STATEMENT_TABLE; private static final Hashtable STATEMENT_TABLE;
@ -259,6 +266,15 @@ public class KeywordSets {
BASE_SPECIFIER_CPP.add(Keywords.VIRTUAL); BASE_SPECIFIER_CPP.add(Keywords.VIRTUAL);
} }
private static final Set CLASS_MEMBER;
static
{
CLASS_MEMBER = new TreeSet(DECL_SPECIFIER_SEQUENCE_CPP);
CLASS_MEMBER.add(Keywords.PUBLIC);
CLASS_MEMBER.add(Keywords.PROTECTED);
CLASS_MEMBER.add(Keywords.PRIVATE);
}
private static final Set POST_USING_CPP; private static final Set POST_USING_CPP;
static static
{ {

View file

@ -183,6 +183,7 @@ public class CompletionEngine implements RelevanceConstants {
// set timeout // set timeout
IPreferenceStore prefStore = CUIPlugin.getDefault().getPreferenceStore(); IPreferenceStore prefStore = CUIPlugin.getDefault().getPreferenceStore();
int timeout = prefStore.getInt(ContentAssistPreference.TIMEOUT_DELAY); int timeout = prefStore.getInt(ContentAssistPreference.TIMEOUT_DELAY);
if( timeout > 0 )
elementRequestor.setTimeout(timeout); elementRequestor.setTimeout(timeout);
// start timer // start timer