use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.TypeAliasDeclaration that) {
TypeAlias a = new TypeAlias();
that.setDeclarationModel(a);
visitDeclaration(that, a);
Scope o = enterScope(a);
super.visit(that);
exitScope(o);
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.SwitchExpression that) {
ControlBlock cb = new ControlBlock();
cb.setId(id++);
visitElement(that, cb);
Scope o = enterScope(cb);
super.visit(that);
exitScope(o);
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.ControlClause that) {
ControlBlock cb = new ControlBlock();
cb.setLet(that instanceof Tree.LetClause);
cb.setId(id++);
that.setControlBlock(cb);
visitElement(that, cb);
Scope o = enterScope(cb);
super.visit(that);
exitScope(o);
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(Tree.TypeConstructor that) {
TypeAlias ta = new TypeAlias();
ta.setShared(true);
ta.setName("Anonymous#" + fid++);
ta.setAnonymous(true);
visitElement(that, ta);
ModelUtil.setVisibleScope(ta);
Scope o = enterScope(ta);
Declaration od = beginDeclaration(ta);
super.visit(that);
endDeclaration(od);
exitScope(o);
ta.setExtendedType(that.getType().getTypeModel());
that.setDeclarationModel(ta);
Type pt = ta.getType();
pt.setTypeConstructor(true);
that.setTypeModel(pt);
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.Constructor that) {
Constructor c = new Constructor();
that.setConstructor(c);
if (scope instanceof Class) {
Class clazz = (Class) scope;
if (that.getIdentifier() == null && clazz.getDefaultConstructor() != null) {
// found an overloaded default constructor
// we'll set up the class overloads later
// when exiting visit(Tree.ClassDefinition)
clazz.setOverloaded(true);
clazz.setAbstraction(true);
}
}
visitDeclaration(that, c, false);
Type at;
Scope realScope = getRealScope(scope);
if (realScope instanceof Class) {
Class clazz = (Class) realScope;
Type ot = clazz.getType();
c.setExtendedType(ot);
at = c.appliedType(ot, NO_TYPE_ARGS);
clazz.setConstructors(true);
if (clazz.isAnonymous()) {
that.addError("anonymous class may not have constructor: '" + clazz.getName() + "' is an anonymous class");
}
} else {
at = null;
that.addError("constructor declaration must occur directly in the body of a class");
}
Function f = new Function();
f.setType(at);
that.setDeclarationModel(f);
visitDeclaration(that, f);
Scope o = enterScope(c);
super.visit(that);
exitScope(o);
f.setImplemented(that.getBlock() != null);
if (that.getParameterList() == null) {
that.addError("missing parameter list in constructor declaration: '" + name(that.getIdentifier()) + "' must have a parameter list", 1000);
} else {
ParameterList model = that.getParameterList().getModel();
model.setFirst(true);
if (model != null) {
c.addParameterList(model);
// TODO: fix this
f.addParameterList(model);
}
}
if (c.isAbstract()) {
if (that.getIdentifier() == null) {
that.addError("default constructor may not be annotated 'abstract'", 1601);
} else if (c.isShared()) {
that.addError("abstract constructor may not be annotated 'shared'", 1610);
}
}
}
Aggregations