use of org.eclipse.ceylon.compiler.java.codegen.recovery.TransformationPlan in project ceylon by eclipse.
the class ClassTransformer method addAtMembers.
private void addAtMembers(ClassDefinitionBuilder classBuilder, ClassOrInterface model, Tree.ClassOrInterface def) {
List<JCExpression> members = List.nil();
for (Declaration member : model.getMembers()) {
if (member instanceof ClassOrInterface == false && member instanceof TypeAlias == false) {
continue;
}
TypeDeclaration innerType = (TypeDeclaration) member;
Tree.Declaration innerTypeTree = findInnerType(def, innerType.getName());
if (innerTypeTree != null) {
TransformationPlan plan = errors().hasDeclarationAndMarkBrokenness(innerTypeTree);
if (plan instanceof Drop) {
continue;
}
}
if (innerType.isAlias() && innerTypeTree != null && Decl.isAncestorLocal(innerTypeTree.getDeclarationModel()))
// for the same reason we do not generate aliases in transform(ClassOrInterface def) let's not list them
continue;
JCAnnotation atMember;
// interfaces are moved to toplevel so they can lose visibility of member types if they are local
if (Decl.isLocal(model) && model instanceof Interface)
atMember = makeAtMember(innerType.getName());
else
atMember = makeAtMember(innerType.getType());
members = members.prepend(atMember);
}
classBuilder.annotations(makeAtMembers(members));
}
use of org.eclipse.ceylon.compiler.java.codegen.recovery.TransformationPlan in project ceylon by eclipse.
the class ClassTransformer method transformClass.
// private void capturedReifiedTypeParameters(ClassOrInterface model,
// ClassDefinitionBuilder classBuilder) {
// if (model.isStatic()) {
// ClassOrInterface outer = (ClassOrInterface)model.getContainer();
// capturedReifiedTypeParameters(outer, classBuilder);
// classBuilder.reifiedTypeParameters(outer.getTypeParameters());
// }
// }
private void transformClass(Tree.AnyClass def, Class model, ClassDefinitionBuilder classBuilder, Tree.ParameterList paramList, boolean generateInstantiator, ClassDefinitionBuilder instantiatorDeclCb, ClassDefinitionBuilder instantiatorImplCb) {
// do reified type params first
// java.util.List<TypeParameter> typeParameters = typeParametersOfAllContainers(model, false);
// for(TypeParameter tp : typeParameters){
// classBuilder.typeParameter(tp, false);
// }
// capturedReifiedTypeParameters(model, classBuilder);
classBuilder.reifiedTypeParameters(Strategy.getEffectiveTypeParameters(model));
if (def.getParameterList() != null) {
TransformationPlan error = errors().hasDeclarationAndMarkBrokenness(def);
if (error instanceof ThrowerCatchallConstructor) {
InitializerBuilder initBuilder = classBuilder.getInitBuilder();
initBuilder.init(make().If(make().Literal(true), statementGen().makeThrowUnresolvedCompilationError(error.getErrorMessage().getMessage()), null));
}
for (Tree.Parameter param : def.getParameterList().getParameters()) {
Tree.TypedDeclaration member = def != null ? Decl.getMemberDeclaration(def, param) : null;
makeAttributeForValueParameter(classBuilder, param, member);
makeMethodForFunctionalParameter(classBuilder, param, member);
}
transformClassOrCtorParameters(def, model, null, def, def.getParameterList(), false, classBuilder, classBuilder.getInitBuilder(), generateInstantiator, instantiatorDeclCb, instantiatorImplCb);
}
satisfaction(def.getSatisfiedTypes(), model, classBuilder);
at(def);
// Generate the inner members list for model loading
addAtMembers(classBuilder, model, def);
addAtLocalDeclarations(classBuilder, def);
// Make sure top types satisfy reified type
addReifiedTypeInterface(classBuilder, model);
}
use of org.eclipse.ceylon.compiler.java.codegen.recovery.TransformationPlan in project ceylon by eclipse.
the class CeylonVisitor method visit.
public void visit(Tree.ClassOrInterface decl) {
TransformationPlan plan = gen.errors().hasDeclarationAndMarkBrokenness(decl);
if (plan instanceof Drop) {
return;
}
if (skipHeaderMergeLater(decl)) {
return;
}
// To accept this class it is either not native or native for this backend
if (!acceptDeclaration(decl))
return;
int annots = gen.checkCompilerAnnotations(decl, defs);
if (decl.getDeclarationModel().isClassOrInterfaceMember()) {
if (decl.getDeclarationModel().isInterfaceMember()) {
classBuilder.getCompanionBuilder((Interface) decl.getDeclarationModel().getContainer()).defs(gen.classGen().transform(decl));
} else {
classBuilder.defs(gen.classGen().transform(decl));
}
} else {
appendList(gen.classGen().transform(decl));
}
gen.resetCompilerAnnotations(annots);
}
use of org.eclipse.ceylon.compiler.java.codegen.recovery.TransformationPlan in project ceylon by eclipse.
the class CeylonVisitor method visit.
public void visit(Tree.AnyMethod decl) {
TransformationPlan plan = gen.errors().hasDeclarationAndMarkBrokenness(decl);
if (plan instanceof Drop) {
return;
}
if (!acceptDeclaration(decl))
return;
int annots = gen.checkCompilerAnnotations(decl, defs);
Function dec = decl.getDeclarationModel();
if (dec.isClassOrInterfaceMember() && (!Decl.isDeferred(dec) || ModelUtil.isCaptured(dec))) {
classBuilder.method(decl, plan);
} else {
appendList(gen.classGen().transformWrappedMethod(decl, plan));
}
gen.resetCompilerAnnotations(annots);
}
use of org.eclipse.ceylon.compiler.java.codegen.recovery.TransformationPlan in project ceylon by eclipse.
the class CeylonVisitor method visit.
public void visit(Tree.AttributeGetterDefinition decl) {
TransformationPlan plan = gen.errors().hasDeclarationAndMarkBrokenness(decl);
if (plan instanceof Drop) {
return;
}
if (!acceptDeclaration(decl))
return;
int annots = gen.checkCompilerAnnotations(decl, defs);
Value dec = decl.getDeclarationModel();
if (dec.isClassMember() && !ModelUtil.isLocalToInitializer(dec) || dec.isStatic()) {
classBuilder.attribute(gen.classGen().transform(decl, false));
} else if (dec.isInterfaceMember() && !ModelUtil.isLocalToInitializer(dec)) {
classBuilder.attribute(gen.classGen().transform(decl, false));
AttributeDefinitionBuilder adb = gen.classGen().transform(decl, true);
if (dec.isShared()) {
adb.ignoreAnnotations();
}
classBuilder.getCompanionBuilder((Interface) dec.getContainer()).attribute(adb);
} else if (dec.isToplevel()) {
topattrBuilder.add(decl);
} else {
appendList(gen.transform(decl));
}
gen.resetCompilerAnnotations(annots);
}
Aggregations