Interface FormatterService
- All Known Implementing Classes:
AbstractCssFormatterService
,AbstractHtmlFormatterService
,AbstractJavaFormatterService
,AbstractJavascriptFormatterService
,AbstractJsonFormatterService
,AbstractXmlFormatterService
,CssParserFormatterService
,DBeaverFormatterService
,EclipseJavaFormatterService
,EclipseJavascriptFormatterService
,GoogleJavaFormatterService
,JacksonJsonFormatterService
,JsoupHtmlFormatterService
,JsoupXmlFormatterService
,JSQLFormatterService
,PalantirJavaFormatterService
,RevelcXmlFormatterService
,SpringJavaFormatterService
,SQLFormatterService
public interface FormatterService
Service interface for external formatter implementations.
- Author:
- bahlef
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Returnstrue
if and only if this implementation would be able to format the givenDocument
, otherwisefalse
.createOptionsPanel
(Project project) Creates and returns theFormatterOptionsPanel
for this formatter which will be displayed in the overall options dialog underneath this formatters selection.boolean
Formats the givenStyledDocument
in regard to the givenchangedElements
.getContinuationIndentSize
(Document document) Returns the continuation indent size configured for the givenDocument
, ornull
if it should not affect the editor behavior.Retruns the display name of this formatter implementation.getId()
Retruns the unique identifier of this formatter implementation.getIndentSize
(Document document) Returns the indent size configured for the givenDocument
, ornull
if it should not affect the editor behavior.getRightMargin
(Document document) Returns the right margin (position of the red line in the editor) configured for the givenDocument
, ornull
if it should not affect the editor behavior.getSpacesPerTab
(Document document) Returns the spaces per tab configured for the givenDocument
, ornull
if it should not affect the editor behavior.isExpandTabToSpaces
(Document document) Returns the expand tab to spaces flag configured for the givenDocument
, ornull
if it should not affect the editor behavior.organizeImports
(StyledDocument document, boolean afterFixImports) Organizes the imports of the givenStyledDocument
.
-
Method Details
-
canHandle
Returnstrue
if and only if this implementation would be able to format the givenDocument
, otherwisefalse
. -
format
boolean format(StyledDocument document, SortedSet<Pair<Integer, Integer>> changedElements) throws BadLocationException, FormattingFailedExceptionFormats the givenStyledDocument
in regard to the givenchangedElements
.- Parameters:
document
- theStyledDocument
which should be formattedchangedElements
- aSortedSet
containing ranges asPair
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 codeFormattingFailedException
- if the givenStyledDocument
cannot be formatted by the given formatter
-
getContinuationIndentSize
Returns the continuation indent size configured for the givenDocument
, ornull
if it should not affect the editor behavior. -
getDisplayName
Retruns the display name of this formatter implementation.- Returns:
- the display name of this formatter implementation
-
getId
Retruns the unique identifier of this formatter implementation.- Returns:
- the unique identifier of this formatter implementation
-
getIndentSize
Returns the indent size configured for the givenDocument
, ornull
if it should not affect the editor behavior. -
createOptionsPanel
Creates and returns theFormatterOptionsPanel
for this formatter which will be displayed in the overall options dialog underneath this formatters selection.- Parameters:
project
- theProject
if the panel which is created is used to modify project specific settings, otherwisenull
- Returns:
- the
FormatterOptionsPanel
for this formatter, ornull
if there are no options a user could make for this formatter
-
getRightMargin
Returns the right margin (position of the red line in the editor) configured for the givenDocument
, ornull
if it should not affect the editor behavior. -
getSpacesPerTab
Returns the spaces per tab configured for the givenDocument
, ornull
if it should not affect the editor behavior. -
getSupportedMimeTypes
- Returns:
- a
List
of supportedMimeType
s for thisFormatterService
-
isExpandTabToSpaces
Returns the expand tab to spaces flag configured for the givenDocument
, ornull
if it should not affect the editor behavior. -
organizeImports
@CheckForNull Boolean organizeImports(StyledDocument document, boolean afterFixImports) throws BadLocationException Organizes the imports of the givenStyledDocument
.- Parameters:
document
- theStyledDocument
afterFixImports
-true
if this method was called after fixing imports, otherwisefalse
- Returns:
true
if the imports have been reorganized, if something went wrong it will returnfalse
, if it wasn't executed, e.g. because it is not activated through its configuration, it will returnnull
- Throws:
BadLocationException
- if something goes wrong while applying the reorganized imports code
-