1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 313982: Content assist in placement new.

This commit is contained in:
Markus Schorn 2010-08-06 11:12:02 +00:00
parent d0fafae908
commit c209eb8372
2 changed files with 54 additions and 7 deletions

View file

@ -224,4 +224,39 @@ public class BasicCompletionTest extends CompletionTestBase {
checkCompletion(code, false, expected);
}
// struct B {
// int m;
// };
// int foo() {
// B * b;
// new (b->
public void testNewExpressions_Bug313982a() throws Exception {
String code = getAboveComment();
String[] expected= {"B", "m"};
checkCompletion(code, true, expected);
}
// struct B {
// int m;
// };
// int foo() {
// B * b;
// new (b->m) B
public void testNewExpressions_Bug313982b() throws Exception {
String code = getAboveComment();
String[] expected= {"B"};
checkCompletion(code, true, expected);
}
// struct B {
// int m;
// };
// int foo() {
// B * b;
// new (b->m) (B
public void testNewExpressions_Bug313982c() throws Exception {
String code = getAboveComment();
String[] expected= {"B"};
checkCompletion(code, true, expected);
}
}

View file

@ -942,7 +942,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
plcmt= expressionList();
endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset();
if (LT(1) == IToken.tLPAREN) {
final int lt1= LT(1);
if (lt1 == IToken.tEOC) {
return newExpression(isGlobal, plcmt, typeid, isNewTypeId, init, offset, endOffset);
}
if (lt1 == IToken.tLPAREN) {
// (P)(T) ...
isNewTypeId= false;
consume(IToken.tLPAREN);
@ -959,12 +963,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
typeid= null;
}
int lt1= LT(1);
if (typeid != null && plcmt != null && (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE)) {
if (typeid != null && plcmt != null) {
// (P)(T)(I) or (P) T (I)
init= bracedOrCtorStyleInitializer();
endOffset= calculateEndOffset(init);
return newExpression(isGlobal, plcmt, typeid, isNewTypeId, init, offset, endOffset);
int lt1= LT(1);
if (lt1 == IToken.tEOC)
return newExpression(isGlobal, plcmt, typeid, isNewTypeId, init, offset, endOffset);
if (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE) {
init= bracedOrCtorStyleInitializer();
endOffset= calculateEndOffset(init);
return newExpression(isGlobal, plcmt, typeid, isNewTypeId, init, offset, endOffset);
}
}
// (T) ...
@ -976,7 +985,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
typeid2= typeId(DeclarationOptions.TYPEID);
endOffset2= consumeOrEOC(IToken.tRPAREN).getEndOffset();
lt1= LT(1);
final int lt1= LT(1);
if (lt1 == IToken.tEOC)
return newExpression(isGlobal, null, typeid2, false, init2, offset, endOffset2);
if (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE) {
if (plcmt != null &&
ASTQueries.findTypeRelevantDeclarator(typeid2.getAbstractDeclarator()) instanceof IASTArrayDeclarator) {