java.lang.Object
de.funfried.netbeans.plugins.external.formatter.sql.jsqlformatter.JSQLFormatterService
All Implemented Interfaces:
FormatterService

public class JSQLFormatterService extends Object implements FormatterService
JSQLFormatter implementation of the FormatterService.
Author:
Andreas Reichel andreas@manticore-projects.com
  • Field Details

  • Constructor Details

    • JSQLFormatterService

      public JSQLFormatterService()
  • Method Details

    • format

      public boolean format(StyledDocument document, SortedSet<Pair<Integer,Integer>> changedElements) throws BadLocationException, FormattingFailedException
      Formats the given StyledDocument in regard to the given changedElements.
      Specified by:
      format in interface FormatterService
      Parameters:
      document - the StyledDocument which should be formatted
      changedElements - a SortedSet containing ranges as Pair objects that should be formatted
      Returns:
      if true formatting was done, otherwise formatting was rejected and needs to be done by NetBeans internal formatter
      Throws:
      BadLocationException - if something goes wrong while applying the formatted code
      FormattingFailedException - if the given StyledDocument cannot be formatted by the given formatter
    • getSupportedMimeTypes

      public List<MimeType> getSupportedMimeTypes()
      Returns a List of supported MimeTypes for this FormatterService.
      Specified by:
      getSupportedMimeTypes in interface FormatterService
      Returns:
      a List of supported MimeTypes for this FormatterService
    • getDisplayName

      @NonNull public String getDisplayName()
      Retruns the display name of this formatter implementation.
      Specified by:
      getDisplayName in interface FormatterService
      Returns:
      the display name of this formatter implementation
    • getId

      @NonNull public String getId()
      Retruns the unique identifier of this formatter implementation.
      Specified by:
      getId in interface FormatterService
      Returns:
      the unique identifier of this formatter implementation
    • createOptionsPanel

      public FormatterOptionsPanel createOptionsPanel(Project project)
      Creates and returns the FormatterOptionsPanel for this formatter which will be displayed in the overall options dialog underneath this formatters selection.
      Specified by:
      createOptionsPanel in interface FormatterService
      Parameters:
      project - the Project if the panel which is created is used to modify project specific settings, otherwise null
      Returns:
      the FormatterOptionsPanel for this formatter, or null if there are no options a user could make for this formatter
    • getContinuationIndentSize

      @CheckForNull public Integer getContinuationIndentSize(Document document)
      Returns the continuation indent size configured for the given Document, or null if it should not affect the editor behavior.
      Specified by:
      getContinuationIndentSize in interface FormatterService
      Parameters:
      document - the Document for which the continuation indent size is requested
      Returns:
      the continuation indent size configured for the given Document, or null if it should not affect the editor behavior
    • getIndentSize

      @CheckForNull public Integer getIndentSize(Document document)
      Returns the indent size configured for the given Document, or null if it should not affect the editor behavior.
      Specified by:
      getIndentSize in interface FormatterService
      Parameters:
      document - the Document for which the indent size is requested
      Returns:
      the indent size configured for the given Document, or null if it should not affect the editor behavior
    • getRightMargin

      @CheckForNull public Integer getRightMargin(Document document)
      Returns the right margin (position of the red line in the editor) configured for the given Document, or null if it should not affect the editor behavior.
      Specified by:
      getRightMargin in interface FormatterService
      Parameters:
      document - the Document for which the right margin is requested
      Returns:
      the right margin (position of the red line in the editor) configured for the given Document, or null if it should not affect the editor behavior
    • getFormatJob

      protected FormatJob getFormatJob(StyledDocument document, SortedSet<Pair<Integer,Integer>> changedElements)
      Returns the FormatJob.
      Parameters:
      document - the StyledDocument which should be formatted
      changedElements - a SortedSet containing ranges as Pair objects that should be formatted
    • getSpacesPerTab

      @CheckForNull public Integer getSpacesPerTab(Document document)
      Returns the spaces per tab configured for the given Document, or null if it should not affect the editor behavior.
      Specified by:
      getSpacesPerTab in interface FormatterService
      Parameters:
      document - the Document for which the spaces per tab is requested
      Returns:
      the spaces per tab configured for the given Document, or null if it should not affect the editor behavior
    • isExpandTabToSpaces

      @CheckForNull public Boolean isExpandTabToSpaces(Document document)
      Returns the expand tab to spaces flag configured for the given Document, or null if it should not affect the editor behavior.
      Specified by:
      isExpandTabToSpaces in interface FormatterService
      Parameters:
      document - the Document for which the expand tab to spaces flag is requested
      Returns:
      the expand tab to spaces flag configured for the given Document, or null if it should not affect the editor behavior
    • organizeImports

      @CheckForNull public Boolean organizeImports(StyledDocument document, boolean afterFixImports) throws BadLocationException
      Organizes the imports of the given StyledDocument.
      Specified by:
      organizeImports in interface FormatterService
      Parameters:
      document - the StyledDocument
      afterFixImports - true if this method was called after fixing imports, otherwise false
      Returns:
      true if the imports have been reorganized, if something went wrong it will return false, if it wasn't executed, e.g. because it is not activated through its configuration, it will return null
      Throws:
      BadLocationException - if something goes wrong while applying the reorganized imports code