use of org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.SetterDeclarationImpl in project ceylon by eclipse.
the class Metamodel method getOrCreateMetamodel.
public static <R> R getOrCreateMetamodel(org.eclipse.ceylon.model.typechecker.model.Declaration declaration) {
synchronized (getLock()) {
Object ret = typeCheckModelToRuntimeModel.get(declaration);
if (ret == null) {
// make sure its module is loaded
org.eclipse.ceylon.model.typechecker.model.Package pkg = getPackage(declaration);
org.eclipse.ceylon.model.typechecker.model.Module mod = pkg.getModule();
getOrCreateMetamodel(mod);
if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Class) {
org.eclipse.ceylon.model.typechecker.model.Class klass = (org.eclipse.ceylon.model.typechecker.model.Class) declaration;
ret = klass.hasConstructors() || klass.hasEnumerated() || klass.isAnonymous() ? new org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.ClassWithConstructorsDeclarationImpl(klass) : new org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.ClassWithInitializerDeclarationImpl(klass);
} else if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Interface) {
org.eclipse.ceylon.model.typechecker.model.Interface interf = (org.eclipse.ceylon.model.typechecker.model.Interface) declaration;
ret = new org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.InterfaceDeclarationImpl(interf);
} else if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.TypeAlias) {
org.eclipse.ceylon.model.typechecker.model.TypeAlias alias = (org.eclipse.ceylon.model.typechecker.model.TypeAlias) declaration;
ret = new org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.AliasDeclarationImpl(alias);
} else if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Function) {
org.eclipse.ceylon.model.typechecker.model.Function method = (org.eclipse.ceylon.model.typechecker.model.Function) declaration;
if (method.getTypeDeclaration() instanceof org.eclipse.ceylon.model.typechecker.model.Constructor) {
ret = new CallableConstructorDeclarationImpl(method, (org.eclipse.ceylon.model.typechecker.model.Constructor) method.getTypeDeclaration());
} else {
ret = new org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.FunctionDeclarationImpl(method);
}
} else if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Value) {
org.eclipse.ceylon.model.typechecker.model.Value value = (org.eclipse.ceylon.model.typechecker.model.Value) declaration;
if (value.getTypeDeclaration() instanceof org.eclipse.ceylon.model.typechecker.model.Constructor) {
ret = new ValueConstructorDeclarationImpl(value, (org.eclipse.ceylon.model.typechecker.model.Constructor) value.getTypeDeclaration());
} else {
ret = new ValueDeclarationImpl(value);
}
} else if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Setter) {
org.eclipse.ceylon.model.typechecker.model.Setter value = (org.eclipse.ceylon.model.typechecker.model.Setter) declaration;
ret = new SetterDeclarationImpl(value);
} else if (declaration instanceof org.eclipse.ceylon.model.typechecker.model.Constructor) {
org.eclipse.ceylon.model.typechecker.model.Constructor value = (org.eclipse.ceylon.model.typechecker.model.Constructor) declaration;
Declaration functionOrValue = value.getContainer().getDirectMember(value.getName(), null, false);
if (functionOrValue instanceof org.eclipse.ceylon.model.typechecker.model.Function) {
ret = new CallableConstructorDeclarationImpl((org.eclipse.ceylon.model.typechecker.model.Function) functionOrValue, value);
} else if (functionOrValue instanceof org.eclipse.ceylon.model.typechecker.model.Value) {
ret = new ValueConstructorDeclarationImpl((org.eclipse.ceylon.model.typechecker.model.Value) functionOrValue, value);
} else if (functionOrValue == null) {
ret = new CallableConstructorDeclarationImpl(value, value);
} else {
throw Metamodel.newModelError("Declaration type not supported yet: " + declaration);
}
} else {
throw Metamodel.newModelError("Declaration type not supported yet: " + declaration);
}
typeCheckModelToRuntimeModel.put(declaration, ret);
}
return (R) ret;
}
}
Aggregations