Search in sources :

Example 1 with NothingType

use of com.redhat.ceylon.model.typechecker.model.NothingType in project ceylon-compiler by ceylon.

the class CeylonDoc method getIcons.

protected final List<String> getIcons(Object obj) {
    List<String> icons = new ArrayList<String>();
    if (obj instanceof Declaration) {
        Declaration decl = (Declaration) obj;
        Annotation deprecated = Util.findAnnotation(decl, "deprecated");
        if (deprecated != null) {
            icons.add("icon-decoration-deprecated");
        }
        if (decl instanceof ClassOrInterface || decl instanceof Constructor) {
            if (decl instanceof Interface) {
                icons.add("icon-interface");
                if (Util.isEnumerated((ClassOrInterface) decl)) {
                    icons.add("icon-decoration-enumerated");
                }
            }
            if (decl instanceof Class) {
                Class klass = (Class) decl;
                if (klass.isAnonymous()) {
                    icons.add("icon-object");
                } else {
                    icons.add("icon-class");
                }
                if (klass.isAbstract()) {
                    icons.add("icon-decoration-abstract");
                }
                if (klass.isFinal() && !klass.isAnonymous() && !klass.isAnnotation()) {
                    icons.add("icon-decoration-final");
                }
                if (Util.isEnumerated(klass)) {
                    icons.add("icon-decoration-enumerated");
                }
            }
            if (decl instanceof Constructor) {
                icons.add("icon-class");
            }
            if (!decl.isShared()) {
                icons.add("icon-decoration-local");
            }
        }
        if (decl instanceof TypedDeclaration) {
            if (decl.isShared()) {
                icons.add("icon-shared-member");
            } else {
                icons.add("icon-local-member");
            }
            if (decl.isFormal()) {
                icons.add("icon-decoration-formal");
            }
            if (decl.isActual()) {
                Declaration refinedDeclaration = decl.getRefinedDeclaration();
                if (refinedDeclaration != null) {
                    if (refinedDeclaration.isFormal()) {
                        icons.add("icon-decoration-impl");
                    }
                    if (refinedDeclaration.isDefault()) {
                        icons.add("icon-decoration-over");
                    }
                }
            }
            if (((TypedDeclaration) decl).isVariable()) {
                icons.add("icon-decoration-variable");
            }
        }
        if (decl instanceof TypeAlias || decl instanceof NothingType) {
            icons.add("icon-type-alias");
        }
        if (decl.isAnnotation()) {
            icons.add("icon-decoration-annotation");
        }
    }
    if (obj instanceof Package) {
        Package pkg = (Package) obj;
        icons.add("icon-package");
        if (!pkg.isShared()) {
            icons.add("icon-decoration-local");
        }
    }
    if (obj instanceof ModuleImport) {
        ModuleImport moduleImport = (ModuleImport) obj;
        icons.add("icon-module");
        if (moduleImport.isExport()) {
            icons.add("icon-module-exported-decoration");
        }
        if (moduleImport.isOptional()) {
            icons.add("icon-module-optional-decoration");
        }
    }
    if (obj instanceof Module) {
        icons.add("icon-module");
    }
    return icons;
}
Also used : ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Constructor(com.redhat.ceylon.model.typechecker.model.Constructor) ArrayList(java.util.ArrayList) TypeAlias(com.redhat.ceylon.model.typechecker.model.TypeAlias) Annotation(com.redhat.ceylon.model.typechecker.model.Annotation) ModuleImport(com.redhat.ceylon.model.typechecker.model.ModuleImport) Class(com.redhat.ceylon.model.typechecker.model.Class) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) Package(com.redhat.ceylon.model.typechecker.model.Package) Module(com.redhat.ceylon.model.typechecker.model.Module) Interface(com.redhat.ceylon.model.typechecker.model.Interface) ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) NothingType(com.redhat.ceylon.model.typechecker.model.NothingType)

Example 2 with NothingType

use of com.redhat.ceylon.model.typechecker.model.NothingType in project ceylon-compiler by ceylon.

the class CeylonDocTool method docNothingType.

private void docNothingType(Package pkg) throws IOException {
    final Annotation nothingDoc = new Annotation();
    nothingDoc.setName("doc");
    nothingDoc.addPositionalArgment("The special type _Nothing_ represents: \n" + " - the intersection of all types, or, equivalently \n" + " - the empty set \n" + "\n" + "_Nothing_ is assignable to all other types, but has no instances. \n" + "A reference to a member of an expression of type _Nothing_ is always an error, since there can never be a receiving instance. \n" + "_Nothing_ is considered to belong to the module _ceylon.language_. However, it cannot be defined within the language. \n" + "\n" + "Because of the restrictions imposed by Ceylon's mixin inheritance model: \n" + "- If X and Y are classes, and X is not a subclass of Y, and Y is not a subclass of X, then the intersection type X&Y is equivalent to _Nothing_. \n" + "- If X is an interface, the intersection type X&Nothing is equivalent to _Nothing_. \n" + "- If X&lt;T&gt; is invariant in its type parameter T, and the distinct types A and B do not involve type parameters, then X&lt;A&gt;&X&lt;B&gt; is equivalent to _Nothing_. \n");
    NothingType nothingType = new NothingType(pkg.getUnit()) {

        @Override
        public List<Annotation> getAnnotations() {
            return Collections.singletonList(nothingDoc);
        }
    };
    doc(nothingType);
}
Also used : Annotation(com.redhat.ceylon.model.typechecker.model.Annotation) NothingType(com.redhat.ceylon.model.typechecker.model.NothingType)

Aggregations

Annotation (com.redhat.ceylon.model.typechecker.model.Annotation)2 NothingType (com.redhat.ceylon.model.typechecker.model.NothingType)2 Class (com.redhat.ceylon.model.typechecker.model.Class)1 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)1 Constructor (com.redhat.ceylon.model.typechecker.model.Constructor)1 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)1 Interface (com.redhat.ceylon.model.typechecker.model.Interface)1 Module (com.redhat.ceylon.model.typechecker.model.Module)1 ModuleImport (com.redhat.ceylon.model.typechecker.model.ModuleImport)1 Package (com.redhat.ceylon.model.typechecker.model.Package)1 TypeAlias (com.redhat.ceylon.model.typechecker.model.TypeAlias)1 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)1 ArrayList (java.util.ArrayList)1