Class AbstractEclipseFormatJob

java.lang.Object
de.funfried.netbeans.plugins.external.formatter.AbstractFormatJob
de.funfried.netbeans.plugins.external.formatter.eclipse.AbstractEclipseFormatJob
All Implemented Interfaces:
FormatJob

public abstract class AbstractEclipseFormatJob extends AbstractFormatJob
Abstract Eclipse formatter implementation of the AbstractFormatJob as a base class for any type of Eclipse Formatter.
Author:
bahlef
  • Constructor Details

  • 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 - the Preferences
      formatterFile - the path to the formatter configuration file
      formatterProfile - the name of the formatter configuration profile
      code - the current (unformatted) code
      Returns:
      the formatted content
      Throws:
      ConfigReadException - if there is an issue parsing the formatter configuration
      ProfileNotFoundException - if the given profile could not be found
      CannotLoadConfigurationException - if there is any issue accessing or reading the formatter configuration
      FormattingFailedException - if the external formatter failed to format the given code
    • getFormatterFile

      protected abstract String getFormatterFile(Preferences pref)
      Returns the configured formatter configuration file.
      Parameters:
      pref - the Preferences
      Returns:
      the configured formatter configuration file
    • getFormatterProfile

      protected abstract String getFormatterProfile(Preferences pref)
      Returns the configured formatter profile name.
      Parameters:
      pref - the Preferences
      Returns:
      the configured formatter profile name
    • getLineFeed

      protected abstract String getLineFeed(Preferences pref)
      Returns the configured line feed.
      Parameters:
      pref - the Preferences
      Returns:
      the configured line feed
    • getCode

      protected String getCode(Preferences pref)
      Returns the content of the document.
      Parameters:
      pref - the Preferences
      Returns:
      The content of the document
    • format

      public final void format() throws BadLocationException
      Executes the formatting of this FormatJob.
      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 file
      formatterProfile - the used formatter profile
      Returns:
      the message which should be shown in a notification after the formatting is done