use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toJvmTypeReference.
public JvmTypeReference toJvmTypeReference(final TypeReference typeRef) {
this.checkCanceled();
JvmTypeReference _switchResult = null;
boolean _matched = false;
if (typeRef instanceof TypeReferenceImpl) {
_matched = true;
_switchResult = ((TypeReferenceImpl) typeRef).getLightweightTypeReference().toJavaCompliantTypeReference();
}
if (!_matched) {
if (typeRef instanceof InferredTypeReferenceImpl) {
_matched = true;
_switchResult = EcoreUtil.<XComputedTypeReferenceImplCustom>copy(((InferredTypeReferenceImpl) typeRef).getDelegate());
}
}
return _switchResult;
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toTypeReference.
public TypeReference toTypeReference(final JvmTypeReference delegate) {
TypeReference _xblockexpression = null;
{
if ((delegate == null)) {
return null;
}
TypeReference _switchResult = null;
boolean _matched = false;
if (delegate instanceof XComputedTypeReferenceImplCustom) {
boolean _isEquivalentComputed = ((XComputedTypeReferenceImplCustom) delegate).isEquivalentComputed();
boolean _not = (!_isEquivalentComputed);
if (_not) {
_matched = true;
InferredTypeReferenceImpl _inferredTypeReferenceImpl = new InferredTypeReferenceImpl();
final Procedure1<InferredTypeReferenceImpl> _function = (InferredTypeReferenceImpl it) -> {
it.setDelegate(((XComputedTypeReferenceImplCustom) delegate));
it.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<InferredTypeReferenceImpl>operator_doubleArrow(_inferredTypeReferenceImpl, _function);
}
}
if (!_matched) {
_switchResult = this.toTypeReference(this.typeRefFactory.toLightweightReference(delegate), delegate);
}
_xblockexpression = _switchResult;
}
return _xblockexpression;
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class MutableJvmClassDeclarationImpl method addTypeParameter.
@Override
public MutableTypeParameterDeclaration addTypeParameter(final String name, final TypeReference... upperBounds) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
ConditionUtils.checkIterable(((Iterable<?>) Conversions.doWrapArray(upperBounds)), "upperBounds");
ConditionUtils.checkInferredTypeReferences("parameter type", upperBounds);
final JvmTypeParameter param = TypesFactory.eINSTANCE.createJvmTypeParameter();
param.setName(name);
this.getDelegate().getTypeParameters().add(param);
for (final TypeReference upper : upperBounds) {
{
final JvmTypeReference typeRef = this.getCompilationUnit().toJvmTypeReference(upper);
final JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
jvmUpperBound.setTypeReference(typeRef);
param.getConstraints().add(jvmUpperBound);
}
}
TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(param);
return ((MutableTypeParameterDeclaration) _typeParameterDeclaration);
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class TypeReferenceProviderImpl method createTypeRef.
public JvmParameterizedTypeReference createTypeRef(final JvmType type, final JvmTypeReference... typeArgs) {
if ((type == null)) {
throw new NullPointerException("type");
}
final JvmParameterizedTypeReference reference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
reference.setType(type);
for (final JvmTypeReference typeArg : typeArgs) {
reference.getArguments().add(EcoreUtil2.<JvmTypeReference>cloneIfContained(typeArg));
}
if ((type instanceof JvmGenericType)) {
final EList<JvmTypeParameter> list = ((JvmGenericType) type).getTypeParameters();
if (((!reference.getArguments().isEmpty()) && (list.size() != reference.getArguments().size()))) {
String _identifier = ((JvmGenericType) type).getIdentifier();
String _plus = ("The type " + _identifier);
String _plus_1 = (_plus + " expects ");
int _size = list.size();
String _plus_2 = (_plus_1 + Integer.valueOf(_size));
String _plus_3 = (_plus_2 + " type arguments, but was ");
int _size_1 = reference.getArguments().size();
String _plus_4 = (_plus_3 + Integer.valueOf(_size_1));
String _plus_5 = (_plus_4 + ". Either pass zero arguments (raw type) or the correct number.");
throw new IllegalArgumentException(_plus_5);
}
}
return reference;
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class JvmExecutableDeclarationImpl method addTypeParameter.
public MutableTypeParameterDeclaration addTypeParameter(final String name, final TypeReference... upperBounds) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
ConditionUtils.checkIterable(((Iterable<?>) Conversions.doWrapArray(upperBounds)), "upperBounds");
ConditionUtils.checkInferredTypeReferences("parameter type", upperBounds);
final JvmTypeParameter param = TypesFactory.eINSTANCE.createJvmTypeParameter();
param.setName(name);
this.getDelegate().getTypeParameters().add(param);
for (final TypeReference upper : upperBounds) {
{
final JvmTypeReference typeRef = this.getCompilationUnit().toJvmTypeReference(upper);
final JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
jvmUpperBound.setTypeReference(typeRef);
param.getConstraints().add(jvmUpperBound);
}
}
TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(param);
return ((MutableTypeParameterDeclaration) _typeParameterDeclaration);
}
Aggregations