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
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 -
* 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);
}
@ -139,7 +139,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
assertNotNull( prefix );
assertTrue( node.getCompletionScope() instanceof IASTFunction );
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];
kinds[0] = IASTNode.LookupKind.ALL;
@ -419,7 +419,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
assertEquals( prefix, "a" );
assertTrue( node.getCompletionScope() instanceof IASTCodeScope );
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.STATEMENT_START );
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
assertNull( 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");
assertTrue(inquestion.isConstructor());
assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.STATEMENT_START );
assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
assertNull(node.getCompletionContext());
LookupKind[] kinds = new LookupKind[ 1 ];
kinds[0] = LookupKind.FIELDS;
@ -545,7 +545,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
assertEquals( inquestion.getName(), "~SimpleTest");
assertTrue(inquestion.isDestructor());
assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.STATEMENT_START );
assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
assertNull(node.getCompletionContext());
LookupKind[] kinds = new LookupKind[ 1 ];
kinds[0] = LookupKind.FIELDS;

View file

@ -31,7 +31,7 @@ public class ParserTestSuite extends TestCase {
suite.addTestSuite(QuickParseASTTests.class);
suite.addTestSuite(ParserSymbolTableTest.class);
suite.addTestSuite(CModelElementsTests.class);
suite.addTestSuite(ContextualParseTest.class);
suite.addTestSuite(CompletionParseTest.class);
// suite.addTestSuite(MacroTests.class);
suite.addTestSuite( PreprocessorTest.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
Added IASTCompletionNode.CompletionKind.New_Type_Reference
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 tCLASSNAME = 53;
// static public final int tCLASSNAME = 53;
static public final int t_and = 54;
@ -307,4 +307,9 @@ public interface IToken {
static public final int tLAST = t_restrict;
/**
* @return
*/
public abstract boolean isKeywordOrOperator();
}

View file

@ -66,10 +66,7 @@ public interface IASTCompletionNode {
// any place where a type or variable name is expected to be introduced
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
public static final CompletionKind NEW_TYPE_REFERENCE = new CompletionKind( 17 );

View file

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

View file

@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
import org.eclipse.cdt.core.parser.ast.IASTScope;
/**
* @author jcamelon
@ -26,13 +27,13 @@ public class TypeId implements IDeclarator
private ITokenDuple name;
private List arrayModifiers = new ArrayList();
private List pointerOperators = new ArrayList();
private final IASTScope scope;
/**
*
*/
public TypeId()
public TypeId(IASTScope scope )
{
super();
this.scope = scope;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IDeclarator#getPointerOperators()
@ -76,4 +77,10 @@ public class TypeId implements IDeclarator
{
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 DECLARATION = new Key( 2 );
public static final Key STATEMENT = new Key(3);
public static final Key BASE_SPECIFIER = new Key(4);
public static final Key POST_USING = new Key( 5 );
/**
* @param enumValue
*/
@ -50,6 +52,10 @@ public class KeywordSets {
return (Set) DECLARATION.get( language );
if( kind == Key.STATEMENT )
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
return null;
@ -155,6 +161,7 @@ public class KeywordSets {
{
STATEMENT_CPP = new TreeSet( STATEMENT_C );
STATEMENT_CPP.add( Keywords.TRY );
//TODO finish this
}
private static final Hashtable STATEMENT;
@ -164,4 +171,22 @@ public class KeywordSets {
STATEMENT.put( ParserLanguage.CPP, STATEMENT_CPP);
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;
}
/* (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
More Completion JUnit tests.

View file

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

View file

@ -161,7 +161,7 @@ public abstract class CompletionProposalsBaseTest extends TestCase{
String[] expected = getExpectedResultsValues();
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];
String displayString = proposal.getDisplayString();
assertEquals(displayString, expected[i]);

View file

@ -8,13 +8,12 @@
* Contributors:
* 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.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/**
* @author hamer
@ -23,7 +22,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* 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 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 expectedScopeName = "ASTCompilationUnit";
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[] expectedResults = {
// Should be
@ -40,13 +39,13 @@ public class CompletionFailedTest_ClassReference_NoPrefix_Bug50621 extends Comp
// "xOtherClass"
};
public CompletionFailedTest_ClassReference_NoPrefix_Bug50621(String name) {
public CompletionTest_ClassReference_NoPrefix(String name) {
super(name);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ClassReference_NoPrefix_Bug50621.class.getName());
suite.addTest(new CompletionFailedTest_ClassReference_NoPrefix_Bug50621("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_ClassReference_NoPrefix.class.getName());
suite.addTest(new CompletionTest_ClassReference_NoPrefix("testCompletionProposals"));
return suite;
}

View file

@ -8,13 +8,12 @@
* Contributors:
* 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.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/**
* @author hamer
@ -23,7 +22,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* 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 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 expectedScopeName = "ASTCompilationUnit";
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[] expectedResults = {
// Should be
@ -39,13 +38,13 @@ public class CompletionFailedTest_ClassReference_Prefix_Bug50621 extends Comple
// "anotherClass"
};
public CompletionFailedTest_ClassReference_Prefix_Bug50621(String name) {
public CompletionTest_ClassReference_Prefix(String name) {
super(name);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ClassReference_Prefix_Bug50621.class.getName());
suite.addTest(new CompletionFailedTest_ClassReference_Prefix_Bug50621("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_ClassReference_Prefix.class.getName());
suite.addTest(new CompletionTest_ClassReference_Prefix("testCompletionProposals"));
return suite;
}

View file

@ -8,14 +8,13 @@
* Contributors:
* 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.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/**
* @author hamer
@ -24,17 +23,18 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* 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 fileFullPath ="resources/contentassist/failedtests/" + fileName;
private final String headerFileName = "CompletionTestStart.h";
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 CompletionKind expectedKind = CompletionKind.STATEMENT_START; // should be CompletionKind.EXCEPTION_REFERENCE ;
private final CompletionKind expectedKind = CompletionKind.EXCEPTION_REFERENCE;
private final String expectedPrefix = "";
private final String[] expectedResults = {
//TODO Hoda is this right? namespaces should not be allowed, unless you mean for qualified type
// Should be
// "aClass",
// "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);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640.class.getName());
suite.addTest(new CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_ExceptionReference_NoPrefix.class.getName());
suite.addTest(new CompletionTest_ExceptionReference_NoPrefix("testCompletionProposals"));
return suite;
}

View file

@ -8,14 +8,13 @@
* Contributors:
* 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.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/**
* @author hamer
@ -24,7 +23,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* 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 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 expectedScopeName = "ASTMethod";
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[] expectedResults = {
//TODO Hoda please validate/verify this list
// Should be
// "aClass",
// "anotherClass",
@ -43,13 +43,13 @@ public class CompletionFailedTest_ExceptionReference_Prefix_Bug50640 extends Co
// "AStruct"
};
public CompletionFailedTest_ExceptionReference_Prefix_Bug50640(String name) {
public CompletionTest_ExceptionReference_Prefix(String name) {
super(name);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ExceptionReference_Prefix_Bug50640.class.getName());
suite.addTest(new CompletionFailedTest_ExceptionReference_Prefix_Bug50640("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_ExceptionReference_Prefix.class.getName());
suite.addTest(new CompletionTest_ExceptionReference_Prefix("testCompletionProposals"));
return suite;
}

View file

@ -21,27 +21,28 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
* 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 fileFullPath ="resources/contentassist/" + fileName;
private final String headerFileName = "CompletionTestStart.h";
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTMethod";
private final String expectedContextName = "null";
private final CompletionKind expectedKind = CompletionKind.STATEMENT_START;
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE;
private final String expectedPrefix = "";
//TODO Hoda - please update this constant with what it is supposed to be
private final String[] expectedResults = {
"anotherField : int",
"anotherMethod() void"
};
public CompletionTest_StatementStart_NoPrefix(String name) {
public CompletionTest_SingleName_Method_NoPrefix(String name) {
super(name);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionTest_StatementStart_NoPrefix.class.getName());
suite.addTest(new CompletionTest_StatementStart_NoPrefix("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_SingleName_Method_NoPrefix.class.getName());
suite.addTest(new CompletionTest_SingleName_Method_NoPrefix("testCompletionProposals"));
return suite;
}
/* (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
*
*/
public class CompletionTest_StatementStart_Prefix extends CompletionProposalsBaseTest{
public class CompletionTest_SingleName_Method_Prefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionTestStart1.cpp";
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 expectedScopeName = "ASTMethod";
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[] expectedResults = {
"anotherField : int",
@ -40,17 +40,20 @@ public class CompletionTest_StatementStart_Prefix extends CompletionProposalsBa
"anotherClass",
"aNamespace",
"anEnumeration",
"aFirstEnum",
"aSecondEnum",
"aThirdEnum",
"AStruct",
"AMacro(x)"
};
public CompletionTest_StatementStart_Prefix(String name) {
public CompletionTest_SingleName_Method_Prefix(String name) {
super(name);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionTest_StatementStart_Prefix.class.getName());
suite.addTest(new CompletionTest_StatementStart_Prefix("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_SingleName_Method_Prefix.class.getName());
suite.addTest(new CompletionTest_SingleName_Method_Prefix("testCompletionProposals"));
return suite;
}

View file

@ -8,12 +8,11 @@
* Contributors:
* 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.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/**
* @author hamer
@ -22,7 +21,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* 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 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 expectedScopeName = "ASTCompilationUnit";
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[] expectedResults = {
//TODO Hoda your test is wrong "using [ ]" --> type
// Should be
// "aNamespace",
// "xNamespace"
};
public CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471(String name) {
public CompletionTest_TypeRef_NoPrefix(String name) {
super(name);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471.class.getName());
suite.addTest(new CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_TypeRef_NoPrefix.class.getName());
suite.addTest(new CompletionTest_TypeRef_NoPrefix("testCompletionProposals"));
return suite;
}

View file

@ -8,13 +8,12 @@
* Contributors:
* 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.TestSuite;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
/**
* @author hamer
@ -23,7 +22,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
* 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 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 expectedScopeName = "ASTCompilationUnit";
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[] expectedResults = {
// Should be
// "aNamespace"
};
public CompletionFailedTest_NamespaceRef_Prefix_Bug50471(String name) {
public CompletionTest_TypeRef_Prefix(String name) {
super(name);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_NamespaceRef_Prefix_Bug50471.class.getName());
suite.addTest(new CompletionFailedTest_NamespaceRef_Prefix_Bug50471("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_TypeRef_Prefix.class.getName());
suite.addTest(new CompletionTest_TypeRef_Prefix("testCompletionProposals"));
return suite;
}

View file

@ -31,7 +31,7 @@ public class CompletionFailedTest_ScopedReference_NoPrefix_Bug50152 extends Com
private final String expectedScopeName = "ASTMethod";
private final String expectedContextName = "null"; // should be "ASTNamespaceDefinition";
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 = {
// 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
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)
addProposalsFromTemplateEngine(viewer, fGlobalContextTemplateEngine, completions);
if( (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|| (kind == IASTCompletionNode.CompletionKind.STATEMENT_START) )
|| (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE) )
addProposalsFromTemplateEngine(viewer, fFunctionContextTemplateEngine, completions);
if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE)
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
if( (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
&& (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.STATEMENT_START))
&& (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE))
return;
IFunctionSummary[] summary;
@ -517,7 +517,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
if (((projectScope) || (projectScopeAndDependency))
&& ( (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.FIELD_TYPE) )
&& (prefix.length() > 0)){
@ -539,7 +539,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
searchPrefix, ICSearchConstants.NAMESPACE, ICSearchConstants.DEFINITIONS, false ));
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(
searchPrefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern(

View file

@ -467,44 +467,45 @@ public class CompletionEngine implements RelevanceConstants {
}
private void completionOnStatementStart( IASTCompletionNode completionNode )
{
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);
// private void completionOnStatementStart( IASTCompletionNode completionNode )
// {
// 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);
// }
//
// }
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){
// 1. Get the search scope node
// 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);
addToCompletions(result);
}
private void completionOnNamespaceReference(IASTCompletionNode completionNode){
// 1. Get the search scope node
IASTScope searchNode = completionNode.getCompletionScope();
@ -692,11 +694,11 @@ public class CompletionEngine implements RelevanceConstants {
// completionOnMemberReference
completionOnScopedReference(completionNode);
}
else if(kind == CompletionKind.STATEMENT_START )
{
// CompletionOnStatementStart
completionOnStatementStart(completionNode);
}
// else if(kind == CompletionKind.STATEMENT_START )
// {
// // CompletionOnStatementStart
// completionOnStatementStart(completionNode);
// }
else if(kind == CompletionKind.FIELD_TYPE){
// CompletionOnFieldType
completionOnFieldType(completionNode);
@ -789,8 +791,8 @@ public class CompletionEngine implements RelevanceConstants {
kindStr = "PREPROCESSOR_DIRECTIVE";
else if(kind == IASTCompletionNode.CompletionKind.USER_SPECIFIED_NAME)
kindStr = "USER_SPECIFIED_NAME";
else if(kind == IASTCompletionNode.CompletionKind.STATEMENT_START)
kindStr = "STATEMENT_START";
// else if(kind == IASTCompletionNode.CompletionKind.STATEMENT_START)
// kindStr = "STATEMENT_START";
else if(kind == IASTCompletionNode.CompletionKind.NO_SUCH_KIND)
kindStr = "NO_SUCH_KIND";