use of org.eclipse.xtext.common.types.JvmType 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.JvmType 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);
}
}
use of org.eclipse.xtext.common.types.JvmType 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.JvmType in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toType.
public Type toType(final JvmType delegate) {
final Function1<JvmType, Type> _function = (JvmType it) -> {
Type _switchResult = null;
boolean _matched = false;
if (delegate instanceof JvmDeclaredType) {
_matched = true;
_switchResult = this.toTypeDeclaration(((JvmDeclaredType) delegate));
}
if (!_matched) {
if (delegate instanceof JvmTypeParameter) {
_matched = true;
_switchResult = this.toTypeParameterDeclaration(((JvmTypeParameter) delegate));
}
}
if (!_matched) {
if (delegate instanceof JvmVoid) {
_matched = true;
VoidTypeImpl _voidTypeImpl = new VoidTypeImpl();
final Procedure1<VoidTypeImpl> _function_1 = (VoidTypeImpl it_1) -> {
it_1.setDelegate(((JvmVoid) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<VoidTypeImpl>operator_doubleArrow(_voidTypeImpl, _function_1);
}
}
if (!_matched) {
if (delegate instanceof JvmPrimitiveType) {
_matched = true;
PrimitiveTypeImpl _primitiveTypeImpl = new PrimitiveTypeImpl();
final Procedure1<PrimitiveTypeImpl> _function_1 = (PrimitiveTypeImpl it_1) -> {
it_1.setDelegate(((JvmPrimitiveType) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<PrimitiveTypeImpl>operator_doubleArrow(_primitiveTypeImpl, _function_1);
}
}
return _switchResult;
};
return this.<JvmType, Type>getOrCreate(delegate, _function);
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class TypeLookupImpl method findTypeOnScope.
private Type findTypeOnScope(final String typeName, final Function1<? super IEObjectDescription, ? extends Boolean> filter) {
final QualifiedName qualifiedName = this.compilationUnit.getQualifiedNameConverter().toQualifiedName(typeName);
final IEObjectDescription result = this.compilationUnit.getScopeProvider().getScope(this.compilationUnit.getXtendFile(), XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE).getSingleElement(qualifiedName);
if ((((result != null) && TypesPackage.Literals.JVM_TYPE.isSuperTypeOf(result.getEClass())) && (filter.apply(result)).booleanValue())) {
EObject _eObjectOrProxy = result.getEObjectOrProxy();
return this.compilationUnit.toType(((JvmType) _eObjectOrProxy));
}
return null;
}
Aggregations