Search in sources :

Example 61 with Declaration

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

the class ClassDoc method writeInheritedMembers.

private void writeInheritedMembers(MemberSpecification specification, String tableTitle, String rowTitle) throws IOException {
    boolean first = true;
    Map<TypeDeclaration, SortedMap<String, Declaration>> superClassInheritedMembersMap = superclassInheritedMembers.get(specification);
    List<TypeDeclaration> superClasses = new ArrayList<TypeDeclaration>(superclassInheritedMembers.get(specification).keySet());
    Collections.sort(superClasses, ReferenceableComparatorByName.INSTANCE);
    for (TypeDeclaration superClass : superClasses) {
        SortedMap<String, Declaration> inheritedMembers = superClassInheritedMembersMap.get(superClass);
        if (first) {
            first = false;
            openTable(null, tableTitle, 1, false);
        }
        writeInheritedMembersRow(rowTitle, superClass, inheritedMembers);
    }
    Map<TypeDeclaration, SortedMap<String, Declaration>> superInterfaceInheritedMembersMap = interfaceInheritedMembers.get(specification);
    List<TypeDeclaration> superInterfaces = new ArrayList<TypeDeclaration>(superInterfaceInheritedMembersMap.keySet());
    Collections.sort(superInterfaces, ReferenceableComparatorByName.INSTANCE);
    for (TypeDeclaration superInterface : superInterfaces) {
        SortedMap<String, Declaration> members = superInterfaceInheritedMembersMap.get(superInterface);
        if (members == null || members.isEmpty()) {
            continue;
        }
        if (first) {
            first = false;
            openTable(null, tableTitle, 1, false);
        }
        writeInheritedMembersRow(rowTitle, superInterface, members);
    }
    if (!first) {
        closeTable();
    }
}
Also used : SortedMap(java.util.SortedMap) ArrayList(java.util.ArrayList) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 62 with Declaration

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

the class ClassDoc method writeInheritedMembersRow.

private void writeInheritedMembersRow(String title, TypeDeclaration superType, SortedMap<String, Declaration> members) throws IOException {
    open("tr", "td");
    write(title);
    writeIcon(superType);
    linkRenderer().to(superType).useScope(klass).withinText(true).write();
    open("div class='inherited-members'");
    boolean first = true;
    for (Entry<String, Declaration> entry : members.entrySet()) {
        if (!first) {
            write(", ");
        } else {
            first = false;
        }
        String name = entry.getKey();
        Declaration member = entry.getValue();
        boolean alias = Util.nullSafeCompare(name, Util.getDeclarationName(member)) != 0;
        LinkRenderer linkRenderer = linkRenderer().withinText(true).to(member).useScope(klass).printMemberContainerName(false);
        if (alias) {
            StringBuilder sb = new StringBuilder();
            sb.append("<code><span class='");
            if (member instanceof TypeDeclaration)
                sb.append("type-");
            sb.append("identifier'>");
            sb.append(name);
            sb.append("</span></code>");
            linkRenderer.useCustomText(sb.toString());
        }
        linkRenderer.write();
    }
    close("div");
    close("td", "tr");
}
Also used : TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 63 with Declaration

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

the class ClassOrPackageDoc method writeLinkToRefinedDeclaration.

private void writeLinkToRefinedDeclaration(FunctionOrValue d) throws IOException {
    Declaration topMostRefinedDecl = d.getRefinedDeclaration();
    if (topMostRefinedDecl != null && topMostRefinedDecl != d) {
        Declaration bottomMostRefinedDecl = findBottomMostRefinedDeclaration(d);
        open("div class='refined section'");
        around("span class='title'", "Refines ");
        if (bottomMostRefinedDecl != null && bottomMostRefinedDecl != topMostRefinedDecl) {
            linkRenderer().to(bottomMostRefinedDecl).withinText(true).useCustomText(getNameWithContainer(bottomMostRefinedDecl)).write();
            around("span class='title'", " ultimately refines ");
            linkRenderer().to(topMostRefinedDecl).withinText(true).useCustomText(getNameWithContainer(topMostRefinedDecl)).write();
        } else {
            linkRenderer().to(topMostRefinedDecl).withinText(true).useCustomText(getNameWithContainer(topMostRefinedDecl)).write();
        }
        close("div");
    }
}
Also used : TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) Util.findBottomMostRefinedDeclaration(com.redhat.ceylon.ceylondoc.Util.findBottomMostRefinedDeclaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 64 with Declaration

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

the class StatementTransformer method definitelySatisfiedOrNot.

private boolean definitelySatisfiedOrNot(java.util.List<Tree.Condition> conditions, boolean satisfied) {
    if (conditions.size() != 1) {
        return false;
    }
    Tree.Condition condition = conditions.get(0);
    if (!(condition instanceof Tree.BooleanCondition)) {
        return false;
    }
    Tree.Term term = ((Tree.BooleanCondition) condition).getExpression().getTerm();
    if (!(term instanceof Tree.BaseMemberExpression)) {
        return false;
    }
    Declaration declaration = ((Tree.BaseMemberExpression) term).getDeclaration();
    return declaration instanceof Value && satisfied ? isBooleanTrue(declaration) : isBooleanFalse(declaration);
}
Also used : Term(com.redhat.ceylon.compiler.typechecker.tree.Tree.Term) Condition(com.redhat.ceylon.compiler.typechecker.tree.Tree.Condition) Value(com.redhat.ceylon.model.typechecker.model.Value) CustomTree(com.redhat.ceylon.compiler.typechecker.tree.CustomTree) JCTree(com.sun.tools.javac.tree.JCTree) Tree(com.redhat.ceylon.compiler.typechecker.tree.Tree) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 65 with Declaration

use of com.redhat.ceylon.model.typechecker.model.Declaration 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)

Aggregations

Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)107 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)95 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)80 Type (com.redhat.ceylon.model.typechecker.model.Type)34 Function (com.redhat.ceylon.model.typechecker.model.Function)33 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)30 Class (com.redhat.ceylon.model.typechecker.model.Class)28 Value (com.redhat.ceylon.model.typechecker.model.Value)28 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)27 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)27 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)24 AttributeDeclaration (com.redhat.ceylon.compiler.typechecker.tree.Tree.AttributeDeclaration)22 JCTree (com.sun.tools.javac.tree.JCTree)22 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)21 MethodDeclaration (com.redhat.ceylon.compiler.typechecker.tree.Tree.MethodDeclaration)20 Interface (com.redhat.ceylon.model.typechecker.model.Interface)20 Scope (com.redhat.ceylon.model.typechecker.model.Scope)20 Package (com.redhat.ceylon.model.typechecker.model.Package)17 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)17 ArrayList (java.util.ArrayList)16