Class AbstractHtmlFormatterService
java.lang.Object
de.funfried.netbeans.plugins.external.formatter.html.base.AbstractHtmlFormatterService
- All Implemented Interfaces:
FormatterService
- Direct Known Subclasses:
JsoupHtmlFormatterService
Abstract base implementation of
FormatterService
for HTML formatters.- Author:
- bahlef
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Formats the givenStyledDocument
in regard to the givenchangedElements
.protected abstract FormatJob
getFormatJob
(StyledDocument document) Returns theFormatJob
.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, createOptionsPanel, getContinuationIndentSize, getDisplayName, getId, getIndentSize, getRightMargin, getSpacesPerTab, isExpandTabToSpaces
-
Constructor Details
-
AbstractHtmlFormatterService
public AbstractHtmlFormatterService()
-
-
Method Details
-
getFormatJob
Returns theFormatJob
.- Parameters:
document
- theStyledDocument
which should be formatted
-
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
-
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
-