private FieldDeclaration addInstanceVar(ConstructorDeclaration constructor, TypeReference typeReference, TypeDeclaration innerClass) { FieldDeclaration field = new FieldDeclaration(); field.modifiers = AccPrivate | AccStatic | AccFinal; field.name = "INSTANCE".toCharArray(); field.type = typeReference; AllocationExpression exp = new AllocationExpression(); exp.type = typeReference; exp.binding = constructor.binding; exp.sourceStart = innerClass.sourceStart; exp.sourceEnd = innerClass.sourceEnd; field.initialization = exp; return field; }
public RecoveredElement add(Statement statement, int bracketBalanceValue) { if (this.alreadyCompletedFieldInitialization || !(statement instanceof Expression)) { return super.add(statement, bracketBalanceValue); } else { if (statement.sourceEnd > 0) this.alreadyCompletedFieldInitialization = true; // else we may still be inside the initialization, having parsed only a part of it yet if (!(statement instanceof AllocationExpression) && this.fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) { AllocationExpression alloc = new AllocationExpression(); alloc.arguments = new Expression[] {(Expression) statement}; this.fieldDeclaration.initialization = alloc; } else { this.fieldDeclaration.initialization = (Expression) statement; this.fieldDeclaration.declarationSourceEnd = statement.sourceEnd; this.fieldDeclaration.declarationEnd = statement.sourceEnd; } return this; } } /*
@Override public RecoveredElement add(Statement statement, int bracketBalanceValue) { if (this.alreadyCompletedFieldInitialization || !(statement instanceof Expression)) { return super.add(statement, bracketBalanceValue); } else { if (statement.sourceEnd > 0) this.alreadyCompletedFieldInitialization = true; // else we may still be inside the initialization, having parsed only a part of it yet if (!(statement instanceof AllocationExpression) && this.fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) { AllocationExpression alloc = new AllocationExpression(); alloc.arguments = new Expression[] {(Expression) statement}; this.fieldDeclaration.initialization = alloc; } else { this.fieldDeclaration.initialization = (Expression) statement; this.fieldDeclaration.declarationSourceEnd = statement.sourceEnd; this.fieldDeclaration.declarationEnd = statement.sourceEnd; } return this; } } /*
alloc = new AllocationExpression(); alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
alloc = new AllocationExpression(); alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
alloc = new AllocationExpression(); alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
alloc = new AllocationExpression(); alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
alloc = new QualifiedAllocationExpression(); } else { alloc = new AllocationExpression();
alloc = new QualifiedAllocationExpression(); } else { alloc = new AllocationExpression();
alloc = new QualifiedAllocationExpression(); } else { alloc = new AllocationExpression();
alloc = new QualifiedAllocationExpression(); } else { alloc = new AllocationExpression();
alloc = new QualifiedAllocationExpression(); } else { alloc = new AllocationExpression();
alloc = new QualifiedAllocationExpression(); } else { alloc = new AllocationExpression();
alloc = new QualifiedAllocationExpression(); } else { alloc = new AllocationExpression();
init = new AllocationExpression(); init.enumConstant = decl; } else {
init = new AllocationExpression(); init.enumConstant = decl; } else {
init = new AllocationExpression(); init.enumConstant = decl; } else {