use of org.eclipse.ceylon.model.loader.model.SetterWithLocalDeclarations in project ceylon by eclipse.
the class AbstractModelLoader method findLocalContainerFromAnnotationAndSetCompanionClass.
private Scope findLocalContainerFromAnnotationAndSetCompanionClass(Package pkg, Interface declaration, AnnotationMirror localContainerAnnotation) {
@SuppressWarnings("unchecked") List<String> path = (List<String>) localContainerAnnotation.getValue("path");
// we start at the package
Scope scope = pkg;
for (String name : path) {
scope = (Scope) getDirectMember(scope, name);
}
String companionClassName = (String) localContainerAnnotation.getValue("companionClassName");
if (companionClassName == null || companionClassName.isEmpty()) {
declaration.setCompanionClassNeeded(false);
return scope;
}
ClassMirror container;
Scope javaClassScope;
if (scope instanceof TypedDeclaration && ((TypedDeclaration) scope).isMember())
javaClassScope = scope.getContainer();
else
javaClassScope = scope;
if (javaClassScope instanceof LazyInterface) {
container = ((LazyInterface) javaClassScope).companionClass;
} else if (javaClassScope instanceof LazyClass) {
container = ((LazyClass) javaClassScope).classMirror;
} else if (javaClassScope instanceof LazyValue) {
container = ((LazyValue) javaClassScope).classMirror;
} else if (javaClassScope instanceof LazyFunction) {
container = ((LazyFunction) javaClassScope).classMirror;
} else if (javaClassScope instanceof SetterWithLocalDeclarations) {
container = ((SetterWithLocalDeclarations) javaClassScope).classMirror;
} else {
throw new ModelResolutionException("Unknown scope class: " + javaClassScope);
}
String qualifiedCompanionClassName = container.getQualifiedName() + "$" + companionClassName;
ClassMirror companionClassMirror = lookupClassMirror(pkg.getModule(), qualifiedCompanionClassName);
if (companionClassMirror == null)
throw new ModelResolutionException("Could not find companion class mirror: " + qualifiedCompanionClassName);
((LazyInterface) declaration).companionClass = companionClassMirror;
return scope;
}
use of org.eclipse.ceylon.model.loader.model.SetterWithLocalDeclarations in project ceylon by eclipse.
the class AbstractModelLoader method makeSetter.
private SetterWithLocalDeclarations makeSetter(Value value, ClassMirror classMirror) {
SetterWithLocalDeclarations setter = new SetterWithLocalDeclarations(classMirror);
Scope scope = value.getContainer();
setter.setContainer(scope);
setter.setScope(scope);
setter.setType(value.getType());
setter.setName(value.getName());
Parameter p = new Parameter();
p.setHidden(true);
Value v = new Value();
v.setType(value.getType());
v.setUnboxed(value.getUnboxed());
v.setInitializerParameter(p);
v.setContainer(setter);
v.setScope(setter);
p.setModel(v);
v.setName(setter.getName());
p.setName(setter.getName());
p.setDeclaration(setter);
setter.setParameter(p);
value.setSetter(setter);
setter.setGetter(value);
return setter;
}
Aggregations