use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ExpressionVisitor method visit.
@Override
public void visit(Tree.ObjectDefinition that) {
Class ac = that.getAnonymousClass();
Declaration od = beginReturnDeclaration(ac);
Tree.Type rt = beginReturnScope(fakeVoid(that));
super.visit(that);
endReturnScope(rt, null);
endReturnDeclaration(od);
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class DeprecationVisitor method visit.
@Override
public void visit(Tree.MemberOrTypeExpression that) {
super.visit(that);
Declaration d = that.getDeclaration();
if (d != null && d.isDeprecated()) {
that.addUsageWarning(Warning.deprecation, "declaration is deprecated: '" + d.getName() + "' is annotated 'deprecated' in " + module(d));
}
if (d instanceof Class && that.getDirectlyInvoked()) {
Class c = (Class) d;
Constructor dc = c.getDefaultConstructor();
if (dc != null && dc.isDeprecated()) {
that.addUsageWarning(Warning.deprecation, "declaration is deprecated: default constructor of '" + d.getName() + "' is annotated 'deprecated' in " + module(d));
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ClassImpl method getCaseValues.
@Override
@TypeInfo("ceylon.language::Sequential<Type>")
public ceylon.language.Sequential<? extends Type> getCaseValues() {
Class classDecl = (Class) declaration.declaration;
if (classDecl.hasEnumerated()) {
// can only possibly have value constructor cases
if (classDecl.getCaseTypes() == null || classDecl.getCaseTypes().isEmpty()) {
// it's not a closed enum of value constructors
return (Sequential) empty_.get_();
}
ArrayList<Type> ctors = new ArrayList<>();
for (ceylon.language.meta.declaration.Declaration d : ((ClassDeclarationImpl) declaration).constructors()) {
Declaration dd = null;
if (d instanceof CallableConstructorDeclarationImpl) {
continue;
} else if (d instanceof ValueConstructorDeclarationImpl) {
dd = ((ValueConstructorDeclarationImpl) d).declaration;
}
// ATM this is an AND WRT annotation types: all must be present
ctors.add(((ValueConstructor<Type>) getDeclaredConstructor(TypeDescriptor.NothingType, d.getName())).get());
}
Object[] array = ctors.toArray(new Object[ctors.size()]);
ObjectArrayIterable<ceylon.language.meta.declaration.Declaration> iterable = new ObjectArrayIterable<ceylon.language.meta.declaration.Declaration>(this.$reifiedType, (Object[]) array);
return (ceylon.language.Sequential) iterable.sequence();
} else {
return super.getCaseValues();
}
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ClassImpl method getDispatch.
ConstructorDispatch<Type, Arguments> getDispatch() {
if (!initialized) {
synchronized (this) {
if (!initialized) {
checkConstructor();
Reference reference;
if (!hasConstructors() && !hasEnumerated()) {
reference = producedType;
} else {
reference = ((org.eclipse.ceylon.model.typechecker.model.Class) declaration.declaration).getDefaultConstructor().appliedReference(producedType, null);
}
this.dispatch = new ConstructorDispatch<Type, Arguments>(reference, this, null, ((Class) producedType.getDeclaration()).getFirstParameterList().getParameters(), instance);
this.initialized = true;
}
}
}
return dispatch;
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ClassDeclarationImpl method init.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void init() {
super.init();
// anonymous classes don't have parameter lists
if (!declaration.isAnonymous()) {
org.eclipse.ceylon.model.typechecker.model.Class classDeclaration = (org.eclipse.ceylon.model.typechecker.model.Class) declaration;
if (classDeclaration.isAbstraction()) {
List<Declaration> overloads = classDeclaration.getOverloads();
if (overloads.size() == 1) {
classDeclaration = (org.eclipse.ceylon.model.typechecker.model.Class) overloads.get(0);
}
// else{
// throw Metamodel.newModelError("Class has more than one overloaded constructor: "+classDeclaration.getNameAsString());
// }
}
ParameterList parameterList = classDeclaration.getParameterList();
if (parameterList != null) {
this.parameters = FunctionalUtil.getParameters(classDeclaration);
} else {
this.parameters = null;
}
} else {
this.parameters = null;
}
if (((Class) declaration).hasConstructors() || ((Class) declaration).hasEnumerated()) {
this.constructors = new LinkedList<ceylon.language.meta.declaration.Declaration>();
for (Declaration d : declaration.getMembers()) {
if (d instanceof Constructor) {
this.constructors.add(Metamodel.<ceylon.language.meta.declaration.Declaration>getOrCreateMetamodel(d));
}
}
} else {
this.constructors = Collections.emptyList();
}
}
Aggregations