Class QuickFixer

  • All Implemented Interfaces:
    org.eclipse.ui.IMarkerResolutionGenerator, org.eclipse.ui.IMarkerResolutionGenerator2

    public class QuickFixer
    extends java.lang.Object
    implements org.eclipse.ui.IMarkerResolutionGenerator2
    Class that handles all quick fixes.
    Author:
    Christopher Mindus
    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      static org.eclipse.core.resources.IMarker[]EMPTY_MARKERS
      Empty array of markers.
      static org.eclipse.ui.IMarkerResolution[]EMPTY_RESOLUTIONS
      Empty array of marker resolutions.
      static java.lang.StringID
      The quick fixer ID.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      QuickFixer() 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static org.eclipse.core.resources.IMarker[]findOtherMarkers​(IQuickFixer fixer, org.eclipse.core.resources.IMarker[] markers)
      Iterate through the list of supplied markers.
      static java.lang.StringgetMarkerAttribute​(java.lang.String... fixerIDs)
      Gets a list of quick-fixes for the marker attribute.
      static java.util.Map<java.lang.String,​java.lang.Object>getMarkerAttributes​(IQuickFix[] fixers)
      Gets the attributes required for quick-fixes when they consist of a instances of IQuickFix.
      static java.util.Map<java.lang.String,​java.lang.Object>getMarkerAttributes​(IQuickFix[] fixers, java.lang.String[] fixerIDs)
      Gets the attributes required for quick-fixes when they consist of a combination of "static quick-fixes" using String IDs and instances of IQuickFix.
      static java.util.Map<java.lang.String,​java.lang.Object>getMarkerAttributes​(java.lang.String[] fixerIDs)
      Gets the attributes required for quick-fixes when they consist of a combination of "static quick-fixes" using String IDs and instances of IQuickFix.
      org.eclipse.ui.IMarkerResolution[]getResolutions​(org.eclipse.core.resources.IMarker marker)
      Returns resolutions for the given marker (may be empty).
      booleanhasResolutions​(org.eclipse.core.resources.IMarker marker)
      Returns whether there are any resolutions for the given marker.
      static voidregister​(java.lang.String fixID, IQuickFixer quickFixer)
      Registers a quick fix with an ID.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ID

        public static final java.lang.String ID
        The quick fixer ID.
      • EMPTY_MARKERS

        public static final org.eclipse.core.resources.IMarker[] EMPTY_MARKERS
        Empty array of markers.
      • EMPTY_RESOLUTIONS

        public static final org.eclipse.ui.IMarkerResolution[] EMPTY_RESOLUTIONS
        Empty array of marker resolutions.
    • Constructor Detail

      • QuickFixer

        public QuickFixer()
    • Method Detail

      • register

        public static void register​(java.lang.String fixID,
                                    IQuickFixer quickFixer)
        Registers a quick fix with an ID.
        Parameters:
        fixID - The fix ID, unique.
        quickFixer - The doer for quick-fixing.
        Throws:
        java.lang.IllegalArgumentException - If the fixID is registered.
      • getMarkerAttribute

        public static java.lang.String getMarkerAttribute​(java.lang.String... fixerIDs)
        Gets a list of quick-fixes for the marker attribute.
        Parameters:
        fixerIDs - The quick-fixer IDs.
        Returns:
        The IDs to use as attribute with the QuickFixer.ID attribute name for the marker, or null for no quick-fixes.
      • getMarkerAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getMarkerAttributes​(java.lang.String[] fixerIDs)
        Gets the attributes required for quick-fixes when they consist of a combination of "static quick-fixes" using String IDs and instances of IQuickFix.
        Parameters:
        fixerIDs - An array of static quick-fixer IDs.
        Returns:
        The map used for the problem or marker.
      • getMarkerAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getMarkerAttributes​(IQuickFix[] fixers)
        Gets the attributes required for quick-fixes when they consist of a instances of IQuickFix.
        Parameters:
        fixers - An array of quick-fixes instances.
        Returns:
        The map used for the problem or marker.
      • getMarkerAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getMarkerAttributes​(IQuickFix[] fixers,
                                                                                                 java.lang.String[] fixerIDs)
        Gets the attributes required for quick-fixes when they consist of a combination of "static quick-fixes" using String IDs and instances of IQuickFix.
        Parameters:
        fixers - An array of quick-fixes instances.
        fixerIDs - An array of static quick-fixer IDs.
        Returns:
        The map used for the problem or marker.
      • findOtherMarkers

        public static org.eclipse.core.resources.IMarker[] findOtherMarkers​(IQuickFixer fixer,
                                                                            org.eclipse.core.resources.IMarker[] markers)
        Iterate through the list of supplied markers. Return any that can also have the receiver applied to them.
        Parameters:
        markers - The array of markers.
        Returns:
        IMarker[]
      • getResolutions

        public org.eclipse.ui.IMarkerResolution[] getResolutions​(org.eclipse.core.resources.IMarker marker)
        Returns resolutions for the given marker (may be empty). This method is called from Eclipse.
        Specified by:
        getResolutions in interface org.eclipse.ui.IMarkerResolutionGenerator
        Parameters:
        marker - The marker.
        Returns:
        Resolutions for the given marker.
      • hasResolutions

        public boolean hasResolutions​(org.eclipse.core.resources.IMarker marker)
        Returns whether there are any resolutions for the given marker.
        Specified by:
        hasResolutions in interface org.eclipse.ui.IMarkerResolutionGenerator2
        Parameters:
        marker - The marker.
        Returns:
        true if there are resolutions for the given marker, false if not.