Search in sources :

Example 1 with TypeDeclaration

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

the class CeylonDocTool method getFileName.

public String getFileName(TypeDeclaration type) {
    // we need postfix, because objects can have same file name like classes/interfaces in not case-sensitive file systems
    String postfix;
    if (type instanceof Class && type.isAnonymous()) {
        postfix = ".object";
    } else {
        postfix = ".type";
    }
    List<String> names = new LinkedList<String>();
    Scope scope = type;
    while (scope instanceof TypeDeclaration) {
        names.add(0, ((TypeDeclaration) scope).getName());
        scope = scope.getContainer();
    }
    return join(".", names) + postfix + ".html";
}
Also used : Scope(com.redhat.ceylon.model.typechecker.model.Scope) Class(com.redhat.ceylon.model.typechecker.model.Class) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) LinkedList(java.util.LinkedList)

Example 2 with TypeDeclaration

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

the class CeylonDocTool method collectAnnotationConstructors.

private void collectAnnotationConstructors() {
    for (Module module : modules) {
        for (Package pkg : getPackages(module)) {
            for (Declaration decl : pkg.getMembers()) {
                if (decl instanceof Function && decl.isAnnotation() && shouldInclude(decl)) {
                    Function annotationCtor = (Function) decl;
                    TypeDeclaration annotationType = annotationCtor.getTypeDeclaration();
                    List<Function> annotationConstructorList = annotationConstructors.get(annotationType);
                    if (annotationConstructorList == null) {
                        annotationConstructorList = new ArrayList<Function>();
                        annotationConstructors.put(annotationType, annotationConstructorList);
                    }
                    annotationConstructorList.add(annotationCtor);
                }
            }
        }
    }
}
Also used : Function(com.redhat.ceylon.model.typechecker.model.Function) Package(com.redhat.ceylon.model.typechecker.model.Package) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Module(com.redhat.ceylon.model.typechecker.model.Module) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 3 with TypeDeclaration

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

the class CeylonDocTool method getObjectFile.

private File getObjectFile(Object modPgkOrDecl) throws IOException {
    final File file;
    if (modPgkOrDecl instanceof TypeDeclaration) {
        TypeDeclaration type = (TypeDeclaration) modPgkOrDecl;
        String filename = getFileName(type);
        file = new File(getFolder(type), filename);
    } else if (modPgkOrDecl instanceof Module) {
        String filename = "index.html";
        file = new File(getApiOutputFolder((Module) modPgkOrDecl), filename);
    } else if (modPgkOrDecl instanceof Package) {
        String filename = "index.html";
        file = new File(getFolder((Package) modPgkOrDecl), filename);
    } else {
        throw new RuntimeException(CeylondMessages.msg("error.unexpected", modPgkOrDecl));
    }
    return file.getCanonicalFile();
}
Also used : Package(com.redhat.ceylon.model.typechecker.model.Package) Module(com.redhat.ceylon.model.typechecker.model.Module) File(java.io.File) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 4 with TypeDeclaration

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

the class ClassDoc method loadInheritedMembers.

private void loadInheritedMembers(MemberSpecification specification, List<TypeDeclaration> superClassOrInterfaceList, Map<MemberSpecification, Map<TypeDeclaration, SortedMap<String, Declaration>>> superClassOrInterfaceInheritedMemebers) {
    LinkedHashMap<TypeDeclaration, SortedMap<String, Declaration>> inheritedMembersMap = new LinkedHashMap<TypeDeclaration, SortedMap<String, Declaration>>();
    for (TypeDeclaration superClassOrInterface : superClassOrInterfaceList) {
        SortedMap<String, Declaration> inheritedMembers = new TreeMap<String, Declaration>();
        for (Declaration member : superClassOrInterface.getMembers()) {
            if (specification.isSatisfiedBy(member) && tool.shouldInclude(member)) {
                inheritedMembers.put(Util.getDeclarationName(member), member);
                for (String alias : member.getAliases()) {
                    inheritedMembers.put(alias, member);
                }
            }
        }
        if (!inheritedMembers.isEmpty()) {
            inheritedMembersMap.put(superClassOrInterface, inheritedMembers);
        }
    }
    superClassOrInterfaceInheritedMemebers.put(specification, inheritedMembersMap);
}
Also used : SortedMap(java.util.SortedMap) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) TreeMap(java.util.TreeMap) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with TypeDeclaration

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

the class ClassDoc method collectSupertypes.

private List<TypeDeclaration> collectSupertypes(TypeDeclaration type) {
    List<TypeDeclaration> supertypes = new ArrayList<TypeDeclaration>();
    if (type instanceof Class && type.getExtendedType() != null) {
        supertypes.add(type.getExtendedType().getDeclaration());
    }
    List<Type> satisfiedTypes = type.getSatisfiedTypes();
    if (satisfiedTypes != null) {
        for (Type satisfiedType : satisfiedTypes) {
            supertypes.add(satisfiedType.getDeclaration());
        }
    }
    return supertypes;
}
Also used : Type(com.redhat.ceylon.model.typechecker.model.Type) Util.isAbbreviatedType(com.redhat.ceylon.ceylondoc.Util.isAbbreviatedType) ArrayList(java.util.ArrayList) Class(com.redhat.ceylon.model.typechecker.model.Class) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Aggregations

TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)140 Type (com.redhat.ceylon.model.typechecker.model.Type)85 Test (org.junit.Test)51 Class (com.redhat.ceylon.model.typechecker.model.Class)40 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)37 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)36 IntersectionType (com.redhat.ceylon.model.typechecker.model.IntersectionType)33 UnionType (com.redhat.ceylon.model.typechecker.model.UnionType)33 TypeParser (com.redhat.ceylon.model.loader.TypeParser)32 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)32 Interface (com.redhat.ceylon.model.typechecker.model.Interface)27 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)24 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)20 ModelUtil.appliedType (com.redhat.ceylon.model.typechecker.model.ModelUtil.appliedType)19 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)19 Function (com.redhat.ceylon.model.typechecker.model.Function)18 ArrayList (java.util.ArrayList)17 JCTree (com.sun.tools.javac.tree.JCTree)16 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)14 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)14