use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.
the class AnalyzerUtil method checkCasesDisjoint.
static boolean checkCasesDisjoint(Type later, Type earlier, Node node, String hint) {
if (!isTypeUnknown(later) && !isTypeUnknown(earlier)) {
Unit unit = node.getUnit();
Type it = intersectionType(later.resolveAliases(), earlier.resolveAliases(), unit);
if (!it.isNothing()) {
if (earlier.isExactly(later)) {
node.addError("case is not disjoint: there is another case of type '" + earlier.asString(unit) + "'" + hint);
} else if (earlier.isSubtypeOf(later)) {
node.addError("case is not disjoint: '" + later.asString(unit) + "' contains '" + earlier.asString(unit) + "'" + hint);
} else {
node.addError("case is not disjoint: '" + later.asString(unit) + "' and '" + earlier.asString(unit) + "' have intersection '" + it.asString(unit) + "'" + hint);
}
return false;
}
}
return true;
}
use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.
the class AnnotationVisitor method getExecutableStatements.
private static List<Tree.Statement> getExecutableStatements(Tree.Body block) {
List<Tree.Statement> list = new ArrayList<Tree.Statement>();
Unit unit = block.getUnit();
for (Tree.Statement s : block.getStatements()) {
if (isExecutableStatement(unit, s)) {
list.add(s);
}
}
return list;
}
use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.
the class AnnotationVisitor method isIllegalAnnotationParameterType.
private static boolean isIllegalAnnotationParameterType(Type pt) {
if (pt != null) {
if (pt.isIntersection() || pt.isUnion()) {
return true;
}
TypeDeclaration ptd = pt.getDeclaration();
Unit unit = ptd.getUnit();
if (!ptd.isAnnotation() && !isEnum(ptd) && !pt.isBoolean() && !pt.isString() && !pt.isInteger() && !pt.isFloat() && !pt.isCharacter() && !pt.isIterable() && !pt.isSequential() && !pt.isSequence() && !pt.isSubtypeOf(unit.getType(unit.getDeclarationDeclaration()))) {
return true;
}
if (pt.isIterable() || pt.isSequential() || pt.isSequence()) {
Type elementType = unit.getIteratedType(pt);
if (isIllegalAnnotationParameterType(elementType)) {
return true;
}
}
}
return false;
}
use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.
the class AnnotationVisitor method visit.
@Override
public void visit(Tree.AnyClass that) {
super.visit(that);
Class c = that.getDeclarationModel();
if (c.isAnnotation()) {
checkAnnotationType(that, c);
}
Unit unit = that.getUnit();
checkAnnotations(that.getAnnotationList(), unit.getClassDeclarationType(c), unit.getClassMetatype(c.getType()), that);
checkServiceAnnotations(c, that.getAnnotationList());
}
use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.
the class AnnotationVisitor method visit.
@Override
public void visit(Tree.Enumerated that) {
super.visit(that);
Value v = that.getDeclarationModel();
Unit unit = that.getUnit();
// TODO: metamodel types for Enumerated!!
checkAnnotations(that.getAnnotationList(), unit.getValueConstructorDeclarationType(), unit.getValueMetatype(v.getTypedReference()), that);
}
Aggregations