Search in sources :

Example 16 with TypeDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypeDeclaration in project ceylon by eclipse.

the class ClassDoc method writeSubtypesHierarchy.

private void writeSubtypesHierarchy(List<TypeDeclaration> types, int level) throws IOException {
    if (types.size() > 1) {
        Collections.sort(types, ReferenceableComparatorByName.INSTANCE);
    }
    for (TypeDeclaration type : types) {
        List<TypeDeclaration> subtypes = collectSubtypes(type);
        writeTypeHierarchyLevel(type, !subtypes.isEmpty());
        if (level == 0 && Util.isEnumerated(type)) {
            around("span class='keyword'", " of");
        }
        open("div class='subhierarchy'");
        writeSubtypesHierarchy(subtypes, level + 1);
        // subhierarchy
        close("div");
        close("li", "ul");
    }
}
Also used : TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)

Example 17 with TypeDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypeDeclaration in project ceylon by eclipse.

the class ClassDoc method writeSuperTypeHierarchy.

private void writeSuperTypeHierarchy(List<TypeDeclaration> types, int level) throws IOException {
    if (types.size() > 1) {
        Collections.sort(types, ReferenceableComparatorByName.INSTANCE);
    }
    for (TypeDeclaration type : types) {
        List<TypeDeclaration> supertypes = collectSupertypes(type);
        writeTypeHierarchyLevel(type, !supertypes.isEmpty());
        open("div class='subhierarchy'");
        writeSuperTypeHierarchy(supertypes, level + 1);
        // subhierarchy
        close("div");
        close("li", "ul");
    }
}
Also used : TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)

Example 18 with TypeDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypeDeclaration in project ceylon by eclipse.

the class Util method getSuperInterfaces.

public static List<TypeDeclaration> getSuperInterfaces(TypeDeclaration decl) {
    Set<TypeDeclaration> superInterfaces = new HashSet<TypeDeclaration>();
    for (Type satisfiedType : decl.getSatisfiedTypes()) {
        superInterfaces.add(satisfiedType.getDeclaration());
        superInterfaces.addAll(getSuperInterfaces(satisfiedType.getDeclaration()));
    }
    List<TypeDeclaration> list = new ArrayList<TypeDeclaration>();
    list.addAll(superInterfaces);
    removeDuplicates(list);
    return list;
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) ArrayList(java.util.ArrayList) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) HashSet(java.util.HashSet)

Example 19 with TypeDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypeDeclaration in project ceylon by eclipse.

the class TypePrinter method abbreviateCallable.

public static boolean abbreviateCallable(Type pt) {
    if (pt.isInterface()) {
        TypeDeclaration dec = pt.getDeclaration();
        Unit unit = dec.getUnit();
        Interface callableDeclaration = unit.getCallableDeclaration();
        return dec.equals(callableDeclaration) && pt.getTypeArgumentList().size() == 2 && pt.getTypeArgumentList().get(0) != null;
    } else {
        return false;
    }
}
Also used : Unit(org.eclipse.ceylon.model.typechecker.model.Unit) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Interface(org.eclipse.ceylon.model.typechecker.model.Interface)

Example 20 with TypeDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypeDeclaration in project ceylon by eclipse.

the class ExpressionVisitor method resolveBaseTypeExpression.

private TypeDeclaration resolveBaseTypeExpression(Tree.BaseTypeExpression that, boolean error) {
    Tree.Identifier id = that.getIdentifier();
    String name = name(id);
    Scope scope = that.getScope();
    TypeDeclaration type = getTypeDeclaration(scope, name, that.getSignature(), that.getEllipsis(), that.getUnit());
    if (type == null) {
        if (error && !dynamic && !isNativeForWrongBackend(scope, unit)) {
            that.addError("type is not defined: '" + name + "'" + correctionMessage(name, scope, unit, cancellable), 102);
            unit.setUnresolvedReferences();
        }
    } else {
        type = (TypeDeclaration) handleAbstractionOrHeader(type, that, error);
        that.setDeclaration(type);
        if (error) {
            if (checkConcreteClass(type, that)) {
                if (checkVisibleConstructor(that, type)) {
                    checkBaseTypeAndConstructorVisibility(that, name, type);
                }
            }
        }
    }
    return type;
}
Also used : NativeUtil.declarationScope(org.eclipse.ceylon.compiler.typechecker.util.NativeUtil.declarationScope) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) CustomTree(org.eclipse.ceylon.compiler.typechecker.tree.CustomTree) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) AnalyzerUtil.getPackageTypeDeclaration(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getPackageTypeDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) AnalyzerUtil.getTypeDeclaration(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypeDeclaration)

Aggregations

TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)303 Type (org.eclipse.ceylon.model.typechecker.model.Type)180 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)88 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)86 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)80 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)70 Class (org.eclipse.ceylon.model.typechecker.model.Class)68 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)65 ModelUtil.appliedType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType)57 UnionType (org.eclipse.ceylon.model.typechecker.model.UnionType)57 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)55 IntersectionType (org.eclipse.ceylon.model.typechecker.model.IntersectionType)51 Test (org.junit.Test)51 AnalyzerUtil.getPackageTypeDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getPackageTypeDeclaration)49 AnalyzerUtil.getTypeDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypeDeclaration)49 ArrayList (java.util.ArrayList)48 Constructor (org.eclipse.ceylon.model.typechecker.model.Constructor)44 Interface (org.eclipse.ceylon.model.typechecker.model.Interface)43 Scope (org.eclipse.ceylon.model.typechecker.model.Scope)39 ModelUtil.intersectionType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.intersectionType)34