use of com.randomnoun.build.javaToGraphviz.dag.ExitEdge in project java-to-graphviz by randomnoun.
the class ControlFlowEdger method addArrayCreationEdges.
private List<ExitEdge> addArrayCreationEdges(Dag dag, DagNode node, LexicalScope scope) {
ArrayCreation ac = (ArrayCreation) node.astNode;
List<DagNode> dimensionDags = getDagChildren(node.children, ac.dimensions(), null);
DagNode arrayInitDag = getDagChild(node.children, ac.getInitializer(), null);
node.gvAttributes.put("type", ac.getType().toString());
List<ExitEdge> prevNodes = null;
if (arrayInitDag != null || dimensionDags.size() > 0) {
// move methodInvocation node after the expression & argument nodes
Rejigger rejigger = hoistNode(dag, node, dimensionDags.size() == 0 ? arrayInitDag : dimensionDags.get(0));
for (DagNode a : dimensionDags) {
if (prevNodes != null) {
for (ExitEdge e : prevNodes) {
e.n2 = a;
// e.classes.add("invocationArgument");
addEdge(e);
}
}
prevNodes = addExpressionEdges(dag, a, scope);
}
// expression is null for method calls within the same object
if (arrayInitDag != null) {
if (prevNodes != null) {
for (ExitEdge e : prevNodes) {
e.n2 = arrayInitDag;
// e.classes.add("invocationArgument");
addEdge(e);
}
}
prevNodes = addExpressionEdges(dag, arrayInitDag, 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.ExitEdge in project java-to-graphviz by randomnoun.
the class ControlFlowEdger method addThrowEdges.
// a throw will add an edge to throwEdges only
// (and returns an empty list as we won't have a normal exit edge)
private List<ExitEdge> addThrowEdges(Dag dag, DagNode breakNode, LexicalScope scope) {
ExitEdge e = new ExitEdge();
// e.label = "throw";
e.n1 = breakNode;
// e.gvAttributes.put("color", "purple");
e.classes.add("throw");
scope.throwEdges.add(e);
return Collections.emptyList();
}
use of com.randomnoun.build.javaToGraphviz.dag.ExitEdge in project java-to-graphviz by randomnoun.
the class ControlFlowEdger method addPostfixExpressionEdges.
private List<ExitEdge> addPostfixExpressionEdges(Dag dag, DagNode node, LexicalScope scope) {
PostfixExpression pe = (PostfixExpression) node.astNode;
DagNode operandDag = getDagChild(node.children, pe.getOperand(), null);
PostfixExpression.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.ExitEdge in project java-to-graphviz by randomnoun.
the class ControlFlowEdger method addMethodInvocationEdges.
private List<ExitEdge> addMethodInvocationEdges(Dag dag, DagNode methodInvocationNode, LexicalScope scope) {
MethodInvocation mi = (MethodInvocation) methodInvocationNode.astNode;
DagNode expressionDag = getDagChild(methodInvocationNode.children, mi.getExpression(), null);
DagNode nameDag = getDagChild(methodInvocationNode.children, mi.getName(), null);
List<DagNode> argumentDags = getDagChildren(methodInvocationNode.children, mi.arguments(), null);
methodInvocationNode.gvAttributes.put("methodName", mi.getName().toString());
// for combined charts only
addEdges(dag, nameDag, scope);
List<ExitEdge> prevNodes = null;
if (expressionDag != null || argumentDags.size() > 0) {
// move methodInvocation node after the expression & argument nodes
Rejigger rejigger = hoistNode(dag, methodInvocationNode, expressionDag != null ? expressionDag : argumentDags.get(0));
// expression is null for method calls within the same object
if (expressionDag != null) {
prevNodes = addExpressionEdges(dag, expressionDag, scope);
}
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);
}
// what's the opposite of rejiggering ?
// hoisting ? petarding ? right I'm just going to say unhoist
prevNodes = rejigger.unhoistNode(dag, prevNodes);
} else {
ExitEdge e = new ExitEdge();
e.n1 = methodInvocationNode;
prevNodes = Collections.singletonList(e);
}
return prevNodes;
}
use of com.randomnoun.build.javaToGraphviz.dag.ExitEdge in project java-to-graphviz by randomnoun.
the class ControlFlowEdger method addMethodReferenceEdges.
private List<ExitEdge> addMethodReferenceEdges(Dag dag, DagNode thisNode, LexicalScope scope) {
// CreationReference or ExpressionMethodReference or SuperMethodReference or TypeMethodReference
MethodReference mr = (MethodReference) thisNode.astNode;
// qualified reference
thisNode.gvAttributes.put("name", mr.toString());
ExitEdge e = new ExitEdge();
e.n1 = thisNode;
return Collections.singletonList(e);
}
Aggregations