Package org.eclipse.jdt.internal.formatter

Examples of org.eclipse.jdt.internal.formatter.DefaultCodeFormatter


      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
      // disable the option for not indenting comments starting on first column
      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
    }
    return new DefaultCodeFormatter(currentOptions);
  }
View Full Code Here


    return codeFormatter;
  }

  private CodeFormatter newCodeFormatter() {
    lastState = javaPropertiesProvider.getModifiedMonitor();
    codeFormatter = new DefaultCodeFormatter(javaPropertiesProvider.get());
    return codeFormatter;
  }
View Full Code Here

            // be the line containing the JSNI method declaration)
            int methodDeclarationOffset = getMethodDeclarationOffset(document, offset);

            int jsniLine1 = document.getLineOfOffset(methodDeclarationOffset);
            int methodIndentLevel = getLineIndentLevel(document, jsniLine1, tabWidth, indentWidth);
            DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(javaFormattingPrefs);
            String indentLine = defaultCodeFormatter.createIndentationString(methodIndentLevel);

            // Extract the JSNI body out of the block and split it up by line
            String jsniSource = document.get(offset, length);
            String body = JsniParser.extractMethodBody(jsniSource);
View Full Code Here

      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
      // disable the option for not indenting comments starting on first column
      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
    }
    return new DefaultCodeFormatter(currentOptions);
  }
View Full Code Here

    newOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE));
    newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT);
    newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT);
    newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT);

    DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(newOptions);
    TextEdit textEdit = defaultCodeFormatter.format(org.eclipse.jdt.core.formatter.CodeFormatter.K_UNKNOWN, string, 0, string.length(), indentLevel, lineSeparator);
    if (positions != null && textEdit != null) {
      // update positions
      TextEdit[] edits = textEdit.getChildren();
      int textEditSize = edits.length;
      int editsIndex = 0;
View Full Code Here

    throws Exception
  {
    IBuffer buffer = src.getBuffer();
    String contents = buffer.getContents();
    String delimiter = StubUtility.getLineDelimiterUsed(src);
    DefaultCodeFormatter formatter =
      new DefaultCodeFormatter(src.getJavaProject().getOptions(true));

    // when the eclipse indent settings differ from vim (tabs vs spaces) then
    // the inserted method's indent may be a bit off. this is a workaround to
    // force reformatting of the code from the start of the line to the start of
    // the next set of code following the new method. Doesn't quite fix indent
    // formatting of methods in nested classes.
    while (offset > 0 &&
        !IndentManipulation.isLineDelimiterChar(buffer.getChar(offset - 1)))
    {
      offset--;
      length++;
    }
    while ((offset + length) < contents.length() &&
        IndentManipulation.isLineDelimiterChar(buffer.getChar(offset + length)))
    {
      length++;
    }

    TextEdit edits = formatter.format(kind, contents, offset, length, 0, delimiter);
    if (edits != null) {
      int oldLength = contents.length();
      Document document = new Document(contents);
      edits.apply(document);
View Full Code Here

      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
      // disable the option for not indenting comments starting on first column
      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
      currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
    }
    return new DefaultCodeFormatter(currentOptions);
  }
View Full Code Here

    newOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE));
    newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT);
    newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT);
    newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT);

    DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(newOptions);
    TextEdit textEdit = defaultCodeFormatter.format(org.eclipse.jdt.core.formatter.CodeFormatter.K_UNKNOWN, string, 0, string.length(), indentLevel, lineSeparator);
    if (positions != null && textEdit != null) {
      // update positions
      TextEdit[] edits = textEdit.getChildren();
      int textEditSize = edits.length;
      int editsIndex = 0;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.formatter.DefaultCodeFormatter

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.