mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core
Provided a partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=50152 Updated IExpressionParser::expression() interface necessitated by this fix, and updated its clients appropriately. org.eclipse.cdt.core.tests Updated test cases that used IExpressionParser::expression(). Added CompletionParseTest::testCompletionInFunctionBodyFullyQualified(). Added CompletionParseTest::testCompletionInFunctionBodyQualifiedName(). org.eclipse.cdt.ui.tests Updated CompletionFailedTest_ScopedReference_Prefix_Bug50152, moved it out of failed tests package and renamed it to CompletionTest_ScopedReference_Prefix_Bug50152. Updated CompletionFailedTest_TypeDef_Bug52948, moved it out of failed tests package and renamed it to CompletionTest_TypeDef_Bug52948. Updated CompletionFailedTest_ScopedReference_NoPrefix_Bug50152 to show Hoda/Andrew what is still broken.
This commit is contained in:
parent
98b86d1d78
commit
26facfb422
16 changed files with 539 additions and 214 deletions
|
@ -1,4 +1,9 @@
|
|||
2004-04-05 Andrew Niefer
|
||||
2004-04-07 John Camelon
|
||||
Updated test cases that used IExpressionParser::expression().
|
||||
Added CompletionParseTest::testCompletionInFunctionBodyFullyQualified().
|
||||
Added CompletionParseTest::testCompletionInFunctionBodyQualifiedName().
|
||||
|
||||
2004-04-06 Andrew Niefer
|
||||
added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testBug47625()
|
||||
|
||||
2004-04-06 John Camelon
|
||||
|
|
|
@ -301,6 +301,7 @@ public class CompleteParseBaseTest extends TestCase
|
|||
public void enterCompilationUnit(IASTCompilationUnit compilationUnit)
|
||||
{
|
||||
pushScope( compilationUnit );
|
||||
this.compilationUnit = getCurrentScope();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -478,7 +479,6 @@ public class CompleteParseBaseTest extends TestCase
|
|||
*/
|
||||
public void exitCompilationUnit(IASTCompilationUnit compilationUnit)
|
||||
{
|
||||
this.compilationUnit = popScope();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@ package org.eclipse.cdt.core.parser.tests;
|
|||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
|
@ -20,17 +22,21 @@ import org.eclipse.cdt.core.parser.ParserUtil;
|
|||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -689,4 +695,116 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertFalse( iter.hasNext() );
|
||||
}
|
||||
|
||||
public void testCompletionInFunctionBodyFullyQualified() throws Exception
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write( "int aInteger = 5;\n");
|
||||
writer.write( "namespace NMS { \n");
|
||||
writer.write( " int foo() { \n");
|
||||
writer.write( "::A ");
|
||||
writer.write( "}\n}\n");
|
||||
String code = writer.toString();
|
||||
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
String stringToCompleteAfter = ( i == 0 ) ? "::" : "::A";
|
||||
IASTCompletionNode node = parse( code, code.indexOf( stringToCompleteAfter) + stringToCompleteAfter.length() );
|
||||
|
||||
validateCompletionNode(node, ( i == 0 ? "" : "A"), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE, getCompilationUnit() );
|
||||
|
||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
||||
node.getCompletionContext() );
|
||||
|
||||
Set results = new HashSet();
|
||||
results.add( "aInteger");
|
||||
if( i == 0 )
|
||||
results.add( "NMS");
|
||||
validateLookupResult(result, results );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param result
|
||||
*/
|
||||
private void validateLookupResult(ILookupResult result, Set matches) {
|
||||
|
||||
assertNotNull( matches );
|
||||
assertEquals( result.getResultsSize(), matches.size() );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
int assertionCount = 0;
|
||||
while( iter.hasNext() )
|
||||
{
|
||||
IASTOffsetableNamedElement element = (IASTOffsetableNamedElement) iter.next();
|
||||
assertTrue( matches.contains( element.getName() ));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
protected IASTCompilationUnit getCompilationUnit() {
|
||||
CompleteParseBaseTest.Scope s = (Scope) callback.getCompilationUnit();
|
||||
IASTCompilationUnit compilationUnit = (IASTCompilationUnit) ((Scope) callback.getCompilationUnit()).getScope();
|
||||
return compilationUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param node
|
||||
*/
|
||||
protected void validateCompletionNode(IASTCompletionNode node, String prefix, CompletionKind kind, IASTNode context ) {
|
||||
assertNotNull( node );
|
||||
assertEquals( node.getCompletionPrefix(), prefix);
|
||||
assertEquals( node.getCompletionKind(), kind );
|
||||
assertEquals( node.getCompletionContext(), context );
|
||||
assertFalse( node.getKeywords().hasNext() );
|
||||
}
|
||||
|
||||
public void testCompletionInFunctionBodyQualifiedName() throws Exception
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write( "namespace ABC {\n");
|
||||
writer.write( " struct DEF { int x; }; \n" );
|
||||
writer.write( " struct GHI { float y;};\n");
|
||||
writer.write( "}\n");
|
||||
writer.write( "int main() { ABC::D }\n");
|
||||
String code = writer.toString();
|
||||
|
||||
for( int j = 0; j< 2; ++j )
|
||||
{
|
||||
String stringToCompleteAfter = (j == 0 ) ? "::" : "::D";
|
||||
IASTCompletionNode node = parse( code, code.indexOf( stringToCompleteAfter) + stringToCompleteAfter.length() );
|
||||
|
||||
IASTNamespaceDefinition namespaceDefinition = null;
|
||||
Iterator i = callback.getCompilationUnit().getDeclarations();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
IASTDeclaration d = (IASTDeclaration) i.next();
|
||||
if( d instanceof IASTNamespaceDefinition )
|
||||
if( ((IASTNamespaceDefinition)d).getName().equals( "ABC") )
|
||||
{
|
||||
namespaceDefinition = (IASTNamespaceDefinition) d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull( namespaceDefinition );
|
||||
validateCompletionNode( node,
|
||||
( j == 0 ) ? "" : "D",
|
||||
IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE, namespaceDefinition );
|
||||
|
||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
||||
node.getCompletionContext() );
|
||||
|
||||
Set results = new HashSet();
|
||||
results.add( "DEF");
|
||||
if( j == 0 )
|
||||
results.add( "GHI");
|
||||
validateLookupResult(result, results );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ExprEvalTest extends TestCase {
|
|||
|
||||
final NullSourceElementRequestor nullCallback = new NullSourceElementRequestor();
|
||||
IExpressionParser parser = InternalParserUtil.createExpressionParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, new NullLogService() ), ParserLanguage.CPP, null );
|
||||
IASTExpression expression = parser.expression(null);
|
||||
IASTExpression expression = parser.expression(null,null);
|
||||
assertEquals(expectedValue, expression.evaluateExpression());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2004-04-07 John Camelon
|
||||
Provided a partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=50152
|
||||
Updated IExpressionParser::expression() interface necessitated by this fix, and updated its clients appropriately.
|
||||
|
||||
2004-04-06 David Daoust
|
||||
Removed some temporary objects that the scanner was producing.
|
||||
Fixed small bug in GCCScannerExtension.
|
||||
|
|
|
@ -132,6 +132,8 @@ public class ContextualParser extends CompleteParser {
|
|||
setCompletionValues(scope, kind, key, null );
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTNode node) throws EndOfFileException {
|
||||
setCompletionScope(scope);
|
||||
setCompletionKeywords(key);
|
||||
|
@ -140,22 +142,18 @@ 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;
|
||||
}
|
||||
setCompletionScope( scope );
|
||||
setCompletionKind( kind );
|
||||
setCompletionKeywords( Key.EMPTY );
|
||||
ITokenDuple duple = new TokenDuple( first, last );
|
||||
try {
|
||||
setCompletionContext( astFactory.lookupSymbolInContext( scope, duple ) );
|
||||
} catch (ASTNotImplementedException e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,4 +165,21 @@ public class ContextualParser extends CompleteParser {
|
|||
this.scope = scope;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind)
|
||||
*/
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind) throws EndOfFileException {
|
||||
setCompletionScope(scope);
|
||||
setCompletionKind(kind);
|
||||
checkEndOfFile();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind,
|
||||
IASTNode context) throws EndOfFileException {
|
||||
setCompletionScope(scope);
|
||||
setCompletionKind(kind);
|
||||
setCompletionContext(context);
|
||||
checkEndOfFile(); }
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
IToken mark = mark();
|
||||
|
||||
try{
|
||||
IASTTypeId typeId = typeId( scope, false );
|
||||
IASTTypeId typeId = typeId( scope, false, CompletionKind.TYPE_REFERENCE );
|
||||
|
||||
expression = astFactory.createExpression( scope, IASTExpression.Kind.POSTFIX_TYPEID_TYPEID,
|
||||
null, null, null, typeId, null, "", null); //$NON-NLS-1$
|
||||
|
@ -188,7 +188,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
if( ! completedArg ){
|
||||
try{
|
||||
expression = assignmentExpression( scope );
|
||||
expression = assignmentExpression( scope, CompletionKind.VARIABLE_TYPE );
|
||||
if( expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY ){
|
||||
throw backtrack;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
*
|
||||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
protected TokenDuple name(IASTScope scope, IASTCompletionNode.CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
protected ITokenDuple name(IASTScope scope, IASTCompletionNode.CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
|
||||
IToken first = LA(1);
|
||||
IToken last = null;
|
||||
|
@ -270,10 +270,13 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
List argumentList = new LinkedList();
|
||||
boolean hasTemplateId = false;
|
||||
boolean startsWithColonColon = false;
|
||||
|
||||
if (LT(1) == IToken.tCOLONCOLON){
|
||||
argumentList.add( null );
|
||||
last = consume( IToken.tCOLONCOLON );
|
||||
setCompletionValues( scope, kind, Key.EMPTY, getCompliationUnit() );
|
||||
startsWithColonColon = true;
|
||||
}
|
||||
|
||||
if (LT(1) == IToken.tCOMPL)
|
||||
|
@ -282,7 +285,15 @@ public class ExpressionParser implements IExpressionParser {
|
|||
switch (LT(1))
|
||||
{
|
||||
case IToken.tIDENTIFIER :
|
||||
last = consume(IToken.tIDENTIFIER);
|
||||
IToken prev = last;
|
||||
last = consume(IToken.tIDENTIFIER);
|
||||
if( startsWithColonColon )
|
||||
setCompletionValues( scope, kind, getCompliationUnit() );
|
||||
else if( prev != null )
|
||||
setCompletionValues(scope, kind, first, prev );
|
||||
else
|
||||
setCompletionValues(scope, kind );
|
||||
|
||||
last = consumeTemplateArguments(scope, last, argumentList);
|
||||
if( last.getType() == IToken.tGT )
|
||||
hasTemplateId = true;
|
||||
|
@ -295,12 +306,14 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
while (LT(1) == IToken.tCOLONCOLON)
|
||||
{
|
||||
last = consume();
|
||||
IToken prev = last;
|
||||
last = consume(IToken.tCOLONCOLON);
|
||||
setCompletionValues( scope, kind, first, prev );
|
||||
|
||||
if (LT(1) == IToken.t_template)
|
||||
if (queryLookaheadCapability() && LT(1) == IToken.t_template)
|
||||
consume();
|
||||
|
||||
if (LT(1) == IToken.tCOMPL)
|
||||
if (queryLookaheadCapability() && LT(1) == IToken.tCOMPL)
|
||||
consume();
|
||||
|
||||
switch (LT(1))
|
||||
|
@ -320,6 +333,37 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
* @param kind
|
||||
*/
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, IASTNode context ) throws EndOfFileException{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
* @param kind
|
||||
*/
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind) throws EndOfFileException{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
protected IASTNode getCompliationUnit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
* @param kind
|
||||
* @param key
|
||||
* @param node
|
||||
*/
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTNode node) throws EndOfFileException
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
* @param last
|
||||
|
@ -394,7 +438,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
IASTExpression exp = null;
|
||||
if (LT(1) != IToken.tRBRACKET)
|
||||
{
|
||||
exp = constantExpression(scope);
|
||||
exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
}
|
||||
consume(IToken.tRBRACKET);
|
||||
IASTArrayModifier arrayMod;
|
||||
|
@ -446,7 +490,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
else
|
||||
{
|
||||
// must be a conversion function
|
||||
typeId(d.getDeclarationWrapper().getScope(), true );
|
||||
typeId(d.getDeclarationWrapper().getScope(), true, CompletionKind.TYPE_REFERENCE );
|
||||
toSend = lastToken;
|
||||
}
|
||||
|
||||
|
@ -531,16 +575,16 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression constantExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
return conditionalExpression(scope);
|
||||
protected IASTExpression constantExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
return conditionalExpression(scope,kind);
|
||||
}
|
||||
|
||||
public IASTExpression expression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression assignmentExpression = assignmentExpression(scope);
|
||||
public IASTExpression expression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression assignmentExpression = assignmentExpression(scope,kind);
|
||||
while (LT(1) == IToken.tCOMMA)
|
||||
{
|
||||
consume();
|
||||
IASTExpression secondExpression = assignmentExpression(scope);
|
||||
IASTExpression secondExpression = assignmentExpression(scope,kind);
|
||||
try
|
||||
{
|
||||
assignmentExpression =
|
||||
|
@ -568,11 +612,11 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression assignmentExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
protected IASTExpression assignmentExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
if (LT(1) == IToken.t_throw) {
|
||||
return throwExpression(scope);
|
||||
}
|
||||
IASTExpression conditionalExpression = conditionalExpression(scope);
|
||||
IASTExpression conditionalExpression = conditionalExpression(scope,kind);
|
||||
// if the condition not taken, try assignment operators
|
||||
if (conditionalExpression != null
|
||||
&& conditionalExpression.getExpressionKind()
|
||||
|
@ -583,57 +627,57 @@ public class ExpressionParser implements IExpressionParser {
|
|||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tSTARASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tDIVASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tMODASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tPLUSASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tMINUSASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tSHIFTRASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tSHIFTLASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tAMPERASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tXORASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
case IToken.tBITORASSIGN :
|
||||
return assignmentOperatorExpression(
|
||||
scope,
|
||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR,
|
||||
conditionalExpression);
|
||||
conditionalExpression, kind);
|
||||
}
|
||||
return conditionalExpression;
|
||||
}
|
||||
|
@ -647,7 +691,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
IASTExpression throwExpression = null;
|
||||
try
|
||||
{
|
||||
throwExpression = expression(scope);
|
||||
throwExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
}
|
||||
catch (BacktrackException b)
|
||||
{
|
||||
|
@ -677,14 +721,14 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @return
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression conditionalExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = logicalOrExpression(scope);
|
||||
protected IASTExpression conditionalExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = logicalOrExpression(scope,kind);
|
||||
if (LT(1) == IToken.tQUESTION)
|
||||
{
|
||||
consume();
|
||||
IASTExpression secondExpression = expression(scope);
|
||||
IASTExpression secondExpression = expression(scope,kind);
|
||||
consume(IToken.tCOLON);
|
||||
IASTExpression thirdExpression = assignmentExpression(scope);
|
||||
IASTExpression thirdExpression = assignmentExpression(scope,kind);
|
||||
try
|
||||
{
|
||||
return astFactory.createExpression(
|
||||
|
@ -712,12 +756,12 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression logicalOrExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = logicalAndExpression(scope);
|
||||
protected IASTExpression logicalOrExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = logicalAndExpression(scope,kind);
|
||||
while (LT(1) == IToken.tOR)
|
||||
{
|
||||
consume();
|
||||
IASTExpression secondExpression = logicalAndExpression(scope);
|
||||
IASTExpression secondExpression = logicalAndExpression(scope,kind);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -746,12 +790,12 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression logicalAndExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = inclusiveOrExpression( scope );
|
||||
protected IASTExpression logicalAndExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = inclusiveOrExpression( scope,kind );
|
||||
while (LT(1) == IToken.tAND)
|
||||
{
|
||||
consume();
|
||||
IASTExpression secondExpression = inclusiveOrExpression( scope );
|
||||
IASTExpression secondExpression = inclusiveOrExpression( scope,kind );
|
||||
try
|
||||
{
|
||||
firstExpression =
|
||||
|
@ -779,12 +823,12 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression inclusiveOrExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = exclusiveOrExpression(scope);
|
||||
protected IASTExpression inclusiveOrExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = exclusiveOrExpression(scope,kind);
|
||||
while (LT(1) == IToken.tBITOR)
|
||||
{
|
||||
consume();
|
||||
IASTExpression secondExpression = exclusiveOrExpression(scope);
|
||||
IASTExpression secondExpression = exclusiveOrExpression(scope,kind);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -813,13 +857,13 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression exclusiveOrExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = andExpression( scope );
|
||||
protected IASTExpression exclusiveOrExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = andExpression( scope,kind );
|
||||
while (LT(1) == IToken.tXOR)
|
||||
{
|
||||
consume();
|
||||
|
||||
IASTExpression secondExpression = andExpression( scope );
|
||||
IASTExpression secondExpression = andExpression( scope,kind );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -848,12 +892,12 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression andExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression firstExpression = equalityExpression(scope);
|
||||
protected IASTExpression andExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression firstExpression = equalityExpression(scope,kind);
|
||||
while (LT(1) == IToken.tAMPER)
|
||||
{
|
||||
consume();
|
||||
IASTExpression secondExpression = equalityExpression(scope);
|
||||
IASTExpression secondExpression = equalityExpression(scope,kind);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -882,8 +926,8 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression equalityExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression firstExpression = relationalExpression(scope);
|
||||
protected IASTExpression equalityExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression firstExpression = relationalExpression(scope,kind);
|
||||
for (;;)
|
||||
{
|
||||
switch (LT(1))
|
||||
|
@ -892,7 +936,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
case IToken.tNOTEQUAL :
|
||||
IToken t = consume();
|
||||
IASTExpression secondExpression =
|
||||
relationalExpression(scope);
|
||||
relationalExpression(scope,kind);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -926,8 +970,8 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression relationalExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = shiftExpression(scope);
|
||||
protected IASTExpression relationalExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = shiftExpression(scope,kind);
|
||||
for (;;)
|
||||
{
|
||||
switch (LT(1))
|
||||
|
@ -943,7 +987,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
IToken t = consume();
|
||||
IToken next = LA(1);
|
||||
IASTExpression secondExpression =
|
||||
shiftExpression(scope);
|
||||
shiftExpression(scope,kind);
|
||||
if (next == LA(1))
|
||||
{
|
||||
// we did not consume anything
|
||||
|
@ -953,24 +997,24 @@ public class ExpressionParser implements IExpressionParser {
|
|||
}
|
||||
else
|
||||
{
|
||||
IASTExpression.Kind kind = null;
|
||||
IASTExpression.Kind expressionKind = null;
|
||||
switch (t.getType())
|
||||
{
|
||||
case IToken.tGT :
|
||||
kind =
|
||||
expressionKind =
|
||||
IASTExpression.Kind.RELATIONAL_GREATERTHAN;
|
||||
break;
|
||||
case IToken.tLT :
|
||||
kind = IASTExpression.Kind.RELATIONAL_LESSTHAN;
|
||||
expressionKind = IASTExpression.Kind.RELATIONAL_LESSTHAN;
|
||||
break;
|
||||
case IToken.tLTEQUAL :
|
||||
kind =
|
||||
expressionKind =
|
||||
IASTExpression
|
||||
.Kind
|
||||
.RELATIONAL_LESSTHANEQUALTO;
|
||||
break;
|
||||
case IToken.tGTEQUAL :
|
||||
kind =
|
||||
expressionKind =
|
||||
IASTExpression
|
||||
.Kind
|
||||
.RELATIONAL_GREATERTHANEQUALTO;
|
||||
|
@ -981,7 +1025,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
firstExpression =
|
||||
astFactory.createExpression(
|
||||
scope,
|
||||
kind,
|
||||
expressionKind,
|
||||
firstExpression,
|
||||
secondExpression,
|
||||
null,
|
||||
|
@ -1007,8 +1051,8 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression shiftExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = additiveExpression(scope);
|
||||
protected IASTExpression shiftExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = additiveExpression(scope,kind);
|
||||
for (;;)
|
||||
{
|
||||
switch (LT(1))
|
||||
|
@ -1017,7 +1061,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
case IToken.tSHIFTR :
|
||||
IToken t = consume();
|
||||
IASTExpression secondExpression =
|
||||
additiveExpression(scope);
|
||||
additiveExpression(scope,kind);
|
||||
try
|
||||
{
|
||||
firstExpression =
|
||||
|
@ -1050,8 +1094,8 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression additiveExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = multiplicativeExpression( scope );
|
||||
protected IASTExpression additiveExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = multiplicativeExpression( scope, kind );
|
||||
for (;;)
|
||||
{
|
||||
switch (LT(1))
|
||||
|
@ -1060,7 +1104,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
case IToken.tMINUS :
|
||||
IToken t = consume();
|
||||
IASTExpression secondExpression =
|
||||
multiplicativeExpression(scope);
|
||||
multiplicativeExpression(scope,kind);
|
||||
try
|
||||
{
|
||||
firstExpression =
|
||||
|
@ -1093,8 +1137,8 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression multiplicativeExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = pmExpression(scope);
|
||||
protected IASTExpression multiplicativeExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||
IASTExpression firstExpression = pmExpression(scope,kind);
|
||||
for (;;)
|
||||
{
|
||||
switch (LT(1))
|
||||
|
@ -1103,18 +1147,18 @@ public class ExpressionParser implements IExpressionParser {
|
|||
case IToken.tDIV :
|
||||
case IToken.tMOD :
|
||||
IToken t = consume();
|
||||
IASTExpression secondExpression = pmExpression(scope);
|
||||
IASTExpression.Kind kind = null;
|
||||
IASTExpression secondExpression = pmExpression(scope,kind);
|
||||
IASTExpression.Kind expressionKind = null;
|
||||
switch (t.getType())
|
||||
{
|
||||
case IToken.tSTAR :
|
||||
kind = IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY;
|
||||
expressionKind = IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY;
|
||||
break;
|
||||
case IToken.tDIV :
|
||||
kind = IASTExpression.Kind.MULTIPLICATIVE_DIVIDE;
|
||||
expressionKind = IASTExpression.Kind.MULTIPLICATIVE_DIVIDE;
|
||||
break;
|
||||
case IToken.tMOD :
|
||||
kind = IASTExpression.Kind.MULTIPLICATIVE_MODULUS;
|
||||
expressionKind = IASTExpression.Kind.MULTIPLICATIVE_MODULUS;
|
||||
break;
|
||||
}
|
||||
try
|
||||
|
@ -1122,7 +1166,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
firstExpression =
|
||||
astFactory.createExpression(
|
||||
scope,
|
||||
kind,
|
||||
expressionKind,
|
||||
firstExpression,
|
||||
secondExpression,
|
||||
null,
|
||||
|
@ -1147,8 +1191,8 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression pmExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression firstExpression = castExpression(scope);
|
||||
protected IASTExpression pmExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression firstExpression = castExpression(scope,kind);
|
||||
for (;;)
|
||||
{
|
||||
switch (LT(1))
|
||||
|
@ -1157,7 +1201,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
case IToken.tARROWSTAR :
|
||||
IToken t = consume();
|
||||
IASTExpression secondExpression =
|
||||
castExpression(scope);
|
||||
castExpression(scope,kind);
|
||||
try
|
||||
{
|
||||
firstExpression =
|
||||
|
@ -1191,7 +1235,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* : unaryExpression
|
||||
* | "(" typeId ")" castExpression
|
||||
*/
|
||||
protected IASTExpression castExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
protected IASTExpression castExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
// TO DO: we need proper symbol checkint to ensure type name
|
||||
if (LT(1) == IToken.tLPAREN)
|
||||
{
|
||||
|
@ -1203,10 +1247,10 @@ public class ExpressionParser implements IExpressionParser {
|
|||
// If this isn't a type name, then we shouldn't be here
|
||||
try
|
||||
{
|
||||
typeId = typeId(scope, false);
|
||||
typeId = typeId(scope, false, CompletionKind.TYPE_REFERENCE);
|
||||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); popped = true;}
|
||||
IASTExpression castExpression = castExpression(scope);
|
||||
IASTExpression castExpression = castExpression(scope,kind);
|
||||
try
|
||||
{
|
||||
return astFactory.createExpression(
|
||||
|
@ -1232,14 +1276,15 @@ public class ExpressionParser implements IExpressionParser {
|
|||
if( templateIdScopes != null && !popped ){ templateIdScopes.pop(); }
|
||||
}
|
||||
}
|
||||
return unaryExpression(scope);
|
||||
return unaryExpression(scope,kind);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param completionKind TODO
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTTypeId typeId(IASTScope scope, boolean skipArrayModifiers) throws EndOfFileException, BacktrackException {
|
||||
protected IASTTypeId typeId(IASTScope scope, boolean skipArrayModifiers, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
||||
IToken mark = mark();
|
||||
ITokenDuple name = null;
|
||||
boolean isConst = false, isVolatile = false;
|
||||
|
@ -1252,7 +1297,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
{
|
||||
try
|
||||
{
|
||||
name = name(scope, CompletionKind.TYPE_REFERENCE );
|
||||
name = name(scope, completionKind );
|
||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||
break;
|
||||
}
|
||||
|
@ -1299,7 +1344,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
case IToken.tIDENTIFIER :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
name = name(scope, CompletionKind.TYPE_REFERENCE);
|
||||
name = name(scope, completionKind );
|
||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||
break;
|
||||
|
||||
|
@ -1383,7 +1428,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
consume();
|
||||
try
|
||||
{
|
||||
name = name(scope, CompletionKind.TYPE_REFERENCE );
|
||||
name = name(scope, completionKind );
|
||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||
} catch( BacktrackException b )
|
||||
{
|
||||
|
@ -1432,7 +1477,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression deleteExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
protected IASTExpression deleteExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
if (LT(1) == IToken.tCOLONCOLON)
|
||||
{
|
||||
// global scope
|
||||
|
@ -1447,7 +1492,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
consume(IToken.tRBRACKET);
|
||||
vectored = true;
|
||||
}
|
||||
IASTExpression castExpression = castExpression(scope);
|
||||
IASTExpression castExpression = castExpression(scope,kind);
|
||||
try
|
||||
{
|
||||
return astFactory.createExpression(
|
||||
|
@ -1512,7 +1557,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
// Try to consume placement list
|
||||
// Note: since expressionList and expression are the same...
|
||||
backtrackMarker = mark();
|
||||
newPlacementExpressions.add(expression(scope));
|
||||
newPlacementExpressions.add(expression(scope, CompletionKind.SINGLE_NAME_REFERENCE));
|
||||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); } //pop 1st Parent
|
||||
placementParseFailure = false;
|
||||
|
@ -1533,7 +1578,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
// CASE: new (typeid-not-looking-as-placement) ...
|
||||
// the first expression in () is not a placement
|
||||
// - then it has to be typeId
|
||||
typeId = typeId(scope, true );
|
||||
typeId = typeId(scope, true, CompletionKind.NEW_TYPE_REFERENCE );
|
||||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); } //pop 1st Paren
|
||||
}
|
||||
|
@ -1558,7 +1603,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
try
|
||||
{
|
||||
backtrackMarker = mark();
|
||||
typeId = typeId(scope, true);
|
||||
typeId = typeId(scope, true, CompletionKind.NEW_TYPE_REFERENCE);
|
||||
}
|
||||
catch (BacktrackException e)
|
||||
{
|
||||
|
@ -1577,7 +1622,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
// The problem is, the first expression might as well be a typeid
|
||||
try
|
||||
{
|
||||
typeId = typeId(scope, true);
|
||||
typeId = typeId(scope, true, CompletionKind.NEW_TYPE_REFERENCE);
|
||||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); } //popping the 2nd Paren
|
||||
|
||||
|
@ -1628,7 +1673,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
// CASE: new typeid ...
|
||||
// new parameters do not start with '('
|
||||
// i.e it has to be a plain typeId
|
||||
typeId = typeId(scope, true);
|
||||
typeId = typeId(scope, true, CompletionKind.NEW_TYPE_REFERENCE);
|
||||
}
|
||||
while (LT(1) == IToken.tLBRACKET)
|
||||
{
|
||||
|
@ -1637,7 +1682,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
|
||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLBRACKET ) ); }
|
||||
|
||||
newTypeIdExpressions.add(assignmentExpression(scope));
|
||||
newTypeIdExpressions.add(assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE));
|
||||
consume(IToken.tRBRACKET);
|
||||
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||
|
@ -1649,7 +1694,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||
|
||||
if (LT(1) != IToken.tRPAREN)
|
||||
newInitializerExpressions.add(expression(scope));
|
||||
newInitializerExpressions.add(expression(scope, CompletionKind.SINGLE_NAME_REFERENCE));
|
||||
|
||||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||
|
@ -1676,41 +1721,41 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression unaryExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
protected IASTExpression unaryExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
switch (LT(1))
|
||||
{
|
||||
case IToken.tSTAR :
|
||||
consume();
|
||||
return unaryOperatorCastExpression(scope,
|
||||
IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION);
|
||||
IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION,kind);
|
||||
case IToken.tAMPER :
|
||||
consume();
|
||||
return unaryOperatorCastExpression(scope,
|
||||
IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION);
|
||||
IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION,kind);
|
||||
case IToken.tPLUS :
|
||||
consume();
|
||||
return unaryOperatorCastExpression(scope,
|
||||
IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION);
|
||||
IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION,kind);
|
||||
case IToken.tMINUS :
|
||||
consume();
|
||||
return unaryOperatorCastExpression(scope,
|
||||
IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION);
|
||||
IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION,kind);
|
||||
case IToken.tNOT :
|
||||
consume();
|
||||
return unaryOperatorCastExpression(scope,
|
||||
IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION);
|
||||
IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION,kind);
|
||||
case IToken.tCOMPL :
|
||||
consume();
|
||||
return unaryOperatorCastExpression(scope,
|
||||
IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION);
|
||||
IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION,kind);
|
||||
case IToken.tINCR :
|
||||
consume();
|
||||
return unaryOperatorCastExpression(scope,
|
||||
IASTExpression.Kind.UNARY_INCREMENT);
|
||||
IASTExpression.Kind.UNARY_INCREMENT,kind);
|
||||
case IToken.tDECR :
|
||||
consume();
|
||||
return unaryOperatorCastExpression(scope,
|
||||
IASTExpression.Kind.UNARY_DECREMENT);
|
||||
IASTExpression.Kind.UNARY_DECREMENT,kind);
|
||||
case IToken.t_sizeof :
|
||||
consume(IToken.t_sizeof);
|
||||
IToken mark = LA(1);
|
||||
|
@ -1721,18 +1766,18 @@ public class ExpressionParser implements IExpressionParser {
|
|||
try
|
||||
{
|
||||
consume(IToken.tLPAREN);
|
||||
d = typeId(scope, false);
|
||||
d = typeId(scope, false, CompletionKind.TYPE_REFERENCE);
|
||||
consume(IToken.tRPAREN);
|
||||
}
|
||||
catch (BacktrackException bt)
|
||||
{
|
||||
backup(mark);
|
||||
unaryExpression = unaryExpression(scope);
|
||||
unaryExpression = unaryExpression(scope,kind);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unaryExpression = unaryExpression(scope);
|
||||
unaryExpression = unaryExpression(scope,kind);
|
||||
}
|
||||
if (d != null & unaryExpression == null)
|
||||
try
|
||||
|
@ -1777,19 +1822,22 @@ public class ExpressionParser implements IExpressionParser {
|
|||
case IToken.t_new :
|
||||
return newExpression(scope);
|
||||
case IToken.t_delete :
|
||||
return deleteExpression(scope);
|
||||
return deleteExpression(scope,kind);
|
||||
case IToken.tCOLONCOLON :
|
||||
switch (LT(2))
|
||||
{
|
||||
case IToken.t_new :
|
||||
return newExpression(scope);
|
||||
case IToken.t_delete :
|
||||
return deleteExpression(scope);
|
||||
default :
|
||||
return postfixExpression(scope);
|
||||
}
|
||||
if( queryLookaheadCapability(2))
|
||||
{
|
||||
switch (LT(2))
|
||||
{
|
||||
case IToken.t_new :
|
||||
return newExpression(scope);
|
||||
case IToken.t_delete :
|
||||
return deleteExpression(scope,kind);
|
||||
default :
|
||||
return postfixExpression(scope,kind);
|
||||
}
|
||||
}
|
||||
default :
|
||||
return postfixExpression(scope);
|
||||
return postfixExpression(scope,kind);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1797,7 +1845,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
* @param expression
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression postfixExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
||||
protected IASTExpression postfixExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression firstExpression = null;
|
||||
boolean isTemplate = false;
|
||||
checkEndOfFile();
|
||||
|
@ -1826,7 +1874,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
}
|
||||
consume( IToken.tLPAREN );
|
||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||
IASTExpression expressionList = expression( scope );
|
||||
IASTExpression expressionList = expression( scope, CompletionKind.TYPE_REFERENCE );
|
||||
consume( IToken.tRPAREN );
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||
try {
|
||||
|
@ -1927,12 +1975,12 @@ public class ExpressionParser implements IExpressionParser {
|
|||
IASTTypeId typeId = null;
|
||||
try
|
||||
{
|
||||
typeId = typeId(scope, false);
|
||||
typeId = typeId(scope, false, CompletionKind.TYPE_REFERENCE);
|
||||
}
|
||||
catch (BacktrackException b)
|
||||
{
|
||||
isTypeId = false;
|
||||
lhs = expression(scope);
|
||||
lhs = expression(scope, CompletionKind.TYPE_REFERENCE);
|
||||
}
|
||||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||
|
@ -1960,7 +2008,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
}
|
||||
break;
|
||||
default :
|
||||
firstExpression = primaryExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
firstExpression = primaryExpression(scope, kind);
|
||||
}
|
||||
IASTExpression secondExpression = null;
|
||||
for (;;)
|
||||
|
@ -1971,7 +2019,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
// array access
|
||||
consume();
|
||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLBRACKET ) ); }
|
||||
secondExpression = expression(scope);
|
||||
secondExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
consume(IToken.tRBRACKET);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||
try
|
||||
|
@ -1999,7 +2047,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
// function call
|
||||
consume(IToken.tLPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||
secondExpression = expression(scope);
|
||||
secondExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||
try
|
||||
|
@ -2182,10 +2230,10 @@ public class ExpressionParser implements IExpressionParser {
|
|||
LA(1);
|
||||
}
|
||||
|
||||
protected IASTExpression simpleTypeConstructorExpression(IASTScope scope, Kind type) throws EndOfFileException, BacktrackException {
|
||||
protected IASTExpression simpleTypeConstructorExpression(IASTScope scope, Kind type ) throws EndOfFileException, BacktrackException {
|
||||
consume();
|
||||
consume(IToken.tLPAREN);
|
||||
IASTExpression inside = expression(scope);
|
||||
IASTExpression inside = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
consume(IToken.tRPAREN);
|
||||
try
|
||||
{
|
||||
|
@ -2340,7 +2388,7 @@ public class ExpressionParser implements IExpressionParser {
|
|||
case IToken.tLPAREN :
|
||||
consume();
|
||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||
IASTExpression lhs = expression(scope);
|
||||
IASTExpression lhs = expression(scope, kind);
|
||||
consume(IToken.tRPAREN);
|
||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||
try
|
||||
|
@ -2579,9 +2627,9 @@ public class ExpressionParser implements IExpressionParser {
|
|||
lastToken = null; // this is not entirely right ...
|
||||
}
|
||||
|
||||
protected IASTExpression assignmentOperatorExpression(IASTScope scope, IASTExpression.Kind kind, IASTExpression lhs) throws EndOfFileException, BacktrackException {
|
||||
protected IASTExpression assignmentOperatorExpression(IASTScope scope, IASTExpression.Kind kind, IASTExpression lhs, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
||||
consume();
|
||||
IASTExpression assignmentExpression = assignmentExpression(scope);
|
||||
IASTExpression assignmentExpression = assignmentExpression(scope,completionKind);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -2615,8 +2663,9 @@ public class ExpressionParser implements IExpressionParser {
|
|||
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);
|
||||
|
||||
protected IASTExpression unaryOperatorCastExpression(IASTScope scope, IASTExpression.Kind kind, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
||||
IASTExpression castExpression = castExpression(scope,completionKind);
|
||||
try
|
||||
{
|
||||
return astFactory.createExpression(
|
||||
|
@ -2640,10 +2689,10 @@ public class ExpressionParser implements IExpressionParser {
|
|||
protected IASTExpression specialCastExpression(IASTScope scope, IASTExpression.Kind kind) throws EndOfFileException, BacktrackException {
|
||||
consume();
|
||||
consume(IToken.tLT);
|
||||
IASTTypeId duple = typeId(scope, false);
|
||||
IASTTypeId duple = typeId(scope, false, CompletionKind.TYPE_REFERENCE);
|
||||
consume(IToken.tGT);
|
||||
consume(IToken.tLPAREN);
|
||||
IASTExpression lhs = expression(scope);
|
||||
IASTExpression lhs = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
consume(IToken.tRPAREN);
|
||||
try
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser;
|
|||
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
import org.eclipse.cdt.core.parser.IFilenameProvider;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
|
||||
|
@ -30,6 +31,6 @@ public interface IExpressionParser extends IFilenameProvider {
|
|||
* @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid
|
||||
* expression
|
||||
*/
|
||||
public IASTExpression expression(IASTScope scope) throws BacktrackException, EndOfFileException;
|
||||
public IASTExpression expression(IASTScope scope, IASTCompletionNode.CompletionKind kind) throws BacktrackException, EndOfFileException;
|
||||
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
|
||||
setCompletionValues(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY );
|
||||
// optional :: and nested classes handled in name
|
||||
TokenDuple duple = null;
|
||||
ITokenDuple duple = null;
|
||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||
duple = name(scope, CompletionKind.NAMESPACE_REFERENCE);
|
||||
else
|
||||
|
@ -284,7 +284,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
}
|
||||
|
||||
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.NAMESPACE_ONLY );
|
||||
TokenDuple name = null;
|
||||
ITokenDuple name = null;
|
||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||
{
|
||||
// optional :: and nested classes handled in name
|
||||
|
@ -573,7 +573,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
if (LT(1) == IToken.tASSIGN) // optional = type-id
|
||||
{
|
||||
consume(IToken.tASSIGN);
|
||||
typeId = typeId(parameterScope, false); // type-id
|
||||
typeId = typeId(parameterScope, false, CompletionKind.TYPE_REFERENCE); // type-id
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
if (LT(1) == IToken.tASSIGN) // optional = type-id
|
||||
{
|
||||
consume(IToken.tASSIGN);
|
||||
optionalTypeId = typeId(parameterScope, false);
|
||||
optionalTypeId = typeId(parameterScope, false, CompletionKind.TYPE_REFERENCE);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -947,8 +947,9 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
new DeclarationWrapper(scope, firstToken.getOffset(), firstToken.getLineNumber(), ownerTemplate);
|
||||
firstToken = null; // necessary for scalability
|
||||
|
||||
setCompletionValues( scope, getCompletionKindForDeclaration(scope, overideKind), Key.DECL_SPECIFIER_SEQUENCE );
|
||||
declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR );
|
||||
CompletionKind completionKindForDeclaration = getCompletionKindForDeclaration(scope, overideKind);
|
||||
setCompletionValues( scope, completionKindForDeclaration, Key.DECL_SPECIFIER_SEQUENCE );
|
||||
declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, completionKindForDeclaration );
|
||||
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED )
|
||||
try
|
||||
{
|
||||
|
@ -974,12 +975,13 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
Declarator declarator = null;
|
||||
if (LT(1) != IToken.tSEMI)
|
||||
{
|
||||
declarator = initDeclarator(sdw, strategy);
|
||||
declarator = initDeclarator(sdw, strategy, completionKindForDeclaration
|
||||
);
|
||||
|
||||
while (LT(1) == IToken.tCOMMA)
|
||||
{
|
||||
consume();
|
||||
initDeclarator(sdw, strategy);
|
||||
initDeclarator(sdw, strategy, completionKindForDeclaration );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1142,7 +1144,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume(IToken.tLPAREN);
|
||||
IASTExpression expressionList = null;
|
||||
|
||||
expressionList = expression(d.getDeclarationWrapper().getScope());
|
||||
expressionList = expression(d.getDeclarationWrapper().getScope(), CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
|
||||
consume(IToken.tRPAREN);
|
||||
|
||||
|
@ -1183,7 +1185,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
|
||||
DeclarationWrapper sdw =
|
||||
new DeclarationWrapper(scope, current.getOffset(), current.getLineNumber(), null);
|
||||
declSpecifierSeq(sdw, true, false);
|
||||
declSpecifierSeq(sdw, true, false, CompletionKind.ARGUMENT_TYPE);
|
||||
if (sdw.getTypeSpecifier() == null
|
||||
&& sdw.getSimpleType()
|
||||
!= IASTSimpleTypeSpecifier.Type.UNSPECIFIED)
|
||||
|
@ -1214,7 +1216,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
|
||||
setCompletionValues(scope,CompletionKind.USER_SPECIFIED_NAME,Key.EMPTY );
|
||||
if (LT(1) != IToken.tSEMI)
|
||||
initDeclarator(sdw, SimpleDeclarationStrategy.TRY_FUNCTION );
|
||||
initDeclarator(sdw, SimpleDeclarationStrategy.TRY_FUNCTION, CompletionKind.VARIABLE_TYPE );
|
||||
|
||||
if( lastToken != null )
|
||||
sdw.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||
|
@ -1289,19 +1291,19 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
* @return whether or not this looks like a constructor (true or false)
|
||||
* @throws EndOfFileException we could encounter EOF while looking ahead
|
||||
*/
|
||||
private boolean lookAheadForConstructorOrConversion(Flags flags, DeclarationWrapper sdw )
|
||||
private boolean lookAheadForConstructorOrConversion(Flags flags, DeclarationWrapper sdw, CompletionKind kind )
|
||||
throws EndOfFileException
|
||||
{
|
||||
if (flags.isForParameterDeclaration())
|
||||
return false;
|
||||
if (LT(2) == IToken.tLPAREN && flags.isForConstructor())
|
||||
if (queryLookaheadCapability(2) && LT(2) == IToken.tLPAREN && flags.isForConstructor())
|
||||
return true;
|
||||
|
||||
IToken mark = mark();
|
||||
Declarator d = new Declarator( sdw );
|
||||
try
|
||||
{
|
||||
consumeTemplatedOperatorName( d );
|
||||
consumeTemplatedOperatorName( d, kind );
|
||||
}
|
||||
catch (BacktrackException e)
|
||||
{
|
||||
|
@ -1380,7 +1382,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
protected void declSpecifierSeq(
|
||||
DeclarationWrapper sdw,
|
||||
boolean parm,
|
||||
boolean tryConstructor )
|
||||
boolean tryConstructor, CompletionKind kind )
|
||||
throws BacktrackException, EndOfFileException
|
||||
{
|
||||
Flags flags = new Flags(parm, tryConstructor);
|
||||
|
@ -1591,7 +1593,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
new TokenDuple(typeNameBegin, typeNameEnd));
|
||||
return;
|
||||
}
|
||||
if (lookAheadForConstructorOrConversion(flags, sdw))
|
||||
if (lookAheadForConstructorOrConversion(flags, sdw, kind))
|
||||
{
|
||||
if (typeNameBegin != null)
|
||||
sdw.setTypeName(
|
||||
|
@ -1607,7 +1609,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
return;
|
||||
}
|
||||
|
||||
ITokenDuple d = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE );
|
||||
ITokenDuple d = name(sdw.getScope(), kind );
|
||||
sdw.setTypeName(d);
|
||||
sdw.setSimpleType( IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME );
|
||||
flags.setEncounteredTypename(true);
|
||||
|
@ -1747,10 +1749,10 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
protected Declarator initDeclarator(
|
||||
DeclarationWrapper sdw, SimpleDeclarationStrategy strategy )
|
||||
DeclarationWrapper sdw, SimpleDeclarationStrategy strategy, CompletionKind kind )
|
||||
throws EndOfFileException, BacktrackException
|
||||
{
|
||||
Declarator d = declarator(sdw, sdw.getScope(), strategy );
|
||||
Declarator d = declarator(sdw, sdw.getScope(), strategy, kind );
|
||||
if( language == ParserLanguage.CPP )
|
||||
optionalCPPInitializer(d);
|
||||
else if( language == ParserLanguage.C )
|
||||
|
@ -1782,7 +1784,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume(IToken.tLPAREN); // EAT IT!
|
||||
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY);
|
||||
IASTExpression astExpression = null;
|
||||
astExpression = expression(scope);
|
||||
astExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY);
|
||||
consume(IToken.tRPAREN);
|
||||
d.setConstructorExpression(astExpression);
|
||||
|
@ -1854,7 +1856,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
// assignmentExpression
|
||||
try
|
||||
{
|
||||
IASTExpression assignmentExpression = assignmentExpression(scope);
|
||||
IASTExpression assignmentExpression = assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
try
|
||||
{
|
||||
return astFactory.createInitializerClause(
|
||||
|
@ -1931,7 +1933,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
try
|
||||
{
|
||||
IASTExpression assignmentExpression =
|
||||
assignmentExpression(scope);
|
||||
assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -1979,7 +1981,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
else if( LT(1) == IToken.tLBRACKET )
|
||||
{
|
||||
consume( IToken.tLBRACKET );
|
||||
constantExpression = expression( scope );
|
||||
constantExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE );
|
||||
consume( IToken.tRBRACKET );
|
||||
kind = IASTDesignator.DesignatorKind.SUBSCRIPT;
|
||||
}
|
||||
|
@ -2014,7 +2016,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
protected Declarator declarator(
|
||||
IDeclaratorOwner owner, IASTScope scope, SimpleDeclarationStrategy strategy )
|
||||
IDeclaratorOwner owner, IASTScope scope, SimpleDeclarationStrategy strategy, CompletionKind kind )
|
||||
throws EndOfFileException, BacktrackException
|
||||
{
|
||||
Declarator d = null;
|
||||
|
@ -2028,11 +2030,11 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
if (LT(1) == IToken.tLPAREN)
|
||||
{
|
||||
consume();
|
||||
declarator(d, scope, strategy );
|
||||
declarator(d, scope, strategy, kind );
|
||||
consume(IToken.tRPAREN);
|
||||
}
|
||||
else
|
||||
consumeTemplatedOperatorName(d);
|
||||
consumeTemplatedOperatorName(d, kind);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
@ -2143,13 +2145,13 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
String image = LA(1).getImage();
|
||||
try
|
||||
{
|
||||
duple = typeId(scope, false);
|
||||
duple = typeId(scope, false, CompletionKind.EXCEPTION_REFERENCE );
|
||||
exceptionSpecIds.add(duple);
|
||||
}
|
||||
catch (BacktrackException e)
|
||||
{
|
||||
failParse();
|
||||
TraceUtil.outputTrace( log, "Unexpected Token =", null, image, null, null ); //$NON-NLS-1$
|
||||
TraceUtil.outputTrace( log, "Unexpected Token =", null, image, null, null );
|
||||
consume();
|
||||
// eat this token anyway
|
||||
continue;
|
||||
|
@ -2207,8 +2209,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
continue;
|
||||
case IToken.tCOLON :
|
||||
consume(IToken.tCOLON);
|
||||
IASTExpression exp = null;
|
||||
exp = constantExpression(scope);
|
||||
IASTExpression exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
d.setBitFieldExpression(exp);
|
||||
default :
|
||||
break;
|
||||
|
@ -2224,7 +2225,8 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
((Declarator)d.getOwner()).setOwnedDeclarator(d);
|
||||
return d;
|
||||
}
|
||||
protected void consumeTemplatedOperatorName(Declarator d)
|
||||
|
||||
protected void consumeTemplatedOperatorName(Declarator d, CompletionKind kind)
|
||||
throws EndOfFileException, BacktrackException
|
||||
{
|
||||
if (LT(1) == IToken.t_operator)
|
||||
|
@ -2233,7 +2235,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
try
|
||||
{
|
||||
ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), CompletionKind.SINGLE_NAME_REFERENCE );
|
||||
ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), kind );
|
||||
d.setName(duple);
|
||||
|
||||
}
|
||||
|
@ -2347,7 +2349,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
if (LT(1) == IToken.tASSIGN)
|
||||
{
|
||||
consume(IToken.tASSIGN);
|
||||
initialValue = constantExpression(sdw.getScope());
|
||||
initialValue = constantExpression(sdw.getScope(), CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
}
|
||||
|
||||
if (LT(1) == IToken.tRBRACE)
|
||||
|
@ -2598,7 +2600,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
break;
|
||||
case IToken.tCOLONCOLON :
|
||||
case IToken.tIDENTIFIER :
|
||||
nameDuple = name(astClassSpec, CompletionKind.CLASS_REFERENCE );
|
||||
nameDuple = name(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE );
|
||||
break;
|
||||
case IToken.tCOMMA :
|
||||
try
|
||||
|
@ -2667,7 +2669,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
case IToken.t_case :
|
||||
consume(IToken.t_case);
|
||||
IASTExpression constant_expression = constantExpression(scope);
|
||||
IASTExpression constant_expression = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
constant_expression.acceptElement(requestor);
|
||||
consume(IToken.tCOLON);
|
||||
statement(scope);
|
||||
|
@ -2735,7 +2737,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume(IToken.tSEMI);
|
||||
if (LT(1) != IToken.tRPAREN)
|
||||
{
|
||||
IASTExpression finalExpression = expression(scope);
|
||||
IASTExpression finalExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
finalExpression.acceptElement(requestor);
|
||||
}
|
||||
consume(IToken.tRPAREN);
|
||||
|
@ -2753,7 +2755,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume();
|
||||
if (LT(1) != IToken.tSEMI)
|
||||
{
|
||||
IASTExpression retVal = expression(scope);
|
||||
IASTExpression retVal = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
retVal.acceptElement(requestor);
|
||||
}
|
||||
consume(IToken.tSEMI);
|
||||
|
@ -2794,9 +2796,9 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
IToken mark = mark();
|
||||
try
|
||||
{
|
||||
IASTExpression thisExpression = expression(scope);
|
||||
IASTExpression expressionStatement = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
consume(IToken.tSEMI);
|
||||
thisExpression.acceptElement( requestor );
|
||||
expressionStatement.acceptElement( requestor );
|
||||
return;
|
||||
}
|
||||
catch (BacktrackException b)
|
||||
|
@ -2857,7 +2859,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
*/
|
||||
protected void condition( IASTScope scope ) throws BacktrackException, EndOfFileException
|
||||
{
|
||||
IASTExpression someExpression = expression( scope );
|
||||
IASTExpression someExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE );
|
||||
someExpression.acceptElement(requestor);
|
||||
//TODO type-specifier-seq declarator = assignment expression
|
||||
}
|
||||
|
@ -2870,7 +2872,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
IToken mark = mark();
|
||||
try
|
||||
{
|
||||
IASTExpression e = expression( scope );
|
||||
IASTExpression e = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE );
|
||||
e.acceptElement(requestor);
|
||||
|
||||
consume( IToken.tSEMI );
|
||||
|
@ -3011,6 +3013,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
|
||||
protected void setCompletionToken( IToken token )
|
||||
{
|
||||
// do nothing!
|
||||
}
|
||||
|
||||
protected IToken getCompletionToken()
|
||||
|
@ -3023,28 +3026,33 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
*/
|
||||
public IASTNode parse(int startingOffset, int endingOffset)
|
||||
throws ParseError {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
throw new ParseError( ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int)
|
||||
*/
|
||||
public IASTCompletionNode parse(int offset) throws ParseError {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
throw new ParseError( ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
|
||||
*/
|
||||
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
||||
// do nothing as of yet
|
||||
// subclasses will need to implement this method
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#parserTimeout()
|
||||
*/
|
||||
protected boolean parserTimeout() {
|
||||
// TODO Auto-generated method stub
|
||||
return requestor.parserTimeout();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#getCompliationUnit()
|
||||
*/
|
||||
protected IASTNode getCompliationUnit() {
|
||||
return compilationUnit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2245,7 +2245,8 @@ public class ParserSymbolTable {
|
|||
}
|
||||
|
||||
if( ! (qualifyingSymbol instanceof IDerivableContainerSymbol) ){
|
||||
throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
|
||||
// throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError ); //TODO - Andrew, why is this an error?
|
||||
return ASTAccessVisibility.PUBLIC;
|
||||
}
|
||||
|
||||
List parents = ((IDerivableContainerSymbol) qualifyingSymbol).getParents();
|
||||
|
|
|
@ -2447,7 +2447,7 @@ public class Scanner implements IScanner {
|
|||
|
||||
parser = InternalParserUtil.createExpressionParser(trial, scannerData.getLanguage(), NULL_LOG_SERVICE);
|
||||
try {
|
||||
IASTExpression exp = parser.expression(null);
|
||||
IASTExpression exp = parser.expression(null, null);
|
||||
if( exp.evaluateExpression() == 0 )
|
||||
return false;
|
||||
return true;
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2004-04-07 John Camelon
|
||||
Updated CompletionFailedTest_ScopedReference_Prefix_Bug50152, moved it out of failed tests package and renamed it to CompletionTest_ScopedReference_Prefix_Bug50152.
|
||||
Updated CompletionFailedTest_TypeDef_Bug52948, moved it out of failed tests package and renamed it to CompletionTest_TypeDef_Bug52948.
|
||||
Updated CompletionFailedTest_ScopedReference_NoPrefix_Bug50152 to show Hoda/Andrew what is still broken.
|
||||
|
||||
2004-03-08 Hoda Amer
|
||||
Added one failed test: CompletionFailedTest_TypeDef_Bug52948
|
||||
|
||||
|
|
|
@ -70,12 +70,12 @@ public class AutomatedSuite extends TestSuite {
|
|||
|
||||
// Failed Tests
|
||||
addTest(CompletionFailedTest_ScopedReference_NoPrefix_Bug50152.suite());
|
||||
addTest(CompletionFailedTest_ScopedReference_Prefix_Bug50152.suite());
|
||||
addTest(CompletionTest_ScopedReference_Prefix_Bug50152.suite());
|
||||
addTest(CompletionTest_MacroRef_NoPrefix.suite());
|
||||
addTest(CompletionTest_MacroRef_Prefix.suite());
|
||||
addTest(CompletionFailedTest_FunctionReference_Bug50807.suite());
|
||||
addTest(CompletionFailedTest_ConstructorReference_Bug50808.suite());
|
||||
addTest(CompletionFailedTest_TypeDef_Bug52948.suite());
|
||||
addTest(CompletionTest_TypeDef_Bug52948.suite());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,27 +21,27 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
|
|||
* Bug#50152: Wrong context sent after a "::"
|
||||
*
|
||||
*/
|
||||
public class CompletionFailedTest_ScopedReference_Prefix_Bug50152 extends CompletionProposalsBaseTest{
|
||||
public class CompletionTest_ScopedReference_Prefix_Bug50152 extends CompletionProposalsBaseTest{
|
||||
|
||||
private final String fileName = "CompletionTestStart31.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"; // should be "ASTNamespaceDefinition";
|
||||
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // should be CompletionKind.SCOPED_REFERENCE;
|
||||
private final String expectedContextName = "ASTNamespaceDefinition";
|
||||
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE;
|
||||
private final String expectedPrefix = "a";
|
||||
private final String[] expectedResults = {
|
||||
// shoud be "aNamespaceFunction() void"
|
||||
"aNamespaceFunction() void"
|
||||
};
|
||||
|
||||
public CompletionFailedTest_ScopedReference_Prefix_Bug50152(String name) {
|
||||
public CompletionTest_ScopedReference_Prefix_Bug50152(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionFailedTest_ScopedReference_Prefix_Bug50152.class.getName());
|
||||
suite.addTest(new CompletionFailedTest_ScopedReference_Prefix_Bug50152("testCompletionProposals"));
|
||||
TestSuite suite= new TestSuite(CompletionTest_ScopedReference_Prefix_Bug50152.class.getName());
|
||||
suite.addTest(new CompletionTest_ScopedReference_Prefix_Bug50152("testCompletionProposals"));
|
||||
return suite;
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.text.contentassist;
|
||||
|
||||
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
|
||||
/**
|
||||
* @author hamer
|
||||
*
|
||||
* Testing Typedef as a possible returned type.
|
||||
* Bug#52948
|
||||
*
|
||||
*/
|
||||
public class CompletionTest_TypeDef_Bug52948 extends CompletionProposalsBaseTest{
|
||||
|
||||
private final String fileName = "CompletionTestStart37.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 = "ASTCompilationUnit";
|
||||
private final String expectedContextName = "null";
|
||||
private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE;
|
||||
private final String expectedPrefix = "m";
|
||||
private final String[] expectedResults = {
|
||||
"myType"
|
||||
};
|
||||
|
||||
public CompletionTest_TypeDef_Bug52948(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionTest_TypeDef_Bug52948.class.getName());
|
||||
suite.addTest(new CompletionTest_TypeDef_Bug52948("testCompletionProposals"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||
*/
|
||||
protected int getCompletionPosition() {
|
||||
return getBuffer().indexOf(" m ") + 2;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedScope()
|
||||
*/
|
||||
protected String getExpectedScopeClassName() {
|
||||
return expectedScopeName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedContext()
|
||||
*/
|
||||
protected String getExpectedContextClassName() {
|
||||
return expectedContextName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedKind()
|
||||
*/
|
||||
protected CompletionKind getExpectedKind() {
|
||||
return expectedKind;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix()
|
||||
*/
|
||||
protected String getExpectedPrefix() {
|
||||
return expectedPrefix;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues()
|
||||
*/
|
||||
protected String[] getExpectedResultsValues() {
|
||||
return expectedResults;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName()
|
||||
*/
|
||||
protected String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath()
|
||||
*/
|
||||
protected String getFileFullPath() {
|
||||
return fileFullPath;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath()
|
||||
*/
|
||||
protected String getHeaderFileFullPath() {
|
||||
return headerFileFullPath;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName()
|
||||
*/
|
||||
protected String getHeaderFileName() {
|
||||
return headerFileName;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,11 +29,11 @@ public class CompletionFailedTest_ScopedReference_NoPrefix_Bug50152 extends Com
|
|||
private final String headerFileName = "CompletionTestStart.h";
|
||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||
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 expectedContextName = "ASTNamespaceDefinition";
|
||||
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE;
|
||||
private final String expectedPrefix = "";
|
||||
private final String[] expectedResults = {
|
||||
// shoud be "aNamespaceFunction() void"
|
||||
// "aNamespaceFunction() void" /* Hoda uncomment this to see the failure */
|
||||
};
|
||||
|
||||
public CompletionFailedTest_ScopedReference_NoPrefix_Bug50152(String name) {
|
||||
|
|
Loading…
Add table
Reference in a new issue