mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Start at content assist for constructor initializers.
This commit is contained in:
parent
90c4d131cc
commit
8230e97539
2 changed files with 37 additions and 12 deletions
|
@ -488,9 +488,12 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
*/
|
*/
|
||||||
protected IASTCompoundStatement compoundStatement()
|
protected IASTCompoundStatement compoundStatement()
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
|
IASTCompoundStatement result = createCompoundStatement();
|
||||||
|
if (LT(1) == IToken.tEOC)
|
||||||
|
return result;
|
||||||
|
|
||||||
int startingOffset = consume(IToken.tLBRACE).getOffset();
|
int startingOffset = consume(IToken.tLBRACE).getOffset();
|
||||||
|
|
||||||
IASTCompoundStatement result = createCompoundStatement();
|
|
||||||
((ASTNode) result).setOffset(startingOffset);
|
((ASTNode) result).setOffset(startingOffset);
|
||||||
result.setPropertyInParent(IASTFunctionDefinition.FUNCTION_BODY);
|
result.setPropertyInParent(IASTFunctionDefinition.FUNCTION_BODY);
|
||||||
while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tEOC) {
|
while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tEOC) {
|
||||||
|
|
|
@ -2808,6 +2808,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
constructorChain = new ArrayList(
|
constructorChain = new ArrayList(
|
||||||
DEFAULT_CONSTRUCTOR_CHAIN_LIST_SIZE);
|
DEFAULT_CONSTRUCTOR_CHAIN_LIST_SIZE);
|
||||||
ctorInitializer(constructorChain);
|
ctorInitializer(constructorChain);
|
||||||
|
hasFunctionBody = true;
|
||||||
break;
|
break;
|
||||||
case IToken.tLBRACE:
|
case IToken.tLBRACE:
|
||||||
break;
|
break;
|
||||||
|
@ -2954,19 +2955,35 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
protected void ctorInitializer(List collection) throws EndOfFileException,
|
protected void ctorInitializer(List collection) throws EndOfFileException,
|
||||||
BacktrackException {
|
BacktrackException {
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
for (;;) {
|
ctorLoop: for (;;) {
|
||||||
if (LT(1) == IToken.tLBRACE)
|
|
||||||
break;
|
|
||||||
ITokenDuple duple = name();
|
ITokenDuple duple = name();
|
||||||
IASTName name = createName(duple);
|
IASTName name = createName(duple);
|
||||||
|
|
||||||
consume(IToken.tLPAREN);
|
int end;
|
||||||
IASTExpression expressionList = null;
|
IASTExpression expressionList = null;
|
||||||
|
switch (LT(1)) {
|
||||||
|
case IToken.tLPAREN:
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
|
||||||
if (LT(1) != IToken.tRPAREN)
|
if (LT(1) != IToken.tRPAREN)
|
||||||
expressionList = expression();
|
expressionList = expression();
|
||||||
|
|
||||||
int end = consume(IToken.tRPAREN).getEndOffset();
|
switch (LT(1)) {
|
||||||
|
case IToken.tRPAREN:
|
||||||
|
case IToken.tEOC:
|
||||||
|
end = consume().getEndOffset();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IToken.tEOC:
|
||||||
|
end = consume().getEndOffset();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
|
||||||
ICPPASTConstructorChainInitializer ctorInitializer = createConstructorChainInitializer();
|
ICPPASTConstructorChainInitializer ctorInitializer = createConstructorChainInitializer();
|
||||||
((ASTNode) ctorInitializer).setOffsetAndLength(duple
|
((ASTNode) ctorInitializer).setOffsetAndLength(duple
|
||||||
.getStartOffset(), end - duple.getStartOffset());
|
.getStartOffset(), end - duple.getStartOffset());
|
||||||
|
@ -2982,11 +2999,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
.setPropertyInParent(ICPPASTConstructorChainInitializer.INITIALIZER);
|
.setPropertyInParent(ICPPASTConstructorChainInitializer.INITIALIZER);
|
||||||
}
|
}
|
||||||
collection.add(ctorInitializer);
|
collection.add(ctorInitializer);
|
||||||
if (LT(1) == IToken.tLBRACE)
|
|
||||||
break;
|
|
||||||
consume(IToken.tCOMMA);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
switch (LT(1)) {
|
||||||
|
case IToken.tCOMMA:
|
||||||
|
consume(IToken.tCOMMA);
|
||||||
|
break;
|
||||||
|
case IToken.tLBRACE:
|
||||||
|
case IToken.tEOC:
|
||||||
|
break ctorLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue