use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class DeclarationErrorVisitor method planAccordingToErrors.
/**
* Update the plan according to the errors on the node
*/
private void planAccordingToErrors(Node that) {
List<Message> errors = that.getErrors();
for (Message message : errors) {
if (isError(that, message)) {
TransformationPlan plan;
/*if (message.getCode() == MEMBER_HAS_WRONG_NUMBER_OF_PARAMETERS
&& model.isActual()
&& model.isClassMember()) {
plan = new ThrowerMethod(that, message);
} else if (message.getCode() == TYPE_OF_PARAMETER_IS_DIFFERENT_TO_CORRESPONDING_PARAMETER
&& model.isActual()
&& model.isClassMember()) {
plan = new ThrowerMethod(that, message);
} else if (message.getCode() == COULD_NOT_DETERMINE_PARAMETER_TYPE_SAME_AS_CORRESPONDING_PARAMETER
&& model.isActual()
&& model.isClassMember()) {
plan = new ThrowerMethod(that, message);
} else if ((message.getCode() == REFINED_MEMBER_WRONG_NUM_PL
|| message.getCode() == MISSING_PL_FUNCTION_DECL)
&& model.isActual()
&& model.isClassMember()) {
plan = new ThrowerMethod(that, message);
} else*/
if (message.getCode() == FORMAL_MEMBER_UNIMPLEMENTED_IN_CLASS_HIERARCHY && (model instanceof Class || (model instanceof Value && ((Value) model).getTypeDeclaration().isAnonymous()))) {
plan = new ThrowerMethod(that, message);
} else if (message.getCode() == PL_AND_CONSTRUCTORS && (model instanceof Class || (model instanceof Value && ((Value) model).getTypeDeclaration().isAnonymous()))) {
plan = new ThrowerCatchallConstructor(that, message);
} else {
plan = new Drop(that, message);
}
newplan(plan);
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class CeylonDocTool method collectSubclasses.
private void collectSubclasses() throws IOException {
for (Module module : modules) {
for (Package pkg : getPackages(module)) {
for (Declaration decl : pkg.getMembers()) {
if (!shouldInclude(decl)) {
continue;
}
if (decl instanceof ClassOrInterface) {
ClassOrInterface c = (ClassOrInterface) decl;
// subclasses map
if (c instanceof Class) {
Type superclass = c.getExtendedType();
if (superclass != null) {
TypeDeclaration superdec = superclass.getDeclaration();
if (subclasses.get(superdec) == null) {
subclasses.put(superdec, new ArrayList<Class>());
}
subclasses.get(superdec).add((Class) c);
}
}
List<Type> satisfiedTypes = new ArrayList<Type>(c.getSatisfiedTypes());
if (satisfiedTypes != null && satisfiedTypes.isEmpty() == false) {
// satisfying classes or interfaces map
for (Type satisfiedType : satisfiedTypes) {
TypeDeclaration superdec = satisfiedType.getDeclaration();
if (satisfyingClassesOrInterfaces.get(superdec) == null) {
satisfyingClassesOrInterfaces.put(superdec, new ArrayList<ClassOrInterface>());
}
satisfyingClassesOrInterfaces.get(superdec).add(c);
}
}
}
}
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class Naming method getMethodNameInternal.
private static String getMethodNameInternal(TypedDeclaration decl) {
String name;
if (decl.isClassOrInterfaceMember() && decl instanceof Function) {
Declaration refined = decl.getRefinedDeclaration();
if (refined instanceof JavaMethod) {
return ((JavaMethod) refined).getRealName();
}
name = quoteMethodNameIfProperty((Function) decl);
} else {
name = decl.getName();
}
if (decl.isClassMember() && "readResolve".equals(name) && Strategy.addReadResolve((Class) decl.getContainer())) {
return quote(name);
}
if (decl.isClassMember() && "writeReplace".equals(name) && Strategy.useSerializationProxy((Class) decl.getContainer())) {
return quote(name);
}
// ERASURE
if (QUOTABLE_METHOD_NAMES.contains(name)) {
return quote(name);
} else {
return quoteIfJavaKeyword(name);
}
}
use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class Naming method makeNamedConstructorName.
public JCExpression makeNamedConstructorName(Constructor constructor, boolean delegation) {
DeclNameFlag[] flags = delegation ? new DeclNameFlag[] { DeclNameFlag.QUALIFIED, DeclNameFlag.DELEGATION } : new DeclNameFlag[] { DeclNameFlag.QUALIFIED };
Class cls = (Class) constructor.getContainer();
if (cls.isToplevel() || (cls.isMember() && ((TypeDeclaration) cls.getContainer()).isToplevel())) {
return makeTypeDeclarationExpression(null, constructor, flags);
} else {
return maker.TypeCast(makeTypeDeclarationExpression(null, constructor, flags), //makeTypeDeclarationExpression(makeTypeDeclarationExpression(null, cls, DeclNameFlag.QUALIFIED), constructor, DeclNameFlag.QUALIFIED),
make().Literal(TypeTags.BOT, null));
}
}
use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class Naming method makeTypeDeclaration.
private <R> R makeTypeDeclaration(TypeDeclarationBuilder<R> declarationBuilder, final TypeDeclaration decl, DeclNameFlag... options) {
EnumSet<DeclNameFlag> flags = EnumSet.noneOf(DeclNameFlag.class);
flags.addAll(Arrays.asList(options));
if (flags.contains(DeclNameFlag.ANNOTATION) && !Decl.isAnnotationClass(decl)) {
throw new BugException(decl.getName());
}
if (flags.contains(DeclNameFlag.ANNOTATIONS) && !(Decl.isAnnotationClass(decl) || decl instanceof Class || gen().isSequencedAnnotation((Class) decl))) {
throw new BugException(decl.getName());
}
java.util.List<Scope> l = new java.util.ArrayList<Scope>();
Scope s = decl;
do {
l.add(s);
s = s.getContainer();
} while (!(s instanceof Package));
Collections.reverse(l);
if (flags.contains(DeclNameFlag.QUALIFIED) && (!decl.isAnonymous() || decl.isNamed())) {
final List<String> packageName;
if (!AbstractTransformer.isJavaArray(decl))
packageName = ((Package) s).getName();
else
packageName = COM_REDHAT_CEYLON_LANGUAGE_PACKAGE;
if (packageName.isEmpty() || !packageName.get(0).isEmpty()) {
declarationBuilder.select("");
}
for (int ii = 0; ii < packageName.size(); ii++) {
declarationBuilder.select(quoteIfJavaKeyword(packageName.get(ii)));
}
}
for (int ii = 0; ii < l.size(); ii++) {
Scope scope = l.get(ii);
final boolean last = ii == l.size() - 1;
appendTypeDeclaration(decl, flags, declarationBuilder, scope, last);
}
return declarationBuilder.result();
}
Aggregations