use of ceylon.language.meta.declaration.OpenType in project ceylon by eclipse.
the class Metamodel method getMetamodelSequential.
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Sequential<? extends ceylon.language.meta.declaration.OpenType> getMetamodelSequential(List<Type> types) {
if (types.isEmpty())
return (Sequential<? extends ceylon.language.meta.declaration.OpenType>) (Sequential) empty_.get_();
ceylon.language.meta.declaration.OpenType[] ret = new ceylon.language.meta.declaration.OpenType[types.size()];
int i = 0;
TypeDescriptor td = TypeDescriptor.NothingType;
for (Type pt : types) {
OpenType mm = Metamodel.getMetamodel(pt);
td = TypeDescriptor.union(((ReifiedType) mm).$getType$());
ret[i++] = mm;
}
return Util.sequentialWrapper(td, ret);
}
use of ceylon.language.meta.declaration.OpenType in project ceylon by eclipse.
the class OpenClassOrInterfaceTypeImpl method init.
protected void init() {
org.eclipse.ceylon.model.typechecker.model.ClassOrInterface decl = (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) producedType.getDeclaration();
this.declaration = (ClassOrInterfaceDeclarationImpl) Metamodel.getOrCreateMetamodel(decl);
java.util.Map<ceylon.language.meta.declaration.TypeParameter, ceylon.language.meta.declaration.OpenType> typeArguments = new LinkedHashMap<ceylon.language.meta.declaration.TypeParameter, ceylon.language.meta.declaration.OpenType>();
java.util.Map<ceylon.language.meta.declaration.TypeParameter, ceylon.language.Sequence<? extends Object>> typeArgumentWithVariances = new LinkedHashMap<ceylon.language.meta.declaration.TypeParameter, ceylon.language.Sequence<? extends Object>>();
Iterator<? extends ceylon.language.meta.declaration.TypeParameter> typeParameters = declaration.getTypeParameterDeclarations().iterator();
Object it;
java.util.Map<org.eclipse.ceylon.model.typechecker.model.TypeParameter, org.eclipse.ceylon.model.typechecker.model.Type> ptArguments = producedType.getTypeArguments();
java.util.Map<TypeParameter, SiteVariance> varianceOverrides = producedType.getVarianceOverrides();
while ((it = typeParameters.next()) != finished_.get_()) {
org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.TypeParameterImpl tp = (org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.TypeParameterImpl) it;
org.eclipse.ceylon.model.typechecker.model.TypeParameter tpDecl = (org.eclipse.ceylon.model.typechecker.model.TypeParameter) tp.declaration;
org.eclipse.ceylon.model.typechecker.model.Type ptArg = ptArguments.get(tpDecl);
OpenType ptArgWrapped = Metamodel.getMetamodel(ptArg);
typeArguments.put(tp, ptArgWrapped);
ceylon.language.meta.declaration.Variance variance = Metamodel.modelVarianceToMetaModel(varianceOverrides, tpDecl);
ceylon.language.Sequence<? extends Object> tuple = ceylon.language.Tuple.instance(Metamodel.TD_OpenTypeArgumentElement, new Object[] { ptArgWrapped, variance });
typeArgumentWithVariances.put(tp, tuple);
}
this.typeArguments = new InternalMap<ceylon.language.meta.declaration.TypeParameter, ceylon.language.meta.declaration.OpenType>(ceylon.language.meta.declaration.TypeParameter.$TypeDescriptor$, ceylon.language.meta.declaration.OpenType.$TypeDescriptor$, typeArguments);
this.typeArgumentWithVariances = new InternalMap<ceylon.language.meta.declaration.TypeParameter, ceylon.language.Sequence<?>>(ceylon.language.meta.declaration.TypeParameter.$TypeDescriptor$, Metamodel.TD_OpenTypeArgument, typeArgumentWithVariances);
org.eclipse.ceylon.model.typechecker.model.Type superType = decl.getExtendedType();
if (superType != null) {
org.eclipse.ceylon.model.typechecker.model.Type superTypeResolved = superType.substitute(producedType);
this.superclass = (ceylon.language.meta.declaration.OpenClassType) Metamodel.getMetamodel(superTypeResolved);
}
List<org.eclipse.ceylon.model.typechecker.model.Type> satisfiedTypes = decl.getSatisfiedTypes();
ceylon.language.meta.declaration.OpenInterfaceType[] interfaces = new ceylon.language.meta.declaration.OpenInterfaceType[satisfiedTypes.size()];
int i = 0;
for (org.eclipse.ceylon.model.typechecker.model.Type pt : satisfiedTypes) {
org.eclipse.ceylon.model.typechecker.model.Type resolvedPt = pt.substitute(producedType);
interfaces[i++] = (ceylon.language.meta.declaration.OpenInterfaceType) Metamodel.getMetamodel(resolvedPt);
}
this.interfaces = Util.sequentialWrapper(ceylon.language.meta.declaration.OpenInterfaceType.$TypeDescriptor$, interfaces);
}
Aggregations