Package org.eclipse.jdt.internal.formatter.align

Examples of org.eclipse.jdt.internal.formatter.align.Alignment


    this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, spaceBeforeOpenParen);
    final Expression[] arguments = ((AllocationExpression) enumConstant.initialization).arguments;
    if (arguments != null) {
      int argumentLength = arguments.length;
      Alignment argumentsAlignment = this.scribe.createAlignment(
          Alignment.ENUM_CONSTANTS_ARGUMENTS,
          methodDeclarationParametersAlignment,
          argumentLength,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(argumentsAlignment);
View Full Code Here


    int alignmentForThrowsClause) {

    final TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
    if (thrownExceptions != null) {
      int thrownExceptionsLength = thrownExceptions.length;
      Alignment throwsAlignment = this.scribe.createAlignment(
          Alignment.THROWS,
          alignmentForThrowsClause,
          thrownExceptionsLength, // throws is the first token
          this.scribe.scanner.currentPosition);
View Full Code Here

  /*
   * Merged traversal of member (types, fields, methods)
   */
  private void formatTypeMembers(TypeDeclaration typeDeclaration) {
    Alignment memberAlignment = this.scribe.createMemberAlignment(
        Alignment.TYPE_MEMBERS,
        this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT,
        3,
        this.scribe.scanner.currentPosition);
    this.scribe.enterMemberAlignment(memberAlignment);
    ASTNode[] members = computeMergedMemberDeclarations(typeDeclaration);
    boolean isChunkStart = false;
    boolean ok = false;
    int membersLength = members.length;
    if (membersLength > 0) {
      int startIndex = 0;
      do {
        try {
          for (int i = startIndex, max = members.length; i < max; i++) {
            while (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
              this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
              this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
            }
            this.scribe.printNewLine();
            ASTNode member = members[i];
            if (member instanceof FieldDeclaration) {
              isChunkStart = memberAlignment.checkChunkStart(Alignment.CHUNK_FIELD, i, this.scribe.scanner.currentPosition);
              if (member instanceof MultiFieldDeclaration) {
                MultiFieldDeclaration multiField = (MultiFieldDeclaration) member;
 
                if (multiField.isStatic()) {
                  format(multiField, this, typeDeclaration.staticInitializerScope, isChunkStart, i == 0);
                } else {
                  format(multiField, this, typeDeclaration.initializerScope, isChunkStart, i == 0);
                }
              } else if (member instanceof Initializer) {
                int newLineBeforeChunk = isChunkStart ? this.preferences.blank_lines_before_new_chunk : 0;
                if (newLineBeforeChunk > 0 && i != 0) {
                  this.scribe.printEmptyLines(newLineBeforeChunk);
                } else if (i == 0) {
                  int newLinesBeforeFirstClassBodyDeclaration = this.preferences.blank_lines_before_first_class_body_declaration;
                  if (newLinesBeforeFirstClassBodyDeclaration > 0) {
                    this.scribe.printEmptyLines(newLinesBeforeFirstClassBodyDeclaration);
                  }
                }
                Initializer initializer = (Initializer) member;
                if (initializer.isStatic()) {
                  initializer.traverse(this, typeDeclaration.staticInitializerScope);
                } else {
                  initializer.traverse(this, typeDeclaration.initializerScope);
                }
              } else {
                FieldDeclaration field = (FieldDeclaration) member;
                if (field.isStatic()) {
                  format(field, this, typeDeclaration.staticInitializerScope, isChunkStart, i == 0);
                } else {
                  format(field, this, typeDeclaration.initializerScope, isChunkStart, i == 0);
                }
              }
            } else if (member instanceof AbstractMethodDeclaration) {
              isChunkStart = memberAlignment.checkChunkStart(Alignment.CHUNK_METHOD, i, this.scribe.scanner.currentPosition);
              format((AbstractMethodDeclaration) member, typeDeclaration.scope, isChunkStart, i == 0);
            } else if (member instanceof TypeDeclaration) {
              isChunkStart = memberAlignment.checkChunkStart(Alignment.CHUNK_TYPE, i, this.scribe.scanner.currentPosition);
              format((TypeDeclaration)member, typeDeclaration.scope, isChunkStart, i == 0);
            }
            while (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
              this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
              this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
View Full Code Here

    if (arguments != null) {
      if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
        this.scribe.space();
      }
      int argumentLength = arguments.length;
      Alignment argumentsAlignment =this.scribe.createAlignment(
          Alignment.ALLOCATION,
          this.preferences.alignment_for_arguments_in_allocation_expression,
          argumentLength,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(argumentsAlignment);
View Full Code Here

        formatOpeningBrace(array_initializer_brace_position, this.preferences.insert_space_before_opening_brace_in_array_initializer);

        int expressionsLength = expressions.length;
        final boolean insert_new_line_after_opening_brace = this.preferences.insert_new_line_after_opening_brace_in_array_initializer;
        boolean ok = false;
        Alignment arrayInitializerAlignment = null;
        if (expressionsLength > 1) {
          if (insert_new_line_after_opening_brace) {
            this.scribe.printNewLine();
          }
          arrayInitializerAlignment = this.scribe.createAlignment(
View Full Code Here

    this.scribe.printNextToken(TerminalTokens.TokenNameEQUAL, this.preferences.insert_space_before_assignment_operator);
    if (this.preferences.insert_space_after_assignment_operator) {
      this.scribe.space();
    }

    Alignment assignmentAlignment = this.scribe.createAlignment(
        Alignment.ASSIGNMENT,
        this.preferences.alignment_for_assignment,
        Alignment.R_OUTERMOST,
        1,
        this.scribe.scanner.currentPosition);
View Full Code Here

    this.scribe.printNextToken(operator, this.preferences.insert_space_before_assignment_operator);
    if (this.preferences.insert_space_after_assignment_operator) {
      this.scribe.space();
    }
    Alignment assignmentAlignment = this.scribe.createAlignment(
        Alignment.COMPOUND_ASSIGNMENT,
        this.preferences.alignment_for_assignment,
        Alignment.R_OUTERMOST,
        1,
        this.scribe.scanner.currentPosition);
View Full Code Here

      if (numberOfParens > 0) {
        manageOpeningParenthesizedExpression(conditionalExpression, numberOfParens);
      }
      conditionalExpression.condition.traverse(this, scope);

      Alignment conditionalExpressionAlignment =this.scribe.createAlignment(
          Alignment.CONDITIONAL_EXPRESSION,
          this.preferences.alignment_for_conditional_expression,
          2,
          this.scribe.scanner.currentPosition);
View Full Code Here

    if (arguments != null) {
      if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
        this.scribe.space();
      }
      int argumentLength = arguments.length;
      Alignment argumentsAlignment =this.scribe.createAlignment(
          Alignment.EXPLICIT_CONSTRUCTOR_CALL,
          this.preferences.alignment_for_arguments_in_explicit_constructor_call,
          argumentLength,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(argumentsAlignment);
View Full Code Here

          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(
            Alignment.COMPACT_IF,
            this.preferences.alignment_for_compact_if,
            Alignment.R_OUTERMOST,
            1,
            this.scribe.scanner.currentPosition,
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.formatter.align.Alignment

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.