1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

org.eclipse.cdt.core

Refactored parser to allow for cleaner content assist implementation.  
	Removed IASTCompletionNode.CompletionKind.STATEMENT_START as it is redundant.  
	Fixed bug 50640 - Wrong completion kind when expecting an exception 
	Fixed bug 50471 - Wrong completion kind after the "using" keyword
	Fixed bug 50621 - Wrong completion kind in a class declaration 

org.eclipse.cdt.core.tests
	Renamed ContextualParseTest to CompletionParseTest.
	Updated COMPLETION_PARSE clients to use SINGLE_NAME_REFERENCE rather than STATEMENT_START.  

org.eclipse.cdt.ui
	Updated COMPLETION_PARSE clients to use SINGLE_NAME_REFERENCE rather than STATEMENT_START.  

org.eclipse.cdt.ui.tests
	Updated COMPLETION_PARSE clients to use SINGLE_NAME_REFERENCE rather than STATEMENT_START.  
	Renamed and updated CompletionTest_StatementStart_NoPrefix to CompletionTest_SingleName_Method_NoPrefix.
	Renamed and updated CompletionTest_StatementStart_Prefix to CompletionTest_SingleName_Method_Prefix.
	Renamed and updated CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640 to CompletionTest_ExceptionReference_NoPrefix and moved to passed tests folder.
	Renamed and updated CompletionFailedTest_ExceptionReference_Prefix_Bug50640 to CompletionTest_ExceptionReference_Prefix and moved to passed tests folder.
	Renamed and updated CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471 to CompletionTest_TypeRef_NoPrefix and moved to passed tests folder.
	Renamed and updated CompletionFailedTest_NamespaceRef_Prefix_Bug50471 to CompletionTest_TypeRef_Prefix and moved to passed tests folder.
	Renamed and updated CompletionFailedTest_ClassReference_Prefix_Bug50621 to CompletionTest_ClassReference_Prefix and moved to passed tests folder.
	Renamed and updated CompletionFailedTest_ClassReference_NoPrefix_Bug50621 to CompletionTest_ClassReference_NoPrefix and moved to passed tests folder.
This commit is contained in:
John Camelon 2004-01-28 04:00:32 +00:00
parent 069a0e8535
commit ebd53b2c6d
29 changed files with 468 additions and 287 deletions

View file

@ -1,3 +1,7 @@
2004-01-27 John Camelon
Renamed ContextualParseTest to CompletionParseTest.
Updated COMPLETION_PARSE clients to use SINGLE_NAME_REFERENCE rather than STATEMENT_START.
2004-01-27 Andrew Niefer 2004-01-27 Andrew Niefer
Added CompleteParseASTTest.testCBoolAsParameter Added CompleteParseASTTest.testCBoolAsParameter

View file

@ -36,10 +36,10 @@ import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
* To change the template for this generated type comment go to Window - * To change the template for this generated type comment go to Window -
* Preferences - Java - Code Generation - Code and Comments * Preferences - Java - Code Generation - Code and Comments
*/ */
public class ContextualParseTest extends CompleteParseBaseTest { public class CompletionParseTest extends CompleteParseBaseTest {
public ContextualParseTest(String name) { public CompletionParseTest(String name) {
super(name); super(name);
} }
@ -139,7 +139,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
assertNotNull( prefix ); assertNotNull( prefix );
assertTrue( node.getCompletionScope() instanceof IASTFunction ); assertTrue( node.getCompletionScope() instanceof IASTFunction );
assertEquals( prefix, i == 0 ? "a" :"" ); assertEquals( prefix, i == 0 ? "a" :"" );
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.STATEMENT_START ); assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1]; IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
kinds[0] = IASTNode.LookupKind.ALL; kinds[0] = IASTNode.LookupKind.ALL;
@ -419,7 +419,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
assertEquals( prefix, "a" ); assertEquals( prefix, "a" );
assertTrue( node.getCompletionScope() instanceof IASTCodeScope ); assertTrue( node.getCompletionScope() instanceof IASTCodeScope );
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.STATEMENT_START ); assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
assertNull( node.getCompletionContext() ); assertNull( node.getCompletionContext() );
ILookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.LOCAL_VARIABLES }, node.getCompletionContext() ); ILookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.LOCAL_VARIABLES }, node.getCompletionContext() );
@ -512,7 +512,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
assertEquals( inquestion.getName(), "SimpleTest"); assertEquals( inquestion.getName(), "SimpleTest");
assertTrue(inquestion.isConstructor()); assertTrue(inquestion.isConstructor());
assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.STATEMENT_START ); assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
assertNull(node.getCompletionContext()); assertNull(node.getCompletionContext());
LookupKind[] kinds = new LookupKind[ 1 ]; LookupKind[] kinds = new LookupKind[ 1 ];
kinds[0] = LookupKind.FIELDS; kinds[0] = LookupKind.FIELDS;
@ -545,7 +545,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
assertEquals( inquestion.getName(), "~SimpleTest"); assertEquals( inquestion.getName(), "~SimpleTest");
assertTrue(inquestion.isDestructor()); assertTrue(inquestion.isDestructor());
assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.STATEMENT_START ); assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
assertNull(node.getCompletionContext()); assertNull(node.getCompletionContext());
LookupKind[] kinds = new LookupKind[ 1 ]; LookupKind[] kinds = new LookupKind[ 1 ];
kinds[0] = LookupKind.FIELDS; kinds[0] = LookupKind.FIELDS;

View file

@ -31,7 +31,7 @@ public class ParserTestSuite extends TestCase {
suite.addTestSuite(QuickParseASTTests.class); suite.addTestSuite(QuickParseASTTests.class);
suite.addTestSuite(ParserSymbolTableTest.class); suite.addTestSuite(ParserSymbolTableTest.class);
suite.addTestSuite(CModelElementsTests.class); suite.addTestSuite(CModelElementsTests.class);
suite.addTestSuite(ContextualParseTest.class); suite.addTestSuite(CompletionParseTest.class);
// suite.addTestSuite(MacroTests.class); // suite.addTestSuite(MacroTests.class);
suite.addTestSuite( PreprocessorTest.class ); suite.addTestSuite( PreprocessorTest.class );
suite.addTestSuite( PreprocessorConditionalTest.class ); suite.addTestSuite( PreprocessorConditionalTest.class );

View file

@ -1,3 +1,10 @@
2004-01-27 John Camelon
Refactored parser to allow for cleaner content assist implementation.
Removed IASTCompletionNode.CompletionKind.STATEMENT_START as it is redundant.
Fixed bug 50640 - Wrong completion kind when expecting an exception
Fixed bug 50471 - Wrong completion kind after the "using" keyword
Fixed bug 50621 - Wrong completion kind in a class declaration
2004-01-17 Hoda Amer 2004-01-17 Hoda Amer
Added IASTCompletionNode.CompletionKind.New_Type_Reference Added IASTCompletionNode.CompletionKind.New_Type_Reference
for a completion kind after a new expression. for a completion kind after a new expression.

View file

@ -137,7 +137,7 @@ public interface IToken {
static public final int tDIV = 52; static public final int tDIV = 52;
static public final int tCLASSNAME = 53; // static public final int tCLASSNAME = 53;
static public final int t_and = 54; static public final int t_and = 54;
@ -307,4 +307,9 @@ public interface IToken {
static public final int tLAST = t_restrict; static public final int tLAST = t_restrict;
/**
* @return
*/
public abstract boolean isKeywordOrOperator();
} }

View file

@ -67,9 +67,6 @@ public interface IASTCompletionNode {
// any place where a type or variable name is expected to be introduced // any place where a type or variable name is expected to be introduced
public static final CompletionKind USER_SPECIFIED_NAME = new CompletionKind( 15 ); public static final CompletionKind USER_SPECIFIED_NAME = new CompletionKind( 15 );
// the beginning of a statement
public static final CompletionKind STATEMENT_START = new CompletionKind( 16 );
// after a new expression // after a new expression
public static final CompletionKind NEW_TYPE_REFERENCE = new CompletionKind( 17 ); public static final CompletionKind NEW_TYPE_REFERENCE = new CompletionKind( 17 );

View file

@ -16,7 +16,7 @@ import java.util.Iterator;
* @author jcamelon * @author jcamelon
* *
*/ */
public interface IASTScope extends IASTNode{ public interface IASTScope extends IASTNode {
public Iterator getDeclarations() throws ASTNotImplementedException; public Iterator getDeclarations() throws ASTNotImplementedException;
} }

View file

@ -25,13 +25,17 @@ import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTNode; import org.eclipse.cdt.core.parser.ast.IASTNode;
import org.eclipse.cdt.core.parser.ast.IASTScope; 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.internal.core.parser.ast.ASTCompletionNode; import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
import org.eclipse.cdt.internal.core.parser.token.*; import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.Token;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
/** /**
* @author jcamelon * @author jcamelon
@ -43,7 +47,6 @@ public class ContextualParser extends Parser implements IParser {
protected IASTNode context; protected IASTNode context;
protected IToken finalToken; protected IToken finalToken;
private Set keywordSet; private Set keywordSet;
private int boundaryOffset;
/** /**
* @param scanner * @param scanner
@ -62,7 +65,6 @@ public class ContextualParser extends Parser implements IParser {
*/ */
public IASTCompletionNode parse(int offset) { public IASTCompletionNode parse(int offset) {
scanner.setOffsetBoundary(offset); scanner.setOffsetBoundary(offset);
boundaryOffset = offset;
translationUnit(); translationUnit();
return new ASTCompletionNode( getCompletionKind(), getCompletionScope(), getCompletionContext(), getCompletionPrefix(), reconcileKeywords( getKeywordSet(), getCompletionPrefix() ) ); return new ASTCompletionNode( getCompletionKind(), getCompletionScope(), getCompletionContext(), getCompletionPrefix(), reconcileKeywords( getKeywordSet(), getCompletionPrefix() ) );
} }
@ -135,7 +137,7 @@ public class ContextualParser extends Parser implements IParser {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCurrentScope(org.eclipse.cdt.core.parser.ast.IASTScope) * @see org.eclipse.cdt.internal.core.parser.Parser#setCurrentScope(org.eclipse.cdt.core.parser.ast.IASTScope)
*/ */
protected void setCurrentScope(IASTScope scope) { protected void setCompletionScope(IASTScope scope) {
this.scope = scope; this.scope = scope;
} }
@ -168,8 +170,9 @@ public class ContextualParser extends Parser implements IParser {
*/ */
protected void handleOffsetLimitException(OffsetLimitReachedException exception) throws OffsetLimitReachedException { protected void handleOffsetLimitException(OffsetLimitReachedException exception) throws OffsetLimitReachedException {
setCompletionToken( exception.getFinalToken() ); setCompletionToken( exception.getFinalToken() );
if( (finalToken!= null )&& (finalToken.getEndOffset() != boundaryOffset )) if( (finalToken!= null )&& (finalToken.isKeywordOrOperator() ))
setCompletionToken(null); setCompletionToken(null);
throw exception; throw exception;
} }
@ -197,13 +200,77 @@ public class ContextualParser extends Parser implements IParser {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionContextForExpression(org.eclipse.cdt.core.parser.ast.IASTExpression, boolean) * @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionContextForExpression(org.eclipse.cdt.core.parser.ast.IASTExpression, boolean)
*/ */
protected void setCompletionContextForExpression( protected IASTNode getCompletionContextForExpression(
IASTExpression firstExpression, IASTExpression firstExpression,
boolean isTemplate) { boolean isTemplate) {
setCompletionContext( astFactory.getCompletionContext( (isTemplate return astFactory.getCompletionContext( (isTemplate
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS ? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION), : IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION),
firstExpression ) ); firstExpression ) ;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTNode, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key, java.lang.String)
*/
protected void setCompletionValues(
IASTScope scope,
CompletionKind kind,
Key key,
IASTNode node, String prefix) throws EndOfFileException {
setCompletionValues(scope, kind, key, node );
setCompletionToken( new Token( IToken.tIDENTIFIER, prefix ) );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTNode, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key)
*/
protected void setCompletionValues(
IASTScope scope,
CompletionKind kind,
Key key ) throws EndOfFileException {
setCompletionValues(scope, kind, key, null );
}
protected void setCompletionValues(
IASTScope scope,
CompletionKind kind,
Key key,
IASTNode node ) throws EndOfFileException
{
setCompletionScope(scope);
setCompletionKeywords(key);
setCompletionKind(kind);
setCompletionContext(node);
checkEndOfFile();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#getCompletionKindForDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope)
*/
protected CompletionKind getCompletionKindForDeclaration(IASTScope scope) {
IASTCompletionNode.CompletionKind kind = null;
if( scope instanceof IASTClassSpecifier )
kind = CompletionKind.FIELD_TYPE;
else if (scope instanceof IASTCodeScope)
// kind = CompletionKind.STATEMENT_START;
kind = CompletionKind.SINGLE_NAME_REFERENCE;
else
kind = CompletionKind.VARIABLE_TYPE;
return kind;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key, org.eclipse.cdt.core.parser.ast.IASTExpression, boolean)
*/
protected void setCompletionValues(
IASTScope scope,
CompletionKind kind,
Key key,
IASTExpression firstExpression,
boolean isTemplate) throws EndOfFileException {
setCompletionValues(scope,kind,key, getCompletionContextForExpression(firstExpression,isTemplate) );
} }
} }

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTScope;
/** /**
* @author jcamelon * @author jcamelon
@ -454,4 +455,11 @@ public class Declarator implements IParameterCollection, IDeclaratorOwner, IDecl
return varArgs; return varArgs;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IDeclarator#getScope()
*/
public IASTScope getScope() {
return getDeclarationWrapper().getScope();
}
} }

View file

@ -14,12 +14,14 @@ import java.util.List;
import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator; import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier; import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
import org.eclipse.cdt.core.parser.ast.IASTScope;
/** /**
* @author jcamelon * @author jcamelon
* *
*/ */
public interface IDeclarator public interface IDeclarator
{ {
public IASTScope getScope();
/** /**
* @return * @return
*/ */

View file

@ -60,7 +60,9 @@ 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.ast.IASTExpression.Kind; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.internal.core.parser.token.*; import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.Token;
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key; import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
/** /**
@ -125,6 +127,7 @@ public abstract class Parser implements IParser
this.requestor = callback; this.requestor = callback;
this.language = language; this.language = language;
this.log = log; this.log = log;
} }
// counter that keeps track of the number of times Parser.parse() is called // counter that keeps track of the number of times Parser.parse() is called
@ -260,14 +263,18 @@ public abstract class Parser 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 );
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 );
// optional :: and nested classes handled in name // optional :: and nested classes handled in name
TokenDuple duple = null; TokenDuple duple = null;
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
duple = name(); duple = name(scope);
else else
throw backtrack; throw backtrack;
if (LT(1) == IToken.tSEMI) if (LT(1) == IToken.tSEMI)
@ -298,12 +305,14 @@ public abstract class Parser implements IParser
{ {
typeName = true; typeName = true;
consume(IToken.t_typename); consume(IToken.t_typename);
} }
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.EMPTY );
TokenDuple name = null; TokenDuple 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(); name = name(scope);
} }
else else
{ {
@ -707,17 +716,19 @@ public abstract class Parser implements IParser
IASTTemplate ownerTemplate) IASTTemplate ownerTemplate)
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
setCurrentScope(scope); IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope);
setCompletionKeywords( Key.DECLARATION ); setCompletionValues(scope, kind, Key.DECLARATION );
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);
setCompletionKind( CompletionKind.NO_SUCH_KIND ); setCompletionValues( scope, CompletionKind.NO_SUCH_KIND, Key.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);
IToken last = consume(IToken.tSEMI); IToken last = consume(IToken.tSEMI);
IASTASMDefinition asmDefinition; IASTASMDefinition asmDefinition;
try try
{ {
@ -735,6 +746,7 @@ public abstract class Parser 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
asmDefinition.acceptElement(requestor); asmDefinition.acceptElement(requestor);
setCompletionValues(scope, kind, Key.DECLARATION );
return; return;
case IToken.t_namespace : case IToken.t_namespace :
namespaceDefinition(scope); namespaceDefinition(scope);
@ -755,23 +767,24 @@ public abstract class Parser implements IParser
default : default :
simpleDeclarationStrategyUnion(scope, ownerTemplate); simpleDeclarationStrategyUnion(scope, ownerTemplate);
} }
setCurrentScope(scope); setCompletionValues(scope, kind, Key.DECLARATION );
setCompletionKeywords( Key.DECLARATION );
} }
protected void simpleDeclarationStrategyUnion(
/**
* @param scope
* @return
*/
protected IASTCompletionNode.CompletionKind getCompletionKindForDeclaration(IASTScope scope) {
return null;
}
protected void simpleDeclarationStrategyUnion(
IASTScope scope, IASTScope scope,
IASTTemplate ownerTemplate) IASTTemplate ownerTemplate)
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
IToken mark = mark(); IToken mark = mark();
if( scope instanceof IASTClassSpecifier )
setCompletionKind( CompletionKind.FIELD_TYPE );
else if (scope instanceof IASTCodeScope)
setCompletionKind( CompletionKind.SINGLE_NAME_REFERENCE);
else
setCompletionKind( CompletionKind.VARIABLE_TYPE );
try try
{ {
simpleDeclaration( simpleDeclaration(
@ -827,6 +840,7 @@ public abstract class Parser implements IParser
{ {
IToken first = consume(IToken.t_namespace); IToken first = consume(IToken.t_namespace);
setCompletionValues(scope,CompletionKind.USER_SPECIFIED_NAME, Key.EMPTY );
IToken identifier = null; IToken identifier = null;
// optional name // optional name
if (LT(1) == IToken.tIDENTIFIER) if (LT(1) == IToken.tIDENTIFIER)
@ -853,14 +867,15 @@ public abstract class Parser implements IParser
throw backtrack; throw backtrack;
} }
namespaceDefinition.enterScope( requestor ); namespaceDefinition.enterScope( requestor );
namepsaceDeclarationLoop : while (LT(1) != IToken.tRBRACE) setCompletionValues(scope,CompletionKind.VARIABLE_TYPE, Key.DECLARATION );
namespaceDeclarationLoop : while (LT(1) != IToken.tRBRACE)
{ {
IToken checkToken = LA(1); IToken checkToken = LA(1);
switch (LT(1)) switch (LT(1))
{ {
case IToken.tRBRACE : case IToken.tRBRACE :
//consume(Token.tRBRACE); //consume(Token.tRBRACE);
break namepsaceDeclarationLoop; break namespaceDeclarationLoop;
default : default :
try try
{ {
@ -876,6 +891,7 @@ public abstract class Parser implements IParser
if (checkToken == LA(1)) if (checkToken == LA(1))
errorHandling(); errorHandling();
} }
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,Key.EMPTY);
// consume the } // consume the }
IToken last = consume(IToken.tRBRACE); IToken last = consume(IToken.tRBRACE);
@ -885,12 +901,13 @@ public abstract class Parser implements IParser
} }
else if( LT(1) == IToken.tASSIGN ) else if( LT(1) == IToken.tASSIGN )
{ {
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,Key.EMPTY);
consume( IToken.tASSIGN ); consume( IToken.tASSIGN );
if( identifier == null ) if( identifier == null )
throw backtrack; throw backtrack;
ITokenDuple duple = name(); ITokenDuple duple = name(scope);
consume( IToken.tSEMI ); consume( IToken.tSEMI );
try try
{ {
@ -935,7 +952,7 @@ public abstract class Parser implements IParser
DeclarationWrapper sdw = DeclarationWrapper sdw =
new DeclarationWrapper(scope, firstToken.getOffset(), firstToken.getLineNumber(), ownerTemplate); new DeclarationWrapper(scope, firstToken.getOffset(), firstToken.getLineNumber(), ownerTemplate);
setCompletionKeywords( Key.DECL_SPECIFIER_SEQUENCE ); setCompletionValues( scope, getCompletionKindForDeclaration(scope), Key.DECL_SPECIFIER_SEQUENCE );
declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR ); declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR );
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED ) if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED )
try try
@ -1109,7 +1126,7 @@ public abstract class Parser implements IParser
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
consume(IToken.tCOLON); consume(IToken.tCOLON);
IASTScope scope = d.getDeclarationWrapper().getScope();
try try
{ {
for (;;) for (;;)
@ -1118,7 +1135,7 @@ public abstract class Parser implements IParser
break; break;
ITokenDuple duple = name(); ITokenDuple duple = name(scope);
consume(IToken.tLPAREN); consume(IToken.tLPAREN);
IASTExpression expressionList = null; IASTExpression expressionList = null;
@ -1528,11 +1545,11 @@ public abstract class Parser 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().getLastToken(); last = name(sdw.getScope()).getLastToken();
if (LT(1) == IToken.t_template) if (LT(1) == IToken.t_template)
{ {
consume(IToken.t_template); consume(IToken.t_template);
last = templateId(); last = templateId(sdw.getScope());
} }
ITokenDuple duple = new TokenDuple(first, last); ITokenDuple duple = new TokenDuple(first, last);
sdw.setTypeName(duple); sdw.setTypeName(duple);
@ -1572,7 +1589,7 @@ public abstract class Parser implements IParser
return; return;
} }
ITokenDuple d = name(); ITokenDuple d = name(sdw.getScope());
sdw.setTypeName(d); sdw.setTypeName(d);
sdw.setSimpleType( IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME ); sdw.setSimpleType( IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME );
flags.setEncounteredTypename(true); flags.setEncounteredTypename(true);
@ -1643,7 +1660,7 @@ public abstract class Parser implements IParser
break; break;
} }
ITokenDuple d = name(); ITokenDuple d = name(sdw.getScope());
IASTTypeSpecifier elaboratedTypeSpec = null; IASTTypeSpecifier elaboratedTypeSpec = null;
final boolean isForewardDecl = ( LT(1) == IToken.tSEMI ); final boolean isForewardDecl = ( LT(1) == IToken.tSEMI );
@ -1741,9 +1758,9 @@ public abstract class Parser implements IParser
* *
* @throws BacktrackException * @throws BacktrackException
*/ */
protected ITokenDuple className() throws EndOfFileException, BacktrackException protected ITokenDuple className(IASTScope scope) throws EndOfFileException, BacktrackException
{ {
ITokenDuple duple = name(); ITokenDuple duple = name(scope);
IToken last = duple.getLastToken(); IToken last = duple.getLastToken();
if (LT(1) == IToken.tLT) { if (LT(1) == IToken.tLT) {
last = consumeTemplateParameters(duple.getLastToken()); last = consumeTemplateParameters(duple.getLastToken());
@ -1762,9 +1779,9 @@ public abstract class Parser implements IParser
* *
* @throws BacktrackException request a backtrack * @throws BacktrackException request a backtrack
*/ */
protected IToken templateId() throws EndOfFileException, BacktrackException protected IToken templateId(IASTScope scope) throws EndOfFileException, BacktrackException
{ {
ITokenDuple duple = name(); ITokenDuple duple = name(scope);
IToken last = consumeTemplateParameters(duple.getLastToken()); IToken last = consumeTemplateParameters(duple.getLastToken());
return last; return last;
} }
@ -1779,7 +1796,7 @@ public abstract class Parser implements IParser
* *
* @throws BacktrackException request a backtrack * @throws BacktrackException request a backtrack
*/ */
protected TokenDuple name() throws BacktrackException, EndOfFileException protected TokenDuple name(IASTScope scope) throws BacktrackException, EndOfFileException
{ {
IToken first = LA(1); IToken first = LA(1);
IToken last = null; IToken last = null;
@ -2184,7 +2201,7 @@ public abstract class Parser implements IParser
{ {
try try
{ {
if( ! astFactory.queryIsTypeName( scope, name() ) ) if( ! astFactory.queryIsTypeName( scope, name(scope) ) )
failed = true; failed = true;
} }
catch (Exception e) catch (Exception e)
@ -2363,7 +2380,7 @@ public abstract class Parser implements IParser
{ {
try try
{ {
ITokenDuple duple = name(); ITokenDuple duple = name(d.getDeclarationWrapper().getScope());
d.setName(duple); d.setName(duple);
} }
@ -2504,7 +2521,7 @@ public abstract class Parser implements IParser
{ {
try try
{ {
nameDuple = name(); nameDuple = name(d.getScope());
} }
catch( BacktrackException bt ) catch( BacktrackException bt )
{ {
@ -2705,11 +2722,10 @@ public abstract class Parser implements IParser
ITokenDuple duple = null; ITokenDuple duple = null;
setCompletionKind( CompletionKind.USER_SPECIFIED_NAME ); setCompletionValues(sdw.getScope(), CompletionKind.USER_SPECIFIED_NAME, Key.EMPTY );
setCompletionKeywords( Key.EMPTY );
// class name // class name
if (LT(1) == IToken.tIDENTIFIER) if (LT(1) == IToken.tIDENTIFIER)
duple = className(); duple = className(sdw.getScope());
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)
@ -2752,10 +2768,7 @@ public abstract class Parser implements IParser
if (LT(1) == IToken.tLBRACE) if (LT(1) == IToken.tLBRACE)
{ {
consume(IToken.tLBRACE); consume(IToken.tLBRACE);
setCompletionKind(CompletionKind.FIELD_TYPE); setCompletionValues(astClassSpecifier, CompletionKind.FIELD_TYPE, Key.DECLARATION );
setCompletionContext(null);
setCompletionKeywords(Key.DECLARATION);
setCurrentScope(astClassSpecifier);
astClassSpecifier.enterScope( requestor ); astClassSpecifier.enterScope( requestor );
memberDeclarationLoop : while (LT(1) != IToken.tRBRACE) memberDeclarationLoop : while (LT(1) != IToken.tRBRACE)
{ {
@ -2831,9 +2844,12 @@ public abstract class Parser implements IParser
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
consume(IToken.tCOLON); consume(IToken.tCOLON);
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSets.Key.BASE_SPECIFIER );
boolean isVirtual = false; boolean isVirtual = false;
ASTAccessVisibility visibility = ASTAccessVisibility.PUBLIC; ASTAccessVisibility visibility = ASTAccessVisibility.PUBLIC;
ITokenDuple nameDuple = null; ITokenDuple nameDuple = null;
baseSpecifierLoop : for (;;) baseSpecifierLoop : for (;;)
{ {
switch (LT(1)) switch (LT(1))
@ -2855,7 +2871,7 @@ public abstract class Parser implements IParser
break; break;
case IToken.tCOLONCOLON : case IToken.tCOLONCOLON :
case IToken.tIDENTIFIER : case IToken.tIDENTIFIER :
nameDuple = name(); nameDuple = name(astClassSpec);
break; break;
case IToken.tCOMMA : case IToken.tCOMMA :
try try
@ -2917,10 +2933,7 @@ public abstract class Parser implements IParser
*/ */
protected void statement(IASTScope scope) throws EndOfFileException, BacktrackException protected void statement(IASTScope scope) throws EndOfFileException, BacktrackException
{ {
setCurrentScope(scope); setCompletionValues(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT);
setCompletionKind( CompletionKind.STATEMENT_START );
setCompletionKeywords( Key.STATEMENT );
switch (LT(1)) switch (LT(1))
{ {
@ -3054,10 +3067,10 @@ public abstract class Parser implements IParser
try try
{ {
IASTExpression thisExpression = expression(scope); IASTExpression thisExpression = expression(scope);
if( queryLookaheadCapability() ) // if( queryLookaheadCapability() )
consume(IToken.tSEMI); consume(IToken.tSEMI);
else // else
throw new EndOfFileException(); // throw new EndOfFileException();
thisExpression.acceptElement( requestor ); thisExpression.acceptElement( requestor );
return; return;
} }
@ -3083,7 +3096,11 @@ public abstract class Parser 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);
consume(IToken.tLPAREN); consume(IToken.tLPAREN);
setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,Key.DECL_SPECIFIER_SEQUENCE );
if( ! queryLookaheadCapability(2))
throw new EndOfFileException();
if( LT(1) == IToken.tELLIPSIS ) if( LT(1) == IToken.tELLIPSIS )
consume( IToken.tELLIPSIS ); consume( IToken.tELLIPSIS );
else else
@ -3173,12 +3190,15 @@ public abstract class Parser implements IParser
newScope.enterScope( requestor ); newScope.enterScope( requestor );
} }
IToken checkToken = null; IToken checkToken = null;
setCurrentScope(createNewScope ? newScope : scope); setCompletionValues(
setCompletionKind( CompletionKind.STATEMENT_START ); (createNewScope ? newScope : scope ),
while (queryLookaheadCapability() && LT(1) != IToken.tRBRACE) CompletionKind.SINGLE_NAME_REFERENCE,
KeywordSets.Key.STATEMENT );
while (LT(1) != IToken.tRBRACE)
// while (queryLookaheadCapability() && LT(1) != IToken.tRBRACE)
{ {
checkToken = LA(1); checkToken = LA(1);
setCurrentScope(createNewScope ? newScope : scope);
try try
{ {
statement(createNewScope ? newScope : scope ); statement(createNewScope ? newScope : scope );
@ -3189,14 +3209,14 @@ public abstract class Parser implements IParser
if( LA(1) == checkToken ) if( LA(1) == checkToken )
errorHandling(); errorHandling();
} }
setCurrentScope(createNewScope ? newScope : scope); setCompletionValues(((createNewScope ? newScope : scope )), CompletionKind.SINGLE_NAME_REFERENCE,
KeywordSets.Key.STATEMENT );
setCompletionKind( CompletionKind.STATEMENT_START );
setCompletionKeywords( Key.STATEMENT );
} }
if( queryLookaheadCapability() ) consume(IToken.tRBRACE); consume(IToken.tRBRACE);
else throw new EndOfFileException(); // if( queryLookaheadCapability() ) consume(IToken.tRBRACE);
// else throw new EndOfFileException();
if( createNewScope ) if( createNewScope )
newScope.exitScope( requestor ); newScope.exitScope( requestor );
} }
@ -3215,7 +3235,7 @@ public abstract class Parser implements IParser
public IASTExpression expression(IASTScope scope) throws BacktrackException, EndOfFileException public IASTExpression expression(IASTScope scope) throws BacktrackException, EndOfFileException
{ {
IASTExpression assignmentExpression = assignmentExpression(scope); IASTExpression assignmentExpression = assignmentExpression(scope);
if( !queryLookaheadCapability() ) return assignmentExpression; // if( !queryLookaheadCapability() ) return assignmentExpression;
while (LT(1) == IToken.tCOMMA) while (LT(1) == IToken.tCOMMA)
{ {
consume(); consume();
@ -3257,7 +3277,7 @@ public abstract class Parser implements IParser
&& conditionalExpression.getExpressionKind() && conditionalExpression.getExpressionKind()
== IASTExpression.Kind.CONDITIONALEXPRESSION) == IASTExpression.Kind.CONDITIONALEXPRESSION)
return conditionalExpression; return conditionalExpression;
if( !queryLookaheadCapability() ) return conditionalExpression; // if( !queryLookaheadCapability() ) return conditionalExpression;
switch (LT(1)) { switch (LT(1)) {
case IToken.tASSIGN : case IToken.tASSIGN :
return assignmentOperatorExpression( return assignmentOperatorExpression(
@ -3388,7 +3408,7 @@ public abstract class Parser implements IParser
throws BacktrackException, EndOfFileException throws BacktrackException, EndOfFileException
{ {
IASTExpression firstExpression = logicalOrExpression(scope); IASTExpression firstExpression = logicalOrExpression(scope);
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
if (LT(1) == IToken.tQUESTION) if (LT(1) == IToken.tQUESTION)
{ {
consume(); consume();
@ -3425,7 +3445,7 @@ public abstract class Parser implements IParser
throws BacktrackException, EndOfFileException throws BacktrackException, EndOfFileException
{ {
IASTExpression firstExpression = logicalAndExpression(scope); IASTExpression firstExpression = logicalAndExpression(scope);
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
while (LT(1) == IToken.tOR) while (LT(1) == IToken.tOR)
{ {
consume(); consume();
@ -3461,7 +3481,7 @@ public abstract class Parser implements IParser
throws BacktrackException, EndOfFileException throws BacktrackException, EndOfFileException
{ {
IASTExpression firstExpression = inclusiveOrExpression( scope ); IASTExpression firstExpression = inclusiveOrExpression( scope );
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
while (LT(1) == IToken.tAND) while (LT(1) == IToken.tAND)
{ {
consume(); consume();
@ -3496,7 +3516,7 @@ public abstract class Parser implements IParser
throws BacktrackException, EndOfFileException throws BacktrackException, EndOfFileException
{ {
IASTExpression firstExpression = exclusiveOrExpression(scope); IASTExpression firstExpression = exclusiveOrExpression(scope);
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
while (LT(1) == IToken.tBITOR) while (LT(1) == IToken.tBITOR)
{ {
consume(); consume();
@ -3532,7 +3552,7 @@ public abstract class Parser implements IParser
throws BacktrackException, EndOfFileException throws BacktrackException, EndOfFileException
{ {
IASTExpression firstExpression = andExpression( scope ); IASTExpression firstExpression = andExpression( scope );
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
while (LT(1) == IToken.tXOR) while (LT(1) == IToken.tXOR)
{ {
consume(); consume();
@ -3568,7 +3588,7 @@ public abstract class Parser implements IParser
protected IASTExpression andExpression(IASTScope scope) throws EndOfFileException, BacktrackException protected IASTExpression andExpression(IASTScope scope) throws EndOfFileException, BacktrackException
{ {
IASTExpression firstExpression = equalityExpression(scope); IASTExpression firstExpression = equalityExpression(scope);
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
while (LT(1) == IToken.tAMPER) while (LT(1) == IToken.tAMPER)
{ {
consume(); consume();
@ -3606,7 +3626,7 @@ public abstract class Parser implements IParser
IASTExpression firstExpression = relationalExpression(scope); IASTExpression firstExpression = relationalExpression(scope);
for (;;) for (;;)
{ {
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
switch (LT(1)) switch (LT(1))
{ {
case IToken.tEQUAL : case IToken.tEQUAL :
@ -3652,7 +3672,7 @@ public abstract class Parser implements IParser
IASTExpression firstExpression = shiftExpression(scope); IASTExpression firstExpression = shiftExpression(scope);
for (;;) for (;;)
{ {
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
switch (LT(1)) switch (LT(1))
{ {
case IToken.tGT : case IToken.tGT :
@ -3732,7 +3752,7 @@ public abstract class Parser implements IParser
IASTExpression firstExpression = additiveExpression(scope); IASTExpression firstExpression = additiveExpression(scope);
for (;;) for (;;)
{ {
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
switch (LT(1)) switch (LT(1))
{ {
case IToken.tSHIFTL : case IToken.tSHIFTL :
@ -3777,7 +3797,7 @@ public abstract class Parser implements IParser
IASTExpression firstExpression = multiplicativeExpression( scope ); IASTExpression firstExpression = multiplicativeExpression( scope );
for (;;) for (;;)
{ {
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
switch (LT(1)) switch (LT(1))
{ {
case IToken.tPLUS : case IToken.tPLUS :
@ -3822,7 +3842,7 @@ public abstract class Parser implements IParser
IASTExpression firstExpression = pmExpression(scope); IASTExpression firstExpression = pmExpression(scope);
for (;;) for (;;)
{ {
if( !queryLookaheadCapability() ) return firstExpression; // if( !queryLookaheadCapability() ) return firstExpression;
switch (LT(1)) switch (LT(1))
{ {
case IToken.tSTAR : case IToken.tSTAR :
@ -3877,7 +3897,7 @@ public abstract class Parser implements IParser
IASTExpression firstExpression = castExpression(scope); IASTExpression firstExpression = castExpression(scope);
for (;;) for (;;)
{ {
if( ! queryLookaheadCapability() ) return firstExpression; // if( ! queryLookaheadCapability() ) return firstExpression;
switch (LT(1)) switch (LT(1))
{ {
case IToken.tDOTSTAR : case IToken.tDOTSTAR :
@ -3920,7 +3940,7 @@ public abstract class Parser implements IParser
protected IASTExpression castExpression( IASTScope scope ) throws EndOfFileException, BacktrackException protected IASTExpression castExpression( IASTScope scope ) 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( ! queryLookaheadCapability() ) return unaryExpression(scope); // if( ! queryLookaheadCapability() ) return unaryExpression(scope);
if (LT(1) == IToken.tLPAREN) if (LT(1) == IToken.tLPAREN)
{ {
IToken mark = mark(); IToken mark = mark();
@ -3977,7 +3997,7 @@ public abstract class Parser implements IParser
{ {
try try
{ {
name = name(); name = name(scope);
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME; kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
break; break;
} }
@ -4024,7 +4044,7 @@ public abstract class Parser implements IParser
case IToken.tIDENTIFIER : case IToken.tIDENTIFIER :
if( encounteredType ) break simpleMods; if( encounteredType ) break simpleMods;
encounteredType = true; encounteredType = true;
name = name(); name = name(scope);
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME; kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
break; break;
@ -4108,7 +4128,7 @@ public abstract class Parser implements IParser
consume(); consume();
try try
{ {
name = name(); name = name(scope);
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME; kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
} catch( BacktrackException b ) } catch( BacktrackException b )
{ {
@ -4122,7 +4142,7 @@ public abstract class Parser implements IParser
if( kind == null ) if( kind == null )
throw backtrack; throw backtrack;
TypeId id = new TypeId(); TypeId id = new TypeId(scope);
IToken last = lastToken; IToken last = lastToken;
lastToken = consumeTemplateParameters( last ); lastToken = consumeTemplateParameters( last );
@ -4407,7 +4427,7 @@ public abstract class Parser implements IParser
protected IASTExpression unaryExpression( IASTScope scope ) protected IASTExpression unaryExpression( IASTScope scope )
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
if( ! queryLookaheadCapability() ) return postfixExpression( scope ); // if( ! queryLookaheadCapability() ) return postfixExpression( scope );
switch (LT(1)) switch (LT(1))
{ {
case IToken.tSTAR : case IToken.tSTAR :
@ -4532,13 +4552,13 @@ public abstract class Parser implements IParser
{ {
IASTExpression firstExpression = null; IASTExpression firstExpression = null;
boolean isTemplate = false; boolean isTemplate = false;
checkEndOfFile();
if( ! queryLookaheadCapability() ) return primaryExpression(scope); // if( ! queryLookaheadCapability() ) return primaryExpression(scope);
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(); ITokenDuple nestedName = name(scope);
boolean templateTokenConsumed = false; boolean templateTokenConsumed = false;
if( LT(1) == IToken.t_template ) if( LT(1) == IToken.t_template )
{ {
@ -4549,7 +4569,7 @@ public abstract class Parser implements IParser
ITokenDuple templateId = null; ITokenDuple templateId = null;
try try
{ {
templateId = new TokenDuple( current, templateId() ); templateId = new TokenDuple( current, templateId(scope) );
} }
catch( BacktrackException bt ) catch( BacktrackException bt )
{ {
@ -4694,7 +4714,7 @@ public abstract class Parser implements IParser
IASTExpression secondExpression = null; IASTExpression secondExpression = null;
for (;;) for (;;)
{ {
if( ! queryLookaheadCapability() )return firstExpression; // if( ! queryLookaheadCapability() )return firstExpression;
switch (LT(1)) switch (LT(1))
{ {
case IToken.tLBRACKET : case IToken.tLBRACKET :
@ -4799,23 +4819,26 @@ public abstract class Parser implements IParser
// member access // member access
consume(IToken.tDOT); consume(IToken.tDOT);
try if( queryLookaheadCapability() )
{
if (LT(1) == IToken.t_template) if (LT(1) == IToken.t_template)
{ {
consume(IToken.t_template); consume(IToken.t_template);
isTemplate = true; isTemplate = true;
} }
} catch( OffsetLimitReachedException olre )
{
setCompletionToken( null );
}
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
setCompletionContextForExpression( firstExpression, isTemplate ); // if( ! queryLookaheadCapability() )
setCompletionKind( IASTCompletionNode.CompletionKind.MEMBER_REFERENCE ); // throw new EndOfFileException();
secondExpression = primaryExpression(scope); secondExpression = primaryExpression(scope);
checkEndOfFile();
// if( ! queryLookaheadCapability() )
// throw new EndOfFileException();
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSets.Key.EMPTY );
try try
{ {
firstExpression = firstExpression =
@ -4833,35 +4856,35 @@ public abstract class Parser implements IParser
catch (ASTSemanticException e5) catch (ASTSemanticException e5)
{ {
failParse(); failParse();
setCompletionContext( null );
throw backtrack; throw backtrack;
} catch (Exception e) } catch (Exception e)
{ {
setCompletionContext( null );
throw backtrack; throw backtrack;
} }
break; break;
case IToken.tARROW : case IToken.tARROW :
// member access // member access
consume(IToken.tARROW); consume(IToken.tARROW);
try if( queryLookaheadCapability() )
{ if (LT(1) == IToken.t_template)
if (LT(1) == IToken.t_template)
{ {
consume(IToken.t_template); consume(IToken.t_template);
isTemplate = true; isTemplate = true;
} }
} catch( OffsetLimitReachedException olre )
{
setCompletionToken( null );
}
setCompletionContextForExpression( firstExpression, isTemplate ); setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
setCompletionKind( IASTCompletionNode.CompletionKind.MEMBER_REFERENCE );
// if( ! queryLookaheadCapability() )
// throw new EndOfFileException();
secondExpression = primaryExpression(scope); secondExpression = primaryExpression(scope);
checkEndOfFile();
// if( ! queryLookaheadCapability() )
// throw new EndOfFileException();
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSets.Key.EMPTY );
try try
{ {
firstExpression = firstExpression =
@ -4879,11 +4902,9 @@ public abstract class Parser implements IParser
catch (ASTSemanticException e) catch (ASTSemanticException e)
{ {
failParse(); failParse();
setCompletionContext( null );
throw backtrack; throw backtrack;
} catch (Exception e) } catch (Exception e)
{ {
setCompletionContext( null );
throw backtrack; throw backtrack;
} }
break; break;
@ -4893,31 +4914,44 @@ public abstract class Parser implements IParser
} }
} }
/**
* @param scope
/** * @param kind
* @param key
* @param firstExpression * @param firstExpression
* @param isTemplate * @param isTemplate
*/ */
protected void setCompletionContextForExpression(IASTExpression firstExpression, boolean isTemplate) { protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, boolean isTemplate) throws EndOfFileException {
} }
/** /**
* @return * @return
* @throws EndOfFileException * @throws EndOfFileException
*/ */
protected boolean queryLookaheadCapability() throws EndOfFileException { protected boolean queryLookaheadCapability( int count ) throws EndOfFileException {
//make sure we can look ahead one before doing this //make sure we can look ahead one before doing this
boolean result = true; boolean result = true;
try try
{ {
LA(1); LA(count);
} }
catch( OffsetLimitReachedException olre ) catch( EndOfFileException olre )
{ {
result = false; result = false;
} }
return result; return result;
} }
protected boolean queryLookaheadCapability() throws EndOfFileException {
return queryLookaheadCapability(1);
}
protected void checkEndOfFile() throws EndOfFileException
{
LA(1);
}
protected IASTExpression specialCastExpression( IASTScope scope, protected IASTExpression specialCastExpression( IASTScope scope,
IASTExpression.Kind kind) IASTExpression.Kind kind)
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
@ -4984,21 +5018,7 @@ public abstract class Parser implements IParser
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
IToken t = null; IToken t = null;
IASTExpression emptyExpression = null; // if( !queryLookaheadCapability() ) return emptyExpression;
try {
emptyExpression = astFactory.createExpression(
scope,
IASTExpression.Kind.PRIMARY_EMPTY,
null,
null,
null,
null,
null, "", null);
} catch (ASTSemanticException e9) {
// TODO Auto-generated catch block
e9.printStackTrace();
}
if( !queryLookaheadCapability() ) return emptyExpression;
switch (LT(1)) switch (LT(1))
{ {
// TO DO: we need more literals... // TO DO: we need more literals...
@ -5152,7 +5172,7 @@ public abstract class Parser implements IParser
IToken mark = mark(); IToken mark = mark();
try try
{ {
duple = name(); duple = name(scope);
} }
catch( BacktrackException bt ) catch( BacktrackException bt )
{ {
@ -5189,7 +5209,7 @@ public abstract class Parser implements IParser
throw backtrack; throw backtrack;
} }
checkEndOfFile();
try try
{ {
return astFactory.createExpression( return astFactory.createExpression(
@ -5209,8 +5229,24 @@ public abstract class Parser implements IParser
throw backtrack; throw backtrack;
} }
default : default :
return emptyExpression; IASTExpression empty = null;
try {
empty = astFactory.createExpression(
scope,
IASTExpression.Kind.PRIMARY_EMPTY,
null,
null,
null,
null,
null, "", null);
} catch (ASTSemanticException e9) {
// TODO Auto-generated catch block
e9.printStackTrace();
}
return empty;
} }
} }
/** /**
* @throws Exception * @throws Exception
@ -5267,10 +5303,6 @@ public abstract class Parser implements IParser
lastToken; // last token we consumed lastToken; // last token we consumed
private boolean limitReached = false; private boolean limitReached = false;
protected void setCurrentScope( IASTScope scope )
{
}
/** /**
* Fetches a token from the scanner. * Fetches a token from the scanner.
* *
@ -5279,7 +5311,7 @@ public abstract class Parser implements IParser
*/ */
protected IToken fetchToken() throws EndOfFileException protected IToken fetchToken() throws EndOfFileException
{ {
if(limitReached) throw new OffsetLimitReachedException(getCompletionToken()); if(limitReached) throw new EndOfFileException();
try try
{ {
@ -5411,16 +5443,12 @@ public abstract class Parser implements IParser
return firstErrorOffset; return firstErrorOffset;
} }
protected void setCompletionContext( IASTNode node ) protected void setCompletionValues( IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSets.Key key )throws EndOfFileException
{ {
} }
protected void setCompletionKind( IASTCompletionNode.CompletionKind kind ) protected void setCompletionValues( IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSets.Key key, IASTNode node, String prefix )throws EndOfFileException
{ {
}
protected void setCompletionKeywords(KeywordSets.Key key )
{
} }
protected void setCompletionToken( IToken token ) protected void setCompletionToken( IToken token )

View file

@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator; import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier; import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
import org.eclipse.cdt.core.parser.ast.IASTScope;
/** /**
* @author jcamelon * @author jcamelon
@ -26,13 +27,13 @@ public class TypeId implements IDeclarator
private ITokenDuple name; private ITokenDuple name;
private List arrayModifiers = new ArrayList(); private List arrayModifiers = new ArrayList();
private List pointerOperators = new ArrayList(); private List pointerOperators = new ArrayList();
private final IASTScope scope;
/** /**
* *
*/ */
public TypeId() public TypeId(IASTScope scope )
{ {
super(); this.scope = scope;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IDeclarator#getPointerOperators() * @see org.eclipse.cdt.internal.core.parser.IDeclarator#getPointerOperators()
@ -76,4 +77,10 @@ public class TypeId implements IDeclarator
{ {
return name; return name;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IDeclarator#getScope()
*/
public IASTScope getScope() {
return scope;
}
} }

View file

@ -31,6 +31,8 @@ public class KeywordSets {
public static final Key DECL_SPECIFIER_SEQUENCE = new Key( 1 ); public static final Key DECL_SPECIFIER_SEQUENCE = new Key( 1 );
public static final Key DECLARATION = new Key( 2 ); public static final Key DECLARATION = new Key( 2 );
public static final Key STATEMENT = new Key(3); 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 );
/** /**
* @param enumValue * @param enumValue
*/ */
@ -50,6 +52,10 @@ public class KeywordSets {
return (Set) DECLARATION.get( language ); return (Set) DECLARATION.get( language );
if( kind == Key.STATEMENT ) if( kind == Key.STATEMENT )
return (Set) STATEMENT.get( language ); return (Set) STATEMENT.get( language );
if( kind == Key.BASE_SPECIFIER )
return BASE_SPECIFIER_CPP;
if( kind == Key.POST_USING )
return POST_USING_CPP;
//TODO finish this //TODO finish this
return null; return null;
@ -155,6 +161,7 @@ public class KeywordSets {
{ {
STATEMENT_CPP = new TreeSet( STATEMENT_C ); STATEMENT_CPP = new TreeSet( STATEMENT_C );
STATEMENT_CPP.add( Keywords.TRY ); STATEMENT_CPP.add( Keywords.TRY );
//TODO finish this
} }
private static final Hashtable STATEMENT; private static final Hashtable STATEMENT;
@ -164,4 +171,22 @@ public class KeywordSets {
STATEMENT.put( ParserLanguage.CPP, STATEMENT_CPP); STATEMENT.put( ParserLanguage.CPP, STATEMENT_CPP);
STATEMENT.put( ParserLanguage.C, STATEMENT_C ); STATEMENT.put( ParserLanguage.C, STATEMENT_C );
} }
private static final Set BASE_SPECIFIER_CPP;
static
{
BASE_SPECIFIER_CPP = new TreeSet();
BASE_SPECIFIER_CPP.add(Keywords.PUBLIC);
BASE_SPECIFIER_CPP.add(Keywords.PROTECTED);
BASE_SPECIFIER_CPP.add(Keywords.PRIVATE);
BASE_SPECIFIER_CPP.add(Keywords.VIRTUAL);
}
private static final Set POST_USING_CPP;
static
{
POST_USING_CPP = new TreeSet();
POST_USING_CPP.add(Keywords.NAMESPACE);
POST_USING_CPP.add(Keywords.TYPENAME);
}
} }

View file

@ -186,4 +186,18 @@ public class Token implements IToken {
return lineNumber; return lineNumber;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IToken#isKeyword()
*/
public boolean isKeywordOrOperator() {
if( type == IToken.tCHAR ) return false;
if( type == IToken.tFLOATINGPT ) return false;
if( type == IToken.tIDENTIFIER ) return false;
if( type == IToken.tINTEGER ) return false;
if( type == IToken.tSTRING ) return false;
if( type == IToken.tLSTRING ) return false;
if( type == IToken.tLCHAR ) return false;
return true;
}
} }

View file

@ -1,3 +1,14 @@
2004-01-27 John Camelon
Updated COMPLETION_PARSE clients to use SINGLE_NAME_REFERENCE rather than STATEMENT_START.
Renamed and updated CompletionTest_StatementStart_NoPrefix to CompletionTest_SingleName_Method_NoPrefix.
Renamed and updated CompletionTest_StatementStart_Prefix to CompletionTest_SingleName_Method_Prefix.
Renamed and updated CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640 to CompletionTest_ExceptionReference_NoPrefix and moved to passed tests folder.
Renamed and updated CompletionFailedTest_ExceptionReference_Prefix_Bug50640 to CompletionTest_ExceptionReference_Prefix and moved to passed tests folder.
Renamed and updated CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471 to CompletionTest_TypeRef_NoPrefix and moved to passed tests folder.
Renamed and updated CompletionFailedTest_NamespaceRef_Prefix_Bug50471 to CompletionTest_TypeRef_Prefix and moved to passed tests folder.
Renamed and updated CompletionFailedTest_ClassReference_Prefix_Bug50621 to CompletionTest_ClassReference_Prefix and moved to passed tests folder.
Renamed and updated CompletionFailedTest_ClassReference_NoPrefix_Bug50621 to CompletionTest_ClassReference_NoPrefix and moved to passed tests folder.
2004-01-27 Hoda Amer 2004-01-27 Hoda Amer
More Completion JUnit tests. More Completion JUnit tests.

View file

@ -46,8 +46,8 @@ public class AutomatedSuite extends TestSuite {
addTest(CompletionTest_ArgumentType_NoPrefix2_Bug50642.suite()); addTest(CompletionTest_ArgumentType_NoPrefix2_Bug50642.suite());
addTest(CompletionTest_ArgumentType_Prefix_Bug50642.suite()); addTest(CompletionTest_ArgumentType_Prefix_Bug50642.suite());
addTest(CompletionTest_ArgumentType_NoPrefix2_Bug50642.suite()); addTest(CompletionTest_ArgumentType_NoPrefix2_Bug50642.suite());
addTest(CompletionTest_StatementStart_Prefix.suite()); addTest(CompletionTest_SingleName_Method_Prefix.suite());
addTest(CompletionTest_StatementStart_NoPrefix.suite()); addTest(CompletionTest_SingleName_Method_NoPrefix.suite());
addTest(CompletionTest_SingleName_Prefix.suite()); addTest(CompletionTest_SingleName_Prefix.suite());
addTest(CompletionTest_SingleName_Prefix2.suite()); addTest(CompletionTest_SingleName_Prefix2.suite());
addTest(CompletionTest_SingleName_NoPrefix.suite()); addTest(CompletionTest_SingleName_NoPrefix.suite());
@ -60,14 +60,14 @@ public class AutomatedSuite extends TestSuite {
// Failed Tests // Failed Tests
addTest(CompletionFailedTest_ScopedReference_NoPrefix_Bug50152.suite()); addTest(CompletionFailedTest_ScopedReference_NoPrefix_Bug50152.suite());
addTest(CompletionFailedTest_ScopedReference_Prefix_Bug50152.suite()); addTest(CompletionFailedTest_ScopedReference_Prefix_Bug50152.suite());
addTest(CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471.suite()); addTest(CompletionTest_TypeRef_NoPrefix.suite());
addTest(CompletionFailedTest_NamespaceRef_Prefix_Bug50471.suite()); addTest(CompletionTest_TypeRef_Prefix.suite());
addTest(CompletionFailedTest_MacroRef_NoPrefix_Bug50487.suite()); addTest(CompletionFailedTest_MacroRef_NoPrefix_Bug50487.suite());
addTest(CompletionFailedTest_MacroRef_Prefix_Bug50487.suite()); addTest(CompletionFailedTest_MacroRef_Prefix_Bug50487.suite());
addTest(CompletionFailedTest_ClassReference_NoPrefix_Bug50621.suite()); addTest(CompletionTest_ClassReference_NoPrefix.suite());
addTest(CompletionFailedTest_ClassReference_Prefix_Bug50621.suite()); addTest(CompletionTest_ClassReference_Prefix.suite());
addTest(CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640.suite()); addTest(CompletionTest_ExceptionReference_NoPrefix.suite());
addTest(CompletionFailedTest_ExceptionReference_Prefix_Bug50640.suite()); addTest(CompletionTest_ExceptionReference_Prefix.suite());
addTest(CompletionFailedTest_NewTypeReference_NoPrefix_Bug50711.suite()); addTest(CompletionFailedTest_NewTypeReference_NoPrefix_Bug50711.suite());
addTest(CompletionFailedTest_NewTypeReference_Prefix_Bug50711.suite()); addTest(CompletionFailedTest_NewTypeReference_Prefix_Bug50711.suite());
} }

View file

@ -161,7 +161,7 @@ public abstract class CompletionProposalsBaseTest extends TestCase{
String[] expected = getExpectedResultsValues(); String[] expected = getExpectedResultsValues();
assertTrue(results.length >= expected.length); assertTrue(results.length >= expected.length);
for (int i = 0; i<expected.length; i++){ for (int i = 0; i< expected.length; i++){
ICompletionProposal proposal = results[i]; ICompletionProposal proposal = results[i];
String displayString = proposal.getDisplayString(); String displayString = proposal.getDisplayString();
assertEquals(displayString, expected[i]); assertEquals(displayString, expected[i]);

View file

@ -8,13 +8,12 @@
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests; package org.eclipse.cdt.ui.tests.text.contentassist;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/** /**
* @author hamer * @author hamer
@ -23,7 +22,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* Bug#50621 :Wrong completion kind in a class declaration * Bug#50621 :Wrong completion kind in a class declaration
* *
*/ */
public class CompletionFailedTest_ClassReference_NoPrefix_Bug50621 extends CompletionProposalsBaseTest{ public class CompletionTest_ClassReference_NoPrefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionFailedTestStart8.h"; private final String fileName = "CompletionFailedTestStart8.h";
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName; private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
@ -31,7 +30,7 @@ public class CompletionFailedTest_ClassReference_NoPrefix_Bug50621 extends Comp
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTCompilationUnit"; private final String expectedScopeName = "ASTCompilationUnit";
private final String expectedContextName = "null"; private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.USER_SPECIFIED_NAME; // sould be CompletionKind.CLASS_REFERENCE; private final CompletionKind expectedKind = CompletionKind.CLASS_REFERENCE;
private final String expectedPrefix = ""; private final String expectedPrefix = "";
private final String[] expectedResults = { private final String[] expectedResults = {
// Should be // Should be
@ -40,13 +39,13 @@ public class CompletionFailedTest_ClassReference_NoPrefix_Bug50621 extends Comp
// "xOtherClass" // "xOtherClass"
}; };
public CompletionFailedTest_ClassReference_NoPrefix_Bug50621(String name) { public CompletionTest_ClassReference_NoPrefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ClassReference_NoPrefix_Bug50621.class.getName()); TestSuite suite= new TestSuite(CompletionTest_ClassReference_NoPrefix.class.getName());
suite.addTest(new CompletionFailedTest_ClassReference_NoPrefix_Bug50621("testCompletionProposals")); suite.addTest(new CompletionTest_ClassReference_NoPrefix("testCompletionProposals"));
return suite; return suite;
} }

View file

@ -8,13 +8,12 @@
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests; package org.eclipse.cdt.ui.tests.text.contentassist;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/** /**
* @author hamer * @author hamer
@ -23,7 +22,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* Bug#50621 :Wrong completion kind in a class declaration * Bug#50621 :Wrong completion kind in a class declaration
* *
*/ */
public class CompletionFailedTest_ClassReference_Prefix_Bug50621 extends CompletionProposalsBaseTest{ public class CompletionTest_ClassReference_Prefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionFailedTestStart7.h"; private final String fileName = "CompletionFailedTestStart7.h";
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName; private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
@ -31,7 +30,7 @@ public class CompletionFailedTest_ClassReference_Prefix_Bug50621 extends Comple
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTCompilationUnit"; private final String expectedScopeName = "ASTCompilationUnit";
private final String expectedContextName = "null"; private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.USER_SPECIFIED_NAME; // sould be CompletionKind.CLASS_REFERENCE; private final CompletionKind expectedKind = CompletionKind.CLASS_REFERENCE;
private final String expectedPrefix = "a"; private final String expectedPrefix = "a";
private final String[] expectedResults = { private final String[] expectedResults = {
// Should be // Should be
@ -39,13 +38,13 @@ public class CompletionFailedTest_ClassReference_Prefix_Bug50621 extends Comple
// "anotherClass" // "anotherClass"
}; };
public CompletionFailedTest_ClassReference_Prefix_Bug50621(String name) { public CompletionTest_ClassReference_Prefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ClassReference_Prefix_Bug50621.class.getName()); TestSuite suite= new TestSuite(CompletionTest_ClassReference_Prefix.class.getName());
suite.addTest(new CompletionFailedTest_ClassReference_Prefix_Bug50621("testCompletionProposals")); suite.addTest(new CompletionTest_ClassReference_Prefix("testCompletionProposals"));
return suite; return suite;
} }

View file

@ -8,14 +8,13 @@
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests; package org.eclipse.cdt.ui.tests.text.contentassist;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/** /**
* @author hamer * @author hamer
@ -24,17 +23,18 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* Bug#50640 : Wrong completion kind when expecting an exception * Bug#50640 : Wrong completion kind when expecting an exception
* *
*/ */
public class CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640 extends CompletionProposalsBaseTest{ public class CompletionTest_ExceptionReference_NoPrefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionFailedTestStart10.cpp"; private final String fileName = "CompletionFailedTestStart10.cpp";
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName; private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
private final String headerFileName = "CompletionTestStart.h"; private final String headerFileName = "CompletionTestStart.h";
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTCodeScope"; // should be "ASTMethod"; private final String expectedScopeName = "ASTMethod";
private final String expectedContextName = "null"; private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.STATEMENT_START; // should be CompletionKind.EXCEPTION_REFERENCE ; private final CompletionKind expectedKind = CompletionKind.EXCEPTION_REFERENCE;
private final String expectedPrefix = ""; private final String expectedPrefix = "";
private final String[] expectedResults = { private final String[] expectedResults = {
//TODO Hoda is this right? namespaces should not be allowed, unless you mean for qualified type
// Should be // Should be
// "aClass", // "aClass",
// "anotherClass", // "anotherClass",
@ -44,13 +44,13 @@ public class CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640 extends
// "..." // "..."
}; };
public CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640(String name) { public CompletionTest_ExceptionReference_NoPrefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640.class.getName()); TestSuite suite= new TestSuite(CompletionTest_ExceptionReference_NoPrefix.class.getName());
suite.addTest(new CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640("testCompletionProposals")); suite.addTest(new CompletionTest_ExceptionReference_NoPrefix("testCompletionProposals"));
return suite; return suite;
} }

View file

@ -8,14 +8,13 @@
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests; package org.eclipse.cdt.ui.tests.text.contentassist;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/** /**
* @author hamer * @author hamer
@ -24,7 +23,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* Bug#50640 : Wrong completion kind when expecting an exception * Bug#50640 : Wrong completion kind when expecting an exception
* *
*/ */
public class CompletionFailedTest_ExceptionReference_Prefix_Bug50640 extends CompletionProposalsBaseTest{ public class CompletionTest_ExceptionReference_Prefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionFailedTestStart9.cpp"; private final String fileName = "CompletionFailedTestStart9.cpp";
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName; private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
@ -32,9 +31,10 @@ public class CompletionFailedTest_ExceptionReference_Prefix_Bug50640 extends Co
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTMethod"; private final String expectedScopeName = "ASTMethod";
private final String expectedContextName = "null"; private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // should be CompletionKind.EXCEPTION_REFERENCE ; private final CompletionKind expectedKind = CompletionKind.EXCEPTION_REFERENCE;
private final String expectedPrefix = "a"; private final String expectedPrefix = "a";
private final String[] expectedResults = { private final String[] expectedResults = {
//TODO Hoda please validate/verify this list
// Should be // Should be
// "aClass", // "aClass",
// "anotherClass", // "anotherClass",
@ -43,13 +43,13 @@ public class CompletionFailedTest_ExceptionReference_Prefix_Bug50640 extends Co
// "AStruct" // "AStruct"
}; };
public CompletionFailedTest_ExceptionReference_Prefix_Bug50640(String name) { public CompletionTest_ExceptionReference_Prefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ExceptionReference_Prefix_Bug50640.class.getName()); TestSuite suite= new TestSuite(CompletionTest_ExceptionReference_Prefix.class.getName());
suite.addTest(new CompletionFailedTest_ExceptionReference_Prefix_Bug50640("testCompletionProposals")); suite.addTest(new CompletionTest_ExceptionReference_Prefix("testCompletionProposals"));
return suite; return suite;
} }

View file

@ -21,27 +21,28 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
* Lookup.THIS * Lookup.THIS
* *
*/ */
public class CompletionTest_StatementStart_NoPrefix extends CompletionProposalsBaseTest{ public class CompletionTest_SingleName_Method_NoPrefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionTestStart5.cpp"; private final String fileName = "CompletionTestStart5.cpp";
private final String fileFullPath ="resources/contentassist/" + fileName; private final String fileFullPath ="resources/contentassist/" + fileName;
private final String headerFileName = "CompletionTestStart.h"; private final String headerFileName = "CompletionTestStart.h";
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTMethod"; private final String expectedScopeName = "ASTMethod";
private final String expectedContextName = "null"; private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.STATEMENT_START; private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE;
private final String expectedPrefix = ""; private final String expectedPrefix = "";
//TODO Hoda - please update this constant with what it is supposed to be
private final String[] expectedResults = { private final String[] expectedResults = {
"anotherField : int", "anotherField : int",
"anotherMethod() void"
}; };
public CompletionTest_StatementStart_NoPrefix(String name) { public CompletionTest_SingleName_Method_NoPrefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionTest_StatementStart_NoPrefix.class.getName()); TestSuite suite= new TestSuite(CompletionTest_SingleName_Method_NoPrefix.class.getName());
suite.addTest(new CompletionTest_StatementStart_NoPrefix("testCompletionProposals")); suite.addTest(new CompletionTest_SingleName_Method_NoPrefix("testCompletionProposals"));
return suite; return suite;
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
* Testing statement start completion kind, with a prefix * Testing statement start completion kind, with a prefix
* *
*/ */
public class CompletionTest_StatementStart_Prefix extends CompletionProposalsBaseTest{ public class CompletionTest_SingleName_Method_Prefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionTestStart1.cpp"; private final String fileName = "CompletionTestStart1.cpp";
private final String fileFullPath ="resources/contentassist/" + fileName; private final String fileFullPath ="resources/contentassist/" + fileName;
@ -28,7 +28,7 @@ public class CompletionTest_StatementStart_Prefix extends CompletionProposalsBa
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTMethod"; private final String expectedScopeName = "ASTMethod";
private final String expectedContextName = "null"; private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.STATEMENT_START; private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE;
private final String expectedPrefix = "a"; private final String expectedPrefix = "a";
private final String[] expectedResults = { private final String[] expectedResults = {
"anotherField : int", "anotherField : int",
@ -40,17 +40,20 @@ public class CompletionTest_StatementStart_Prefix extends CompletionProposalsBa
"anotherClass", "anotherClass",
"aNamespace", "aNamespace",
"anEnumeration", "anEnumeration",
"aFirstEnum",
"aSecondEnum",
"aThirdEnum",
"AStruct", "AStruct",
"AMacro(x)" "AMacro(x)"
}; };
public CompletionTest_StatementStart_Prefix(String name) { public CompletionTest_SingleName_Method_Prefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionTest_StatementStart_Prefix.class.getName()); TestSuite suite= new TestSuite(CompletionTest_SingleName_Method_Prefix.class.getName());
suite.addTest(new CompletionTest_StatementStart_Prefix("testCompletionProposals")); suite.addTest(new CompletionTest_SingleName_Method_Prefix("testCompletionProposals"));
return suite; return suite;
} }

View file

@ -8,12 +8,11 @@
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests; package org.eclipse.cdt.ui.tests.text.contentassist;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/** /**
* @author hamer * @author hamer
@ -22,7 +21,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* Bug#50471 : Wrong completion kind after the "using" keyword * Bug#50471 : Wrong completion kind after the "using" keyword
* *
*/ */
public class CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471 extends CompletionProposalsBaseTest{ public class CompletionTest_TypeRef_NoPrefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionFailedTestStart3.cpp"; private final String fileName = "CompletionFailedTestStart3.cpp";
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName; private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
@ -30,21 +29,22 @@ public class CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471 extends Comple
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTCompilationUnit"; private final String expectedScopeName = "ASTCompilationUnit";
private final String expectedContextName = "null"; private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE; // should be CompletionKind.NAMESPACE_REFERENCE; private final CompletionKind expectedKind = CompletionKind.TYPE_REFERENCE;
private final String expectedPrefix = ""; private final String expectedPrefix = "";
private final String[] expectedResults = { private final String[] expectedResults = {
//TODO Hoda your test is wrong "using [ ]" --> type
// Should be // Should be
// "aNamespace", // "aNamespace",
// "xNamespace" // "xNamespace"
}; };
public CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471(String name) { public CompletionTest_TypeRef_NoPrefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471.class.getName()); TestSuite suite= new TestSuite(CompletionTest_TypeRef_NoPrefix.class.getName());
suite.addTest(new CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471("testCompletionProposals")); suite.addTest(new CompletionTest_TypeRef_NoPrefix("testCompletionProposals"));
return suite; return suite;
} }

View file

@ -8,13 +8,12 @@
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests; package org.eclipse.cdt.ui.tests.text.contentassist;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/** /**
* @author hamer * @author hamer
@ -23,7 +22,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* Bug#50471 : Wrong completion kind after the "using" keyword * Bug#50471 : Wrong completion kind after the "using" keyword
* *
*/ */
public class CompletionFailedTest_NamespaceRef_Prefix_Bug50471 extends CompletionProposalsBaseTest{ public class CompletionTest_TypeRef_Prefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionFailedTestStart4.cpp"; private final String fileName = "CompletionFailedTestStart4.cpp";
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName; private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
@ -31,20 +30,20 @@ public class CompletionFailedTest_NamespaceRef_Prefix_Bug50471 extends Completi
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTCompilationUnit"; private final String expectedScopeName = "ASTCompilationUnit";
private final String expectedContextName = "null"; private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE; // should be CompletionKind.NAMESPACE_REFERENCE; private final CompletionKind expectedKind = CompletionKind.TYPE_REFERENCE;
private final String expectedPrefix = "a"; private final String expectedPrefix = "a";
private final String[] expectedResults = { private final String[] expectedResults = {
// Should be // Should be
// "aNamespace" // "aNamespace"
}; };
public CompletionFailedTest_NamespaceRef_Prefix_Bug50471(String name) { public CompletionTest_TypeRef_Prefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_NamespaceRef_Prefix_Bug50471.class.getName()); TestSuite suite= new TestSuite(CompletionTest_TypeRef_Prefix.class.getName());
suite.addTest(new CompletionFailedTest_NamespaceRef_Prefix_Bug50471("testCompletionProposals")); suite.addTest(new CompletionTest_TypeRef_Prefix("testCompletionProposals"));
return suite; return suite;
} }

View file

@ -31,7 +31,7 @@ public class CompletionFailedTest_ScopedReference_NoPrefix_Bug50152 extends Com
private final String expectedScopeName = "ASTMethod"; private final String expectedScopeName = "ASTMethod";
private final String expectedContextName = "null"; // should be "ASTNamespaceDefinition"; private final String expectedContextName = "null"; // should be "ASTNamespaceDefinition";
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // should be CompletionKind.SCOPED_REFERENCE; private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // should be CompletionKind.SCOPED_REFERENCE;
private final String expectedPrefix = "::"; // should be ""; private final String expectedPrefix = "";
private final String[] expectedResults = { private final String[] expectedResults = {
// shoud be "aNamespaceFunction() void" // shoud be "aNamespaceFunction() void"
}; };

View file

@ -1,3 +1,6 @@
2004-01-27 John Camelon
Updated COMPLETION_PARSE clients to use SINGLE_NAME_REFERENCE rather than STATEMENT_START.
2004-01-27 Hoda Amer 2004-01-27 Hoda Amer
Added handling for New_Type_Reference completion type Added handling for New_Type_Reference completion type

View file

@ -410,7 +410,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE) if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
addProposalsFromTemplateEngine(viewer, fGlobalContextTemplateEngine, completions); addProposalsFromTemplateEngine(viewer, fGlobalContextTemplateEngine, completions);
if( (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE) if( (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|| (kind == IASTCompletionNode.CompletionKind.STATEMENT_START) ) || (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE) )
addProposalsFromTemplateEngine(viewer, fFunctionContextTemplateEngine, completions); addProposalsFromTemplateEngine(viewer, fFunctionContextTemplateEngine, completions);
if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE) if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE)
addProposalsFromTemplateEngine(viewer, fStructureContextTemplateEngine, completions); addProposalsFromTemplateEngine(viewer, fStructureContextTemplateEngine, completions);
@ -441,7 +441,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
// calling functions should happen only within the context of a code body // calling functions should happen only within the context of a code body
if( (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE) if( (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
&& (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.STATEMENT_START)) && (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE))
return; return;
IFunctionSummary[] summary; IFunctionSummary[] summary;
@ -517,7 +517,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
if (((projectScope) || (projectScopeAndDependency)) if (((projectScope) || (projectScopeAndDependency))
&& ( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE) && ( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|| (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.STATEMENT_START) || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|| (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.VARIABLE_TYPE) || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
|| (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FIELD_TYPE) ) || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FIELD_TYPE) )
&& (prefix.length() > 0)){ && (prefix.length() > 0)){
@ -539,7 +539,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
searchPrefix, ICSearchConstants.NAMESPACE, ICSearchConstants.DEFINITIONS, false )); searchPrefix, ICSearchConstants.NAMESPACE, ICSearchConstants.DEFINITIONS, false ));
if( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE) if( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|| (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.STATEMENT_START)){ || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)){
orPattern.addPattern(SearchEngine.createSearchPattern( orPattern.addPattern(SearchEngine.createSearchPattern(
searchPrefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false )); searchPrefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern( orPattern.addPattern(SearchEngine.createSearchPattern(

View file

@ -467,44 +467,45 @@ public class CompletionEngine implements RelevanceConstants {
} }
private void completionOnStatementStart( IASTCompletionNode completionNode ) // private void completionOnStatementStart( IASTCompletionNode completionNode )
{ // {
IASTScope searchNode = completionNode.getCompletionScope(); // IASTScope searchNode = completionNode.getCompletionScope();
//
// ILookupResult result = null;
// if (completionNode.getCompletionPrefix().length() > 0){
// // lookup fields and methods with the right visibility
// IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[8];
// kinds[0] = IASTNode.LookupKind.FIELDS;
// kinds[1] = IASTNode.LookupKind.METHODS;
// kinds[2] = IASTNode.LookupKind.VARIABLES;
// kinds[3] = IASTNode.LookupKind.STRUCTURES;
// kinds[4] = IASTNode.LookupKind.ENUMERATIONS;
// kinds[5] = IASTNode.LookupKind.NAMESPACES;
// kinds[6] = IASTNode.LookupKind.FUNCTIONS;
// kinds[7] = IASTNode.LookupKind.LOCAL_VARIABLES;
//
// result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, null);
// addToCompletions (result);
//
// List macros = lookupMacros(completionNode.getCompletionPrefix());
// addMacrosToCompletions(macros.iterator());
// }
// else // prefix is empty
// {
// // instead of only fields and methods
// IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
// kinds[0] = IASTNode.LookupKind.THIS;
// result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
// addToCompletions(result);
//
// kinds = new IASTNode.LookupKind[1];
// kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
// result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
// addToCompletions(result);
// }
//
// }
ILookupResult result = null;
if (completionNode.getCompletionPrefix().length() > 0){
// lookup fields and methods with the right visibility
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[8];
kinds[0] = IASTNode.LookupKind.FIELDS;
kinds[1] = IASTNode.LookupKind.METHODS;
kinds[2] = IASTNode.LookupKind.VARIABLES;
kinds[3] = IASTNode.LookupKind.STRUCTURES;
kinds[4] = IASTNode.LookupKind.ENUMERATIONS;
kinds[5] = IASTNode.LookupKind.NAMESPACES;
kinds[6] = IASTNode.LookupKind.FUNCTIONS;
kinds[7] = IASTNode.LookupKind.LOCAL_VARIABLES;
result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, null);
addToCompletions (result);
List macros = lookupMacros(completionNode.getCompletionPrefix());
addMacrosToCompletions(macros.iterator());
}
else // prefix is empty
{
// instead of only fields and methods
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
kinds[0] = IASTNode.LookupKind.THIS;
result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
addToCompletions(result);
kinds = new IASTNode.LookupKind[1];
kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
addToCompletions(result);
}
}
private void completionOnScopedReference(IASTCompletionNode completionNode){ private void completionOnScopedReference(IASTCompletionNode completionNode){
// 1. Get the search scope node // 1. Get the search scope node
// the search node is the name before the qualification // the search node is the name before the qualification
@ -598,6 +599,7 @@ public class CompletionEngine implements RelevanceConstants {
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, null); ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, null);
addToCompletions(result); addToCompletions(result);
} }
private void completionOnNamespaceReference(IASTCompletionNode completionNode){ private void completionOnNamespaceReference(IASTCompletionNode completionNode){
// 1. Get the search scope node // 1. Get the search scope node
IASTScope searchNode = completionNode.getCompletionScope(); IASTScope searchNode = completionNode.getCompletionScope();
@ -692,11 +694,11 @@ public class CompletionEngine implements RelevanceConstants {
// completionOnMemberReference // completionOnMemberReference
completionOnScopedReference(completionNode); completionOnScopedReference(completionNode);
} }
else if(kind == CompletionKind.STATEMENT_START ) // else if(kind == CompletionKind.STATEMENT_START )
{ // {
// CompletionOnStatementStart // // CompletionOnStatementStart
completionOnStatementStart(completionNode); // completionOnStatementStart(completionNode);
} // }
else if(kind == CompletionKind.FIELD_TYPE){ else if(kind == CompletionKind.FIELD_TYPE){
// CompletionOnFieldType // CompletionOnFieldType
completionOnFieldType(completionNode); completionOnFieldType(completionNode);
@ -789,8 +791,8 @@ public class CompletionEngine implements RelevanceConstants {
kindStr = "PREPROCESSOR_DIRECTIVE"; kindStr = "PREPROCESSOR_DIRECTIVE";
else if(kind == IASTCompletionNode.CompletionKind.USER_SPECIFIED_NAME) else if(kind == IASTCompletionNode.CompletionKind.USER_SPECIFIED_NAME)
kindStr = "USER_SPECIFIED_NAME"; kindStr = "USER_SPECIFIED_NAME";
else if(kind == IASTCompletionNode.CompletionKind.STATEMENT_START) // else if(kind == IASTCompletionNode.CompletionKind.STATEMENT_START)
kindStr = "STATEMENT_START"; // kindStr = "STATEMENT_START";
else if(kind == IASTCompletionNode.CompletionKind.NO_SUCH_KIND) else if(kind == IASTCompletionNode.CompletionKind.NO_SUCH_KIND)
kindStr = "NO_SUCH_KIND"; kindStr = "NO_SUCH_KIND";