Examples of IfStatement


Examples of com.google.test.metric.cpp.dom.IfStatement

  }

  public void testCompoundIfElseStatement() throws Exception {
    TranslationUnit unit = parse("void foo() { if (true) {} else {} }");
    FunctionDefinition functionFoo = unit.getChild(0);
    IfStatement ifStatement = functionFoo.getChild(0);
    assertNotNull(ifStatement);
    ElseStatement elseStatement = functionFoo.getChild(1);
    assertNotNull(elseStatement);
  }
View Full Code Here

Examples of com.google.test.metric.cpp.dom.IfStatement

  }

  public void testIfElseAndLoopStatements() throws Exception {
    TranslationUnit unit = parse("void foo() { if (true) { for(;;); } else { while(true); } }");
    FunctionDefinition functionFoo = unit.getChild(0);
    IfStatement ifStatement = functionFoo.getChild(0);
    LoopStatement forStatement = ifStatement.getChild(0);
    assertNotNull(forStatement);
    ElseStatement elseStatement = functionFoo.getChild(1);
    LoopStatement whileStatement = elseStatement.getChild(0);
    assertNotNull(whileStatement);
  }
View Full Code Here

Examples of net.sourceforge.htmlunit.corejs.javascript.ast.IfStatement

        }

        if (type == CASE) {
            handleSwitchCase((SwitchCase) node);
        } else if (type == IF && parentType == IF) {
            final IfStatement elseIfStatement = (IfStatement) node;
            final IfStatement ifStatement = (IfStatement) parent;

            if (ifStatement.getElsePart() == elseIfStatement) {
                flattenElseIf(elseIfStatement, ifStatement);
                data.addExecutableLine(getActualLineNumber(node));
            }
        } else if (parentType != CASE) {
            // issue #54
            if (parent.getClass() == LabeledStatement.class) {
                return;
            }

            if (parent.hasChildren()) {
                parent.addChildBefore(newInstrumentationNode(getActualLineNumber(node)), node);
            } else {
                // if, else, while, do, for without {} around their respective 'blocks' for some reason
                // don't have children. Meh. Creating blocks to ease instrumentation.
                final Block block = newInstrumentedBlock(node);

                if (parentType == IF) {
                    final IfStatement ifStatement = (IfStatement) parent;

                    if (ifStatement.getThenPart() == node) {
                        ifStatement.setThenPart(block);
                    } else if (ifStatement.getElsePart() == node) {
                        ifStatement.setElsePart(block);
                    }
                } else if (parentType == WHILE || parentType == FOR || parentType == DO) {
                    ((Loop) parent).setBody(block);
                } else {
                    logger.warn("Cannot handle node with parent that has no children, parent class: {}, parent source:\n{}",
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.ast.IfStatement

    } else if (statement instanceof TryStatement) {
      printTryStatement((TryStatement) statement, indent);
      return output;
    } else if (statement instanceof IfStatement) {
      printIndent(indent);
      IfStatement is = (IfStatement) statement;
      printIndent(indent).append("if ("); //$NON-NLS-1$
      printExpression(is.condition).append(")\n"); //$NON-NLS-1$
      printStatement(is.thenStatement, indent + 2);
      if (is.elseStatement != null) {
        output.append('\n');
View Full Code Here

Examples of org.codehaus.groovy.ast.stmt.IfStatement

        final BlockStatement body = new BlockStatement();
        // TODO use pList and fList
        if (cacheResult) {
            final FieldNode hashField = cNode.addField("$hash$code", ACC_PRIVATE | ACC_SYNTHETIC, ClassHelper.int_TYPE, null);
            final Expression hash = new VariableExpression(hashField);
            body.addStatement(new IfStatement(
                    isZeroExpr(hash),
                    calculateHashStatements(cNode, hash, includeFields, callSuper, excludes, includes),
                    new EmptyStatement()
            ));
            body.addStatement(new ReturnStatement(hash));
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IfStatement

     *
     * @param expr conditional expression
     * @param ifblock block executed when condition <code>true</code>
     */
    public void addIfStatement(ExpressionBuilderBase expr, BlockBuilder ifblock) {
        IfStatement ifstmt = m_ast.newIfStatement();
        ifstmt.setExpression(expr.getExpression());
        ifstmt.setThenStatement(ifblock.m_block);
        m_block.statements().add(ifstmt);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IfStatement

     * @param expr conditional expression
     * @param ifblock block executed when condition <code>true</code>
     * @param elseblock block executed when condition <code>false</code>
     */
    public void addIfElseStatement(ExpressionBuilderBase expr, BlockBuilder ifblock, BlockBuilder elseblock) {
        IfStatement ifstmt = m_ast.newIfStatement();
        ifstmt.setExpression(expr.getExpression());
        ifstmt.setThenStatement(ifblock.m_block);
        ifstmt.setElseStatement(elseblock.m_block);
        m_block.statements().add(ifstmt);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IfStatement

     * @param ifblock block executed when condition <code>true</code>
     * @param elseblock block executed when condition <code>false</code>
     */
    public void addIfElseIfStatement(ExpressionBuilderBase ifexpr, ExpressionBuilderBase elsexpr, BlockBuilder ifblock,
        BlockBuilder elseblock) {
        IfStatement ifstmt = m_ast.newIfStatement();
        ifstmt.setExpression(ifexpr.getExpression());
        ifstmt.setThenStatement(ifblock.m_block);
        IfStatement elseifstmt = m_ast.newIfStatement();
        elseifstmt.setExpression(elsexpr.getExpression());
        elseifstmt.setThenStatement(elseblock.m_block);
        ifstmt.setElseStatement(elseifstmt);
        m_block.statements().add(ifstmt);
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.IfStatement

  //optimize the push/pop
  this.expressionLengthPtr--;
  Statement thenStatement = (Statement) this.astStack[this.astPtr];
  this.astStack[this.astPtr] =
    new IfStatement(
      this.expressionStack[this.expressionPtr--],
      thenStatement,
      this.intStack[this.intPtr--],
      this.endStatementPosition);
}
View Full Code Here

Examples of org.eclipse.php.internal.core.ast.nodes.IfStatement

  public void testDeleteBlockFirst() throws Exception {
    String str = "<?php if ($a) { $a = 5; $b = 4; $c = 4; }  ?>";
    String expected = "<?php if ($a) { $b = 4; $c = 4; }  ?>";
    parseAndCompare(str, expected, new ICodeManiplator() {
      public void manipulate(Program program) {
        IfStatement statement = (IfStatement) program.statements().get(
            0);
        Block block = (Block) statement.getTrueStatement();
        block.statements().remove(0);
      }
    });
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.