use of org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.IntersectionTypeImpl in project ceylon by eclipse.
the class Metamodel method getAppliedMetamodel.
@SuppressWarnings({ "rawtypes", "unchecked" })
@NonNull
public static <T> ceylon.language.meta.model.Type<T> getAppliedMetamodel(Type pt) {
TypeDeclaration declaration = pt.getDeclaration();
if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Constructor) {
org.eclipse.ceylon.model.typechecker.model.Constructor ctorDeclaration = (org.eclipse.ceylon.model.typechecker.model.Constructor) declaration;
Type ctorType = pt;
pt = pt.getExtendedType();
declaration = pt.getDeclaration();
TypeDescriptor reifiedArguments;
if (!ModelUtil.isEnumeratedConstructor(ctorDeclaration) && !declaration.isAnonymous() && !isLocalType(declaration))
reifiedArguments = Metamodel.getTypeDescriptorForArguments(declaration.getUnit(), (Functional) ctorDeclaration, ctorType);
else
reifiedArguments = TypeDescriptor.NothingType;
TypeDescriptor reifiedType = getTypeDescriptorForProducedType(pt);
if (declaration.isToplevel() || isLocalType(declaration))
return new org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.ClassImpl(reifiedType, reifiedArguments, pt, Metamodel.getAppliedMetamodel(pt.getQualifyingType()), null);
TypeDescriptor reifiedContainer = getTypeDescriptorForProducedType(pt.getQualifyingType());
return new org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberClassImpl(reifiedContainer, reifiedType, reifiedArguments, pt);
}
if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Class) {
// anonymous classes don't have parameter lists
TypeDescriptor reifiedArguments;
if (!declaration.isAnonymous() && !isLocalType(declaration))
reifiedArguments = Metamodel.getTypeDescriptorForArguments(declaration.getUnit(), (Functional) declaration, pt);
else
reifiedArguments = TypeDescriptor.NothingType;
TypeDescriptor reifiedType = getTypeDescriptorForProducedType(pt);
if (declaration.isToplevel() || isLocalType(declaration))
return new org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.ClassImpl(reifiedType, reifiedArguments, pt, null, null);
// Workaround for old binaries where static members could have some qualified TDs
// but not always. If the qualifying type is missing treat it as a toplevel
org.eclipse.ceylon.model.typechecker.model.Type qt = pt.getQualifyingType();
if (qt == null && declaration.isStatic()) {
qt = ((org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) declaration.getContainer()).getType();
}
TypeDescriptor reifiedContainer = getTypeDescriptorForProducedType(qt);
return new org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberClassImpl(reifiedContainer, reifiedType, reifiedArguments, pt);
}
if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Interface) {
TypeDescriptor reifiedType = getTypeDescriptorForProducedType(pt);
if (declaration.isToplevel() || isLocalType(declaration))
return new org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.InterfaceImpl<T>(reifiedType, pt, null, null);
// Workaround for old binaries where static members could have some qualified TDs
// but not always. If the qualifying type is missing treat it as a toplevel
org.eclipse.ceylon.model.typechecker.model.Type qt = pt.getQualifyingType();
if (qt == null && declaration.isStatic()) {
qt = ((org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) declaration.getContainer()).getType();
}
TypeDescriptor reifiedContainer = getTypeDescriptorForProducedType(qt);
return new org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberInterfaceImpl(reifiedContainer, reifiedType, pt);
}
if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.UnionType) {
TypeDescriptor reifiedType = getTypeDescriptorForProducedType(pt);
return new UnionTypeImpl<T>(reifiedType, (org.eclipse.ceylon.model.typechecker.model.UnionType) declaration);
}
if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.IntersectionType) {
TypeDescriptor reifiedType = getTypeDescriptorForProducedType(pt);
return new IntersectionTypeImpl<T>(reifiedType, (org.eclipse.ceylon.model.typechecker.model.IntersectionType) declaration);
}
if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.NothingType) {
return (ceylon.language.meta.model.Type<T>) ceylon.language.meta.model.nothingType_.get_();
}
if (declaration instanceof UnknownType) {
((UnknownType) declaration).reportErrors();
}
throw Metamodel.newModelError("Declaration type not supported yet: " + declaration);
}
Aggregations