Class AbstractJavaFormatterService<F extends FormatJob>
java.lang.Object
de.funfried.netbeans.plugins.external.formatter.java.base.AbstractJavaFormatterService<F>
- Type Parameters:
F
- theFormatJob
type
- All Implemented Interfaces:
FormatterService
- Direct Known Subclasses:
EclipseJavaFormatterService
,GoogleJavaFormatterService
,PalantirJavaFormatterService
,SpringJavaFormatterService
public abstract class AbstractJavaFormatterService<F extends FormatJob>
extends Object
implements FormatterService
Abstract base implementation of
FormatterService
for Java formatters.- Author:
- bahlef
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Formats the givenStyledDocument
in regard to the givenchangedElements
.protected abstract F
getFormatJob
(StyledDocument document, SortedSet<Pair<Integer, Integer>> changedElements) Returns theAbstractJavaFormatterService
.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, organizeImports
-
Constructor Details
-
AbstractJavaFormatterService
public AbstractJavaFormatterService()
-
-
Method Details
-
getFormatJob
protected abstract F getFormatJob(StyledDocument document, SortedSet<Pair<Integer, Integer>> changedElements) Returns theAbstractJavaFormatterService
.- Parameters:
document
- theStyledDocument
which should be formattedchangedElements
- aSortedSet
containing ranges asPair
objects that 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
-