Search in sources :

Example 31 with Package

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

the class CeylonDocTool method collectSubclasses.

private void collectSubclasses() throws IOException {
    for (Module module : modules) {
        for (Package pkg : getPackages(module)) {
            for (Declaration decl : pkg.getMembers()) {
                if (!shouldInclude(decl)) {
                    continue;
                }
                if (decl instanceof ClassOrInterface) {
                    ClassOrInterface c = (ClassOrInterface) decl;
                    // subclasses map
                    if (c instanceof Class) {
                        Type superclass = c.getExtendedType();
                        if (superclass != null) {
                            TypeDeclaration superdec = superclass.getDeclaration();
                            if (subclasses.get(superdec) == null) {
                                subclasses.put(superdec, new ArrayList<Class>());
                            }
                            subclasses.get(superdec).add((Class) c);
                        }
                    }
                    List<Type> satisfiedTypes = new ArrayList<Type>(c.getSatisfiedTypes());
                    if (satisfiedTypes != null && satisfiedTypes.isEmpty() == false) {
                        // satisfying classes or interfaces map
                        for (Type satisfiedType : satisfiedTypes) {
                            TypeDeclaration superdec = satisfiedType.getDeclaration();
                            if (satisfyingClassesOrInterfaces.get(superdec) == null) {
                                satisfyingClassesOrInterfaces.put(superdec, new ArrayList<ClassOrInterface>());
                            }
                            satisfyingClassesOrInterfaces.get(superdec).add(c);
                        }
                    }
                }
            }
        }
    }
}
Also used : ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) NothingType(com.redhat.ceylon.model.typechecker.model.NothingType) Type(com.redhat.ceylon.model.typechecker.model.Type) ArrayList(java.util.ArrayList) Class(com.redhat.ceylon.model.typechecker.model.Class) 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 32 with Package

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

the class ModuleDoc method generate.

public void generate() throws IOException {
    writeHeader("Overview");
    writeNavBar();
    open("div class='container-fluid'");
    writeDescription();
    writePackagesTable("Packages", tool.getPackages(module));
    writeDependencies();
    close("div");
    for (Package pkg : module.getPackages()) {
        if (tool.isRootPackage(module, pkg) && !pkg.getMembers().isEmpty()) {
            rootPackageDoc = new PackageDoc(tool, writer, pkg);
            rootPackageDoc.generate();
        }
    }
    writeFooter();
}
Also used : Package(com.redhat.ceylon.model.typechecker.model.Package)

Example 33 with Package

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

the class Naming method makeTypeDeclaration.

private <R> R makeTypeDeclaration(TypeDeclarationBuilder<R> declarationBuilder, final TypeDeclaration decl, DeclNameFlag... options) {
    EnumSet<DeclNameFlag> flags = EnumSet.noneOf(DeclNameFlag.class);
    flags.addAll(Arrays.asList(options));
    if (flags.contains(DeclNameFlag.ANNOTATION) && !Decl.isAnnotationClass(decl)) {
        throw new BugException(decl.getName());
    }
    if (flags.contains(DeclNameFlag.ANNOTATIONS) && !(Decl.isAnnotationClass(decl) || decl instanceof Class || gen().isSequencedAnnotation((Class) decl))) {
        throw new BugException(decl.getName());
    }
    java.util.List<Scope> l = new java.util.ArrayList<Scope>();
    Scope s = decl;
    do {
        l.add(s);
        s = s.getContainer();
    } while (!(s instanceof Package));
    Collections.reverse(l);
    if (flags.contains(DeclNameFlag.QUALIFIED) && (!decl.isAnonymous() || decl.isNamed())) {
        final List<String> packageName;
        if (!AbstractTransformer.isJavaArray(decl))
            packageName = ((Package) s).getName();
        else
            packageName = COM_REDHAT_CEYLON_LANGUAGE_PACKAGE;
        if (packageName.isEmpty() || !packageName.get(0).isEmpty()) {
            declarationBuilder.select("");
        }
        for (int ii = 0; ii < packageName.size(); ii++) {
            declarationBuilder.select(quoteIfJavaKeyword(packageName.get(ii)));
        }
    }
    for (int ii = 0; ii < l.size(); ii++) {
        Scope scope = l.get(ii);
        final boolean last = ii == l.size() - 1;
        appendTypeDeclaration(decl, flags, declarationBuilder, scope, last);
    }
    return declarationBuilder.result();
}
Also used : ArrayList(java.util.ArrayList) Scope(com.redhat.ceylon.model.typechecker.model.Scope) Class(com.redhat.ceylon.model.typechecker.model.Class) LazyClass(com.redhat.ceylon.model.loader.model.LazyClass) Package(com.redhat.ceylon.model.typechecker.model.Package)

Example 34 with Package

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

the class Naming method getTypeArgumentDescriptorName.

public String getTypeArgumentDescriptorName(TypeParameter tp) {
    String name;
    if (tp.isCaptured()) {
        // must build unique name
        StringBuilder sb = new StringBuilder();
        LinkedList<Declaration> decls = new LinkedList<Declaration>();
        Scope scope = tp;
        while (scope != null && scope instanceof Package == false) {
            if (scope instanceof Declaration)
                decls.add((Declaration) scope);
            scope = scope.getContainer();
        }
        Iterator<Declaration> iterator = decls.descendingIterator();
        while (iterator.hasNext()) {
            sb.append(iterator.next().getName());
            if (iterator.hasNext())
                sb.append("$");
        }
        name = sb.toString();
    } else {
        name = tp.getName();
    }
    return prefixName(Prefix.$reified$, name);
}
Also used : Scope(com.redhat.ceylon.model.typechecker.model.Scope) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Package(com.redhat.ceylon.model.typechecker.model.Package) LinkedList(java.util.LinkedList)

Example 35 with Package

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

the class MethodDefinitionBuilder method isParamTypeLocalToMethod.

private boolean isParamTypeLocalToMethod(Parameter parameter, Type nonWideningType) {
    // error recovery
    if (nonWideningType == null)
        return false;
    if (parameter.getModel().getTypeErased()) {
        return false;
    }
    Declaration method = parameter.getDeclaration();
    TypeDeclaration paramTypeDecl = nonWideningType.getDeclaration();
    if (paramTypeDecl instanceof TypeParameter && Decl.equalScopeDecl(paramTypeDecl.getContainer(), method)) {
        return false;
    }
    Scope scope = paramTypeDecl.getContainer();
    while (scope != null && !(scope instanceof Package)) {
        if (Decl.equalScopeDecl(scope, method)) {
            return true;
        }
        scope = scope.getContainer();
    }
    return false;
}
Also used : TypeParameter(com.redhat.ceylon.model.typechecker.model.TypeParameter) JCTypeParameter(com.sun.tools.javac.tree.JCTree.JCTypeParameter) Scope(com.redhat.ceylon.model.typechecker.model.Scope) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Package(com.redhat.ceylon.model.typechecker.model.Package) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Aggregations

Package (com.redhat.ceylon.model.typechecker.model.Package)47 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)18 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)17 Module (com.redhat.ceylon.model.typechecker.model.Module)16 Scope (com.redhat.ceylon.model.typechecker.model.Scope)16 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)14 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)11 ArrayList (java.util.ArrayList)10 Class (com.redhat.ceylon.model.typechecker.model.Class)8 Interface (com.redhat.ceylon.model.typechecker.model.Interface)7 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)6 Value (com.redhat.ceylon.model.typechecker.model.Value)6 PhasedUnit (com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)5 Function (com.redhat.ceylon.model.typechecker.model.Function)5 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)5 Type (com.redhat.ceylon.model.typechecker.model.Type)4 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)4 CeylonCompilationUnit (com.redhat.ceylon.compiler.java.codegen.CeylonCompilationUnit)3 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)3 File (java.io.File)3