Search in sources :

Example 26 with DagNode

use of com.randomnoun.build.javaToGraphviz.dag.DagNode in project java-to-graphviz by randomnoun.

the class ControlFlowEdger method addSynchronizedEdges.

// in the css you want to put a subgraph around the synchronizedBlock ( the expression is hoisted above this node )
private List<ExitEdge> addSynchronizedEdges(Dag dag, DagNode synchronizedNode, LexicalScope scope) {
    SynchronizedStatement ss = (SynchronizedStatement) synchronizedNode.astNode;
    DagNode expressionDag = getDagChild(synchronizedNode.children, ss.getExpression(), null);
    DagNode synchronizedBlock = getDagChild(synchronizedNode.children, ss.getBody(), null);
    Rejigger rejigger = hoistNode(dag, synchronizedNode, expressionDag);
    List<ExitEdge> prevNodes = addExpressionEdges(dag, expressionDag, scope);
    prevNodes = rejigger.unhoistNode(dag, prevNodes);
    for (ExitEdge e : prevNodes) {
        e.n2 = synchronizedBlock;
        addEdge(e);
    }
    prevNodes = addBlockEdges(dag, synchronizedBlock, scope);
    return prevNodes;
}
Also used : DagNode(com.randomnoun.build.javaToGraphviz.dag.DagNode) ExitEdge(com.randomnoun.build.javaToGraphviz.dag.ExitEdge) SynchronizedStatement(org.eclipse.jdt.core.dom.SynchronizedStatement)

Example 27 with DagNode

use of com.randomnoun.build.javaToGraphviz.dag.DagNode in project java-to-graphviz by randomnoun.

the class ControlFlowEdger method addArrayInitializerEdges.

private List<ExitEdge> addArrayInitializerEdges(Dag dag, DagNode node, LexicalScope scope) {
    ArrayInitializer ai = (ArrayInitializer) node.astNode;
    // maybe we evaluate the index first ? not sure. reckon it's probably the array ref
    List<DagNode> expressionDags = getDagChildren(node.children, ai.expressions(), null);
    List<ExitEdge> prevNodes = null;
    if (expressionDags.size() > 0) {
        // move methodInvocation node after the expression & argument nodes
        Rejigger rejigger = hoistNode(dag, node, expressionDags.get(0));
        for (DagNode expr : expressionDags) {
            if (prevNodes != null) {
                for (ExitEdge e : prevNodes) {
                    e.n2 = expr;
                    e.classes.add("invocationArgument");
                    addEdge(e);
                }
            }
            prevNodes = addExpressionEdges(dag, expr, scope);
        }
        prevNodes = rejigger.unhoistNode(dag, prevNodes);
    } else {
        ExitEdge e = new ExitEdge();
        e.n1 = node;
        prevNodes = Collections.singletonList(e);
    }
    return prevNodes;
}
Also used : DagNode(com.randomnoun.build.javaToGraphviz.dag.DagNode) ExitEdge(com.randomnoun.build.javaToGraphviz.dag.ExitEdge) ArrayInitializer(org.eclipse.jdt.core.dom.ArrayInitializer)

Example 28 with DagNode

use of com.randomnoun.build.javaToGraphviz.dag.DagNode in project java-to-graphviz by randomnoun.

the class ControlFlowEdger method addParenthesizedExpressionEdges.

private List<ExitEdge> addParenthesizedExpressionEdges(Dag dag, DagNode node, LexicalScope scope) {
    ParenthesizedExpression pe = (ParenthesizedExpression) node.astNode;
    DagNode exprDag = getDagChild(node.children, pe.getExpression(), null);
    // don't really need these in the dag
    Rejigger rejigger = hoistNode(dag, node, exprDag);
    List<ExitEdge> prevNodes = addExpressionEdges(dag, exprDag, scope);
    rejigger.unhoistNode(dag, null);
    return prevNodes;
}
Also used : ParenthesizedExpression(org.eclipse.jdt.core.dom.ParenthesizedExpression) DagNode(com.randomnoun.build.javaToGraphviz.dag.DagNode) ExitEdge(com.randomnoun.build.javaToGraphviz.dag.ExitEdge)

Example 29 with DagNode

use of com.randomnoun.build.javaToGraphviz.dag.DagNode in project java-to-graphviz by randomnoun.

the class ControlFlowEdger method addPrefixExpressionEdges.

private List<ExitEdge> addPrefixExpressionEdges(Dag dag2, DagNode node, LexicalScope scope) {
    PrefixExpression pe = (PrefixExpression) node.astNode;
    DagNode operandDag = getDagChild(node.children, pe.getOperand(), null);
    PrefixExpression.Operator op = pe.getOperator();
    node.gvAttributes.put("operatorToken", op.toString());
    // @TODO camelcase
    node.gvAttributes.put("operatorName", Text.getLastComponent(op.getClass().getName()));
    Rejigger rejigger = hoistNode(dag, node, operandDag);
    List<ExitEdge> prevNodes = addExpressionEdges(dag, operandDag, scope);
    prevNodes = rejigger.unhoistNode(dag, prevNodes);
    return prevNodes;
}
Also used : DagNode(com.randomnoun.build.javaToGraphviz.dag.DagNode) ExitEdge(com.randomnoun.build.javaToGraphviz.dag.ExitEdge) PrefixExpression(org.eclipse.jdt.core.dom.PrefixExpression)

Example 30 with DagNode

use of com.randomnoun.build.javaToGraphviz.dag.DagNode in project java-to-graphviz by randomnoun.

the class ControlFlowEdger method addSuperMethodInvocationEdges.

private List<ExitEdge> addSuperMethodInvocationEdges(Dag dag, DagNode methodInvocationNode, LexicalScope scope) {
    SuperMethodInvocation smi = (SuperMethodInvocation) methodInvocationNode.astNode;
    String qualifier = smi.getQualifier() == null ? "" : smi.getQualifier().toString() + ".";
    // smi.typeArguments(); ?
    methodInvocationNode.gvAttributes.put("methodName", qualifier + ".super." + smi.getName().toString());
    List<DagNode> argumentDags = getDagChildren(methodInvocationNode.children, smi.arguments(), null);
    List<ExitEdge> prevNodes = null;
    if (argumentDags.size() > 0) {
        // move methodInvocation node after the argument nodes
        Rejigger rejigger = hoistNode(dag, methodInvocationNode, argumentDags.get(0));
        for (DagNode a : argumentDags) {
            if (prevNodes != null) {
                for (ExitEdge e : prevNodes) {
                    e.n2 = a;
                    e.classes.add("invocationArgument");
                    addEdge(e);
                }
            }
            prevNodes = addExpressionEdges(dag, a, scope);
        }
        prevNodes = rejigger.unhoistNode(dag, prevNodes);
    } else {
        ExitEdge e = new ExitEdge();
        e.n1 = methodInvocationNode;
        prevNodes = Collections.singletonList(e);
    }
    return prevNodes;
}
Also used : DagNode(com.randomnoun.build.javaToGraphviz.dag.DagNode) ExitEdge(com.randomnoun.build.javaToGraphviz.dag.ExitEdge) SuperMethodInvocation(org.eclipse.jdt.core.dom.SuperMethodInvocation)

Aggregations

DagNode (com.randomnoun.build.javaToGraphviz.dag.DagNode)55 ExitEdge (com.randomnoun.build.javaToGraphviz.dag.ExitEdge)33 DagEdge (com.randomnoun.build.javaToGraphviz.dag.DagEdge)20 DagSubgraph (com.randomnoun.build.javaToGraphviz.dag.DagSubgraph)11 ArrayList (java.util.ArrayList)8 DagElement (com.randomnoun.build.javaToGraphviz.dom.DagElement)6 GvComment (com.randomnoun.build.javaToGraphviz.comment.GvComment)3 ExceptionErrorHandler (com.randomnoun.build.javaToGraphviz.dom.StylesheetApplier.ExceptionErrorHandler)3 CSSOMParser (com.steadystate.css.parser.CSSOMParser)3 ASTNode (org.eclipse.jdt.core.dom.ASTNode)3 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)3 ConditionalExpression (org.eclipse.jdt.core.dom.ConditionalExpression)3 InfixExpression (org.eclipse.jdt.core.dom.InfixExpression)3 InstanceofExpression (org.eclipse.jdt.core.dom.InstanceofExpression)3 CommentText (com.randomnoun.build.javaToGraphviz.comment.CommentText)2 GvEndGraphComment (com.randomnoun.build.javaToGraphviz.comment.GvEndGraphComment)2 GvEndSubgraphComment (com.randomnoun.build.javaToGraphviz.comment.GvEndSubgraphComment)2 GvGraphComment (com.randomnoun.build.javaToGraphviz.comment.GvGraphComment)2 GvKeepNodeComment (com.randomnoun.build.javaToGraphviz.comment.GvKeepNodeComment)2 GvLiteralComment (com.randomnoun.build.javaToGraphviz.comment.GvLiteralComment)2