VariableDeclaration declaration = (VariableDeclaration) constNode;
Element element = declaration.getElement();
EvaluationResultImpl result = declaration.getInitializer().accept(createConstantVisitor());
((VariableElementImpl) element).setEvaluationResult(result);
} else if (constNode instanceof InstanceCreationExpression) {
InstanceCreationExpression expression = (InstanceCreationExpression) constNode;
ConstructorElement constructor = expression.getStaticElement();
if (constructor == null) {
// Couldn't resolve the constructor so we can't compute a value. No problem--the error
// has already been reported.
return;
}
ConstantVisitor constantVisitor = createConstantVisitor();
EvaluationResultImpl result = evaluateConstructorCall(
constNode,
expression.getArgumentList().getArguments(),
constructor,
constantVisitor);
expression.setEvaluationResult(result);
} else if (constNode instanceof ConstructorDeclaration) {
ConstructorDeclaration declaration = (ConstructorDeclaration) constNode;
NodeList<ConstructorInitializer> initializers = declaration.getInitializers();
ConstructorElementImpl constructor = (ConstructorElementImpl) declaration.getElement();
constructor.setConstantInitializers(new InitializerCloner().cloneNodeList(initializers));