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:
parent
d0fafae908
commit
c209eb8372
2 changed files with 54 additions and 7 deletions
|
@ -224,4 +224,39 @@ public class BasicCompletionTest extends CompletionTestBase {
|
||||||
checkCompletion(code, false, expected);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -942,7 +942,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
plcmt= expressionList();
|
plcmt= expressionList();
|
||||||
endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset();
|
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) ...
|
// (P)(T) ...
|
||||||
isNewTypeId= false;
|
isNewTypeId= false;
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
|
@ -959,12 +963,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
typeid= null;
|
typeid= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lt1= LT(1);
|
if (typeid != null && plcmt != null) {
|
||||||
if (typeid != null && plcmt != null && (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE)) {
|
|
||||||
// (P)(T)(I) or (P) T (I)
|
// (P)(T)(I) or (P) T (I)
|
||||||
init= bracedOrCtorStyleInitializer();
|
int lt1= LT(1);
|
||||||
endOffset= calculateEndOffset(init);
|
if (lt1 == IToken.tEOC)
|
||||||
return newExpression(isGlobal, plcmt, typeid, isNewTypeId, init, offset, endOffset);
|
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) ...
|
// (T) ...
|
||||||
|
@ -976,7 +985,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
typeid2= typeId(DeclarationOptions.TYPEID);
|
typeid2= typeId(DeclarationOptions.TYPEID);
|
||||||
endOffset2= consumeOrEOC(IToken.tRPAREN).getEndOffset();
|
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 (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE) {
|
||||||
if (plcmt != null &&
|
if (plcmt != null &&
|
||||||
ASTQueries.findTypeRelevantDeclarator(typeid2.getAbstractDeclarator()) instanceof IASTArrayDeclarator) {
|
ASTQueries.findTypeRelevantDeclarator(typeid2.getAbstractDeclarator()) instanceof IASTArrayDeclarator) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue