Class RNCTextDocumentService
- All Implemented Interfaces:
org.eclipse.lsp4j.services.TextDocumentService
.rnc files.
This service is registered with the CompositeTextDocumentService and
handles all LSP requests for files matching the .rnc extension. It routes
each request (completion, hover, formatting, etc.) to the RNCLanguageService
facade, analogous to how XMLTextDocumentService routes requests to
XMLLanguageService.
Use case: when a user opens, edits, or closes a .rnc file in the editor,
this service is selected by canHandle(String) and manages the full
lifecycle: parsing, validation with delay, and responding to LSP feature requests.
Validation flow:
onDidOpen→ validates immediately (async, no delay)onDidChange→ validates with delay viaModelValidatorDelayerto debounce rapid keystrokesonDidClose→ cancels any pending validation for the closed URI
Validation itself uses RNCValidator (Jing's CompactParseable) and
is version-aware: if the document changes while validation is running, the result is
discarded via CancellationException.
-
Field Summary
Fields inherited from class org.eclipse.lemminx.AbstractTextDocumentService
documents, xmlLanguageServer -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new RNC text document service. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines whether this service handles the given document URI.CompletableFuture<List<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.Command, org.eclipse.lsp4j.CodeAction>>> codeAction(org.eclipse.lsp4j.CodeActionParams params) HandlestextDocument/codeActionfor RNC files.CompletableFuture<List<? extends org.eclipse.lsp4j.CodeLens>> codeLens(org.eclipse.lsp4j.CodeLensParams params) HandlestextDocument/codeLensfor RNC files.CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either<List<org.eclipse.lsp4j.CompletionItem>, org.eclipse.lsp4j.CompletionList>> completion(org.eclipse.lsp4j.CompletionParams params) HandlestextDocument/completionfor RNC files.CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either<List<? extends org.eclipse.lsp4j.Location>, List<? extends org.eclipse.lsp4j.LocationLink>>> definition(org.eclipse.lsp4j.DefinitionParams params) HandlestextDocument/definitionfor RNC files.CompletableFuture<List<? extends org.eclipse.lsp4j.DocumentHighlight>> documentHighlight(org.eclipse.lsp4j.DocumentHighlightParams params) HandlestextDocument/documentHighlightfor RNC files.CompletableFuture<List<org.eclipse.lsp4j.DocumentLink>> documentLink(org.eclipse.lsp4j.DocumentLinkParams params) CompletableFuture<List<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.SymbolInformation, org.eclipse.lsp4j.DocumentSymbol>>> documentSymbol(org.eclipse.lsp4j.DocumentSymbolParams params) CompletableFuture<List<org.eclipse.lsp4j.FoldingRange>> foldingRange(org.eclipse.lsp4j.FoldingRangeRequestParams params) HandlestextDocument/foldingRangefor RNC files.CompletableFuture<List<? extends org.eclipse.lsp4j.TextEdit>> formatting(org.eclipse.lsp4j.DocumentFormattingParams params) HandlestextDocument/formattingfor RNC files.protected List<ConfigurationField> Returns the list of configuration fields that can be scoped per folder viaworkspace/configuration.CompletableFuture<org.eclipse.lsp4j.Hover> hover(org.eclipse.lsp4j.HoverParams params) HandlestextDocument/hoverfor RNC files.CompletableFuture<List<org.eclipse.lsp4j.InlayHint>> inlayHint(org.eclipse.lsp4j.InlayHintParams params) protected voidonDidChange(ModelTextDocument<RNCDocument, SharedSettings> document) Called when an RNC document is changed.protected voidonDidClose(String uri) Called when an RNC document is closed.protected voidonDidOpen(ModelTextDocument<RNCDocument, SharedSettings> document) Called when an RNC document is opened.protected voidRe-validates all open RNC files when the workspace index scan completes.CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either3<org.eclipse.lsp4j.Range, org.eclipse.lsp4j.PrepareRenameResult, org.eclipse.lsp4j.PrepareRenameDefaultBehavior>> prepareRename(org.eclipse.lsp4j.PrepareRenameParams params) CompletableFuture<List<? extends org.eclipse.lsp4j.Location>> references(org.eclipse.lsp4j.ReferenceParams params) CompletableFuture<org.eclipse.lsp4j.WorkspaceEdit> rename(org.eclipse.lsp4j.RenameParams params) CompletableFuture<org.eclipse.lsp4j.CodeAction> resolveCodeAction(org.eclipse.lsp4j.CodeAction unresolved) CompletableFuture<org.eclipse.lsp4j.CompletionItem> resolveCompletionItem(org.eclipse.lsp4j.CompletionItem unresolved) CompletableFuture<List<org.eclipse.lsp4j.SelectionRange>> selectionRange(org.eclipse.lsp4j.SelectionRangeParams params) voidupdateSettings(Object initSettings) Called when the client sends updated settings.Methods inherited from class org.eclipse.lemminx.AbstractTextDocumentService
allDocuments, clearAllScopedSettings, colorPresentation, computeModelAsync, computeModelAsyncCompose, didChange, didClose, didOpen, didSave, documentColor, documentIsOpen, getDocument, getOrPullScopedSettings, getSharedSettings, inlineCompletion, isIncrementalSupport, linkedEditingRange, publishDiagnostics, rangeFormatting, semanticTokensFull, setClientConfigurationSupport, typeDefinitionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.lsp4j.services.TextDocumentService
callHierarchyIncomingCalls, callHierarchyOutgoingCalls, declaration, diagnostic, documentLinkResolve, implementation, inlineValue, moniker, onTypeFormatting, prepareCallHierarchy, prepareTypeHierarchy, rangesFormatting, resolveCodeLens, resolveInlayHint, semanticTokensFullDelta, semanticTokensRange, signatureHelp, typeHierarchySubtypes, typeHierarchySupertypes, willSave, willSaveWaitUntil
-
Constructor Details
-
RNCTextDocumentService
Creates a new RNC text document service.- Parameters:
server- the XML language server that hosts this service.
-
-
Method Details
-
updateSettings
Description copied from class:AbstractTextDocumentServiceCalled when the client sends updated settings. Subclasses may override to extract settings specific to their file type.- Overrides:
updateSettingsin classAbstractTextDocumentService<RNCDocument>- Parameters:
initSettings- the settings object (content underxml).
-
getScopedFields
Description copied from class:AbstractTextDocumentServiceReturns the list of configuration fields that can be scoped per folder viaworkspace/configuration. Subclasses should override to return the appropriate scoped fields for their file type.- Overrides:
getScopedFieldsin classAbstractTextDocumentService<RNCDocument>- Returns:
- the scoped fields, or
nullif scoped settings are not supported by this service.
-
canHandle
Determines whether this service handles the given document URI.Returns
truefor URIs ending with.rnc(RELAX NG Compact Syntax files).- Specified by:
canHandlein classAbstractTextDocumentService<RNCDocument>- Parameters:
uri- the document URI to check.- Returns:
trueif the URI points to a.rncfile.
-
onDidOpen
Called when an RNC document is opened. Triggers immediate validation (no delay) so the user sees diagnostics right away.- Overrides:
onDidOpenin classAbstractTextDocumentService<RNCDocument>
-
onDidChange
Called when an RNC document is changed. Triggers delayed validation to debounce rapid keystrokes and avoid unnecessary re-validation.- Overrides:
onDidChangein classAbstractTextDocumentService<RNCDocument>
-
onDidClose
Called when an RNC document is closed. Cancels any pending validation to avoid publishing stale diagnostics for a closed file.- Overrides:
onDidClosein classAbstractTextDocumentService<RNCDocument>
-
onIndexScanCompleted
protected void onIndexScanCompleted()Re-validates all open RNC files when the workspace index scan completes. Needed because some diagnostics (e.g. "missing start" suppression) depend on cross-file workspace information that is only available after the full scan.- Overrides:
onIndexScanCompletedin classAbstractTextDocumentService<RNCDocument>
-
completion
public CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either<List<org.eclipse.lsp4j.CompletionItem>,org.eclipse.lsp4j.CompletionList>> completion(org.eclipse.lsp4j.CompletionParams params) HandlestextDocument/completionfor RNC files.Use case: provides keyword, snippet, and define-reference completions based on the cursor context (top-level, after assign, inside pattern, etc.).
- Specified by:
completionin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
completionin classAbstractTextDocumentService<RNCDocument>
-
resolveCompletionItem
public CompletableFuture<org.eclipse.lsp4j.CompletionItem> resolveCompletionItem(org.eclipse.lsp4j.CompletionItem unresolved) - Specified by:
resolveCompletionItemin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
resolveCompletionItemin classAbstractTextDocumentService<RNCDocument>
-
hover
HandlestextDocument/hoverfor RNC files.Use case: shows define declarations or keyword documentation on hover.
- Specified by:
hoverin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
hoverin classAbstractTextDocumentService<RNCDocument>
-
documentHighlight
public CompletableFuture<List<? extends org.eclipse.lsp4j.DocumentHighlight>> documentHighlight(org.eclipse.lsp4j.DocumentHighlightParams params) HandlestextDocument/documentHighlightfor RNC files.Use case: highlights the definition (Write) and all references (Read) of a define name when the cursor is placed on it.
- Specified by:
documentHighlightin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
documentHighlightin classAbstractTextDocumentService<RNCDocument>
-
documentSymbol
public CompletableFuture<List<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.SymbolInformation,org.eclipse.lsp4j.DocumentSymbol>>> documentSymbol(org.eclipse.lsp4j.DocumentSymbolParams params) - Specified by:
documentSymbolin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
documentSymbolin classAbstractTextDocumentService<RNCDocument>
-
definition
public CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either<List<? extends org.eclipse.lsp4j.Location>,List<? extends org.eclipse.lsp4j.LocationLink>>> definition(org.eclipse.lsp4j.DefinitionParams params) HandlestextDocument/definitionfor RNC files.Use case: navigates from a define reference (e.g.
rootinstart = root) to its declaration (root = element root \{ ... \}).- Specified by:
definitionin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
definitionin classAbstractTextDocumentService<RNCDocument>
-
references
public CompletableFuture<List<? extends org.eclipse.lsp4j.Location>> references(org.eclipse.lsp4j.ReferenceParams params) - Specified by:
referencesin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
referencesin classAbstractTextDocumentService<RNCDocument>
-
prepareRename
public CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either3<org.eclipse.lsp4j.Range,org.eclipse.lsp4j.PrepareRenameResult, prepareRenameorg.eclipse.lsp4j.PrepareRenameDefaultBehavior>> (org.eclipse.lsp4j.PrepareRenameParams params) - Specified by:
prepareRenamein interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
prepareRenamein classAbstractTextDocumentService<RNCDocument>
-
rename
public CompletableFuture<org.eclipse.lsp4j.WorkspaceEdit> rename(org.eclipse.lsp4j.RenameParams params) - Specified by:
renamein interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
renamein classAbstractTextDocumentService<RNCDocument>
-
foldingRange
public CompletableFuture<List<org.eclipse.lsp4j.FoldingRange>> foldingRange(org.eclipse.lsp4j.FoldingRangeRequestParams params) HandlestextDocument/foldingRangefor RNC files.Use case: provides fold regions for brace blocks and consecutive comment groups.
- Specified by:
foldingRangein interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
foldingRangein classAbstractTextDocumentService<RNCDocument>
-
documentLink
public CompletableFuture<List<org.eclipse.lsp4j.DocumentLink>> documentLink(org.eclipse.lsp4j.DocumentLinkParams params) - Specified by:
documentLinkin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
documentLinkin classAbstractTextDocumentService<RNCDocument>
-
codeLens
public CompletableFuture<List<? extends org.eclipse.lsp4j.CodeLens>> codeLens(org.eclipse.lsp4j.CodeLensParams params) HandlestextDocument/codeLensfor RNC files.Use case: shows "N references" above each define declaration.
- Specified by:
codeLensin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
codeLensin classAbstractTextDocumentService<RNCDocument>
-
codeAction
public CompletableFuture<List<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.Command,org.eclipse.lsp4j.CodeAction>>> codeAction(org.eclipse.lsp4j.CodeActionParams params) HandlestextDocument/codeActionfor RNC files.Use case: provides quick-fix code actions for parser errors (e.g. insert missing
\}, add missing=, insert URI placeholder).- Specified by:
codeActionin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
codeActionin classAbstractTextDocumentService<RNCDocument>
-
resolveCodeAction
public CompletableFuture<org.eclipse.lsp4j.CodeAction> resolveCodeAction(org.eclipse.lsp4j.CodeAction unresolved) - Specified by:
resolveCodeActionin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
resolveCodeActionin classAbstractTextDocumentService<RNCDocument>
-
inlayHint
public CompletableFuture<List<org.eclipse.lsp4j.InlayHint>> inlayHint(org.eclipse.lsp4j.InlayHintParams params) - Specified by:
inlayHintin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
inlayHintin classAbstractTextDocumentService<RNCDocument>
-
selectionRange
public CompletableFuture<List<org.eclipse.lsp4j.SelectionRange>> selectionRange(org.eclipse.lsp4j.SelectionRangeParams params) - Specified by:
selectionRangein interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
selectionRangein classAbstractTextDocumentService<RNCDocument>
-
formatting
public CompletableFuture<List<? extends org.eclipse.lsp4j.TextEdit>> formatting(org.eclipse.lsp4j.DocumentFormattingParams params) HandlestextDocument/formattingfor RNC files.Use case: formats the entire RNC document, adjusting indentation, spacing around operators, and blank lines between top-level definitions.
- Specified by:
formattingin interfaceorg.eclipse.lsp4j.services.TextDocumentService- Overrides:
formattingin classAbstractTextDocumentService<RNCDocument>
-