Class Formatter


  • public class Formatter
    extends org.eclipse.jdt.core.formatter.CodeFormatter
    A CodeFormatter that applies Spring formatting conventions.
    Author:
    Phillip Webb
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String DEFAULT_LINE_SEPARATOR
      The default line separator.
      • Fields inherited from class org.eclipse.jdt.core.formatter.CodeFormatter

        F_INCLUDE_COMMENTS, K_CLASS_BODY_DECLARATIONS, K_COMPILATION_UNIT, K_EXPRESSION, K_JAVA_DOC, K_MODULE_INFO, K_MULTI_LINE_COMMENT, K_SINGLE_LINE_COMMENT, K_STATEMENTS, K_UNKNOWN
    • Constructor Summary

      Constructors 
      Constructor Description
      Formatter()
      Create a new formatter instance.
      Formatter​(FormatterOption... options)
      Create a new formatter instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String 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 setOptions​(Map<String,​String> options)  
    • Field Detail

      • DEFAULT_LINE_SEPARATOR

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

      • Formatter

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

        public Formatter​(FormatterOption... options)
        Create a new formatter instance.
        Parameters:
        options - formatter options
    • Method Detail

      • 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)
        Specified by:
        format in class org.eclipse.jdt.core.formatter.CodeFormatter
      • 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)
        Specified by:
        format in class org.eclipse.jdt.core.formatter.CodeFormatter
      • createIndentationString

        public String createIndentationString​(int indentationLevel)
        Overrides:
        createIndentationString in class org.eclipse.jdt.core.formatter.CodeFormatter
      • setOptions

        public void setOptions​(Map<String,​String> options)
        Overrides:
        setOptions in class org.eclipse.jdt.core.formatter.CodeFormatter