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

Bug 308611: Content assist after '?' in conditional expression.

This commit is contained in:
Markus Schorn 2010-04-26 13:14:33 +00:00
parent e25607ecbf
commit 817e8b717b
2 changed files with 23 additions and 10 deletions

View file

@ -205,14 +205,23 @@ public class BasicCompletionTest extends CompletionTestBase {
checkCompletion(code, true, expectedCpp);
}
// typedef int MyType;
// void func(){
// static_cast<My
// typedef int MyType;
// void func(){
// static_cast<My
public void testCastExpression_Bug301933() throws Exception {
String code = getAboveComment();
String[] expectedCpp= {"MyType"};
checkCompletion(code, true, expectedCpp);
}
// int v1, v2;
// void func() {
// v1= 0 ? v
public void testConditionalOperator_Bug308611() throws Exception {
String code = getAboveComment();
String[] expected= {"v1", "v2"};
checkCompletion(code, true, expected);
checkCompletion(code, false, expected);
}
}

View file

@ -968,14 +968,18 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
final IASTInitializerClause right= operator.fExpression;
switch(operator.fOperatorToken) {
case IToken.tQUESTION:
final IASTInitializerClause negative;
if (operator.fNext == null || operator.fNext.fOperatorToken != IToken.tCOLON) {
assert false;
ASTNode node= (ASTNode) left;
throwBacktrack(node.getOffset(), node.getLength());
return null; // Will never be reached.
if (LTcatchEOF(1) != IToken.tEOC || operator.fNext != null) {
assert false;
ASTNode node= (ASTNode) left;
throwBacktrack(node.getOffset(), node.getLength());
}
negative= null;
} else {
negative= operator.fNext.fExpression;
operator.fNext= operator.fNext.fNext;
}
IASTInitializerClause negative= operator.fNext.fExpression;
operator.fNext= operator.fNext.fNext;
IASTConditionalExpression conditionalEx = nodeFactory.newConditionalExpession(left, (IASTExpression) right, (IASTExpression) negative);
setRange(conditionalEx, left);
if (negative != null) {