Examples of Alignment


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

      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(
            "messageArguments", //$NON-NLS-1$
            this.preferences.alignment_for_arguments_in_method_invocation,
            Alignment.R_OUTERMOST,
            argumentLength,
            this.scribe.scanner.currentPosition);
        this.scribe.enterAlignment(argumentsAlignment);
        boolean okForArguments = false;
        do {
          try {
            for (int j = 0; j < argumentLength; j++) {
              if (j > 0) {
                this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments);
                this.scribe.printTrailingComment();
              }
              this.scribe.alignFragment(argumentsAlignment, j);
              if (j > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) {
                this.scribe.space();
              }
              arguments[j].traverse(this, scope);
            }
            okForArguments = true;
          } catch (AlignmentException e) {
            this.scribe.redoAlignment(e);
          }
        } while (!okForArguments);
        this.scribe.exitAlignment(argumentsAlignment, true);
        this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_method_invocation);
      } else {
        this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_between_empty_parens_in_method_invocation);
      }
      if (numberOfParens > 0) {
        manageClosingParenthesizedExpression(currentMessageSend, numberOfParens);
      }
      startingPositionInCascade = 2;
    }
    Alignment cascadingMessageSendAlignment =
      this.scribe.createAlignment(
        "cascadingMessageSendAlignment", //$NON-NLS-1$
        this.preferences.alignment_for_selector_in_method_invocation,
        Alignment.R_INNERMOST,
        size,
        this.scribe.scanner.currentPosition);
    this.scribe.enterAlignment(cascadingMessageSendAlignment);
    boolean ok = false;
    do {
      try {
        this.scribe.alignFragment(cascadingMessageSendAlignment, 0);
        this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
        for (int i = startingPositionInCascade; i < size; i++) {
          MessageSend currentMessageSend = fragments[i];
          final int numberOfParens = (currentMessageSend.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
          if (numberOfParens > 0) {
            manageOpeningParenthesizedExpression(currentMessageSend, numberOfParens);
          }
          TypeReference[] typeArguments = currentMessageSend.typeArguments;
          if (typeArguments != null) {
              this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_type_arguments);
              if (this.preferences.insert_space_after_opening_angle_bracket_in_type_arguments) {
                this.scribe.space();
              }
              int length = typeArguments.length;
              for (int j = 0; j < length - 1; j++) {
                typeArguments[j].traverse(this, scope);
                this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_type_arguments);
                if (this.preferences.insert_space_after_comma_in_type_arguments) {
                  this.scribe.space();
                }       
              }
              typeArguments[length - 1].traverse(this, scope);
              if (isClosingGenericToken()) {
                this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS, this.preferences.insert_space_before_closing_angle_bracket_in_type_arguments);
              }
              if (this.preferences.insert_space_after_closing_angle_bracket_in_type_arguments) {
                this.scribe.space();
              }
          }
          ASTNode[] arguments = currentMessageSend.arguments;
          this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier); // selector
          this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_method_invocation);
          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(
                "messageArguments", //$NON-NLS-1$
                this.preferences.alignment_for_arguments_in_method_invocation,
                Alignment.R_OUTERMOST,
                argumentLength,
                this.scribe.scanner.currentPosition);
View Full Code Here

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

   */
  private void formatClassBodyDeclarations(ASTNode[] nodes) {
    final int FIELD = 1, METHOD = 2, TYPE = 3;
    this.scribe.lastNumberOfNewLines = 1;
    ASTNode[] mergedNodes = computeMergedMemberDeclarations(nodes);
    Alignment memberAlignment = this.scribe.createMemberAlignment("typeMembers", this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT, 4, this.scribe.scanner.currentPosition); //$NON-NLS-1$
    this.scribe.enterMemberAlignment(memberAlignment);
    boolean isChunkStart = false;
    boolean ok = false;
    int startIndex = 0;
    do {
      try {
        for (int i = startIndex, max = mergedNodes.length; i < max; i++) {
          ASTNode member = mergedNodes[i];
          if (member instanceof FieldDeclaration) {
            isChunkStart = memberAlignment.checkChunkStart(FIELD, i, this.scribe.scanner.currentPosition);
            if (member instanceof MultiFieldDeclaration){
              MultiFieldDeclaration multiField = (MultiFieldDeclaration) member;
              format(multiField, this, null, 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;
              initializer.traverse(this, null);
            } else {
              FieldDeclaration field = (FieldDeclaration) member;
              format(field, this, null, isChunkStart, i == 0);
            }
          } else if (member instanceof AbstractMethodDeclaration) {
            isChunkStart = memberAlignment.checkChunkStart(METHOD, i, this.scribe.scanner.currentPosition);
            format((AbstractMethodDeclaration) member, null, isChunkStart, i == 0);
          } else {
            isChunkStart = memberAlignment.checkChunkStart(TYPE, i, this.scribe.scanner.currentPosition);
            format((TypeDeclaration)member, null, isChunkStart, i == 0);
          }
          if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
            this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
            this.scribe.printTrailingComment();
View Full Code Here

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

       */ 
      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("localDeclarationAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$
      this.scribe.enterAlignment(assignmentAlignment);
      boolean ok = false;
      do {
        try {
          this.scribe.alignFragment(assignmentAlignment, 0);
View Full Code Here

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

      if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
        this.scribe.space();
      }
      int argumentsLength = arguments.length;
      if (argumentsLength > 1) {
        Alignment argumentsAlignment = this.scribe.createAlignment(
            "messageArguments", //$NON-NLS-1$
            this.preferences.alignment_for_arguments_in_method_invocation,
            argumentsLength,
            this.scribe.scanner.currentPosition);
        this.scribe.enterAlignment(argumentsAlignment);
View Full Code Here

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

    if (arguments != null) {
      if (spaceBeforeFirstParameter) {
        this.scribe.space();
      }
      int argumentLength = arguments.length;
      Alignment argumentsAlignment = this.scribe.createAlignment(
          "methodArguments",//$NON-NLS-1$
          methodDeclarationParametersAlignment,
          argumentLength,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(argumentsAlignment);
View Full Code Here

Examples of org.aspectj.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(
          "enumConstantArguments",//$NON-NLS-1$
          methodDeclarationParametersAlignment,
          argumentLength,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(argumentsAlignment);
View Full Code Here

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

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

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

  /*
   * Merged traversal of member (types, fields, methods)
   */
  private void formatTypeMembers(TypeDeclaration typeDeclaration) {
    Alignment memberAlignment = this.scribe.createMemberAlignment("typeMembers", this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT, 3, this.scribe.scanner.currentPosition); //$NON-NLS-1$
    this.scribe.enterMemberAlignment(memberAlignment);
    ASTNode[] members = computeMergedMemberDeclarations(typeDeclaration);
    boolean isChunkStart = false;
    boolean ok = false;
    int startIndex = 0;
    do {
      try {
        for (int i = startIndex, max = members.length; i < max; i++) {
          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);
          }
          if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
            this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
            this.scribe.printTrailingComment();
View Full Code Here

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

    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(
          "allocation",//$NON-NLS-1$
          this.preferences.alignment_for_arguments_in_allocation_expression,
          argumentLength,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(argumentsAlignment);
View Full Code Here

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

      final boolean insert_new_line_after_opening_brace = this.preferences.insert_new_line_after_opening_brace_in_array_initializer;
      if (expressionsLength > 1) {
        if (insert_new_line_after_opening_brace) {
          this.scribe.printNewLine();
        }
        Alignment arrayInitializerAlignment =this.scribe.createAlignment(
            "array_initializer",//$NON-NLS-1$
            this.preferences.alignment_for_expressions_in_array_initializer,
            Alignment.R_OUTERMOST,
            expressionsLength,
            this.scribe.scanner.currentPosition,
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.