use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class RegisterGlobalsContextImpl method registerClass.
@Override
public void registerClass(final String qualifiedName) throws IllegalArgumentException {
final JvmGenericType newType = TypesFactory.eINSTANCE.createJvmGenericType();
newType.setVisibility(JvmVisibility.PUBLIC);
EList<JvmTypeReference> _superTypes = newType.getSuperTypes();
JvmTypeReference _typeForName = this.compilationUnit.getTypeReferences().getTypeForName(Object.class, this.compilationUnit.getXtendFile());
_superTypes.add(_typeForName);
this.setNameAndAccept(newType, qualifiedName);
}
use of org.eclipse.xtext.common.types.JvmTypeReference 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.JvmTypeReference in project xtext-xtend by eclipse.
the class AnnotationReferenceBuildContextImpl method throwNotApplicable.
protected void throwNotApplicable(final JvmAnnotationValue it, final String valueType) {
JvmTypeReference _returnType = it.getOperation().getReturnType();
JvmType _type = null;
if (_returnType != null) {
_type = _returnType.getType();
}
String _isNotApplicableMessage = ConditionUtils.isNotApplicableMessage(valueType, this.getAnnotationValueTypeName(_type));
throw new IllegalArgumentException(_isNotApplicableMessage);
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class AnnotationReferenceBuildContextImpl method _setValue.
protected void _setValue(final JvmAnnotationValue it, final Object value, final String componentType, final boolean mustBeArray) {
if ((componentType == null)) {
this.throwNotApplicable(it, value.getClass().getName());
}
boolean _or = false;
if (mustBeArray) {
_or = true;
} else {
JvmTypeReference _returnType = it.getOperation().getReturnType();
JvmType _type = null;
if (_returnType != null) {
_type = _returnType.getType();
}
EClass _eClass = null;
if (_type != null) {
_eClass = _type.eClass();
}
boolean _equals = Objects.equal(_eClass, TypesPackage.Literals.JVM_ARRAY_TYPE);
_or = _equals;
}
if (_or) {
this.throwNotApplicable(it, (componentType + "[]"));
}
this.throwNotApplicable(it, componentType);
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class AnnotationReferenceBuildContextImpl method checkType.
protected void checkType(final JvmAnnotationValue it, final String componentType, final boolean mustBeArray) {
if ((componentType == null)) {
return;
}
JvmTypeReference _returnType = it.getOperation().getReturnType();
JvmType _type = null;
if (_returnType != null) {
_type = _returnType.getType();
}
final JvmType returnType = _type;
boolean _or = false;
if (mustBeArray) {
_or = true;
} else {
EClass _eClass = null;
if (returnType != null) {
_eClass = returnType.eClass();
}
boolean _equals = Objects.equal(_eClass, TypesPackage.Literals.JVM_ARRAY_TYPE);
_or = _equals;
}
if (_or) {
ConditionUtils.checkTypeName(this.getAnnotationValueTypeName(returnType), (componentType + "[]"));
} else {
ConditionUtils.checkTypeName(this.getAnnotationValueTypeName(returnType), componentType);
}
}
Aggregations