Class Formatter

java.lang.Object
io.spring.javaformat.formatter.Formatter

public class Formatter extends Object
A code formatter that applies Spring formatting conventions.
Author:
Phillip Webb
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The default line separator.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new formatter instance.
    Formatter(JavaFormatConfig javaFormatConfig)
    Create a new formatter instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    createIndentationString(int indentationLevel)
     
    org.eclipse.text.edits.TextEdit
    format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator)
     
    org.eclipse.text.edits.TextEdit
    format(int kind, String source, org.eclipse.jface.text.IRegion[] regions, int indentationLevel, String lineSeparator)
     
    org.eclipse.text.edits.TextEdit
    format(String source)
    Format the given source content.
    org.eclipse.text.edits.TextEdit
    format(String source, int offset, int length)
    Format a specific subsection of the given source content.
    org.eclipse.text.edits.TextEdit
    format(String source, int offset, int length, String lineSeparator)
    Format a specific subsection of the given source content.
    org.eclipse.text.edits.TextEdit
    format(String source, String lineSeparator)
    Format the given source content.
    org.eclipse.text.edits.TextEdit
    format(String source, org.eclipse.jface.text.IRegion[] regions)
    Format specific subsections of the given source content.
    org.eclipse.text.edits.TextEdit
    format(String source, org.eclipse.jface.text.IRegion[] regions, String lineSeparator)
    Format specific subsections of the given source content.
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_LINE_SEPARATOR

      public static final String DEFAULT_LINE_SEPARATOR
      The default line separator.
  • Constructor Details

    • Formatter

      public Formatter()
      Create a new formatter instance.
    • Formatter

      public Formatter(JavaFormatConfig javaFormatConfig)
      Create a new formatter instance.
      Parameters:
      javaFormatConfig - the java format config to use
  • Method Details

    • format

      public org.eclipse.text.edits.TextEdit format(String source)
      Format the given source content.
      Parameters:
      source - the source content to format
      Returns:
      the text edit
    • format

      public org.eclipse.text.edits.TextEdit format(String source, String lineSeparator)
      Format the given source content.
      Parameters:
      source - the source content to format
      lineSeparator - the line separator
      Returns:
      the text edit
    • format

      public org.eclipse.text.edits.TextEdit format(String source, int offset, int length)
      Format a specific subsection of the given source content.
      Parameters:
      source - the source content to format
      offset - the offset to start formatting
      length - the length to format
      Returns:
      the text edit
    • format

      public org.eclipse.text.edits.TextEdit format(String source, int offset, int length, String lineSeparator)
      Format a specific subsection of the given source content.
      Parameters:
      source - the source content to format
      offset - the offset to start formatting
      length - the length to format
      lineSeparator - the line separator
      Returns:
      the text edit
    • format

      public org.eclipse.text.edits.TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator)
    • format

      public org.eclipse.text.edits.TextEdit format(String source, org.eclipse.jface.text.IRegion[] regions)
      Format specific subsections of the given source content.
      Parameters:
      source - the source content to format
      regions - the regions to format
      Returns:
      the text edit
    • format

      public org.eclipse.text.edits.TextEdit format(String source, org.eclipse.jface.text.IRegion[] regions, String lineSeparator)
      Format specific subsections of the given source content.
      Parameters:
      source - the source content to format
      regions - the regions to format
      lineSeparator - the line separator
      Returns:
      the text edit
    • format

      public org.eclipse.text.edits.TextEdit format(int kind, String source, org.eclipse.jface.text.IRegion[] regions, int indentationLevel, String lineSeparator)
    • createIndentationString

      public String createIndentationString(int indentationLevel)
    • setOptions

      public void setOptions(Map<String,String> options)