use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.
the class ConstantExpressionsInterpreter method getJavaType.
protected Class<?> getJavaType(final JvmType type, final ClassFinder classFinder) throws ClassNotFoundException {
if ((type instanceof JvmArrayType)) {
JvmType t = type;
String dimensions = "";
while ((t instanceof JvmArrayType)) {
{
dimensions = (dimensions + "[]");
t = ((JvmArrayType) t).getComponentType();
}
}
final Class<?> componentClass = this.getJavaType(t, classFinder);
String _name = componentClass.getName();
String _plus = (_name + dimensions);
return classFinder.forName(_plus);
}
String _identifier = type.getIdentifier();
boolean _equals = Objects.equal(_identifier, "java.lang.Class");
if (_equals) {
return JvmTypeReference.class;
}
if ((type instanceof JvmEnumerationType)) {
return JvmEnumerationLiteral.class;
}
if ((type instanceof JvmAnnotationType)) {
return XAnnotation.class;
}
return classFinder.forName(type.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.
the class XAnnotationExtensions method tryFindAnnotationType.
public JvmAnnotationType tryFindAnnotationType(final XAnnotation it) {
Object _eGet = it.eGet(XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE, false);
final Object proxy = _eGet;
boolean _matched = false;
if (proxy instanceof EObject) {
boolean _eIsProxy = ((EObject) proxy).eIsProxy();
if (_eIsProxy) {
_matched = true;
final URI uri = ((InternalEObject) proxy).eProxyURI();
EObject _eObject = it.eResource().getResourceSet().getEObject(uri, true);
return ((JvmAnnotationType) _eObject);
}
}
if (!_matched) {
if (proxy instanceof JvmAnnotationType) {
_matched = true;
return ((JvmAnnotationType) proxy);
}
}
return null;
}
use of org.eclipse.xtext.common.types.JvmAnnotationType 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.JvmAnnotationType 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.JvmAnnotationType in project xtext-xtend by eclipse.
the class JvmAnnotationReferenceImpl method findOperation.
private JvmOperation findOperation(final String name) {
ConditionUtils.checkJavaIdentifier(name, "name");
AnnotationTypeDeclaration _annotationTypeDeclaration = this.getAnnotationTypeDeclaration();
final JvmAnnotationType jvmAnnoType = ((JvmAnnotationTypeDeclarationImpl) _annotationTypeDeclaration).getDelegate();
final Function1<JvmOperation, Boolean> _function = (JvmOperation it) -> {
String _simpleName = it.getSimpleName();
return Boolean.valueOf(Objects.equal(_simpleName, name));
};
final JvmOperation jvmOperation = IterableExtensions.<JvmOperation>findFirst(jvmAnnoType.getDeclaredOperations(), _function);
if ((jvmOperation == null)) {
String _identifier = jvmAnnoType.getIdentifier();
String _plus = ((("The annotation property \'" + name) + "\' is not declared on the annotation type \'") + _identifier);
String _plus_1 = (_plus + "\'.");
throw new IllegalArgumentException(_plus_1);
}
return jvmOperation;
}
Aggregations