Class AbstractExternalQuickfixProvider

  • Direct Known Subclasses:
    FormAndCommandExportMethodQuickfix

    public abstract class AbstractExternalQuickfixProvider
    extends Object
    Class for expanding mechanism of quickfixes in Built-in language
    This class contains some useful method for creating different quickfixes.
    Implementation of this class should contains some special public method with special annotation Fix. Each this method providing quickfix for validation issue with code equals to argument of annotation Fix
    Example of implementation:
     public class FooQuickfix
       extends AbstractExternalQuickfixProvider
     {
         @Fix(FooValidationIssueCode)
         public void doFooQickfix(final Issue issue, IssueResolutionAcceptor acceptor)
         {
             acceptor.accept(issue, "fooQuickfixTitle", "fooQuickfixExtensionTitle", imagesOfFooQuickfix, new ExternalQuickfixModification<ModelObject>(issue, ModelObject.class,
                 new Function<ModelObject, TextEdit>()
                 {
                     @Override
                     public TextEdit apply(ModelObject method)
                     {
                         //foo qiuckfix action for creating text changes
                     }
                 }));
         }
     }
     
    • Constructor Detail

      • AbstractExternalQuickfixProvider

        public AbstractExternalQuickfixProvider()
    • Method Detail

      • getTextViewer

        protected org.eclipse.jface.text.ITextViewer getTextViewer​(org.eclipse.xtext.ui.editor.model.edit.IModificationContext context)
        Gets ITextViewer from IModificationContext
        Parameters:
        context - actual IModificationContext of quickfix, can't be null
        Returns:
        ITextViewer from IModificationContext or null it there is no implementation of ITextViewer for this IModificationContext
      • selectAndReveal

        protected void selectAndReveal​(org.eclipse.jface.text.ITextViewer viewer,
                                       int posStart,
                                       int length)
        Selects and reveals some text from ITextViewer
        Parameters:
        viewer - actual ITextViewer, can't be null
        posStart - start position of selecting and revealing text in ITextViewer
        length - length of selecting and revealing area