use of org.eclipse.xtext.common.types.JvmAnnotationValue in project xtext-xtend by eclipse.
the class AnnotationReferenceBuildContextImpl method setValues.
protected void setValues(final String name, final Object values, final String componentType, final boolean mustBeArray) {
final JvmOperation op = this.findOperation(name, mustBeArray);
final JvmAnnotationValue newValue = this.createAnnotationValue(op, values);
newValue.setOperation(op);
this.setValue(newValue, values, componentType, mustBeArray);
this.remove(op);
this.delegate.getExplicitValues().add(newValue);
}
use of org.eclipse.xtext.common.types.JvmAnnotationValue in project xtext-xtend by eclipse.
the class JvmAnnotationReferenceImpl method getExpression.
@Override
public Expression getExpression(final String property) {
final JvmOperation op = this.findOperation(property);
final Function1<JvmAnnotationValue, Boolean> _function = (JvmAnnotationValue it) -> {
return Boolean.valueOf((Objects.equal(it.getOperation(), op) || ((it.getOperation() == null) && Objects.equal(op.getSimpleName(), "value"))));
};
final JvmAnnotationValue annotationValue = IterableExtensions.<JvmAnnotationValue>findFirst(this.getDelegate().getValues(), _function);
boolean _matched = false;
if (annotationValue instanceof JvmCustomAnnotationValue) {
_matched = true;
EObject _head = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue) annotationValue).getValues());
final XExpression expression = ((XExpression) _head);
if (((expression != null) && this.getCompilationUnit().isBelongedToCompilationUnit(expression))) {
return this.getCompilationUnit().toExpression(expression);
}
}
return null;
}
use of org.eclipse.xtext.common.types.JvmAnnotationValue in project xtext-xtend by eclipse.
the class JvmAnnotationReferenceImpl method getValue.
@Override
public Object getValue(final String property) {
try {
final JvmOperation op = this.findOperation(property);
final Function1<JvmAnnotationValue, Boolean> _function = (JvmAnnotationValue it) -> {
return Boolean.valueOf((Objects.equal(it.getOperation(), op) || ((it.getOperation() == null) && Objects.equal(op.getSimpleName(), "value"))));
};
final JvmAnnotationValue annotationValue = IterableExtensions.<JvmAnnotationValue>findFirst(this.getDelegate().getValues(), _function);
final boolean isArrayType = ((op != null) && this.getCompilationUnit().getTypeReferences().isArray(op.getReturnType()));
if ((annotationValue != null)) {
return this.getCompilationUnit().translateAnnotationValue(annotationValue, isArrayType);
}
} catch (final Throwable _t) {
if (_t instanceof ConstantExpressionEvaluationException) {
final ConstantExpressionEvaluationException e = (ConstantExpressionEvaluationException) _t;
this.getCompilationUnit().getProblemSupport().addError(this, e.getMessage());
} else {
throw Exceptions.sneakyThrow(_t);
}
}
return null;
}
Aggregations