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 -
Method Summary
Modifier and TypeMethodDescriptionvoiddoCodeAction(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 aCodeActionthat inserts text at the end of the diagnostic range.protected abstract StringgetInsertText(boolean snippetSupported) Returns the text to insert at the diagnostic's end position.protected abstract StringgetTitle()Returns the human-readable title for the code action, displayed in the editor's quick-fix menu (e.g.
-
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 aCodeActionthat inserts text at the end of the diagnostic range. Delegates togetTitle()for the action label andgetInsertText(boolean)for the text to insert.- Specified by:
doCodeActionin interfaceIRNCCodeActionParticipant- Parameters:
rncDocument- the RNC document.diagnostic- the diagnostic to fix.document- the text document.snippetSupported-trueif the client supports snippet syntax (tab stops, placeholders).codeActions- the list to add the created code action to.cancelChecker- the cancel checker.
-
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
Returns the text to insert at the diagnostic's end position.When
snippetSupportedistrue, the returned text may contain LSP snippet syntax ($0for final cursor,${1:placeholder}for editable placeholders) to guide the user after the fix is applied.- Parameters:
snippetSupported-trueif the client supports snippet syntax.- Returns:
- the text to insert (plain or snippet).
- See Also:
-