Class FormatterServiceDelegate

java.lang.Object
de.funfried.netbeans.plugins.external.formatter.FormatterServiceDelegate

public class FormatterServiceDelegate extends Object
Singleton delegation class for calling the activated external formatter, if no external formatter is activated nothing will be done by this implementation. There is no fallback to the internal NetBeans formatter in here!
Author:
markiewb, bahlef
  • Method Details

    • getInstance

      @NonNull public static FormatterServiceDelegate getInstance()
      Returns the singleton instance of FormatterServiceDelegate.
      Returns:
      the singleton instance
    • format

      public boolean format(StyledDocument document, SortedSet<Pair<Integer,Integer>> changedElements)
      Formats the given StyledDocument in regard to the given changedElements.
      Parameters:
      document - the StyledDocument which should be formatted
      changedElements - a SortedSet containing ranges as Pair objects that should be formatted
      Returns:
      true if and only if a external formatter was found to handle the given StyledDocument even if there was an error while formatting, otherwise and if an external formatter delegates formatting to the NetBeans formatter it is false
    • getContinuationIndentSize

      @CheckForNull public Integer getContinuationIndentSize(Document document)
      Returns the continuation indent size configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document.
      Parameters:
      document - the Document for which the continuation indent size is requested
      Returns:
      the continuation indent size configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document
    • getIndentSize

      @CheckForNull public Integer getIndentSize(Document document)
      Returns the indent size configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document.
      Parameters:
      document - the Document for which the indent size is requested
      Returns:
      the indent size configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document
    • getRightMargin

      @CheckForNull public Integer getRightMargin(Document document)
      Returns the right margin (position of the red line in the editor) configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document.
      Parameters:
      document - the Document for which the right margin is requested
      Returns:
      the right margin (position of the red line in the editor) configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document
    • getSpacesPerTab

      @CheckForNull public Integer getSpacesPerTab(Document document)
      Returns the spaces per tab configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document.
      Parameters:
      document - the Document for which the spaces per tab is requested
      Returns:
      the spaces per tab configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document
    • isExpandTabToSpaces

      @CheckForNull public Boolean isExpandTabToSpaces(Document document)
      Returns the expand tab to spaces flag configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document.
      Parameters:
      document - the Document for which the expand tab to spaces flag is requested
      Returns:
      the expand tab to spaces flag configured by the formatter which is activated for the given Document, or null if the internal NetBeans code formatter is used for the given document
    • organizeImports

      @CheckForNull public Boolean organizeImports(StyledDocument document, boolean afterFixImports)