Search in sources :

Example 11 with Statement

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

the class AbstractCaseClauseFactory method buildComplexNode.

static ComplexNode buildComplexNode(ReentrantASTIterator astpp, AbstractCaseClause abstrCaseClause) {
    ComplexNode cNode = new ComplexNode(astpp.container(), abstrCaseClause);
    Node entryNode = new HelperNode(NodeNames.ENTRY, astpp.pos(), abstrCaseClause);
    List<Node> stmtNodes = new LinkedList<>();
    Node caseConditionNode = null;
    if (abstrCaseClause instanceof CaseClause) {
        CaseClause caseClause = (CaseClause) abstrCaseClause;
        caseConditionNode = DelegatingNodeFactory.create(astpp, NodeNames.CONDITION, caseClause, caseClause.getExpression());
    }
    EList<Statement> stmts = abstrCaseClause.getStatements();
    for (int i = 0; i < stmts.size(); i++) {
        Statement stmt = stmts.get(i);
        Node blockNode = new DelegatingNode("stmt_" + i, astpp.pos(), abstrCaseClause, stmt);
        stmtNodes.add(blockNode);
        astpp.visitUtil(blockNode.getDelegatedControlFlowElement());
    }
    Node exitNode = new HelperNode(NodeNames.EXIT, astpp.pos(), abstrCaseClause);
    cNode.addNode(entryNode);
    cNode.addNode(caseConditionNode);
    for (Node blockNode : stmtNodes) cNode.addNode(blockNode);
    cNode.addNode(exitNode);
    List<Node> nodes = new LinkedList<>();
    nodes.add(entryNode);
    nodes.add(caseConditionNode);
    nodes.addAll(stmtNodes);
    nodes.add(exitNode);
    cNode.connectInternalSucc(nodes);
    cNode.setEntryNode(entryNode);
    cNode.setExitNode(exitNode);
    return cNode;
}
Also used : HelperNode(org.eclipse.n4js.flowgraphs.model.HelperNode) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) Statement(org.eclipse.n4js.n4JS.Statement) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) DelegatingNode(org.eclipse.n4js.flowgraphs.model.DelegatingNode) HelperNode(org.eclipse.n4js.flowgraphs.model.HelperNode) Node(org.eclipse.n4js.flowgraphs.model.Node) CaseClause(org.eclipse.n4js.n4JS.CaseClause) AbstractCaseClause(org.eclipse.n4js.n4JS.AbstractCaseClause) DelegatingNode(org.eclipse.n4js.flowgraphs.model.DelegatingNode) LinkedList(java.util.LinkedList)

Example 12 with Statement

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

the class BlockFactory method buildComplexNode.

static ComplexNode buildComplexNode(ReentrantASTIterator astpp, org.eclipse.n4js.n4JS.Block block) {
    ComplexNode cNode = new ComplexNode(astpp.container(), block);
    Node entryNode = new HelperNode(NodeNames.ENTRY, astpp.pos(), block);
    List<Node> blockNodes = new LinkedList<>();
    EList<Statement> stmts = block.getStatements();
    for (int i = 0; i < stmts.size(); i++) {
        Statement stmt = stmts.get(i);
        Node blockNode = DelegatingNodeFactory.create(astpp, "stmt_" + i, block, stmt);
        blockNodes.add(blockNode);
    }
    Node exitNode = new HelperNode(NodeNames.EXIT, astpp.pos(), block);
    cNode.addNode(entryNode);
    for (Node blockNode : blockNodes) cNode.addNode(blockNode);
    cNode.addNode(exitNode);
    List<Node> nodes = new LinkedList<>();
    nodes.add(entryNode);
    nodes.addAll(blockNodes);
    nodes.add(exitNode);
    cNode.connectInternalSucc(nodes);
    cNode.setEntryNode(entryNode);
    cNode.setExitNode(exitNode);
    if (FGUtils.isCFContainer(block)) {
        exitNode.addCatchToken(new CatchToken(ControlFlowType.CatchesAll));
    } else {
        LabelledStatement lblStmt = ASTUtils.getLabelledStatement(block);
        if (lblStmt != null) {
            exitNode.addCatchToken(new CatchToken(ControlFlowType.Break, lblStmt));
        }
    }
    return cNode;
}
Also used : HelperNode(org.eclipse.n4js.flowgraphs.model.HelperNode) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) Statement(org.eclipse.n4js.n4JS.Statement) LabelledStatement(org.eclipse.n4js.n4JS.LabelledStatement) LabelledStatement(org.eclipse.n4js.n4JS.LabelledStatement) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) HelperNode(org.eclipse.n4js.flowgraphs.model.HelperNode) Node(org.eclipse.n4js.flowgraphs.model.Node) CatchToken(org.eclipse.n4js.flowgraphs.model.CatchToken) LinkedList(java.util.LinkedList)

Example 13 with Statement

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

the class PropertyMethodDeclarationImpl method existsExplicitSuperCall.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean existsExplicitSuperCall() {
    final Function1<ExpressionStatement, Expression> _function = new Function1<ExpressionStatement, Expression>() {

        public Expression apply(final ExpressionStatement it) {
            return it.getExpression();
        }
    };
    final Function1<ParameterizedCallExpression, Boolean> _function_1 = new Function1<ParameterizedCallExpression, Boolean>() {

        public Boolean apply(final ParameterizedCallExpression it) {
            Expression _target = it.getTarget();
            return Boolean.valueOf((_target instanceof SuperLiteral));
        }
    };
    final boolean existsSuperCall = IteratorExtensions.<ParameterizedCallExpression>exists(Iterators.<ParameterizedCallExpression>filter(IteratorExtensions.<ExpressionStatement, Expression>map(Iterators.<ExpressionStatement>filter(EcoreUtilN4.<Statement>getAllDirectlyFoundContentsOfType(this.getBody(), Statement.class), ExpressionStatement.class), _function), ParameterizedCallExpression.class), _function_1);
    return existsSuperCall;
}
Also used : Expression(org.eclipse.n4js.n4JS.Expression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) Statement(org.eclipse.n4js.n4JS.Statement) ExpressionStatement(org.eclipse.n4js.n4JS.ExpressionStatement) ExpressionStatement(org.eclipse.n4js.n4JS.ExpressionStatement) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) SuperLiteral(org.eclipse.n4js.n4JS.SuperLiteral)

Example 14 with Statement

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

the class N4MethodDeclarationImpl method existsExplicitSuperCall.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean existsExplicitSuperCall() {
    final Function1<ExpressionStatement, Expression> _function = new Function1<ExpressionStatement, Expression>() {

        public Expression apply(final ExpressionStatement it) {
            return it.getExpression();
        }
    };
    final Function1<ParameterizedCallExpression, Boolean> _function_1 = new Function1<ParameterizedCallExpression, Boolean>() {

        public Boolean apply(final ParameterizedCallExpression it) {
            Expression _target = it.getTarget();
            return Boolean.valueOf((_target instanceof SuperLiteral));
        }
    };
    final boolean existsSuperCall = IteratorExtensions.<ParameterizedCallExpression>exists(Iterators.<ParameterizedCallExpression>filter(IteratorExtensions.<ExpressionStatement, Expression>map(Iterators.<ExpressionStatement>filter(EcoreUtilN4.<Statement>getAllDirectlyFoundContentsOfType(this.getBody(), Statement.class), ExpressionStatement.class), _function), ParameterizedCallExpression.class), _function_1);
    return existsSuperCall;
}
Also used : Expression(org.eclipse.n4js.n4JS.Expression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) Statement(org.eclipse.n4js.n4JS.Statement) ExpressionStatement(org.eclipse.n4js.n4JS.ExpressionStatement) ExpressionStatement(org.eclipse.n4js.n4JS.ExpressionStatement) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) SuperLiteral(org.eclipse.n4js.n4JS.SuperLiteral)

Example 15 with Statement

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

the class ArrowFunctionImpl method implicitReturnExpr.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Expression implicitReturnExpr() {
    Expression _xifexpression = null;
    boolean _isSingleExprImplicitReturn = this.isSingleExprImplicitReturn();
    if (_isSingleExprImplicitReturn) {
        Statement _get = this.getBody().getStatements().get(0);
        _xifexpression = ((ExpressionStatement) _get).getExpression();
    } else {
        _xifexpression = null;
    }
    return _xifexpression;
}
Also used : FunctionExpression(org.eclipse.n4js.n4JS.FunctionExpression) Expression(org.eclipse.n4js.n4JS.Expression) Statement(org.eclipse.n4js.n4JS.Statement) ExpressionStatement(org.eclipse.n4js.n4JS.ExpressionStatement)

Aggregations

Statement (org.eclipse.n4js.n4JS.Statement)16 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)6 ExpressionStatement (org.eclipse.n4js.n4JS.ExpressionStatement)6 Expression (org.eclipse.n4js.n4JS.Expression)4 IfStatement (org.eclipse.n4js.n4JS.IfStatement)4 EObject (org.eclipse.emf.ecore.EObject)3 ForStatement (org.eclipse.n4js.n4JS.ForStatement)3 LabelledStatement (org.eclipse.n4js.n4JS.LabelledStatement)3 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)3 SuperLiteral (org.eclipse.n4js.n4JS.SuperLiteral)3 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)3 LinkedList (java.util.LinkedList)2 ComplexNode (org.eclipse.n4js.flowgraphs.model.ComplexNode)2 HelperNode (org.eclipse.n4js.flowgraphs.model.HelperNode)2 Node (org.eclipse.n4js.flowgraphs.model.Node)2 BinaryLogicalExpression (org.eclipse.n4js.n4JS.BinaryLogicalExpression)2 ConditionalExpression (org.eclipse.n4js.n4JS.ConditionalExpression)2 DoStatement (org.eclipse.n4js.n4JS.DoStatement)2 IterationStatement (org.eclipse.n4js.n4JS.IterationStatement)2 ParenExpression (org.eclipse.n4js.n4JS.ParenExpression)2