Search in sources :

Example 1 with Cluster

use of com.github.sevntu.checkstyle.dot.domain.Cluster in project methods-distance by sevntu-checkstyle.

the class DependencyInfoGraphSerializer method serializeInfo.

public static String serializeInfo(Dependencies dependencies) {
    final MethodOrder info = new MethodOrder(dependencies);
    final Graph graph = new Graph("dependencies");
    graph.setRankdir(Rankdirs.LR);
    final Cluster simpleMethods = new Cluster("simple");
    final Map<Method, Node> methodToNode = info.getMethods().stream().filter(method -> !info.isInterfaceMethod(method)).collect(Collectors.toMap(Function.identity(), DependencyInfoGraphSerializer::createNode));
    methodToNode.entrySet().stream().forEach(methodAndNode -> {
        if (info.hasMethodDependencies(methodAndNode.getKey())) {
            graph.addComponent(methodAndNode.getValue());
        } else {
            simpleMethods.addComponent(methodAndNode.getValue());
        }
    });
    graph.addComponent(simpleMethods);
    for (final Method caller : methodToNode.keySet()) {
        for (final Method callee : info.getMethodDependenciesInAppearanceOrder(caller)) {
            graph.addComponent(createEdge(caller, callee, methodToNode, info));
        }
    }
    final Comment comment = new Comment(getDescription());
    graph.addComponent(comment);
    return serialize(graph);
}
Also used : PrintWriter(java.io.PrintWriter) Cluster(com.github.sevntu.checkstyle.dot.domain.Cluster) Graph(com.github.sevntu.checkstyle.dot.domain.Graph) Element(com.github.sevntu.checkstyle.dot.domain.Element) FileUtils(com.github.sevntu.checkstyle.utils.FileUtils) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) MethodOrder(com.github.sevntu.checkstyle.ordering.MethodOrder) Shapes(com.github.sevntu.checkstyle.dot.domain.Shapes) Method(com.github.sevntu.checkstyle.ordering.Method) List(java.util.List) Colors(com.github.sevntu.checkstyle.dot.domain.Colors) Rankdirs(com.github.sevntu.checkstyle.dot.domain.Rankdirs) Map(java.util.Map) AttributeHolder(com.github.sevntu.checkstyle.dot.domain.AttributeHolder) Comment(com.github.sevntu.checkstyle.dot.domain.Comment) Node(com.github.sevntu.checkstyle.dot.domain.Node) Edge(com.github.sevntu.checkstyle.dot.domain.Edge) Dependencies(com.github.sevntu.checkstyle.domain.Dependencies) Comment(com.github.sevntu.checkstyle.dot.domain.Comment) Graph(com.github.sevntu.checkstyle.dot.domain.Graph) Node(com.github.sevntu.checkstyle.dot.domain.Node) Cluster(com.github.sevntu.checkstyle.dot.domain.Cluster) MethodOrder(com.github.sevntu.checkstyle.ordering.MethodOrder) Method(com.github.sevntu.checkstyle.ordering.Method)

Aggregations

Dependencies (com.github.sevntu.checkstyle.domain.Dependencies)1 AttributeHolder (com.github.sevntu.checkstyle.dot.domain.AttributeHolder)1 Cluster (com.github.sevntu.checkstyle.dot.domain.Cluster)1 Colors (com.github.sevntu.checkstyle.dot.domain.Colors)1 Comment (com.github.sevntu.checkstyle.dot.domain.Comment)1 Edge (com.github.sevntu.checkstyle.dot.domain.Edge)1 Element (com.github.sevntu.checkstyle.dot.domain.Element)1 Graph (com.github.sevntu.checkstyle.dot.domain.Graph)1 Node (com.github.sevntu.checkstyle.dot.domain.Node)1 Rankdirs (com.github.sevntu.checkstyle.dot.domain.Rankdirs)1 Shapes (com.github.sevntu.checkstyle.dot.domain.Shapes)1 Method (com.github.sevntu.checkstyle.ordering.Method)1 MethodOrder (com.github.sevntu.checkstyle.ordering.MethodOrder)1 FileUtils (com.github.sevntu.checkstyle.utils.FileUtils)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintWriter (java.io.PrintWriter)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1