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:
parent
37e64d553e
commit
fb57293d47
13 changed files with 314 additions and 212 deletions
|
@ -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.IASTNode.ILookupResult;
|
||||
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
|
||||
|
@ -1146,4 +1148,52 @@ public class CompletionParseTest extends CompletionParseBaseTest {
|
|||
assertNotNull( result );
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.IParserData;
|
||||
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 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 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
|
||||
* @return
|
||||
|
@ -55,7 +55,7 @@ public interface IParserExtension {
|
|||
* @param key 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
|
||||
* @return
|
||||
|
|
|
@ -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.extension.IParserExtension;
|
||||
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
|
||||
|
@ -135,13 +135,13 @@ public class CompletionParser extends ContextualParser implements IParser {
|
|||
while (LT(1) == IToken.t_catch)
|
||||
{
|
||||
consume(IToken.t_catch);
|
||||
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY );
|
||||
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY );
|
||||
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 )
|
||||
consume( IToken.tELLIPSIS );
|
||||
else
|
||||
simpleDeclarationStrategyUnion( scope, null, CompletionKind.EXCEPTION_REFERENCE, Key.DECLARATION); // was exceptionDeclaration
|
||||
simpleDeclarationStrategyUnion( scope, null, CompletionKind.EXCEPTION_REFERENCE, KeywordSetKey.DECLARATION); // was exceptionDeclaration
|
||||
consume(IToken.tRPAREN);
|
||||
|
||||
catchBlockCompoundStatement(scope);
|
||||
|
|
|
@ -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.IASTExpression.Kind;
|
||||
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.TokenFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||
|
||||
/**
|
||||
* @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 );
|
||||
}
|
||||
|
||||
|
@ -128,18 +128,18 @@ public class ContextualParser extends CompleteParser {
|
|||
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 ) );
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
setCompletionKeywords(key);
|
||||
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 );
|
||||
setCompletionKind( kind );
|
||||
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 );
|
||||
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)
|
||||
*/
|
||||
protected void setCompletionValuesNoContext(IASTScope scope,
|
||||
CompletionKind kind, Key key) throws EndOfFileException {
|
||||
CompletionKind kind, KeywordSetKey key) throws EndOfFileException {
|
||||
setCompletionScope(scope);
|
||||
setCompletionKeywords(key);
|
||||
setCompletionKind(kind);
|
||||
|
|
|
@ -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.IASTExpression.Kind;
|
||||
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.KeywordSets.Key;
|
||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||
|
||||
/**
|
||||
|
@ -308,7 +307,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
|
||||
if( ! completedArg ){
|
||||
try{
|
||||
expression = assignmentExpression( scope, CompletionKind.VARIABLE_TYPE, Key.EXPRESSION );
|
||||
expression = assignmentExpression( scope, CompletionKind.VARIABLE_TYPE, KeywordSetKey.EXPRESSION );
|
||||
if( expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY ){
|
||||
throw backtrack;
|
||||
}
|
||||
|
@ -320,7 +319,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
}
|
||||
if( !completedArg ){
|
||||
try{
|
||||
ITokenDuple nameDuple = name( scope, null, Key.EMPTY );
|
||||
ITokenDuple nameDuple = name( scope, null, KeywordSetKey.EMPTY );
|
||||
expression = astFactory.createExpression( scope, IASTExpression.Kind.ID_EXPRESSION,
|
||||
null, null, null, null, nameDuple, EMPTY_STRING, null);
|
||||
list.add( expression );
|
||||
|
@ -371,7 +370,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
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());
|
||||
return duple.getLastToken();//last;
|
||||
}
|
||||
|
@ -389,7 +388,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param key TODO
|
||||
* @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();
|
||||
|
||||
|
@ -406,7 +405,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
if (LT(1) == IToken.tCOLONCOLON){
|
||||
argumentList.addSegment( null );
|
||||
last = consume( IToken.tCOLONCOLON );
|
||||
setCompletionValues( scope, kind, Key.EMPTY, getCompliationUnit() );
|
||||
setCompletionValues( scope, kind, KeywordSetKey.EMPTY, getCompliationUnit() );
|
||||
startsWithColonColon = true;
|
||||
}
|
||||
|
||||
|
@ -421,7 +420,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
if( startsWithColonColon )
|
||||
setCompletionValues( scope, kind, getCompliationUnit() );
|
||||
else if( prev != null )
|
||||
setCompletionValues(scope, kind, first, prev, Key.EMPTY );
|
||||
setCompletionValues(scope, kind, first, prev, KeywordSetKey.EMPTY );
|
||||
else
|
||||
setCompletionValuesNoContext(scope, kind, key );
|
||||
|
||||
|
@ -439,7 +438,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
{
|
||||
IToken prev = last;
|
||||
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)
|
||||
consume();
|
||||
|
@ -455,7 +454,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
case IToken.tIDENTIFIER :
|
||||
prev = last;
|
||||
last = consume();
|
||||
setCompletionValues( scope, kind, first, prev, Key.EMPTY );
|
||||
setCompletionValues( scope, kind, first, prev, KeywordSetKey.EMPTY );
|
||||
last = consumeTemplateArguments(scope, last, argumentList, kind);
|
||||
if( last.getType() == IToken.tGT )
|
||||
hasTemplateId = true;
|
||||
|
@ -478,7 +477,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param kind
|
||||
* @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
|
||||
|
@ -514,7 +513,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param key
|
||||
* @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;
|
||||
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);
|
||||
IASTArrayModifier arrayMod;
|
||||
|
@ -719,7 +718,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
{
|
||||
try
|
||||
{
|
||||
nameDuple = name(d.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EMPTY );
|
||||
nameDuple = name(d.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EMPTY );
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
|
@ -765,11 +764,11 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
}
|
||||
|
||||
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);
|
||||
while (LT(1) == IToken.tCOMMA)
|
||||
{
|
||||
|
@ -810,8 +809,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression assignmentExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||
setCompletionValues(scope, kind, Key.EXPRESSION );
|
||||
protected IASTExpression assignmentExpression(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException, BacktrackException {
|
||||
setCompletionValues(scope, kind, key );
|
||||
if (LT(1) == IToken.t_throw) {
|
||||
return throwExpression(scope,key);
|
||||
}
|
||||
|
@ -885,9 +884,9 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
setCompletionValues( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||
setCompletionValues( scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION );
|
||||
IASTExpression throwExpression = null;
|
||||
try
|
||||
{
|
||||
|
@ -922,7 +921,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @return
|
||||
* @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);
|
||||
if (LT(1) == IToken.tQUESTION)
|
||||
{
|
||||
|
@ -957,7 +956,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
while (LT(1) == IToken.tOR)
|
||||
{
|
||||
|
@ -992,7 +991,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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 );
|
||||
while (LT(1) == IToken.tAND)
|
||||
{
|
||||
|
@ -1026,7 +1025,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
while (LT(1) == IToken.tBITOR)
|
||||
{
|
||||
|
@ -1061,7 +1060,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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 );
|
||||
while (LT(1) == IToken.tXOR)
|
||||
{
|
||||
|
@ -1097,7 +1096,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
while (LT(1) == IToken.tAMPER)
|
||||
{
|
||||
|
@ -1153,7 +1152,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
for (;;)
|
||||
{
|
||||
|
@ -1198,7 +1197,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
for (;;)
|
||||
{
|
||||
|
@ -1280,7 +1279,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
for (;;)
|
||||
{
|
||||
|
@ -1324,7 +1323,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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 );
|
||||
for (;;)
|
||||
{
|
||||
|
@ -1368,7 +1367,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
for (;;)
|
||||
{
|
||||
|
@ -1424,7 +1423,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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);
|
||||
for (;;)
|
||||
{
|
||||
|
@ -1469,7 +1468,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* : unaryExpression
|
||||
* | "(" 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
|
||||
if (LT(1) == IToken.tLPAREN)
|
||||
{
|
||||
|
@ -1552,7 +1551,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
{
|
||||
try
|
||||
{
|
||||
name = name(scope, completionKind, Key.DECL_SPECIFIER_SEQUENCE );
|
||||
name = name(scope, completionKind, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
|
||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||
break;
|
||||
}
|
||||
|
@ -1599,7 +1598,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
case IToken.tIDENTIFIER :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
name = name(scope, completionKind, Key.EMPTY );
|
||||
name = name(scope, completionKind, KeywordSetKey.EMPTY );
|
||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||
break;
|
||||
|
||||
|
@ -1683,7 +1682,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
consume();
|
||||
try
|
||||
{
|
||||
name = name(scope, completionKind, Key.EMPTY );
|
||||
name = name(scope, completionKind, KeywordSetKey.EMPTY );
|
||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||
} catch( BacktrackException b )
|
||||
{
|
||||
|
@ -1744,7 +1743,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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)
|
||||
{
|
||||
// global scope
|
||||
|
@ -1801,8 +1800,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* directnewdeclarator [ constantexpression ]
|
||||
* newinitializer: ( expressionlist? )
|
||||
*/
|
||||
protected IASTExpression newExpression(IASTScope scope, Key key) throws BacktrackException, EndOfFileException {
|
||||
setCompletionValues(scope, CompletionKind.NEW_TYPE_REFERENCE, Key.EMPTY);
|
||||
protected IASTExpression newExpression(IASTScope scope, KeywordSetKey key) throws BacktrackException, EndOfFileException {
|
||||
setCompletionValues(scope, CompletionKind.NEW_TYPE_REFERENCE, KeywordSetKey.EMPTY);
|
||||
if (LT(1) == IToken.tCOLONCOLON)
|
||||
{
|
||||
// global scope
|
||||
|
@ -1913,7 +1912,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
// new-expression ends here.
|
||||
try
|
||||
{
|
||||
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, Key.EMPTY);
|
||||
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.EMPTY);
|
||||
return astFactory.createExpression(
|
||||
scope, IASTExpression.Kind.NEW_TYPEID,
|
||||
null, null, null, typeId, null,
|
||||
|
@ -1973,7 +1972,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||
}
|
||||
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, Key.EMPTY);
|
||||
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.EMPTY);
|
||||
try
|
||||
{
|
||||
return astFactory.createExpression(
|
||||
|
@ -2002,7 +2001,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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))
|
||||
{
|
||||
case IToken.tSTAR :
|
||||
|
@ -2130,16 +2129,16 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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;
|
||||
boolean isTemplate = false;
|
||||
|
||||
setCompletionValues( scope, kind, Key.EXPRESSION );
|
||||
setCompletionValues( scope, kind, key );
|
||||
switch (LT(1))
|
||||
{
|
||||
case 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;
|
||||
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_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);
|
||||
if( secondExpression != null && secondExpression.getExpressionKind() == Kind.ID_EXPRESSION && secondExpression.getIdExpression().indexOf( '~') != -1 )
|
||||
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_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);
|
||||
|
||||
if( secondExpression != null && secondExpression.getExpressionKind() == Kind.ID_EXPRESSION && secondExpression.getIdExpression().indexOf( '~') != -1 )
|
||||
|
@ -2541,7 +2540,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
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();
|
||||
consume(IToken.tLPAREN);
|
||||
setCurrentFunctionName( typeName );
|
||||
|
@ -2574,7 +2573,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param expression
|
||||
* @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;
|
||||
switch (LT(1))
|
||||
{
|
||||
|
@ -2857,7 +2856,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
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();
|
||||
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);
|
||||
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(IToken.tLT);
|
||||
IASTTypeId duple = typeId(scope, false, CompletionKind.TYPE_REFERENCE);
|
||||
|
|
|
@ -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.extension.IParserExtension;
|
||||
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.KeywordSets.Key;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -78,7 +77,7 @@ public class GCCParserExtension implements IParserExtension {
|
|||
/* (non-Javadoc)
|
||||
* @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 {
|
||||
switch( data.LT(1))
|
||||
{
|
||||
|
@ -117,7 +116,7 @@ public class GCCParserExtension implements IParserExtension {
|
|||
* @param type TODO
|
||||
* @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;
|
||||
try
|
||||
{
|
||||
|
@ -241,7 +240,7 @@ public class GCCParserExtension implements IParserExtension {
|
|||
/* (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)
|
||||
*/
|
||||
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;
|
||||
try
|
||||
{
|
||||
|
@ -336,7 +335,7 @@ public class GCCParserExtension implements IParserExtension {
|
|||
/* (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)
|
||||
*/
|
||||
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;
|
||||
IToken mark = null;
|
||||
try {
|
||||
|
@ -429,9 +428,9 @@ public class GCCParserExtension implements IParserExtension {
|
|||
if( parserData.LT(1) == 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 );
|
||||
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 );
|
||||
Map extensionParms = new Hashtable();
|
||||
extensionParms.put( IASTGCCDesignator.SECOND_EXRESSION, constantExpression2 );
|
||||
|
|
|
@ -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.IASTExpression;
|
||||
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
|
||||
|
@ -32,6 +32,6 @@ public interface IExpressionParser extends IFilenameProvider {
|
|||
* @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid
|
||||
* 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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.IASTTypeId;
|
||||
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.KeywordSets.Key;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
|
@ -97,7 +96,7 @@ public interface IParserData extends IExpressionParser {
|
|||
* @param key TODO
|
||||
* @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
|
||||
*/
|
||||
|
@ -112,7 +111,7 @@ public interface IParserData extends IExpressionParser {
|
|||
* @param key TODO
|
||||
* @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;
|
||||
}
|
|
@ -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.IASTCompletionNode.CompletionKind;
|
||||
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.KeywordSets.Key;
|
||||
|
||||
/**
|
||||
* 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() );
|
||||
try {
|
||||
setCompletionValues(compilationUnit, CompletionKind.VARIABLE_TYPE, Key.DECLARATION );
|
||||
setCompletionValues(compilationUnit, CompletionKind.VARIABLE_TYPE, KeywordSetKey.DECLARATION );
|
||||
} catch (EndOfFileException e1) {
|
||||
compilationUnit.exitScope( requestor, astFactory.getReferenceManager() );
|
||||
return;
|
||||
|
@ -147,7 +146,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
try
|
||||
{
|
||||
int checkOffset = LA(1).hashCode();
|
||||
declaration(compilationUnit, null, null);
|
||||
declaration(compilationUnit, null, null, KeywordSetKey.DECLARATION);
|
||||
if (LA(1).hashCode() == checkOffset)
|
||||
errorHandling();
|
||||
}
|
||||
|
@ -235,18 +234,18 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throws EndOfFileException, BacktrackException
|
||||
{
|
||||
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)
|
||||
{
|
||||
// using-directive
|
||||
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
|
||||
ITokenDuple duple = null;
|
||||
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
|
||||
throw backtrack;
|
||||
if (LT(1) == IToken.tSEMI)
|
||||
|
@ -269,7 +268,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
@ -277,12 +276,12 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume(IToken.t_typename);
|
||||
}
|
||||
|
||||
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.NAMESPACE_ONLY );
|
||||
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.NAMESPACE_ONLY );
|
||||
ITokenDuple name = null;
|
||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
|
@ -308,7 +307,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
declaration.acceptElement( requestor, astFactory.getReferenceManager() );
|
||||
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), Key.DECLARATION );
|
||||
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), KeywordSetKey.DECLARATION );
|
||||
return declaration;
|
||||
}
|
||||
throw backtrack;
|
||||
|
@ -363,7 +362,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
default :
|
||||
try
|
||||
{
|
||||
declaration(linkage, null, null);
|
||||
declaration(linkage, null, null, KeywordSetKey.DECLARATION);
|
||||
}
|
||||
catch (BacktrackException bt)
|
||||
{
|
||||
|
@ -398,7 +397,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
linkage.enterScope( requestor, astFactory.getReferenceManager() );
|
||||
declaration(linkage, null, null);
|
||||
declaration(linkage, null, null, KeywordSetKey.DECLARATION);
|
||||
linkage.exitScope( requestor, astFactory.getReferenceManager() );
|
||||
return linkage;
|
||||
|
||||
|
@ -448,7 +447,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
templateInstantiation.enterScope( requestor, astFactory.getReferenceManager() );
|
||||
declaration(templateInstantiation, templateInstantiation, null);
|
||||
declaration(templateInstantiation, templateInstantiation, null, KeywordSetKey.DECLARATION);
|
||||
templateInstantiation.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber());
|
||||
templateInstantiation.exitScope( requestor, astFactory.getReferenceManager() );
|
||||
|
||||
|
@ -475,7 +474,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
templateSpecialization.enterScope(requestor, astFactory.getReferenceManager());
|
||||
declaration(templateSpecialization, templateSpecialization, null);
|
||||
declaration(templateSpecialization, templateSpecialization, null, KeywordSetKey.DECLARATION);
|
||||
templateSpecialization.setEndingOffsetAndLineNumber(
|
||||
lastToken.getEndOffset(), lastToken.getLineNumber());
|
||||
templateSpecialization.exitScope(requestor, astFactory.getReferenceManager());
|
||||
|
@ -504,7 +503,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
}
|
||||
templateDecl.enterScope( requestor, astFactory.getReferenceManager() );
|
||||
try{
|
||||
declaration(templateDecl, templateDecl, null );
|
||||
declaration(templateDecl, templateDecl, null, KeywordSetKey.DECLARATION );
|
||||
} catch( EndOfFileException e ){
|
||||
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||
templateDecl.exitScope( requestor, astFactory.getReferenceManager() );
|
||||
|
@ -717,24 +716,25 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
* - usingDirective into usingDeclaration
|
||||
* - explicitInstantiation and explicitSpecialization into
|
||||
* templateDeclaration
|
||||
*
|
||||
* @param overideKey TODO
|
||||
* @param container IParserCallback object which serves as the owner scope for this declaration.
|
||||
*
|
||||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
protected void declaration(
|
||||
IASTScope scope,
|
||||
IASTTemplate ownerTemplate, CompletionKind overideKind)
|
||||
IASTTemplate ownerTemplate, CompletionKind overideKind, KeywordSetKey overideKey)
|
||||
throws EndOfFileException, BacktrackException
|
||||
{
|
||||
|
||||
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, overideKind);
|
||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||
setCompletionValues(scope, kind, overideKey);
|
||||
IASTDeclaration resultDeclaration = null;
|
||||
switch (LT(1))
|
||||
{
|
||||
case 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);
|
||||
String assembly = consume(IToken.tSTRING).getImage();
|
||||
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
|
||||
// do the callback
|
||||
resultDeclaration.acceptElement(requestor, astFactory.getReferenceManager());
|
||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION );
|
||||
break;
|
||||
case IToken.t_namespace :
|
||||
resultDeclaration = namespaceDefinition(scope);
|
||||
|
@ -776,9 +776,9 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
break;
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@ -792,7 +792,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
|
||||
protected IASTDeclaration simpleDeclarationStrategyUnion(
|
||||
IASTScope scope,
|
||||
IASTTemplate ownerTemplate, CompletionKind overrideKind, Key overrideKey)
|
||||
IASTTemplate ownerTemplate, CompletionKind overrideKind, KeywordSetKey overrideKey)
|
||||
throws EndOfFileException, BacktrackException
|
||||
{
|
||||
simpleDeclarationMark = mark();
|
||||
|
@ -859,7 +859,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
|
||||
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, null);
|
||||
|
||||
setCompletionValues(scope,CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY );
|
||||
setCompletionValues(scope,CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY );
|
||||
IToken identifier = null;
|
||||
// optional name
|
||||
if (LT(1) == IToken.tIDENTIFIER)
|
||||
|
@ -887,7 +887,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
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)
|
||||
{
|
||||
int checkToken = LA(1).hashCode();
|
||||
|
@ -899,7 +899,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
default :
|
||||
try
|
||||
{
|
||||
declaration(namespaceDefinition, null, null);
|
||||
declaration(namespaceDefinition, null, null, KeywordSetKey.DECLARATION);
|
||||
}
|
||||
catch (BacktrackException bt)
|
||||
{
|
||||
|
@ -911,27 +911,27 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
if (checkToken == LA(1).hashCode())
|
||||
errorHandling();
|
||||
}
|
||||
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,Key.EMPTY );
|
||||
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY );
|
||||
// consume the }
|
||||
IToken last = consume(IToken.tRBRACE);
|
||||
|
||||
namespaceDefinition.setEndingOffsetAndLineNumber(
|
||||
last.getOffset() + last.getLength(), last.getLineNumber());
|
||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION );
|
||||
namespaceDefinition.exitScope( requestor, astFactory.getReferenceManager() );
|
||||
return namespaceDefinition;
|
||||
}
|
||||
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 );
|
||||
|
||||
if( identifier == null )
|
||||
throw backtrack;
|
||||
|
||||
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY);
|
||||
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY);
|
||||
consume( IToken.tSEMI );
|
||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION );
|
||||
IASTNamespaceAlias alias = null;
|
||||
try
|
||||
{
|
||||
|
@ -972,7 +972,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
protected IASTDeclaration simpleDeclaration(
|
||||
SimpleDeclarationStrategy strategy,
|
||||
IASTScope scope,
|
||||
IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler, Key overrideKey)
|
||||
IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler, KeywordSetKey overrideKey)
|
||||
throws BacktrackException, EndOfFileException
|
||||
{
|
||||
IToken firstToken = LA(1);
|
||||
|
@ -982,7 +982,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
firstToken = null; // necessary for scalability
|
||||
|
||||
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 );
|
||||
IASTSimpleTypeSpecifier simpleTypeSpecifier = null;
|
||||
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED )
|
||||
|
@ -1209,12 +1209,12 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
break;
|
||||
|
||||
|
||||
ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EMPTY );
|
||||
ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EMPTY );
|
||||
|
||||
consume(IToken.tLPAREN);
|
||||
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);
|
||||
|
||||
|
@ -1259,7 +1259,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
|
||||
DeclarationWrapper sdw =
|
||||
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
|
||||
&& sdw.getSimpleType()
|
||||
!= IASTSimpleTypeSpecifier.Type.UNSPECIFIED)
|
||||
|
@ -1289,7 +1289,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
|
||||
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY );
|
||||
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY );
|
||||
if (LT(1) != IToken.tSEMI)
|
||||
initDeclarator(sdw, SimpleDeclarationStrategy.TRY_FUNCTION, CompletionKind.VARIABLE_TYPE, constructInitializersInParameters );
|
||||
|
||||
|
@ -1482,7 +1482,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
protected void declSpecifierSeq(
|
||||
DeclarationWrapper sdw,
|
||||
boolean parm,
|
||||
boolean tryConstructor, CompletionKind kind, Key key )
|
||||
boolean tryConstructor, CompletionKind kind, KeywordSetKey key )
|
||||
throws BacktrackException, EndOfFileException
|
||||
{
|
||||
Flags flags = new Flags(parm, tryConstructor);
|
||||
|
@ -1661,7 +1661,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume(IToken.t_typename );
|
||||
IToken first = LA(1);
|
||||
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)
|
||||
{
|
||||
consume(IToken.t_template);
|
||||
|
@ -1806,7 +1806,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
throw backtrack;
|
||||
}
|
||||
|
||||
ITokenDuple d = name(sdw.getScope(), completionKind, Key.EMPTY);
|
||||
ITokenDuple d = name(sdw.getScope(), completionKind, KeywordSetKey.EMPTY);
|
||||
IASTTypeSpecifier elaboratedTypeSpec = null;
|
||||
final boolean isForewardDecl = ( LT(1) == IToken.tSEMI );
|
||||
|
||||
|
@ -1872,24 +1872,24 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
// handle initializer
|
||||
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)
|
||||
{
|
||||
consume(IToken.tASSIGN);
|
||||
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY);
|
||||
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY);
|
||||
throwAwayMarksForInitializerClause(d);
|
||||
IASTInitializerClause clause = initializerClause(scope,constructInitializers);
|
||||
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 )
|
||||
{
|
||||
// initializer in constructor
|
||||
consume(IToken.tLPAREN); // EAT IT!
|
||||
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY);
|
||||
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY);
|
||||
IASTExpression astExpression = null;
|
||||
astExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY);
|
||||
astExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
|
||||
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY);
|
||||
consume(IToken.tRPAREN);
|
||||
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
|
||||
{
|
||||
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 )
|
||||
{
|
||||
consume( IToken.tASSIGN );
|
||||
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 ) );
|
||||
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
|
||||
try
|
||||
{
|
||||
IASTExpression assignmentExpression = assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||
IASTExpression assignmentExpression = assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
|
||||
try
|
||||
{
|
||||
return createInitializerClause(
|
||||
|
@ -2058,7 +2058,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
try
|
||||
{
|
||||
IASTExpression assignmentExpression =
|
||||
assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||
assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -2118,7 +2118,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
else if( LT(1) == 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 )
|
||||
{
|
||||
backup( mark );
|
||||
|
@ -2223,7 +2223,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
try
|
||||
{
|
||||
queryName = name(parameterScope, CompletionKind.TYPE_REFERENCE, Key.EMPTY );
|
||||
queryName = name(parameterScope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.EMPTY );
|
||||
if( ! astFactory.queryIsTypeName( parameterScope, queryName ) )
|
||||
failed = true;
|
||||
}
|
||||
|
@ -2248,7 +2248,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
d.setIsFunction(true);
|
||||
// TODO need to create a temporary scope object here
|
||||
consume(IToken.tLPAREN);
|
||||
setCompletionValues( scope, CompletionKind.ARGUMENT_TYPE, Key.DECL_SPECIFIER_SEQUENCE );
|
||||
setCompletionValues( scope, CompletionKind.ARGUMENT_TYPE, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
|
||||
boolean seenParameter = false;
|
||||
parameterDeclarationLoop : for (;;)
|
||||
{
|
||||
|
@ -2256,7 +2256,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
case IToken.tRPAREN :
|
||||
consume();
|
||||
setCompletionValues( parameterScope, CompletionKind.NO_SUCH_KIND, KeywordSets.Key.FUNCTION_MODIFIER );
|
||||
setCompletionValues( parameterScope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.FUNCTION_MODIFIER );
|
||||
break parameterDeclarationLoop;
|
||||
case IToken.tELLIPSIS :
|
||||
consume();
|
||||
|
@ -2264,7 +2264,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
break;
|
||||
case IToken.tCOMMA :
|
||||
consume();
|
||||
setCompletionValues( parameterScope, CompletionKind.ARGUMENT_TYPE, Key.DECL_SPECIFIER_SEQUENCE );
|
||||
setCompletionValues( parameterScope, CompletionKind.ARGUMENT_TYPE, KeywordSetKey.DECL_SPECIFIER_SEQUENCE );
|
||||
seenParameter = false;
|
||||
break;
|
||||
default :
|
||||
|
@ -2381,7 +2381,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
continue;
|
||||
case 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);
|
||||
default :
|
||||
break;
|
||||
|
@ -2410,7 +2410,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
try
|
||||
{
|
||||
ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), kind, Key.EMPTY );
|
||||
ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), kind, KeywordSetKey.EMPTY );
|
||||
d.setName(duple);
|
||||
|
||||
}
|
||||
|
@ -2531,7 +2531,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
if (LT(1) == 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;
|
||||
if (LT(1) == IToken.tRBRACE)
|
||||
|
@ -2643,10 +2643,10 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
|
||||
ITokenDuple duple = null;
|
||||
|
||||
setCompletionValues(sdw.getScope(), completionKind, Key.EMPTY );
|
||||
setCompletionValues(sdw.getScope(), completionKind, KeywordSetKey.EMPTY );
|
||||
// class name
|
||||
if (LT(1) == IToken.tIDENTIFIER)
|
||||
duple = name( sdw.getScope(), completionKind, Key.EMPTY );
|
||||
duple = name( sdw.getScope(), completionKind, KeywordSetKey.EMPTY );
|
||||
if (duple != null && !duple.isIdentifier())
|
||||
nameType = ClassNameType.TEMPLATE;
|
||||
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)
|
||||
{
|
||||
consume(IToken.tLBRACE);
|
||||
setCompletionValues(astClassSpecifier, CompletionKind.FIELD_TYPE, Key.DECLARATION );
|
||||
setCompletionValues(astClassSpecifier, CompletionKind.FIELD_TYPE, KeywordSetKey.MEMBER );
|
||||
astClassSpecifier.enterScope( requestor, astFactory.getReferenceManager() );
|
||||
handleClassSpecifier( astClassSpecifier );
|
||||
memberDeclarationLoop : while (LT(1) != IToken.tRBRACE)
|
||||
|
@ -2720,7 +2720,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
default :
|
||||
try
|
||||
{
|
||||
declaration(astClassSpecifier, null, null);
|
||||
declaration(astClassSpecifier, null, null, KeywordSetKey.MEMBER);
|
||||
}
|
||||
catch (BacktrackException bt)
|
||||
{
|
||||
|
@ -2770,7 +2770,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
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;
|
||||
ASTAccessVisibility visibility = ASTAccessVisibility.PUBLIC;
|
||||
ITokenDuple nameDuple = null;
|
||||
|
@ -2781,26 +2781,26 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
case 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;
|
||||
break;
|
||||
case IToken.t_public :
|
||||
consume();
|
||||
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.EMPTY );
|
||||
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY );
|
||||
break;
|
||||
case IToken.t_protected :
|
||||
consume();
|
||||
visibility = ASTAccessVisibility.PROTECTED;
|
||||
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.EMPTY );
|
||||
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY );
|
||||
break;
|
||||
case IToken.t_private :
|
||||
visibility = ASTAccessVisibility.PRIVATE;
|
||||
consume();
|
||||
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.EMPTY );
|
||||
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY );
|
||||
break;
|
||||
case IToken.tCOLONCOLON :
|
||||
case IToken.tIDENTIFIER :
|
||||
nameDuple = name(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, Key.BASE_SPECIFIER );
|
||||
nameDuple = name(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER );
|
||||
break;
|
||||
case IToken.tCOMMA :
|
||||
try
|
||||
|
@ -2824,7 +2824,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
visibility = ASTAccessVisibility.PUBLIC;
|
||||
nameDuple = null;
|
||||
consume();
|
||||
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.BASE_SPECIFIER );
|
||||
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER );
|
||||
continue baseSpecifierLoop;
|
||||
default :
|
||||
break baseSpecifierLoop;
|
||||
|
@ -2866,13 +2866,13 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
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))
|
||||
{
|
||||
case 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());
|
||||
endExpression(constant_expression);
|
||||
consume(IToken.tCOLON);
|
||||
|
@ -2952,7 +2952,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume(IToken.tSEMI);
|
||||
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());
|
||||
endExpression(finalExpression);
|
||||
}
|
||||
|
@ -2974,7 +2974,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume();
|
||||
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());
|
||||
endExpression(retVal);
|
||||
}
|
||||
|
@ -3016,7 +3016,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
IASTExpression expressionStatement = null;
|
||||
try
|
||||
{
|
||||
expressionStatement = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT);
|
||||
expressionStatement = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.STATEMENT);
|
||||
consume(IToken.tSEMI);
|
||||
expressionStatement.acceptElement( requestor, astFactory.getReferenceManager() );
|
||||
endExpression(expressionStatement);
|
||||
|
@ -3030,7 +3030,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
}
|
||||
|
||||
// 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 )
|
||||
consume( IToken.tELLIPSIS );
|
||||
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);
|
||||
|
||||
catchBlockCompoundStatement(scope);
|
||||
|
@ -3083,7 +3083,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
*/
|
||||
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());
|
||||
|
||||
endExpression(someExpression);
|
||||
|
@ -3097,7 +3097,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
IToken mark = mark();
|
||||
try
|
||||
{
|
||||
IASTExpression e = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.DECLARATION );
|
||||
IASTExpression e = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.DECLARATION );
|
||||
consume( IToken.tSEMI );
|
||||
e.acceptElement(requestor, astFactory.getReferenceManager());
|
||||
|
||||
|
@ -3143,7 +3143,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
setCompletionValues(
|
||||
(createNewScope ? newScope : scope ),
|
||||
CompletionKind.SINGLE_NAME_REFERENCE,
|
||||
KeywordSets.Key.STATEMENT );
|
||||
KeywordSetKey.STATEMENT );
|
||||
|
||||
while (LT(1) != IToken.tRBRACE)
|
||||
{
|
||||
|
@ -3159,7 +3159,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
errorHandling();
|
||||
}
|
||||
setCompletionValues(((createNewScope ? newScope : scope )), CompletionKind.SINGLE_NAME_REFERENCE,
|
||||
KeywordSets.Key.STATEMENT );
|
||||
KeywordSetKey.STATEMENT );
|
||||
}
|
||||
|
||||
consume(IToken.tRBRACE);
|
||||
|
|
|
@ -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.EmptyIterator;
|
||||
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.SimpleToken;
|
||||
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 {
|
||||
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 );
|
||||
}
|
||||
|
@ -2175,7 +2176,7 @@ public final class Scanner implements IScanner, IScannerData {
|
|||
|
||||
IASTCompletionNode node = new ASTCompletionNode( kind,
|
||||
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 );
|
||||
}
|
||||
|
@ -2190,12 +2191,12 @@ public final class Scanner implements IScanner, IScannerData {
|
|||
|
||||
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
|
||||
{
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,6 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
|
||||
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.ParserLanguage;
|
||||
|
||||
|
@ -26,51 +25,35 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
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 );
|
||||
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 )
|
||||
if( kind == KeywordSetKey.EMPTY )
|
||||
return EMPTY_TABLE;
|
||||
if( kind == Key.DECL_SPECIFIER_SEQUENCE )
|
||||
if( kind == KeywordSetKey.DECL_SPECIFIER_SEQUENCE )
|
||||
return (Set) DECL_SPECIFIER_SEQUENCE_TABLE.get( language );
|
||||
if( kind == Key.DECLARATION )
|
||||
if( kind == KeywordSetKey.DECLARATION )
|
||||
return (Set) DECLARATION_TABLE.get( language );
|
||||
if( kind == Key.STATEMENT )
|
||||
if( kind == KeywordSetKey.STATEMENT )
|
||||
return (Set) STATEMENT_TABLE.get( language );
|
||||
if( kind == Key.BASE_SPECIFIER )
|
||||
if( kind == KeywordSetKey.BASE_SPECIFIER )
|
||||
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;
|
||||
if( kind == Key.FUNCTION_MODIFIER )
|
||||
if( kind == KeywordSetKey.FUNCTION_MODIFIER )
|
||||
return (Set) FUNCTION_MODIFIER_TABLE.get( language );
|
||||
if( kind == Key.NAMESPACE_ONLY )
|
||||
if( kind == KeywordSetKey.NAMESPACE_ONLY )
|
||||
return NAMESPACE_ONLY_SET;
|
||||
if( kind == Key.MACRO )
|
||||
if( kind == KeywordSetKey.MACRO )
|
||||
return MACRO_ONLY;
|
||||
if( kind == Key.PP_DIRECTIVE )
|
||||
if( kind == KeywordSetKey.PP_DIRECTIVE )
|
||||
return PP_DIRECTIVES;
|
||||
if( kind == Key.EXPRESSION )
|
||||
if( kind == KeywordSetKey.EXPRESSION )
|
||||
return (Set) EXPRESSION_TABLE.get( language );
|
||||
//TODO finish this
|
||||
return null;
|
||||
|
@ -157,7 +140,10 @@ public class KeywordSets {
|
|||
DECLARATION_CPP = new TreeSet();
|
||||
DECLARATION_CPP.addAll( DECL_SPECIFIER_SEQUENCE_CPP );
|
||||
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;
|
||||
|
@ -166,7 +152,6 @@ public class KeywordSets {
|
|||
DECLARATION_C = new TreeSet();
|
||||
DECLARATION_C.addAll(DECL_SPECIFIER_SEQUENCE_C );
|
||||
DECLARATION_C.add(Keywords.ASM );
|
||||
// more to come
|
||||
}
|
||||
|
||||
private static final Hashtable DECLARATION_TABLE;
|
||||
|
@ -229,7 +214,17 @@ public class KeywordSets {
|
|||
STATEMENT_C.addAll( DECLARATION_C );
|
||||
STATEMENT_C.addAll( EXPRESSION_C );
|
||||
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;
|
||||
|
@ -238,7 +233,19 @@ public class KeywordSets {
|
|||
STATEMENT_CPP = new TreeSet( DECLARATION_CPP );
|
||||
STATEMENT_CPP.addAll( EXPRESSION_CPP );
|
||||
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;
|
||||
|
@ -259,6 +266,15 @@ public class KeywordSets {
|
|||
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;
|
||||
static
|
||||
{
|
||||
|
|
|
@ -183,7 +183,8 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
// set timeout
|
||||
IPreferenceStore prefStore = CUIPlugin.getDefault().getPreferenceStore();
|
||||
int timeout = prefStore.getInt(ContentAssistPreference.TIMEOUT_DELAY);
|
||||
elementRequestor.setTimeout(timeout);
|
||||
if( timeout > 0 )
|
||||
elementRequestor.setTimeout(timeout);
|
||||
|
||||
// start timer
|
||||
elementRequestor.startTimer();
|
||||
|
|
Loading…
Add table
Reference in a new issue