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

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


    this.scribe.printTrailingComment();
  }
  private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) {
    int statementsLength = statements.length;
    for (int i = 0; i < statementsLength; i++) {
      final Statement statement = statements[i];
      if (i > 0 && (statements[i - 1] instanceof EmptyStatement) && !(statement instanceof EmptyStatement)) {
        this.scribe.printNewLine();
      }
      statement.traverse(this, scope);
      if (statement instanceof Expression) {
        this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
        this.scribe.printTrailingComment();
        if (i != statementsLength - 1) {
          if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
View Full Code Here


  public boolean visit(DoStatement doStatement, BlockScope scope) {

    this.scribe.printNextToken(TerminalTokens.TokenNamedo);
    final int line = this.scribe.line;
   
    final Statement action = doStatement.action;
    if (action != null) {
      if (action instanceof Block) {
        formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
        action.traverse(this, scope);
      } else if (action instanceof EmptyStatement) {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
      } else {
        this.scribe.printNewLine();
        this.scribe.indent();
        action.traverse(this, scope);
        if (action instanceof Expression) {
          this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
          this.scribe.printTrailingComment();
        }
        this.scribe.printNewLine();
View Full Code Here

    }
    forStatement.collection.traverse(this, scope);

    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_for);
   
    final Statement action = forStatement.action;
    if (action != null) {
      if (action instanceof Block) {
              formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
        action.traverse(this, scope);
      } else if (action instanceof EmptyStatement) {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
      } else {
        this.scribe.indent();
        this.scribe.printNewLine();
        action.traverse(this, scope);
        this.scribe.unIndent();
      }
      if (action instanceof Expression) {
        this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
        this.scribe.printTrailingComment();
View Full Code Here

        }
      }
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_for);
   
    final Statement action = forStatement.action;
    if (action != null) {
      if (action instanceof Block) {
              formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
        action.traverse(this, scope);
      } else if (action instanceof EmptyStatement) {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
      } else {
        this.scribe.indent();
        this.scribe.printNewLine();
        action.traverse(this, scope);
        this.scribe.unIndent();
      }
      if (action instanceof Expression) {
        this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
        this.scribe.printTrailingComment();
View Full Code Here

      this.scribe.space();
    }
    ifStatement.condition.traverse(this, scope);
    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_if);

    final Statement thenStatement = ifStatement.thenStatement;
    final Statement elseStatement = ifStatement.elseStatement;

    boolean thenStatementIsBlock = false;
    if (thenStatement != null) {
      if (thenStatement instanceof Block) {
        thenStatementIsBlock = true;
        if (isGuardClause((Block)thenStatement) && elseStatement == null && this.preferences.keep_guardian_clause_on_one_line) {
          /*
           * Need a specific formatting for guard clauses
           * guard clauses are block with a single return or throw
           * statement
           */
           formatGuardClauseBlock((Block) thenStatement, scope);
        } else {
          formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
          thenStatement.traverse(this, scope);
          if (elseStatement != null && (this.preferences.insert_new_line_before_else_in_if_statement)) {
            this.scribe.printNewLine();
          }
        }
      } else if (elseStatement == null && this.preferences.keep_simple_if_on_one_line) {
        Alignment compactIfAlignment = this.scribe.createAlignment(
            "compactIf", //$NON-NLS-1$
            this.preferences.alignment_for_compact_if,
            Alignment.R_OUTERMOST,
            1,
            this.scribe.scanner.currentPosition,
            1,
            false);
        this.scribe.enterAlignment(compactIfAlignment);
        boolean ok = false;
        do {
          try {
            this.scribe.alignFragment(compactIfAlignment, 0);
            this.scribe.space();
            thenStatement.traverse(this, scope);
            if (thenStatement instanceof Expression) {
              this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
              this.scribe.printTrailingComment();
            }
            ok = true;
          } catch (AlignmentException e) {
            this.scribe.redoAlignment(e);
          }
        } while (!ok);
        this.scribe.exitAlignment(compactIfAlignment, true);
      } else if (this.preferences.keep_then_statement_on_same_line) {
        this.scribe.space();
        thenStatement.traverse(this, scope);
        if (thenStatement instanceof Expression) {
          this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
          this.scribe.printTrailingComment();
        }
        if (elseStatement != null) {
          this.scribe.printNewLine();
        }
      } else {
        this.scribe.printTrailingComment();
        this.scribe.printNewLine();
        this.scribe.indent();
        thenStatement.traverse(this, scope);
        if (thenStatement instanceof Expression) {
          this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
          this.scribe.printTrailingComment();
        }
        if (elseStatement != null) {
          this.scribe.printNewLine();
        }
        this.scribe.unIndent();
      }
    }
   
    if (elseStatement != null) {
      if (thenStatementIsBlock) {
        this.scribe.printNextToken(TerminalTokens.TokenNameelse, this.preferences.insert_space_after_closing_brace_in_block);
      } else {
        this.scribe.printNextToken(TerminalTokens.TokenNameelse, true);
      }
      if (elseStatement instanceof Block) {
        elseStatement.traverse(this, scope);
      } else if (elseStatement instanceof IfStatement) {
        if (!this.preferences.compact_else_if) {
          this.scribe.printNewLine();
          this.scribe.indent();
        }
        this.scribe.space();
        elseStatement.traverse(this, scope);
        if (!this.preferences.compact_else_if) {
          this.scribe.unIndent();
        }
      } else if (this.preferences.keep_else_statement_on_same_line) {
        this.scribe.space();
        elseStatement.traverse(this, scope);
        if (elseStatement instanceof Expression) {
          this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
          this.scribe.printTrailingComment();
        }
      } else {
        this.scribe.printNewLine();
        this.scribe.indent();
        elseStatement.traverse(this, scope);
        if (elseStatement instanceof Expression) {
          this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
          this.scribe.printTrailingComment();
        }
        this.scribe.unIndent();
View Full Code Here

    this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier);
    this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_labeled_statement);
    if (this.preferences.insert_space_after_colon_in_labeled_statement) {
      this.scribe.space();
    }
    final Statement statement = labeledStatement.statement;
    statement.traverse(this, scope);
    if (statement instanceof Expression) {
      this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
      this.scribe.printTrailingComment();
    }
    return false;
View Full Code Here

    boolean wasACase = false;
    boolean wasAStatement = 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 (wasACase) {
            this.scribe.printNewLine();
          }
          if ((wasACase && this.preferences.indent_switchstatements_compare_to_cases)
            || (wasAStatement && this.preferences.indent_switchstatements_compare_to_cases)) {
            this.scribe.unIndent();
          }
          statement.traverse(this, scope);
          this.scribe.printTrailingComment();
          wasACase = true;
          wasAStatement = false;
          if (this.preferences.indent_switchstatements_compare_to_cases) {
            this.scribe.indent();
          }
        } else if (statement instanceof BreakStatement) {
          if (this.preferences.indent_breaks_compare_to_cases) {
            if (wasAStatement && !this.preferences.indent_switchstatements_compare_to_cases) {
              this.scribe.indent();
            }
          } else {
            if (wasAStatement) {
              if (this.preferences.indent_switchstatements_compare_to_cases) {
                this.scribe.unIndent();
              }
            }
            if (wasACase && this.preferences.indent_switchstatements_compare_to_cases) {
              this.scribe.unIndent();
            }
          }
          if (wasACase) {
            this.scribe.printNewLine();
          }
          statement.traverse(this, scope);
          if (this.preferences.indent_breaks_compare_to_cases) {
            this.scribe.unIndent();
          }
          wasACase = false;
          wasAStatement = false;
        } else if (statement instanceof Block) {
          String bracePosition;
          if (wasACase) {
            if (this.preferences.indent_switchstatements_compare_to_cases) {
              this.scribe.unIndent();
            }
            bracePosition =  this.preferences.brace_position_for_block_in_case;
            formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_after_colon_in_case);
            if (this.preferences.indent_switchstatements_compare_to_cases) {
              this.scribe.indent();
            }
          } else {
            bracePosition =  this.preferences.brace_position_for_block;
            formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_before_opening_brace_in_block);
          }
          wasAStatement = true;
          wasACase = false;
        } else {
          this.scribe.printNewLine();
          statement.traverse(this, scope);
          wasAStatement = true;
          wasACase = false;
        }
        if (statement instanceof Expression) {
          /*
 
View Full Code Here

    }
    whileStatement.condition.traverse(this, scope);
   
    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while);
   
    final Statement action = whileStatement.action;
    if (action != null) {
      if (action instanceof Block) {
                formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
        action.traverse(this, scope);
      } else if (action instanceof EmptyStatement) {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
      } else {
        this.scribe.printNewLine();
        this.scribe.indent();
        action.traverse(this, scope);
        if (action instanceof Expression) {
          this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
          this.scribe.printTrailingComment();
        }
        this.scribe.unIndent();
View Full Code Here

 
  int lastEnd = blockDeclaration.sourceStart;
 
  // only collect the non-null updated statements
  for (int i = 0; i < this.statementCount; i++){
    Statement updatedStatement = this.statements[i].updatedStatement();
    if (updatedStatement != null){
      updatedStatements[updatedCount++] = updatedStatement;
     
      if (updatedStatement instanceof LocalDeclaration) {
        LocalDeclaration localDeclaration = (LocalDeclaration) updatedStatement;
View Full Code Here

  Statement[] updatedStatements = new Statement[this.statementCount];
  int updatedCount = 0;
 
  // only collect the non-null updated statements
  for (int i = 0; i < this.statementCount; i++){
    Statement updatedStatement = this.statements[i].updatedStatement();
    if (updatedStatement != null){
      updatedStatements[updatedCount++] = updatedStatement;
    }
  }
  if (updatedCount == 0) return null; // not interesting block
View Full Code Here

TOP

Related Classes of org.aspectj.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.