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

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


    }

    this.scribe.printComment(Scribe.PRESERVE_EMPTY_LINES_IN_STRING_LITERAL_CONCATENATION);
    ASTNode[] fragments = stringLiteral.literals;
    int fragmentsSize = stringLiteral.counter;
    Alignment binaryExpressionAlignment = this.scribe.createAlignment(
        Alignment.STRING_CONCATENATION,
        this.preferences.alignment_for_binary_expression,
        Alignment.R_OUTERMOST,
        fragmentsSize,
        this.scribe.scanner.currentPosition);
View Full Code Here


      int multiCatchAlignment,
      BlockScope scope) {
    UnionTypeReference unionType = (UnionTypeReference) argument.type;
    int length = unionType.typeReferences != null ? unionType.typeReferences.length : 0;
    if (length > 0) {
      Alignment argumentsAlignment = this.scribe.createAlignment(
          Alignment.MULTI_CATCH,
          multiCatchAlignment,
          length,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(argumentsAlignment);
View Full Code Here

  public Alignment createAlignment(int kind, int mode, int count, int sourceRestart, int continuationIndent, boolean adjust){
    return createAlignment(kind, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust);
  }

  public Alignment createAlignment(int kind, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust){
    Alignment alignment = new Alignment(kind, mode, tieBreakRule, this, count, sourceRestart, continuationIndent);
    // specific break indentation for message arguments inside binary expressions
    if ((this.currentAlignment == null && this.formatter.expressionsDepth >= 0) ||
      (this.currentAlignment != null && this.currentAlignment.kind == Alignment.BINARY_EXPRESSION &&
        (this.formatter.expressionsPos & CodeFormatterVisitor.EXPRESSIONS_POS_MASK) == CodeFormatterVisitor.EXPRESSIONS_POS_BETWEEN_TWO)) {
      switch (kind) {
        case Alignment.CONDITIONAL_EXPRESSION:
        case Alignment.MESSAGE_ARGUMENTS:
        case Alignment.MESSAGE_SEND:
          if (this.formatter.lastBinaryExpressionAlignmentBreakIndentation == alignment.breakIndentationLevel) {
            alignment.breakIndentationLevel += this.indentationSize;
            alignment.shiftBreakIndentationLevel += this.indentationSize;
            this.formatter.lastBinaryExpressionAlignmentBreakIndentation = 0;
          }
          break;
      }
    }
    // adjust break indentation
    if (adjust && this.memberAlignment != null) {
      Alignment current = this.memberAlignment;
      while (current.enclosing != null) {
        current = current.enclosing;
      }
      if ((current.mode & Alignment.M_MULTICOLUMN) != 0) {
        final int indentSize = this.indentationSize;
View Full Code Here

    }
    return alignment;
  }

  public Alignment createMemberAlignment(int kind, int mode, int count, int sourceRestart) {
    Alignment mAlignment = createAlignment(kind, mode, Alignment.R_INNERMOST, count, sourceRestart);
    mAlignment.breakIndentationLevel = this.indentationLevel;
    return mAlignment;
  }
View Full Code Here

    alignment.location.lastLocalDeclarationSourceStart = this.formatter.lastLocalDeclarationSourceStart;
    this.memberAlignment = alignment;
  }

  public void exitAlignment(Alignment alignment, boolean discardAlignment){
    Alignment current = this.currentAlignment;
    while (current != null){
      if (current == alignment) break;
      current = current.enclosing;
    }
    if (current == null) {
View Full Code Here

      }
    }
  }

  public void exitMemberAlignment(Alignment alignment){
    Alignment current = this.memberAlignment;
    while (current != null){
      if (current == alignment) break;
      current = current.enclosing;
    }
    if (current == null) {
View Full Code Here

            useAlignmentBreakIndentation = true;
            break;
        }

        // If there's an alignment try to align on its break indentation level
        Alignment alignment = this.currentAlignment;
        if (alignment == null) {
          if (useLastBinaryExpressionAlignmentBreakIndentation) {
            if (this.indentationLevel < this.formatter.lastBinaryExpressionAlignmentBreakIndentation) {
              this.indentationLevel = this.formatter.lastBinaryExpressionAlignmentBreakIndentation;
            }
View Full Code Here

      return;
    }
    // search for closest breakable alignment, using tiebreak rules
    // look for outermost breakable one
    int relativeDepth = 0, outerMostDepth = -1;
    Alignment targetAlignment = this.currentAlignment;
    while (targetAlignment != null){
      if (targetAlignment.tieBreakRule == Alignment.R_OUTERMOST && targetAlignment.couldBreak()){
        outerMostDepth = relativeDepth;
      }
      targetAlignment = targetAlignment.enclosing;
      relativeDepth++;
    }
    if (outerMostDepth >= 0) {
      throw new AlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth);
    }
    // look for innermost breakable one
    relativeDepth = 0;
    targetAlignment = this.currentAlignment;
    while (targetAlignment != null){
      if (targetAlignment.couldBreak()){
        throw new AlignmentException(AlignmentException.LINE_TOO_LONG, relativeDepth);
      }
      targetAlignment = targetAlignment.enclosing;
      relativeDepth++;
    }
View Full Code Here

  private void handleLineTooLongSmartly() {
    // search for closest breakable alignment, using tiebreak rules
    // look for outermost breakable one
    int relativeDepth = 0, outerMostDepth = -1;
    Alignment targetAlignment = this.currentAlignment;
    int previousKind = -1;
    int insideMessage = 0;
    boolean insideStringConcat = false;
    while (targetAlignment != null){
      boolean couldBreak = targetAlignment.tieBreakRule == Alignment.R_OUTERMOST ||
        (!insideStringConcat &&
            insideMessage > 0 && targetAlignment.kind == Alignment.MESSAGE_ARGUMENTS &&
            (!targetAlignment.wasReset() || previousKind != Alignment.MESSAGE_SEND));
      if (couldBreak && targetAlignment.couldBreak()){
        outerMostDepth = relativeDepth;
      }
      switch (targetAlignment.kind) {
        case Alignment.MESSAGE_ARGUMENTS:
        case Alignment.MESSAGE_SEND:
          insideMessage++;
          break;
        case Alignment.STRING_CONCATENATION:
          insideStringConcat = true;
          break;
      }
      previousKind = targetAlignment.kind;
      targetAlignment = targetAlignment.enclosing;
      relativeDepth++;
    }
    if (outerMostDepth >= 0) {
      throw new AlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth);
    }
    // look for innermost breakable one
    relativeDepth = 0;
    targetAlignment = this.currentAlignment;
    AlignmentException alignmentException = null;
    int msgArgsDepth = -1;
    while (targetAlignment != null) {
      if (targetAlignment.kind == Alignment.MESSAGE_ARGUMENTS) {
        msgArgsDepth = relativeDepth;
      }
      if (alignmentException == null) {
        if (targetAlignment.couldBreak()) {
          // do not throw the exception immediately to have a chance to reset
          // previously broken alignments (see bug 203588)
          alignmentException = new AlignmentException(AlignmentException.LINE_TOO_LONG, relativeDepth);
          if (insideStringConcat) throw alignmentException;
        }
      } else if (targetAlignment.wasSplit) {
        // reset the nearest already broken outermost alignment.
        // Note that it's not done twice to avoid infinite loop while raising
        // the exception on an innermost alignment...
        if (!targetAlignment.wasReset()) {
          targetAlignment.reset();
          if (msgArgsDepth > alignmentException.relativeDepth) {
            alignmentException.relativeDepth = msgArgsDepth;
          }
          throw alignmentException;
        }
View Full Code Here

  public Alignment createAlignment(int kind, int mode, int count, int sourceRestart, int continuationIndent, boolean adjust){
    return createAlignment(kind, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust);
  }

  public Alignment createAlignment(int kind, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust){
    Alignment alignment = new Alignment(kind, mode, tieBreakRule, this, count, sourceRestart, continuationIndent);
    // specific break indentation for message arguments inside binary expressions
    if ((this.currentAlignment == null && this.formatter.expressionsDepth >= 0) ||
      (this.currentAlignment != null && this.currentAlignment.kind == Alignment.BINARY_EXPRESSION &&
        (this.formatter.expressionsPos & CodeFormatterVisitor.EXPRESSIONS_POS_MASK) == CodeFormatterVisitor.EXPRESSIONS_POS_BETWEEN_TWO)) {
      switch (kind) {
        case Alignment.CONDITIONAL_EXPRESSION:
        case Alignment.MESSAGE_ARGUMENTS:
        case Alignment.MESSAGE_SEND:
          if (this.formatter.lastBinaryExpressionAlignmentBreakIndentation == alignment.breakIndentationLevel) {
            alignment.breakIndentationLevel += this.indentationSize;
            alignment.shiftBreakIndentationLevel += this.indentationSize;
            this.formatter.lastBinaryExpressionAlignmentBreakIndentation = 0;
          }
          break;
      }
    }
    // adjust break indentation
    if (adjust && this.memberAlignment != null) {
      Alignment current = this.memberAlignment;
      while (current.enclosing != null) {
        current = current.enclosing;
      }
      if ((current.mode & Alignment.M_MULTICOLUMN) != 0) {
        final int indentSize = this.indentationSize;
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.