Search in sources :

Example 1 with FlowEdge

use of org.eclipse.n4js.flowgraphs.FlowEdge in project n4js by eclipse.

the class PathWalkerGuide method visitNode.

@Override
public void visitNode(Node node) {
    if (node instanceof RepresentingNode) {
        ControlFlowElement cfeEnd = node.getRepresentedControlFlowElement();
        if (lastVisitedNode != null) {
            ControlFlowElement cfeStart = lastVisitedNode.getRepresentedControlFlowElement();
            FlowEdge edge = new FlowEdge(cfeStart, cfeEnd, cfTypes);
            walker.visit(edge);
        }
        cfTypes.clear();
        walker.visit(cfeEnd);
        lastVisitedNode = node;
    }
}
Also used : FlowEdge(org.eclipse.n4js.flowgraphs.FlowEdge) ControlFlowEdge(org.eclipse.n4js.flowgraphs.model.ControlFlowEdge) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Example 2 with FlowEdge

use of org.eclipse.n4js.flowgraphs.FlowEdge in project n4js by eclipse.

the class BranchWalker method visit.

@Override
protected final void visit(Node start, Node end, ControlFlowEdge edge) {
    pEdgeTypes.add(edge.cfType);
    if (end instanceof RepresentingNode || this.getContainer() == end.getControlFlowElement()) {
        ControlFlowElement endCFE = end.getRepresentedControlFlowElement();
        endCFE = endCFE == null ? end.getControlFlowElement() : endCFE;
        if (lastRN != null) {
            ControlFlowElement startCFE = lastRN.getRepresentedControlFlowElement();
            startCFE = startCFE == null ? lastRN.getControlFlowElement() : startCFE;
            FlowEdge flowEdge = new FlowEdge(startCFE, endCFE, pEdgeTypes);
            visit(flowEdge);
            pEdgeTypes.clear();
        } else {
            HashSet<EdgeInfo> edgeInfos = new HashSet<>();
            addPredecedingRepNodes(this, edgeInfos, new EdgeInfo(this));
            for (EdgeInfo edgeInfo : edgeInfos) {
                ControlFlowElement startCFE = edgeInfo.startNode.getRepresentedControlFlowElement();
                startCFE = startCFE == null ? edgeInfo.startNode.getControlFlowElement() : startCFE;
                FlowEdge flowEdge = new FlowEdge(startCFE, endCFE, edgeInfo.pEdgeTypes);
                edgeInfo.edgeOwner.visit(flowEdge);
            }
            pEdgeTypes.clear();
        }
    }
}
Also used : FlowEdge(org.eclipse.n4js.flowgraphs.FlowEdge) ControlFlowEdge(org.eclipse.n4js.flowgraphs.model.ControlFlowEdge) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement) HashSet(java.util.HashSet)

Aggregations

FlowEdge (org.eclipse.n4js.flowgraphs.FlowEdge)2 ControlFlowEdge (org.eclipse.n4js.flowgraphs.model.ControlFlowEdge)2 RepresentingNode (org.eclipse.n4js.flowgraphs.model.RepresentingNode)2 ControlFlowElement (org.eclipse.n4js.n4JS.ControlFlowElement)2 HashSet (java.util.HashSet)1