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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations