Examples of Alignment


Examples of opennlp.ccg.alignment.Alignment

                    Status.forAbbreviation(a.getAttribute("status"))));
          }
        }
      }
     
      Alignment a = new Alignment(new Phrase(id,
            Alignments.tokenize(first.getElementsByTagName("string").item(0).getTextContent())),
              new Phrase(id,
                Alignments.tokenize(second.getElementsByTagName("string").item(0).getTextContent())),
            ms);
     
      Element firstLF = (Element)first.getElementsByTagName("lf").item(0),
          secondLF = (Element)second.getElementsByTagName("lf").item(0);
     
      LFGraphDifference diff = (firstLF != null && secondLF != null)
          ? new LFGraphDifference(LFGraphFactory.newGraphFrom(firstLF),
              LFGraphFactory.newGraphFrom(secondLF), a)
          : null;
     
      for(PhrasePosition pos : PhrasePosition.values()) {
        Element str = out.createElement("string");
        str.setAttribute("number", Integer.toString(id));
        str.setAttribute("position", pos.name());
        str.setTextContent(Alignments.untokenize(a.get(pos)));
       
        dlfsElement.appendChild(str);
      }
     
      Element msEl = out.createElement("mappings");
View Full Code Here

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

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

  public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust){
    Alignment alignment = new Alignment(name, mode, tieBreakRule, this, count, sourceRestart, continuationIndent);
    // 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

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

    }
    return alignment;
  }

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

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

    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

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

      this.currentAlignment = alignment.enclosing;
    }
  }
 
  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

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

 
  public void handleLineTooLong() {
    // 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

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

    BinaryExpressionFragmentBuilder builder = buildFragments(binaryExpression, scope);
    final int fragmentsSize = builder.size();
   
    if ((builder.realFragmentsSize() > 1 || builder.size() > 4) && numberOfParens == 0) {
      this.scribe.printComment();
      Alignment binaryExpressionAlignment = this.scribe.createAlignment("binaryExpressionAlignment", this.preferences.alignment_for_binary_expression, Alignment.R_OUTERMOST, fragmentsSize, this.scribe.scanner.currentPosition); //$NON-NLS-1$
      this.scribe.enterAlignment(binaryExpressionAlignment);
      boolean ok = false;
      ASTNode[] fragments = builder.fragments();
      int[] operators = builder.operators();
      do {
View Full Code Here

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

      final int newLinesBeforeField = this.preferences.blank_lines_before_field;
      if (newLinesBeforeField > 0) {
        this.scribe.printEmptyLines(newLinesBeforeField);
      }
    }
    Alignment memberAlignment = this.scribe.getMemberAlignment();
 
        this.scribe.printComment();
    this.scribe.printModifiers(fieldDeclaration.annotations, this);
    this.scribe.space();
    /*
     * Field type
     */
    fieldDeclaration.type.traverse(this, scope);
   
    /*
     * Field name
     */
    this.scribe.alignFragment(memberAlignment, 0);
 
    this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
 
    /*
     * Check for extra dimensions
     */
    int extraDimensions = getDimensions();
    if (extraDimensions != 0) {
       for (int i = 0; i < extraDimensions; i++) {
         this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
         this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
       }
    }
 
    /*
     * Field initialization
     */
    final Expression initialization = fieldDeclaration.initialization;
    if (initialization != null) {
      this.scribe.alignFragment(memberAlignment, 1);
      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("fieldDeclarationAssignmentAlignment", 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

      final int newLinesBeforeField = this.preferences.blank_lines_before_field;
      if (newLinesBeforeField > 0) {
        this.scribe.printEmptyLines(newLinesBeforeField);
      }
    }
    Alignment fieldAlignment = this.scribe.getMemberAlignment();
 
        this.scribe.printComment();
    this.scribe.printModifiers(multiFieldDeclaration.annotations, this);
    this.scribe.space();
 
    multiFieldDeclaration.declarations[0].type.traverse(this, scope);
 
    final int multipleFieldDeclarationsLength = multiFieldDeclaration.declarations.length;

    Alignment multiFieldDeclarationsAlignment =this.scribe.createAlignment(
        "multiple_field",//$NON-NLS-1$
        this.preferences.alignment_for_multiple_fields,
        multipleFieldDeclarationsLength - 1,
        this.scribe.scanner.currentPosition);
    this.scribe.enterAlignment(multiFieldDeclarationsAlignment);
View Full Code Here

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

    /*
     * Superclass
     */
    final TypeReference superclass = typeDeclaration.superclass;
    if (superclass != null) {
      Alignment superclassAlignment =this.scribe.createAlignment(
          "superclass", //$NON-NLS-1$
          this.preferences.alignment_for_superclass_in_type_declaration,
          2,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(superclassAlignment);
      boolean ok = false;
      do {
        try {
          this.scribe.alignFragment(superclassAlignment, 0);
          this.scribe.printNextToken(TerminalTokens.TokenNameextends, true);
          this.scribe.alignFragment(superclassAlignment, 1);
          this.scribe.space();
          superclass.traverse(this, typeDeclaration.scope);
          ok = true;
        } catch (AlignmentException e) {
          this.scribe.redoAlignment(e);
        }
      } while (!ok);
      this.scribe.exitAlignment(superclassAlignment, true);
    }

    /*
     * Super Interfaces
     */
    final TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
    if (superInterfaces != null) {
      int alignment_for_superinterfaces;
      int kind = TypeDeclaration.kind(typeDeclaration.modifiers);
      switch(kind) {
        case TypeDeclaration.ENUM_DECL :
          alignment_for_superinterfaces = this.preferences.alignment_for_superinterfaces_in_enum_declaration;
          break;
        default:
          alignment_for_superinterfaces = this.preferences.alignment_for_superinterfaces_in_type_declaration;
          break;
      }
      int superInterfaceLength = superInterfaces.length;
      Alignment interfaceAlignment =this.scribe.createAlignment(
          "superInterfaces",//$NON-NLS-1$
          alignment_for_superinterfaces,
          superInterfaceLength+1// implements token is first fragment
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(interfaceAlignment);
      boolean ok = false;
      do {
        try {
          this.scribe.alignFragment(interfaceAlignment, 0);
          if (kind == TypeDeclaration.INTERFACE_DECL) {
            this.scribe.printNextToken(TerminalTokens.TokenNameextends, true);
          } else  {
            this.scribe.printNextToken(TerminalTokens.TokenNameimplements, true);
          }
          for (int i = 0; i < superInterfaceLength; i++) {
            if (i > 0) {
              this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_superinterfaces);
              this.scribe.printTrailingComment();
              this.scribe.alignFragment(interfaceAlignment, i+1);
              if (this.preferences.insert_space_after_comma_in_superinterfaces) {
                this.scribe.space();
              }
              superInterfaces[i].traverse(this, typeDeclaration.scope);
            } else {
              this.scribe.alignFragment(interfaceAlignment, i+1);
              this.scribe.space();
              superInterfaces[i].traverse(this, typeDeclaration.scope);
            }
          }
          ok = true;
        } catch (AlignmentException e) {
          this.scribe.redoAlignment(e);
        }
      } while (!ok);
      this.scribe.exitAlignment(interfaceAlignment, true);
    }

    /*
     * Type body
     */
    String class_declaration_brace;
    boolean space_before_opening_brace;
    int kind = TypeDeclaration.kind(typeDeclaration.modifiers);
    switch(kind) {
      case TypeDeclaration.ENUM_DECL :
        class_declaration_brace = this.preferences.brace_position_for_enum_declaration;
        space_before_opening_brace = this.preferences.insert_space_before_opening_brace_in_enum_declaration;
        break;
      case TypeDeclaration.ANNOTATION_TYPE_DECL :
        class_declaration_brace = this.preferences.brace_position_for_annotation_type_declaration;
        space_before_opening_brace =  this.preferences.insert_space_before_opening_brace_in_annotation_type_declaration;
        break;
      default:
        class_declaration_brace = this.preferences.brace_position_for_type_declaration;
        space_before_opening_brace = this.preferences.insert_space_before_opening_brace_in_type_declaration;
        break;
    }
        formatLeftCurlyBrace(line, class_declaration_brace);
    formatTypeOpeningBrace(class_declaration_brace, space_before_opening_brace, typeDeclaration);
   
    boolean indent_body_declarations_compare_to_header;
    switch(kind) {
      case TypeDeclaration.ENUM_DECL :
        indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_enum_declaration_header;
        break;
      case TypeDeclaration.ANNOTATION_TYPE_DECL :
        indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_annotation_declaration_header;
        break;
      default:
        indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_type_header;
        break;
    }   
    if (indent_body_declarations_compare_to_header) {
      this.scribe.indent();
    }
   
    if (kind == TypeDeclaration.ENUM_DECL) {
      FieldDeclaration[] fieldDeclarations = typeDeclaration.fields;
      boolean hasConstants = false;
      if (fieldDeclarations != null) {
        int length = fieldDeclarations.length;
        int enumConstantsLength = 0;
        for (int i = 0; i < length; i++) {
          FieldDeclaration fieldDeclaration = fieldDeclarations[i];
          if (fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
            enumConstantsLength++;
          } else {
            break;
          }
        }
        hasConstants = enumConstantsLength != 0;
        if (enumConstantsLength > 1) {
          Alignment enumConstantsAlignment = this.scribe.createAlignment(
              "enumConstants",//$NON-NLS-1$
              this.preferences.alignment_for_enum_constants,
              enumConstantsLength,
              this.scribe.scanner.currentPosition,
              0, // we don't want to indent enum constants when splitting to a new line
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.