Search in sources :

Example 16 with ControlFlowElement

use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.

the class NullDereferenceAnalyser method getNullDereferences.

/**
 * @return a list of all AST locations where a null pointer dereference can happen
 */
public Iterable<NullDereferenceResult> getNullDereferences() {
    Set<NullDereferenceResult> nullDerefs = new HashSet<>();
    for (Assumption ass : failedAssumptions.values()) {
        IsNotNull inn = (IsNotNull) ass;
        ControlFlowElement astLocation = inn.creationSite;
        NullDereferenceResult ndr = new NullDereferenceResult(astLocation, inn);
        nullDerefs.add(ndr);
    }
    return nullDerefs;
}
Also used : ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement) HashSet(java.util.HashSet) Assumption(org.eclipse.n4js.flowgraphs.dataflow.Assumption)

Example 17 with ControlFlowElement

use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.

the class BranchWalker method visit.

@Override
protected final void visit(Node node) {
    if (node instanceof RepresentingNode) {
        lastRN = node;
        ControlFlowElement cfe = node.getRepresentedControlFlowElement();
        visit(cfe);
        return;
    }
    if (this.getContainer() == node.getControlFlowElement()) {
        ControlFlowElement cfe = node.getControlFlowElement();
        if (lastRN == null) {
            enterContainer(cfe);
        } else {
            exitContainer(cfe);
        }
        lastRN = node;
    }
}
Also used : RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Example 18 with ControlFlowElement

use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.

the class CFGraphProvider method getConnectedEdges.

@Override
public List<Edge> getConnectedEdges(Node node, List<Node> allNodes) {
    ControlFlowElement cfe = (ControlFlowElement) node.getElement();
    List<Edge> succs = edgesMap.get(cfe);
    if (succs == null) {
        return Collections.emptyList();
    }
    return succs;
}
Also used : ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement) Edge(org.eclipse.n4js.smith.ui.graph.Edge) CFEdge(org.eclipse.n4js.smith.ui.graph.CFEdge) FlowEdge(org.eclipse.n4js.flowgraphs.FlowEdge)

Example 19 with ControlFlowElement

use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.

the class CatchNodeFinder method getContainer.

/**
 * To find the correct catch node, all containers are searched, starting from the innermost.
 */
private static ControlFlowElement getContainer(ControlFlowElement cfe) {
    EObject container = cfe.eContainer();
    if (container instanceof ControlFlowElement) {
        return (ControlFlowElement) container;
    }
    boolean getNextContainer = false;
    getNextContainer |= container instanceof CatchBlock;
    getNextContainer |= container instanceof FinallyBlock;
    if (getNextContainer) {
        return (ControlFlowElement) container.eContainer();
    }
    return null;
}
Also used : CatchBlock(org.eclipse.n4js.n4JS.CatchBlock) FinallyBlock(org.eclipse.n4js.n4JS.FinallyBlock) EObject(org.eclipse.emf.ecore.EObject) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Example 20 with ControlFlowElement

use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.

the class ControlFlowGraphFactory method isExitingFinallyBlock.

private static boolean isExitingFinallyBlock(ComplexNodeMapper cnMapper, Node node) {
    ControlFlowElement cfe = node.getControlFlowElement();
    ComplexNode cn = cnMapper.get(cfe);
    boolean isExitingFinallyBlock = true;
    isExitingFinallyBlock &= cfe instanceof Block;
    isExitingFinallyBlock &= cfe.eContainer() instanceof FinallyBlock;
    isExitingFinallyBlock &= cn.getExit() == node;
    return isExitingFinallyBlock;
}
Also used : ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) FinallyBlock(org.eclipse.n4js.n4JS.FinallyBlock) FinallyBlock(org.eclipse.n4js.n4JS.FinallyBlock) Block(org.eclipse.n4js.n4JS.Block) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Aggregations

ControlFlowElement (org.eclipse.n4js.n4JS.ControlFlowElement)52 EObject (org.eclipse.emf.ecore.EObject)12 ComplexNode (org.eclipse.n4js.flowgraphs.model.ComplexNode)12 LinkedList (java.util.LinkedList)10 RepresentingNode (org.eclipse.n4js.flowgraphs.model.RepresentingNode)10 ParameterParser (org.eclipse.xpect.parameter.ParameterParser)9 Xpect (org.eclipse.xpect.runner.Xpect)9 Node (org.eclipse.n4js.flowgraphs.model.Node)8 HashSet (java.util.HashSet)7 ControlFlowType (org.eclipse.n4js.flowgraphs.ControlFlowType)5 ControlFlowEdge (org.eclipse.n4js.flowgraphs.model.ControlFlowEdge)4 HashMap (java.util.HashMap)3 FlowEdge (org.eclipse.n4js.flowgraphs.FlowEdge)3 FinallyBlock (org.eclipse.n4js.n4JS.FinallyBlock)3 LinkedHashSet (java.util.LinkedHashSet)2 N4JSFlowAnalyser (org.eclipse.n4js.flowgraphs.N4JSFlowAnalyser)2 Assumption (org.eclipse.n4js.flowgraphs.dataflow.Assumption)2 Symbol (org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol)2 Block (org.eclipse.n4js.n4JS.Block)2 ExpressionStatement (org.eclipse.n4js.n4JS.ExpressionStatement)2