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:
parent
e25607ecbf
commit
817e8b717b
2 changed files with 23 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
if (LTcatchEOF(1) != IToken.tEOC || operator.fNext != null) {
|
||||
assert false;
|
||||
ASTNode node= (ASTNode) left;
|
||||
throwBacktrack(node.getOffset(), node.getLength());
|
||||
return null; // Will never be reached.
|
||||
}
|
||||
IASTInitializerClause negative= operator.fNext.fExpression;
|
||||
negative= null;
|
||||
} else {
|
||||
negative= operator.fNext.fExpression;
|
||||
operator.fNext= operator.fNext.fNext;
|
||||
}
|
||||
IASTConditionalExpression conditionalEx = nodeFactory.newConditionalExpession(left, (IASTExpression) right, (IASTExpression) negative);
|
||||
setRange(conditionalEx, left);
|
||||
if (negative != null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue