use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class CompilationUnitImpl method translateAnnotation.
protected AnnotationReference translateAnnotation(final XAnnotation annotation) {
AnnotationReference _xblockexpression = null;
{
AnnotationReferenceBuildContextImpl _annotationReferenceBuildContextImpl = new AnnotationReferenceBuildContextImpl();
final Procedure1<AnnotationReferenceBuildContextImpl> _function = (AnnotationReferenceBuildContextImpl it) -> {
it.setCompilationUnit(this);
JvmAnnotationReference _createJvmAnnotationReference = this.typesFactory.createJvmAnnotationReference();
final Procedure1<JvmAnnotationReference> _function_1 = (JvmAnnotationReference reference) -> {
JvmType _annotationType = annotation.getAnnotationType();
reference.setAnnotation(((JvmAnnotationType) _annotationType));
};
JvmAnnotationReference _doubleArrow = ObjectExtensions.<JvmAnnotationReference>operator_doubleArrow(_createJvmAnnotationReference, _function_1);
it.setDelegate(_doubleArrow);
};
final AnnotationReferenceBuildContextImpl buildContext = ObjectExtensions.<AnnotationReferenceBuildContextImpl>operator_doubleArrow(_annotationReferenceBuildContextImpl, _function);
EList<XAnnotationElementValuePair> _elementValuePairs = annotation.getElementValuePairs();
for (final XAnnotationElementValuePair valuePair : _elementValuePairs) {
{
final XExpression value = valuePair.getValue();
if ((value != null)) {
final JvmOperation operation = valuePair.getElement();
final Object annotationValue = this.translateAnnotationValue(value, operation.getReturnType());
buildContext.set(operation.getSimpleName(), annotationValue);
}
}
}
XExpression _value = annotation.getValue();
boolean _tripleNotEquals = (_value != null);
if (_tripleNotEquals) {
final Object annotationValue = this.translateAnnotationValue(annotation.getValue(), null);
buildContext.set("value", annotationValue);
}
_xblockexpression = this.toAnnotationReference(buildContext.getDelegate());
}
return _xblockexpression;
}
use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class CompilationUnitImpl method findExpectedType.
protected JvmTypeReference findExpectedType(final JvmAnnotationValue value) {
JvmOperation _operation = value.getOperation();
boolean _tripleNotEquals = (_operation != null);
if (_tripleNotEquals) {
return value.getOperation().getReturnType();
}
JvmTypeReference _switchResult = null;
EObject _eContainer = value.eContainer();
final EObject container = _eContainer;
boolean _matched = false;
if (container instanceof JvmOperation) {
_matched = true;
_switchResult = ((JvmOperation) container).getReturnType();
}
if (!_matched) {
if (container instanceof JvmAnnotationReference) {
_matched = true;
JvmTypeReference _xblockexpression = null;
{
final JvmOperation defaultOp = IterableExtensions.<JvmOperation>head(Iterables.<JvmOperation>filter(((JvmAnnotationReference) container).getAnnotation().findAllFeaturesByName("value"), JvmOperation.class));
JvmTypeReference _xifexpression = null;
if ((defaultOp != null)) {
_xifexpression = defaultOp.getReturnType();
}
_xblockexpression = _xifexpression;
}
_switchResult = _xblockexpression;
}
}
return _switchResult;
}
use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class XAnnotationExtensions method getProcessorType.
public JvmType getProcessorType(final JvmAnnotationType it) {
final Function1<JvmAnnotationReference, Boolean> _function = (JvmAnnotationReference it_1) -> {
JvmAnnotationType _annotation = it_1.getAnnotation();
String _identifier = null;
if (_annotation != null) {
_identifier = _annotation.getIdentifier();
}
String _name = Active.class.getName();
return Boolean.valueOf(Objects.equal(_identifier, _name));
};
final JvmAnnotationReference activeAnnotation = IterableExtensions.<JvmAnnotationReference>findFirst(it.getAnnotations(), _function);
final Function1<JvmAnnotationValue, Boolean> _function_1 = (JvmAnnotationValue it_1) -> {
return Boolean.valueOf(((it_1.getOperation() == null) || Objects.equal(it_1.getOperation().getSimpleName(), "value")));
};
final JvmAnnotationValue annoVal = IterableExtensions.<JvmAnnotationValue>findFirst(activeAnnotation.getValues(), _function_1);
boolean _matched = false;
if (annoVal instanceof JvmTypeAnnotationValue) {
_matched = true;
JvmTypeReference _head = IterableExtensions.<JvmTypeReference>head(((JvmTypeAnnotationValue) annoVal).getValues());
JvmType _type = null;
if (_head != null) {
_type = _head.getType();
}
return _type;
}
if (!_matched) {
if (annoVal instanceof JvmCustomAnnotationValue) {
_matched = true;
EObject _head = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue) annoVal).getValues());
JvmOperation _operation = ((JvmCustomAnnotationValue) annoVal).getOperation();
JvmTypeReference _returnType = null;
if (_operation != null) {
_returnType = _operation.getReturnType();
}
final Object type = this.constantExpressionsInterpreter.evaluate(((XExpression) _head), _returnType);
if ((type instanceof JvmTypeReference)) {
return ((JvmTypeReference) type).getType();
}
}
}
return null;
}
use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class AnnotationReferenceProviderImpl method createJvmAnnotationReference.
protected JvmAnnotationReference createJvmAnnotationReference(final JvmType type) {
JvmAnnotationReference _switchResult = null;
boolean _matched = false;
if (type instanceof JvmAnnotationType) {
_matched = true;
JvmAnnotationReference _createJvmAnnotationReference = TypesFactory.eINSTANCE.createJvmAnnotationReference();
final Procedure1<JvmAnnotationReference> _function = (JvmAnnotationReference it) -> {
it.setAnnotation(((JvmAnnotationType) type));
};
_switchResult = ObjectExtensions.<JvmAnnotationReference>operator_doubleArrow(_createJvmAnnotationReference, _function);
}
if (!_matched) {
_switchResult = null;
}
return _switchResult;
}
use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method transform.
protected void transform(XtendEnumLiteral literal, JvmEnumerationType container) {
if (literal.getName() == null)
return;
JvmEnumerationLiteral jvmLiteral = typesFactory.createJvmEnumerationLiteral();
associator.associatePrimary(literal, jvmLiteral);
jvmLiteral.setSimpleName(literal.getName());
jvmLiteral.setVisibility(JvmVisibility.PUBLIC);
jvmLiteral.setStatic(true);
jvmLiteral.setFinal(true);
jvmTypesBuilder.copyDocumentationTo(literal, jvmLiteral);
for (XAnnotation anno : literal.getAnnotations()) {
if (!annotationTranslationFilter.apply(anno))
continue;
JvmAnnotationReference annotationReference = jvmTypesBuilder.getJvmAnnotationReference(anno);
if (annotationReference != null)
jvmLiteral.getAnnotations().add(annotationReference);
}
container.getMembers().add(jvmLiteral);
}
Aggregations