Package org.eclipse.jdt.internal.compiler.ast

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


    boolean wasACase = false;
    boolean wasABreak = false;
    if (statements != null) {
      int statementsLength = statements.length;
      for (int i = 0; i < statementsLength; i++) {
        final Statement statement = statements[i];
        if (statement instanceof CaseStatement) {
          if (wasABreak) {
            this.scribe.setIndentation(switchIndentationLevel, caseIndentation);
            this.scribe.printComment();
          } else {
            if (wasACase) {
              this.scribe.printComment(Scribe.PRESERVE_EMPTY_LINES_IN_SWITCH_CASE);
            } else {
              this.scribe.printComment();
            }
            this.scribe.setIndentation(switchIndentationLevel, caseIndentation);
          }
          if (wasACase) {
            this.scribe.printNewLine();
          }
          statement.traverse(this, scope);
          // Print following trailing (if any) comment at statement indentation
          this.scribe.setIndentation(switchIndentationLevel, statementIndentation);
          this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.COMPLEX_TRAILING_COMMENT);
          wasACase = true;
          wasABreak = false;
        } else if (statement instanceof BreakStatement) {
          this.scribe.setIndentation(switchIndentationLevel, breakIndentation);
          if (wasACase) {
            this.scribe.printNewLine();
          }
          this.scribe.printComment();
          statement.traverse(this, scope);
          wasACase = false;
          wasABreak = true;
        } else if (statement instanceof Block) {
          this.scribe.setIndentation(switchIndentationLevel, wasACase ? caseIndentation : statementIndentation);
          this.scribe.printComment();
          String bracePosition = wasACase ? this.preferences.brace_position_for_block_in_case : this.preferences.brace_position_for_block;
          formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_before_opening_brace_in_block);
          wasACase = false;
          wasABreak = false;
        } else {
          this.scribe.setIndentation(switchIndentationLevel, statementIndentation);
          this.scribe.printNewLine();
          this.scribe.printComment();
          statement.traverse(this, scope);
          wasACase = false;
          wasABreak = false;
        }
        if (statement instanceof Expression) {
          /*
 
View Full Code Here


          }
        }
        if (sam.returnType != TypeBinding.VOID) {
          // ii)
          final TypeBinding r = sam.returnType;
          Statement body = lambda.body();
          if (body instanceof Expression) {
            variables.addAll(new ConstraintExpressionFormula((Expression) body, r, COMPATIBLE).inputVariables(context));
          } else {
            // TODO: should I use LambdaExpression.resultExpressions? (is currently private).
            body.traverse(new ASTVisitor() {
              public boolean visit(ReturnStatement returnStatement, BlockScope scope) {
                variables.addAll(new ConstraintExpressionFormula(returnStatement.expression, r, COMPATIBLE).inputVariables(context));
                return false;
              }
            }, (BlockScope)null);
View Full Code Here

        this.lastCheckPoint = type.declarationSourceEnd + 1;
      }
      continue;
    }
    if (this.assistNode != null && node instanceof Statement) {
      Statement stmt = (Statement) node;
      if (!(stmt instanceof Expression) || ((Expression) stmt).statementExpression()) {
        if (this.assistNode.sourceStart >= stmt.sourceStart && this.assistNode.sourceEnd <= stmt.sourceEnd) {
          element.add(stmt, 0);
          this.lastCheckPoint = stmt.sourceEnd + 1;
          this.isOrphanCompletionNode = false;
View Full Code Here

  // DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'

  //the 'while' pushes a value on this.intStack that we need to remove
  this.intPtr--;

  Statement statement = (Statement) this.astStack[this.astPtr];
  this.expressionLengthPtr--;
  this.astStack[this.astPtr] =
    new DoStatement(
      this.expressionStack[this.expressionPtr--],
      statement,
View Full Code Here

  Statement[] inits, updates;
  boolean scope = true;

  //statements
  this.astLengthPtr--;
  Statement statement = (Statement) this.astStack[this.astPtr--];

  //updates are on the expresion stack
  if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) == 0) {
    updates = null;
  } else {
View Full Code Here

protected void consumeStatementIfNoElse() {
  // IfThenStatement ::=  'if' '(' Expression ')' Statement

  //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--],
View Full Code Here

protected void consumeStatementLabel() {
  // LabeledStatement ::= 'Identifier' ':' Statement
  // LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf

  //optimize push/pop
  Statement statement = (Statement) this.astStack[this.astPtr];
  this.astStack[this.astPtr] =
    new LabeledStatement(
      this.identifierStack[this.identifierPtr],
      statement,
      this.identifierPositionStack[this.identifierPtr--],
View Full Code Here

protected void consumeStatementWhile() {
  // WhileStatement ::= 'while' '(' Expression ')' Statement
  // WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf

  this.expressionLengthPtr--;
  Statement statement = (Statement) this.astStack[this.astPtr];
  this.astStack[this.astPtr] =
    new WhileStatement(
      this.expressionStack[this.expressionPtr--],
      statement,
      this.intStack[this.intPtr--],
View Full Code Here

          } else {
            this.lastCheckPoint = statement.sourceEnd + 1;
          }
        }
      } else if(node instanceof Statement) {
        Statement statement = (Statement) node;
        element = element.add(statement, 0);
        this.lastCheckPoint = statement.sourceEnd + 1;
      }
    }
  }
View Full Code Here

  // EnhancedForStatement ::= EnhancedForStatementHeader Statement
  // EnhancedForStatementNoShortIf ::= EnhancedForStatementHeader StatementNoShortIf

  //statements
  this.astLengthPtr--;
  Statement statement = (Statement) this.astStack[this.astPtr--];

  // foreach statement is on the ast stack
  ForeachStatement foreachStatement = (ForeachStatement) this.astStack[this.astPtr];
  foreachStatement.action = statement;
  // remember useful empty statement
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ast.Statement

Copyright © 2018 www.massapicom. 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.