Package org.jvnet.sorcerer.util

Examples of org.jvnet.sorcerer.util.JsonWriter$Writable


        w.close();
    }

    public void generateProjectJs(final Map<String, String> cus, PrintWriter w) throws IOException {
        try {
            final JsonWriter jw = new JsonWriter(w);
            jw.startObject();
            jw.property("name", "Project"); // TODO
            jw.propertyUnquoted("linker", "linker.self");
            jw.property("sources", new JsonWriter.Writable() {
                public void write(JsonWriter w) {
                    for (Map.Entry<String, String> entry : cus.entrySet()) {
                        jw.property(entry.getKey(), entry.getValue());
                    }
                }
            });
            // write dependencies
            for (Dependency dep : pss.getDependencies()) {
                jw.object(dep);
            }
            jw.endObject();
        } finally {
            w.close();
        }
    }
View Full Code Here


    }

    public void generateClassListJs(PackageElement p, PrintWriter w) throws IOException {
        try {
            w.printf("setClassList(\"%s\",",p.getQualifiedName());
            JsonWriter jw = new JsonWriter(w);
            jw.startArray();
            for (TypeElement t : pss.getClassElements(p)) {
                if(pss.getTrees().getTree(t)==null)
                    continue;   // not a part of the compilation unit
                jw.startObject();
                jw.property("name",t.getSimpleName());
                jw.property("kind",getKindString(t.getKind()));
                jw.property("script",t.getQualifiedName().toString().replace('.','/')+".js");
                jw.property("access",getAccessLevel(t));
                jw.endObject();
            }
            jw.endArray();
            w.println(");");
        } finally {
            w.close();
        }
    }
View Full Code Here

            if(!pt.isLocal())
                types.add(pt);
        }

        w.println("setProjectUsage(");
        JsonWriter js = new JsonWriter(w);
        js.startArray();
        for (Map.Entry<PackageElement,Set<ParsedType>> pkg : pkgs.entrySet()) {
            js.startObject();
            js.property("package",pkg.getKey().getQualifiedName());
            js.key("classes");
            js.startArray();
            String[] names = new String[pkg.getValue().size()];
            int idx=0;
            for (ParsedType pt : pkg.getValue()) {
                names[idx++] = pt.getPackageLocalName();
            }
            Arrays.sort(names);
            for (String n : names) {
                js.object(n);
            }
            js.endArray();
            js.endObject();
        }
        js.endArray();
        w.println(")");
        w.close();
    }
View Full Code Here

        return type.element.getQualifiedName().toString().replace('.','/')+"-usage.js";
    }

    public void write(ParsedType type, PrintWriter pw) {
        pw.println("setClassUsage('"+type.element.getQualifiedName()+"',");
        JsonWriter w = new JsonWriter(pw);
        w.startObject();
        for (Entry<Element, Set<TreePath>> e : type.findReferers(pss.getSourcePositions()).entrySet()) {
            w.key(getKeyName(type,e.getKey()));
            NodePkgInfo root = new NodePkgInfo("");

            // builds a top-down tree.
            for (TreePath t : e.getValue())
                root.add(t).getLeaves().add(t);

            // then write it out!
            w.object(root);
        }
        w.endObject();
        pw.println(");");
        pw.close();
    }
View Full Code Here

            packageNames.add(pe.getQualifiedName().toString());
        packageNames.sort();

        try {
            w.println("setProject(");
            JsonWriter jw = new JsonWriter(w);
            jw.startArray();
            {// write self
                jw.startObject();
                jw.property("name","Project"); // TODO
                jw.propertyUnquoted("linker","linker.self");
                jw.property("packages",packageNames);
                jw.endObject();
            }
            // write dependencies
            for (Dependency dep : pss.getDependencies())
                jw.object(dep);
            jw.endArray();
            w.println(");");
        } finally {
            w.close();
        }
    }
View Full Code Here

    }

    public void generateClassListJs(PackageElement p, PrintWriter w) throws IOException {
        try {
            w.printf("setClassList(\"%s\",",p.getQualifiedName());
            JsonWriter jw = new JsonWriter(w);
            jw.startArray();
            for (TypeElement t : pss.getClassElements(p)) {
                if(pss.getTrees().getTree(t)==null)
                    continue;   // not a part of the compilation unit
                jw.startObject();
                jw.property("name",t.getSimpleName());
                jw.property("kind",getKindString(t.getKind()));
                jw.property("script",t.getQualifiedName().toString().replace('.','/')+".js");
                jw.property("access",getAccessLevel(t));
                jw.endObject();
            }
            jw.endArray();
            w.println(");");
        } finally {
            w.close();
        }
    }
View Full Code Here

            if(!pt.isLocal())
                types.add(pt);
        }

        w.println("setProjectUsage(");
        JsonWriter js = new JsonWriter(w);
        js.startArray();
        for (Entry<PackageElement,Set<ParsedType>> pkg : pkgs.entrySet()) {
            js.startObject();
            js.property("package",pkg.getKey().getQualifiedName());
            js.key("classes");
            js.startArray();
            String[] names = new String[pkg.getValue().size()];
            int idx=0;
            for (ParsedType pt : pkg.getValue()) {
                names[idx++] = pt.getPackageLocalName();
            }
            Arrays.sort(names);
            for (String n : names) {
                js.object(n);
            }
            js.endArray();
            js.endObject();
        }
        js.endArray();
        w.println(")");
        w.close();
    }
View Full Code Here

TOP

Related Classes of org.jvnet.sorcerer.util.JsonWriter$Writable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.