Search in sources :

Example 1 with ClassNode

use of com.google.classyshark.silverghost.methodscounter.ClassNode in project android-classyshark by google.

the class SilverGhostFacade method inspectPackages.

public static void inspectPackages(List<String> args) {
    String fileName = args.get(1);
    File file = new File(fileName);
    if (!file.exists()) {
        System.err.printf("File '%s' does not exist", fileName);
        return;
    }
    RootBuilder rootBuilder = new RootBuilder();
    MethodCountExporter methodCountExporter = new TreeMethodCountExporter(new PrintWriter(System.out));
    if (args.size() > 2) {
        for (int i = 2; i < args.size(); i++) {
            if (args.get(i).equals("-flat")) {
                methodCountExporter = new FlatMethodCountExporter(new PrintWriter(System.out));
            }
        }
    }
    ClassNode rootNode = rootBuilder.fillClassesWithMethods(fileName);
    methodCountExporter.exportMethodCounts(rootNode);
}
Also used : ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode) RootBuilder(com.google.classyshark.silverghost.methodscounter.RootBuilder) TreeMethodCountExporter(com.google.classyshark.silverghost.exporter.TreeMethodCountExporter) FlatMethodCountExporter(com.google.classyshark.silverghost.exporter.FlatMethodCountExporter) TreeMethodCountExporter(com.google.classyshark.silverghost.exporter.TreeMethodCountExporter) MethodCountExporter(com.google.classyshark.silverghost.exporter.MethodCountExporter) File(java.io.File) FlatMethodCountExporter(com.google.classyshark.silverghost.exporter.FlatMethodCountExporter) PrintWriter(java.io.PrintWriter)

Example 2 with ClassNode

use of com.google.classyshark.silverghost.methodscounter.ClassNode in project android-classyshark by google.

the class MethodsCountPanel method addNodes.

private void addNodes(ClassNode parent, DefaultMutableTreeNode jTreeParent) {
    for (ClassNode n : parent.getChildNodes().values()) {
        DefaultMutableTreeNode newJTreeNode = new DefaultMutableTreeNode(n);
        jTreeParent.add(newJTreeNode);
        addNodes(n, newJTreeNode);
    }
}
Also used : ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 3 with ClassNode

use of com.google.classyshark.silverghost.methodscounter.ClassNode in project android-classyshark by google.

the class Exporter method writeMethodCounts.

public static void writeMethodCounts(File archive) {
    File outputFile = new File("method_counts.txt");
    System.out.println(outputFile.toString());
    try (PrintWriter pw = new PrintWriter(outputFile)) {
        RootBuilder rootBuilder = new RootBuilder();
        ClassNode classNode = rootBuilder.fillClassesWithMethods(archive);
        MethodCountExporter methodCountExporter = new TreeMethodCountExporter(pw);
        methodCountExporter.exportMethodCounts(classNode);
    } catch (IOException ex) {
        ex.printStackTrace(System.err);
    }
}
Also used : ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode) RootBuilder(com.google.classyshark.silverghost.methodscounter.RootBuilder) IOException(java.io.IOException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 4 with ClassNode

use of com.google.classyshark.silverghost.methodscounter.ClassNode in project android-classyshark by google.

the class FlatMethodCountExporter method printNode.

private void printNode(ClassNode classNode, String[] path) {
    for (String p : path) {
        pw.print(p);
        pw.print('.');
    }
    pw.println(classNode.getKey() + " - " + classNode.getMethodCount());
    Iterator<ClassNode> it = classNode.getChildNodes().values().iterator();
    String[] newPath = new String[path.length + 1];
    System.arraycopy(path, 0, newPath, 0, path.length);
    newPath[newPath.length - 1] = classNode.getKey();
    while (it.hasNext()) {
        ClassNode child = it.next();
        printNode(child, newPath);
    }
}
Also used : ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode)

Example 5 with ClassNode

use of com.google.classyshark.silverghost.methodscounter.ClassNode in project android-classyshark by google.

the class TreeMethodCountExporter method printNode.

private void printNode(ClassNode classNode, boolean[] isFinalLevel) {
    renderTreeStructure(isFinalLevel);
    pw.println(classNode.getKey() + " - " + classNode.getMethodCount());
    Iterator<ClassNode> it = classNode.getChildNodes().values().iterator();
    boolean[] isFinalLevel2 = new boolean[isFinalLevel.length + 1];
    System.arraycopy(isFinalLevel, 0, isFinalLevel2, 0, isFinalLevel.length);
    while (it.hasNext()) {
        ClassNode child = it.next();
        isFinalLevel2[isFinalLevel2.length - 1] = !it.hasNext();
        printNode(child, isFinalLevel2);
    }
}
Also used : ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode)

Aggregations

ClassNode (com.google.classyshark.silverghost.methodscounter.ClassNode)8 RootBuilder (com.google.classyshark.silverghost.methodscounter.RootBuilder)2 File (java.io.File)2 PrintWriter (java.io.PrintWriter)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 FileTransferHandler (com.google.classyshark.gui.panel.FileTransferHandler)1 CellRenderer (com.google.classyshark.gui.panel.tree.CellRenderer)1 FlatMethodCountExporter (com.google.classyshark.silverghost.exporter.FlatMethodCountExporter)1 MethodCountExporter (com.google.classyshark.silverghost.exporter.MethodCountExporter)1 TreeMethodCountExporter (com.google.classyshark.silverghost.exporter.TreeMethodCountExporter)1 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Font (java.awt.Font)1 AffineTransform (java.awt.geom.AffineTransform)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 ArrayList (java.util.ArrayList)1 JScrollPane (javax.swing.JScrollPane)1 JTree (javax.swing.JTree)1 EmptyBorder (javax.swing.border.EmptyBorder)1