Class AbstractRNCInsertCodeAction

java.lang.Object
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.codeaction.AbstractRNCInsertCodeAction
All Implemented Interfaces:
IRNCCodeActionParticipant
Direct Known Subclasses:
missing_assignCodeAction, missing_nameCodeAction, missing_uriCodeAction

public abstract class AbstractRNCInsertCodeAction extends Object implements IRNCCodeActionParticipant
Base class for simple RNC code actions that insert text at the diagnostic's end position.

Subclasses provide the insert text and title; this class handles the boilerplate of creating the CodeAction with the correct range.

Use case: code actions for missing tokens (missing assign, missing name, missing URI) share the same pattern — insert a snippet at the end of the error range.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    doCodeAction(RNCDocument rncDocument, org.eclipse.lsp4j.Diagnostic diagnostic, org.eclipse.lsp4j.TextDocumentItem document, boolean snippetSupported, List<org.eclipse.lsp4j.CodeAction> codeActions, IRNCDocumentProvider documentProvider, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)
    Creates a CodeAction that inserts text at the end of the diagnostic range.
    protected abstract String
    getInsertText(boolean snippetSupported)
    Returns the text to insert at the diagnostic's end position.
    protected abstract String
    Returns the human-readable title for the code action, displayed in the editor's quick-fix menu (e.g.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractRNCInsertCodeAction

      public AbstractRNCInsertCodeAction()
  • Method Details

    • doCodeAction

      public void doCodeAction(RNCDocument rncDocument, org.eclipse.lsp4j.Diagnostic diagnostic, org.eclipse.lsp4j.TextDocumentItem document, boolean snippetSupported, List<org.eclipse.lsp4j.CodeAction> codeActions, IRNCDocumentProvider documentProvider, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)
      Creates a CodeAction that inserts text at the end of the diagnostic range. Delegates to getTitle() for the action label and getInsertText(boolean) for the text to insert.
      Specified by:
      doCodeAction in interface IRNCCodeActionParticipant
      Parameters:
      rncDocument - the RNC document.
      diagnostic - the diagnostic to fix.
      document - the text document.
      snippetSupported - true if the client supports snippet syntax (tab stops, placeholders).
      codeActions - the list to add the created code action to.
      cancelChecker - the cancel checker.
    • getTitle

      protected abstract String getTitle()
      Returns the human-readable title for the code action, displayed in the editor's quick-fix menu (e.g. "Add '='", "Add name", "Add URI").
      Returns:
      the code action title.
    • getInsertText

      protected abstract String getInsertText(boolean snippetSupported)
      Returns the text to insert at the diagnostic's end position.

      When snippetSupported is true, the returned text may contain LSP snippet syntax ($0 for final cursor, ${1:placeholder} for editable placeholders) to guide the user after the fix is applied.

      Parameters:
      snippetSupported - true if the client supports snippet syntax.
      Returns:
      the text to insert (plain or snippet).
      See Also: