use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.BaseType that) {
super.visit(that);
final Scope scope = that.getScope();
final String name = name(that.getIdentifier());
if (inExtends) {
final Tree.TypeArgumentList tal = that.getTypeArgumentList();
final boolean packageQualified = that.getPackageQualified();
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
return packageQualified ? getPackageTypeDeclaration(name, null, false, unit) : getTypeDeclaration(scope, name, null, false, unit);
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
return getTypeArgumentMap(dec, null, AnalyzerUtil.getTypeArguments(tal, null, tps));
}
@Override
public Map<TypeParameter, SiteVariance> initVarianceOverrides() {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
return getVarianceMap(dec, null, AnalyzerUtil.getVariances(tal, tps));
}
};
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.QualifiedType that) {
super.visit(that);
final String name = name(that.getIdentifier());
final Tree.StaticType outerType = that.getOuterType();
if (inExtends) {
final Tree.TypeArgumentList tal = that.getTypeArgumentList();
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
if (outerType == null) {
return null;
} else {
TypeDeclaration dec = outerType.getTypeModel().getDeclaration();
return AnalyzerUtil.getTypeMember(dec, name, null, false, unit, scope);
}
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
if (outerType == null) {
return emptyMap();
} else {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
Type ot = outerType.getTypeModel();
return getTypeArgumentMap(dec, ot, AnalyzerUtil.getTypeArguments(tal, ot, tps));
}
}
@Override
public Map<TypeParameter, SiteVariance> initVarianceOverrides() {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
Type ot = outerType.getTypeModel();
return getVarianceMap(dec, ot, AnalyzerUtil.getVariances(tal, tps));
}
};
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(Tree.SequenceType that) {
super.visit(that);
if (inExtends) {
final Tree.StaticType elementType = that.getElementType();
final Tree.NaturalLiteral length = that.getLength();
Type t;
if (length == null) {
t = new LazyType(unit) {
@Override
public boolean isUnknown() {
return false;
}
@Override
public TypeDeclaration initDeclaration() {
return unit.getSequentialDeclaration();
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
List<TypeParameter> stps = unit.getSequentialDeclaration().getTypeParameters();
return singletonMap(stps.get(0), elementType.getTypeModel());
}
};
} else {
final int len;
try {
len = parseInt(length.getText());
} catch (NumberFormatException nfe) {
return;
}
if (len < 1 || len > 1000) {
return;
} else {
t = new StaticLengthSequenceType(elementType, len);
}
}
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(Tree.IterableType that) {
super.visit(that);
if (inExtends) {
final Tree.Type elem = that.getElementType();
Type t = new LazyType(unit) {
Type iterableType() {
final Type elementType;
final boolean atLeastOne;
if (elem == null) {
elementType = unit.getNothingType();
atLeastOne = false;
} else if (elem instanceof Tree.SequencedType) {
Tree.SequencedType set = (Tree.SequencedType) elem;
elementType = set.getType().getTypeModel();
atLeastOne = set.getAtLeastOne();
} else {
elementType = null;
atLeastOne = false;
}
if (elementType != null) {
return atLeastOne ? unit.getNonemptyIterableType(elementType) : unit.getIterableType(elementType);
} else {
Type ut = new UnknownType(unit).getType();
return unit.getIterableType(ut);
}
}
@Override
public boolean isUnknown() {
return false;
}
@Override
public TypeDeclaration initDeclaration() {
return iterableType().getDeclaration();
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
return iterableType().getTypeArguments();
}
};
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(final Tree.UnionType that) {
super.visit(that);
final List<Tree.StaticType> sts = that.getStaticTypes();
if (inExtends) {
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
List<Type> types = new ArrayList<Type>(sts.size());
for (Tree.StaticType st : sts) {
Type t = st.getTypeModel();
if (t != null) {
types.add(t);
}
}
UnionType ut = new UnionType(unit);
ut.setCaseTypes(types);
return ut;
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
return emptyMap();
}
};
that.setTypeModel(t);
}
}
Aggregations