Class DBeaverFormatterService
java.lang.Object
de.funfried.netbeans.plugins.external.formatter.sql.dbeaver.DBeaverFormatterService
- All Implemented Interfaces:
FormatterService
DBeaver SQL formatter implementation of the
FormatterService
.- Author:
- bahlef
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateOptionsPanel
(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.protected FormatJob
getFormatJob
(StyledDocument document, SortedSet<Pair<Integer, Integer>> changedElements) Returns theFormatJob
.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
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.funfried.netbeans.plugins.external.formatter.FormatterService
canHandle
-
Field Details
-
ID
The ID of this formatter service.- See Also:
-
-
Constructor Details
-
DBeaverFormatterService
public DBeaverFormatterService()
-
-
Method Details
-
format
public boolean format(StyledDocument document, SortedSet<Pair<Integer, Integer>> changedElements) throws BadLocationException, FormattingFailedExceptionFormats the givenStyledDocument
in regard to the givenchangedElements
.- Specified by:
format
in interfaceFormatterService
- 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
-
getSupportedMimeTypes
- Specified by:
getSupportedMimeTypes
in interfaceFormatterService
- Returns:
- a
List
of supportedMimeType
s for thisFormatterService
-
getDisplayName
Retruns the display name of this formatter implementation.- Specified by:
getDisplayName
in interfaceFormatterService
- Returns:
- the display name of this formatter implementation
-
getId
Retruns the unique identifier of this formatter implementation.- Specified by:
getId
in interfaceFormatterService
- Returns:
- the unique identifier of this formatter implementation
-
createOptionsPanel
Creates and returns theFormatterOptionsPanel
for this formatter which will be displayed in the overall options dialog underneath this formatters selection.- Specified by:
createOptionsPanel
in interfaceFormatterService
- 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
-
getContinuationIndentSize
Returns the continuation indent size configured for the givenDocument
, ornull
if it should not affect the editor behavior.- Specified by:
getContinuationIndentSize
in interfaceFormatterService
- Parameters:
document
- theDocument
for which the continuation indent size is requested- Returns:
- the continuation indent size configured for the given
Document
, ornull
if it should not affect the editor behavior
-
getIndentSize
Returns the indent size configured for the givenDocument
, ornull
if it should not affect the editor behavior.- Specified by:
getIndentSize
in interfaceFormatterService
- Parameters:
document
- theDocument
for which the indent size is requested- Returns:
- the indent size configured for the given
Document
, ornull
if it should not affect the editor behavior
-
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.- Specified by:
getRightMargin
in interfaceFormatterService
- Parameters:
document
- theDocument
for which the right margin is requested- Returns:
- the right margin (position of the red line in the editor) configured
for the given
Document
, ornull
if it should not affect the editor behavior
-
getFormatJob
protected FormatJob getFormatJob(StyledDocument document, SortedSet<Pair<Integer, Integer>> changedElements) Returns theFormatJob
.- Parameters:
document
- theStyledDocument
which should be formattedchangedElements
- aSortedSet
containing ranges asPair
objects that should be formatted
-
getSpacesPerTab
Returns the spaces per tab configured for the givenDocument
, ornull
if it should not affect the editor behavior.- Specified by:
getSpacesPerTab
in interfaceFormatterService
- Parameters:
document
- theDocument
for which the spaces per tab is requested- Returns:
- the spaces per tab configured for the given
Document
, ornull
if it should not affect the editor behavior
-
isExpandTabToSpaces
Returns the expand tab to spaces flag configured for the givenDocument
, ornull
if it should not affect the editor behavior.- Specified by:
isExpandTabToSpaces
in interfaceFormatterService
- Parameters:
document
- theDocument
for which the expand tab to spaces flag is requested- Returns:
- the expand tab to spaces flag configured for the given
Document
, ornull
if it should not affect the editor behavior
-
organizeImports
@CheckForNull public Boolean organizeImports(StyledDocument document, boolean afterFixImports) throws BadLocationException Organizes the imports of the givenStyledDocument
.- Specified by:
organizeImports
in interfaceFormatterService
- 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
-