mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core
Refactored parser for further content assist work. org.eclipse.cdt.ui.tests Updated failed test to fail in new way as Content Assist feature work continues on ...
This commit is contained in:
parent
8404420b80
commit
3f823a9e08
6 changed files with 92 additions and 70 deletions
|
@ -1,3 +1,6 @@
|
|||
2004-03-03 John Camelon
|
||||
Refactored parser for further content assist work.
|
||||
|
||||
2004-03-03 John Camelon
|
||||
Added some trace statements to CompleteParseASTFactory.
|
||||
Cleaned up usage of Enum.getValue() wrt encapsulation of enumerator value.
|
||||
|
|
|
@ -17,7 +17,9 @@ import org.eclipse.cdt.core.parser.IParserLogService;
|
|||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
|
@ -25,6 +27,7 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||
import org.eclipse.cdt.internal.core.parser.token.Token;
|
||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||
|
||||
/**
|
||||
|
@ -137,6 +140,25 @@ public class ContextualParser extends CompleteParser {
|
|||
checkEndOfFile();
|
||||
}
|
||||
|
||||
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last ) throws EndOfFileException{
|
||||
if( !queryLookaheadCapability() )
|
||||
{
|
||||
setCompletionScope( scope );
|
||||
setCompletionKind( kind );
|
||||
setCompletionKeywords( Key.EMPTY );
|
||||
ITokenDuple duple = new TokenDuple( first, last );
|
||||
ITokenDuple realDuple = duple.getSubrange( 0, duple.length() - 3 );
|
||||
IASTNode node = null;
|
||||
try {
|
||||
node = astFactory.lookupSymbolInContext( scope, realDuple );
|
||||
setCompletionContext( node );
|
||||
} catch (ASTNotImplementedException e) {
|
||||
// assert false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, boolean isTemplate) throws EndOfFileException {
|
||||
setCompletionValues(scope,kind,key, getCompletionContextForExpression(firstExpression,isTemplate) );
|
||||
}
|
||||
|
|
|
@ -173,67 +173,67 @@ public class ExpressionParser implements IExpressionParser {
|
|||
*
|
||||
* name2
|
||||
* : IDENTIFER
|
||||
* : template-id
|
||||
*
|
||||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
protected TokenDuple name(IASTScope scope, IASTCompletionNode.CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
|
||||
IToken first = LA(1);
|
||||
IToken last = null;
|
||||
IToken mark = mark();
|
||||
|
||||
try
|
||||
{
|
||||
if (LT(1) == IToken.tCOLONCOLON)
|
||||
last = consume( IToken.tCOLONCOLON );
|
||||
// TODO - whacky way to deal with destructors, please revisit
|
||||
if (LT(1) == IToken.tCOMPL)
|
||||
consume();
|
||||
switch (LT(1))
|
||||
{
|
||||
case IToken.tIDENTIFIER :
|
||||
last = consume(IToken.tIDENTIFIER);
|
||||
IToken secondMark = null;
|
||||
if( queryLookaheadCapability() )
|
||||
secondMark = mark();
|
||||
else
|
||||
return new TokenDuple(last, last);
|
||||
|
||||
try
|
||||
{
|
||||
last = consumeTemplateParameters(last);
|
||||
} catch( BacktrackException bt )
|
||||
{
|
||||
backup( secondMark );
|
||||
}
|
||||
break;
|
||||
default :
|
||||
backup(mark);
|
||||
throw backtrack;
|
||||
}
|
||||
while (LT(1) == IToken.tCOLONCOLON)
|
||||
{
|
||||
last = consume();
|
||||
if (LT(1) == IToken.t_template)
|
||||
consume();
|
||||
if (LT(1) == IToken.tCOMPL)
|
||||
consume();
|
||||
switch (LT(1))
|
||||
{
|
||||
case IToken.t_operator :
|
||||
backup(mark);
|
||||
throw backtrack;
|
||||
case IToken.tIDENTIFIER :
|
||||
last = consume();
|
||||
last = consumeTemplateParameters(last);
|
||||
}
|
||||
}
|
||||
|
||||
return new TokenDuple(first, last);
|
||||
} catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
backup(mark);
|
||||
throw backtrack;
|
||||
}
|
||||
|
||||
if (LT(1) == IToken.tCOLONCOLON)
|
||||
last = consume( IToken.tCOLONCOLON );
|
||||
|
||||
if (LT(1) == IToken.tCOMPL)
|
||||
consume();
|
||||
|
||||
switch (LT(1))
|
||||
{
|
||||
case IToken.tIDENTIFIER :
|
||||
last = consume(IToken.tIDENTIFIER);
|
||||
IToken secondMark = null;
|
||||
|
||||
secondMark = mark();
|
||||
|
||||
try
|
||||
{
|
||||
last = consumeTemplateParameters(last);
|
||||
} catch( BacktrackException bt )
|
||||
{
|
||||
backup( secondMark );
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
backup(mark);
|
||||
throw backtrack;
|
||||
}
|
||||
|
||||
while (LT(1) == IToken.tCOLONCOLON)
|
||||
{
|
||||
last = consume();
|
||||
|
||||
if (LT(1) == IToken.t_template)
|
||||
consume();
|
||||
|
||||
if (LT(1) == IToken.tCOMPL)
|
||||
consume();
|
||||
|
||||
switch (LT(1))
|
||||
{
|
||||
case IToken.t_operator :
|
||||
backup(mark);
|
||||
throw backtrack;
|
||||
case IToken.tIDENTIFIER :
|
||||
last = consume();
|
||||
last = consumeTemplateParameters(last);
|
||||
}
|
||||
}
|
||||
|
||||
return new TokenDuple(first, last);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1814,7 +1814,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
}
|
||||
break;
|
||||
default :
|
||||
firstExpression = primaryExpression(scope);
|
||||
firstExpression = primaryExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
}
|
||||
IASTExpression secondExpression = null;
|
||||
for (;;)
|
||||
|
@ -1932,7 +1932,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
|
||||
|
||||
secondExpression = primaryExpression(scope);
|
||||
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE);
|
||||
checkEndOfFile();
|
||||
|
||||
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSets.Key.EMPTY );
|
||||
|
@ -1973,7 +1973,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
|
||||
|
||||
secondExpression = primaryExpression(scope);
|
||||
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE);
|
||||
checkEndOfFile();
|
||||
|
||||
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSets.Key.EMPTY );
|
||||
|
@ -2062,7 +2062,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression primaryExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
protected IASTExpression primaryExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
IToken t = null;
|
||||
switch (LT(1))
|
||||
{
|
||||
|
@ -2217,7 +2217,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
IToken mark = mark();
|
||||
try
|
||||
{
|
||||
duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
duple = name(scope, kind);
|
||||
}
|
||||
catch( BacktrackException bt )
|
||||
{
|
||||
|
@ -2248,12 +2248,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
duple = d.getNameDuple();
|
||||
}
|
||||
catch(OffsetLimitReachedException olre )
|
||||
{
|
||||
backup(mark);
|
||||
throw backtrack;
|
||||
}
|
||||
|
||||
|
||||
checkEndOfFile();
|
||||
try
|
||||
{
|
||||
|
@ -2458,6 +2453,9 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, boolean isTemplate) throws EndOfFileException {
|
||||
}
|
||||
|
||||
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last ) throws EndOfFileException {
|
||||
}
|
||||
|
||||
protected IASTExpression unaryOperatorCastExpression(IASTScope scope, IASTExpression.Kind kind) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression castExpression = castExpression(scope);
|
||||
|
|
|
@ -2754,10 +2754,6 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
backup( mark );
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
backup(mark);
|
||||
}
|
||||
|
||||
// declarationStatement
|
||||
declaration(scope, null, null);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-03-03 John Camelon
|
||||
Updated failed test to fail in new way as Content Assist feature work continues on ...
|
||||
|
||||
2004-01-30 John Camelon
|
||||
Updated CompletionFailedTest_MacroRef_NoPrefix_Bug50487, renamed it to CompletionTest_MacroRef_NoPrefix and moved to passed test package.
|
||||
Updated CompletionFailedTest_MacroRef_Prefix_Bug50487, renamed it to Y and moved to passed test package.
|
||||
|
|
|
@ -32,7 +32,7 @@ public class CompletionFailedTest_FunctionReference_Bug50807 extends Completion
|
|||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||
private final String expectedScopeName = "ASTMethod";
|
||||
private final String expectedContextName = "null"; // either the context or the prefix should be meaningful "ASTMethod"
|
||||
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // should be CompletionKind.FUNCTION_REFERENCE;
|
||||
private final CompletionKind expectedKind = CompletionKind.NO_SUCH_KIND; // should be CompletionKind.FUNCTION_REFERENCE;
|
||||
private final String expectedPrefix = ""; // should be "xAClassMethod"
|
||||
private final String[] expectedResults = {
|
||||
// should be
|
||||
|
|
Loading…
Add table
Reference in a new issue