use of org.eclipse.xtext.xbase.interpreter.StackedConstantExpressionEvaluationException in project xtext-xtend by eclipse.
the class ConstantExpressionsInterpreter method evaluateField.
protected Object evaluateField(final XAbstractFeatureCall call, final JvmField field, final Context context) {
if ((field.isSetConstant() || (field.eResource() instanceof TypeResource))) {
boolean _isConstant = field.isConstant();
if (_isConstant) {
return field.getConstantValue();
} else {
String _simpleName = field.getDeclaringType().getSimpleName();
String _plus = ("Field " + _simpleName);
String _plus_1 = (_plus + ".");
String _simpleName_1 = field.getSimpleName();
String _plus_2 = (_plus_1 + _simpleName_1);
String _plus_3 = (_plus_2 + " is not a constant");
throw new ConstantExpressionEvaluationException(_plus_3);
}
}
final XExpression expression = this.containerProvider.getAssociatedExpression(field);
boolean _contains = context.getAlreadyEvaluating().contains(expression);
if (_contains) {
throw new ConstantExpressionEvaluationException("Endless recursive evaluation detected.");
}
try {
final Map<String, JvmIdentifiableElement> visibleFeatures = this.findVisibleFeatures(expression);
JvmTypeReference _type = field.getType();
ClassFinder _classFinder = context.getClassFinder();
Set<XExpression> _alreadyEvaluating = context.getAlreadyEvaluating();
final Context ctx = new Context(_type, _classFinder, visibleFeatures, _alreadyEvaluating);
return this.evaluate(expression, ctx);
} catch (final Throwable _t) {
if (_t instanceof ConstantExpressionEvaluationException) {
final ConstantExpressionEvaluationException e = (ConstantExpressionEvaluationException) _t;
throw new StackedConstantExpressionEvaluationException(call, field, e);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
Aggregations