Class AbstractEclipseFormatJob
java.lang.Object
de.funfried.netbeans.plugins.external.formatter.AbstractFormatJob
de.funfried.netbeans.plugins.external.formatter.eclipse.AbstractEclipseFormatJob
- All Implemented Interfaces:
FormatJob
Abstract Eclipse formatter implementation of the
AbstractFormatJob
as a base
class for any type of Eclipse Formatter.- Author:
- bahlef
-
Nested Class Summary
Nested classes/interfaces inherited from class de.funfried.netbeans.plugins.external.formatter.AbstractFormatJob
AbstractFormatJob.BreakException
-
Field Summary
Fields inherited from class de.funfried.netbeans.plugins.external.formatter.AbstractFormatJob
changedElements, document
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractEclipseFormatJob
(StyledDocument document, SortedSet<Pair<Integer, Integer>> changedElements) Protected constructor to create a new instance ofAbstractEclipseFormatJob
. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
format()
Executes the formatting of thisFormatJob
.protected String
getCode
(Preferences pref) Returns the content of thedocument
.protected abstract String
getFormattedContent
(Preferences pref, String formatterFile, String formatterProfile, String code) Returns the formatted content.protected abstract String
getFormatterFile
(Preferences pref) Returns the configured formatter configuration file.protected abstract String
Returns the configured formatter profile name.protected abstract String
getLineFeed
(Preferences pref) Returns the configured line feed.protected abstract String
getNotificationMessageForEclipseFormatterConfigurationFileType
(String formatterFile, String formatterProfile) Returns the message which should be shown in a notification after the formatting is done.Methods inherited from class de.funfried.netbeans.plugins.external.formatter.AbstractFormatJob
avoidGuardedSection, getCode, getFormatableSections, setFormattedCode
-
Constructor Details
-
AbstractEclipseFormatJob
protected AbstractEclipseFormatJob(StyledDocument document, SortedSet<Pair<Integer, Integer>> changedElements) Protected constructor to create a new instance ofAbstractEclipseFormatJob
.- Parameters:
document
- theStyledDocument
which sould be formattedchangedElements
- the ranges which should be formatted
-
-
Method Details
-
getFormattedContent
protected abstract String getFormattedContent(Preferences pref, String formatterFile, String formatterProfile, String code) throws ConfigReadException, ProfileNotFoundException, CannotLoadConfigurationException, FormattingFailedException Returns the formatted content.- Parameters:
pref
- thePreferences
formatterFile
- the path to the formatter configuration fileformatterProfile
- the name of the formatter configuration profilecode
- the current (unformatted) code- Returns:
- the formatted content
- Throws:
ConfigReadException
- if there is an issue parsing the formatter configurationProfileNotFoundException
- if the givenprofile
could not be foundCannotLoadConfigurationException
- if there is any issue accessing or reading the formatter configurationFormattingFailedException
- if the external formatter failed to format the given code
-
getFormatterFile
Returns the configured formatter configuration file.- Parameters:
pref
- thePreferences
- Returns:
- the configured formatter configuration file
-
getFormatterProfile
Returns the configured formatter profile name.- Parameters:
pref
- thePreferences
- Returns:
- the configured formatter profile name
-
getLineFeed
Returns the configured line feed.- Parameters:
pref
- thePreferences
- Returns:
- the configured line feed
-
getCode
Returns the content of thedocument
.- Parameters:
pref
- thePreferences
- Returns:
- The content of the
document
-
format
Executes the formatting of thisFormatJob
.- Throws:
BadLocationException
- if something goes wrong while applying the formatted code
-
getNotificationMessageForEclipseFormatterConfigurationFileType
@NonNull protected abstract String getNotificationMessageForEclipseFormatterConfigurationFileType(String formatterFile, String formatterProfile) Returns the message which should be shown in a notification after the formatting is done.- Parameters:
formatterFile
- the used formatter configuration fileformatterProfile
- the used formatter profile- Returns:
- the message which should be shown in a notification after the formatting is done
-