use of org.eclipse.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.
the class JvmTypeDeclarationImpl method isAssignableFrom.
public boolean isAssignableFrom(final Type otherType) {
if ((otherType == null)) {
return false;
}
final TypeReference thisTypeRef = this.getCompilationUnit().getTypeReferenceProvider().newTypeReference(((Type) this));
final TypeReference thatTypeRef = this.getCompilationUnit().getTypeReferenceProvider().newTypeReference(otherType);
return thisTypeRef.isAssignableFrom(thatTypeRef);
}
use of org.eclipse.xtend.lib.macro.declaration.TypeReference 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.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.
the class MutableJvmInterfaceDeclarationImpl 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.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.
the class MutableJvmInterfaceDeclarationImpl method setExtendedInterfaces.
@Override
public void setExtendedInterfaces(final Iterable<? extends TypeReference> superinterfaces) {
this.checkMutable();
ConditionUtils.checkIterable(superinterfaces, "superinterfaces");
this.getDelegate().getSuperTypes().clear();
for (final TypeReference typeRef : superinterfaces) {
{
boolean _isInferred = typeRef.isInferred();
if (_isInferred) {
throw new IllegalArgumentException("Cannot use inferred type as extended interface.");
}
EList<JvmTypeReference> _superTypes = this.getDelegate().getSuperTypes();
JvmTypeReference _jvmTypeReference = this.getCompilationUnit().toJvmTypeReference(typeRef);
_superTypes.add(_jvmTypeReference);
}
}
}
use of org.eclipse.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.
the class PrimitiveTypeImpl method isAssignableFrom.
@Override
public boolean isAssignableFrom(final Type otherType) {
if ((otherType == null)) {
return false;
}
final TypeReference thisTypeRef = this.getCompilationUnit().getTypeReferenceProvider().newTypeReference(this);
final TypeReference thatTypeRef = this.getCompilationUnit().getTypeReferenceProvider().newTypeReference(otherType);
return thisTypeRef.isAssignableFrom(thatTypeRef);
}
Aggregations