Class RNCLanguageService
XMLLanguageService for XML documents.
This service provides the core language intelligence for .rnc files,
including completion, hover, go-to-definition, document highlighting, folding,
code lens, code actions, semantic tokens, and formatting. Each feature is
implemented by a dedicated delegate class in its own sub-package.
Use case: RNCTextDocumentService creates an instance of this service
and delegates all LSP requests (completion, hover, formatting, etc.) to it.
Example usage:
RNCLanguageService service = new RNCLanguageService(documentProvider); CompletionList list = service.doComplete(document, position, true, cancelChecker); Hover hover = service.doHover(document, position, cancelChecker); List<? extends TextEdit> edits = service.format(document, sharedSettings);
Static helper methods for identifier resolution and range creation are
in RNCPositionUtils.
-
Constructor Summary
ConstructorsConstructorDescriptionRNCLanguageService(IRNCDocumentProvider documentProvider) Creates a new RNC language service, initializing all feature delegates. -
Method Summary
Modifier and TypeMethodDescriptionList<org.eclipse.lsp4j.CodeAction> doCodeActions(RNCDocument rncDocument, org.eclipse.lsp4j.Range range, org.eclipse.lsp4j.CodeActionContext context, boolean snippetSupported, boolean resolveSupported, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes code actions (quick fixes) for diagnostics in the given range.org.eclipse.lsp4j.CompletionListdoComplete(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, SharedSettings sharedSettings, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes completion items for the given position in an RNC document.org.eclipse.lsp4j.HoverdoHover(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, SharedSettings sharedSettings, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes hover information for the word at the given position.org.eclipse.lsp4j.WorkspaceEditdoRename(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, String newName, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Renames the symbol at the given position across all its occurrences.List<? extends org.eclipse.lsp4j.LocationLink> findDefinition(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Finds the definition location for the symbol at the given position.List<org.eclipse.lsp4j.DocumentHighlight> findDocumentHighlights(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Finds all occurrences of the symbol at the given position for highlighting.List<org.eclipse.lsp4j.DocumentLink> findDocumentLinks(RNCDocument rncDocument, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Finds document links (clickable URIs) in an RNC document.List<org.eclipse.lsp4j.DocumentSymbol> findDocumentSymbols(RNCDocument rncDocument, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes hierarchical document symbols for the Outline view.List<? extends org.eclipse.lsp4j.Location> findReferences(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, org.eclipse.lsp4j.ReferenceContext context, WorkspaceIndex workspaceIndex, Function<String, String> openDocContent, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Finds all references to the symbol at the given position.List<org.eclipse.lsp4j.SymbolInformation> findSymbolInformations(RNCDocument rncDocument, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes flat symbol information for workspace-wide symbol search.List<? extends org.eclipse.lsp4j.TextEdit> format(TextDocument textDocument, SharedSettings sharedSettings, RNCFormattingSettings rncFormattingSettings) Formats an RNC document by adjusting whitespace (indentation, spacing around operators, blank lines between definitions).List<org.eclipse.lsp4j.CodeLens> getCodeLens(RNCDocument rncDocument, boolean supportedByClient, WorkspaceIndex workspaceIndex, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes code lenses for an RNC document.List<org.eclipse.lsp4j.FoldingRange> getFoldingRanges(RNCDocument rncDocument, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes folding ranges for an RNC document.List<org.eclipse.lsp4j.InlayHint> getInlayHints(RNCDocument rncDocument, org.eclipse.lsp4j.Range range) Computes inlay hints for an RNC document.List<org.eclipse.lsp4j.SelectionRange> getSelectionRanges(RNCDocument rncDocument, List<org.eclipse.lsp4j.Position> positions, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.Range, org.eclipse.lsp4j.PrepareRenameResult> prepareRename(RNCDocument rncDocument, org.eclipse.lsp4j.Position position) Validates whether rename is possible at the given position and returns the range of the symbol to rename.org.eclipse.lsp4j.CodeActionresolveCodeAction(RNCDocument rncDocument, org.eclipse.lsp4j.CodeAction unresolved, boolean snippetSupported) Resolves a code action by computing its workspace edit lazily.org.eclipse.lsp4j.CompletionItemresolveCompletionItem(org.eclipse.lsp4j.CompletionItem item, RNCDocument rncDocument, SharedSettings sharedSettings, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Resolves a completion item by adding documentation (hover content).
-
Constructor Details
-
RNCLanguageService
Creates a new RNC language service, initializing all feature delegates.- Parameters:
documentProvider- provides access to open RNC documents (checks in-memory documents first, falls back to disk).
-
-
Method Details
-
findDocumentHighlights
public List<org.eclipse.lsp4j.DocumentHighlight> findDocumentHighlights(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Finds all occurrences of the symbol at the given position for highlighting.Use case: when the cursor is on a define name or reference, all usages in the document are highlighted (definition = Write, references = Read).
- Parameters:
rncDocument- the parsed RNC document (AST).position- the cursor position.cancelChecker- used to abort if the request is cancelled.- Returns:
- the list of document highlights.
-
findDefinition
public List<? extends org.eclipse.lsp4j.LocationLink> findDefinition(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Finds the definition location for the symbol at the given position.Use case: "Go to Definition" on a define reference navigates to the define declaration; on an include URI navigates to the file.
- Parameters:
rncDocument- the parsed RNC document (AST).position- the cursor position.cancelChecker- used to abort if the request is cancelled.- Returns:
- the list of definition location links.
-
findReferences
public List<? extends org.eclipse.lsp4j.Location> findReferences(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, org.eclipse.lsp4j.ReferenceContext context, WorkspaceIndex workspaceIndex, Function<String, String> openDocContent, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Finds all references to the symbol at the given position.Use case: "Find All References" on a define name shows everywhere it is used in the document (and optionally includes the declaration). When the cursor is not on a define name and
workspaceIndexis non-null, falls back to cross-file workspace references (e.g. code lens click at position(0,0)).- Parameters:
rncDocument- the parsed RNC document (AST).position- the cursor position.context- whether to include the declaration itself.workspaceIndex- the workspace Bloom index for cross-file lookup, ornullif the workspace index feature is disabled.cancelChecker- used to abort if the request is cancelled.- Returns:
- the list of reference locations.
-
prepareRename
public org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.Range,org.eclipse.lsp4j.PrepareRenameResult> prepareRename(RNCDocument rncDocument, org.eclipse.lsp4j.Position position) Validates whether rename is possible at the given position and returns the range of the symbol to rename.Use case: the client calls this before showing the rename input box to verify the cursor is on a renameable symbol (define name or reference).
- Parameters:
rncDocument- the parsed RNC document (AST).position- the cursor position.- Returns:
- the renameable range, or
nullif rename is not applicable.
-
doRename
public org.eclipse.lsp4j.WorkspaceEdit doRename(RNCDocument rncDocument, org.eclipse.lsp4j.Position position, String newName, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Renames the symbol at the given position across all its occurrences.Use case: the user renames a define — all references and the declaration are updated to the new name.
- Parameters:
rncDocument- the parsed RNC document (AST).position- the cursor position on the symbol to rename.newName- the new name.cancelChecker- used to abort if the request is cancelled.- Returns:
- the workspace edit with all text changes.
-
getFoldingRanges
public List<org.eclipse.lsp4j.FoldingRange> getFoldingRanges(RNCDocument rncDocument, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes folding ranges for an RNC document.Use case: provides fold regions for multi-line defines, includes, divs, consecutive declarations, and consecutive comment lines.
- Parameters:
rncDocument- the parsed RNC document (AST).cancelChecker- used to check if the operation has been cancelled.- Returns:
- a list of
FoldingRangefor the document.
-
getCodeLens
public List<org.eclipse.lsp4j.CodeLens> getCodeLens(RNCDocument rncDocument, boolean supportedByClient, WorkspaceIndex workspaceIndex, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes code lenses for an RNC document.Use case — workspace lens: When
workspaceIndexis non-null, a "N references" lens is added at position(0,0)showing how many workspace XML files reference this RNC file. This is the same lens thatWorkspaceIndexCodeLensParticipantproduces for XSD/DTD/RNG files, but RNC files go through a separate text document service and therefore callWorkspaceIndexCodeLensSupportdirectly.Use case — per-define lens: Each
definegets a lens showing its reference count within the file (and included files).- Parameters:
rncDocument- the parsed RNC document (AST).supportedByClient- whether the client supports code lens.workspaceIndex- the populated workspace Bloom index, ornullif the workspace index feature is disabled.cancelChecker- used to abort if the request is cancelled.- Returns:
- the list of code lenses.
-
findDocumentLinks
public List<org.eclipse.lsp4j.DocumentLink> findDocumentLinks(RNCDocument rncDocument, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Finds document links (clickable URIs) in an RNC document.Use case: the quoted URI in
include "types.rnc"becomes a clickable link that opens the referenced file.- Parameters:
rncDocument- the parsed RNC document (AST).cancelChecker- used to abort if the request is cancelled.- Returns:
- the list of document links.
-
findDocumentSymbols
public List<org.eclipse.lsp4j.DocumentSymbol> findDocumentSymbols(RNCDocument rncDocument, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes hierarchical document symbols for the Outline view.Use case: populates the editor's Outline panel with a tree of namespace declarations, start, defines, includes, and nested element/attribute patterns.
- Parameters:
rncDocument- the parsed RNC document (AST).cancelChecker- used to abort if the request is cancelled.- Returns:
- the list of hierarchical document symbols.
-
findSymbolInformations
public List<org.eclipse.lsp4j.SymbolInformation> findSymbolInformations(RNCDocument rncDocument, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes flat symbol information for workspace-wide symbol search.Use case: allows "Go to Symbol in Workspace" (Ctrl+T) to find RNC defines and declarations across all open files.
- Parameters:
rncDocument- the parsed RNC document (AST).cancelChecker- used to abort if the request is cancelled.- Returns:
- a flat list of symbol information entries.
-
getSelectionRanges
public List<org.eclipse.lsp4j.SelectionRange> getSelectionRanges(RNCDocument rncDocument, List<org.eclipse.lsp4j.Position> positions, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) -
getInlayHints
public List<org.eclipse.lsp4j.InlayHint> getInlayHints(RNCDocument rncDocument, org.eclipse.lsp4j.Range range) Computes inlay hints for an RNC document.Inherited start hint: When the document has an
includebut no ownstartdeclaration, an inlay hint shows the inherited start pattern from the included file at the end of the include URI.- Parameters:
rncDocument- the parsed RNC document (AST).range- the range for which hints are requested.- Returns:
- the list of inlay hints.
-
doCodeActions
public List<org.eclipse.lsp4j.CodeAction> doCodeActions(RNCDocument rncDocument, org.eclipse.lsp4j.Range range, org.eclipse.lsp4j.CodeActionContext context, boolean snippetSupported, boolean resolveSupported, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Computes code actions (quick fixes) for diagnostics in the given range.Use case: when the user clicks the light bulb on an error, code actions offer fixes like "Create define", "Did you mean", "Add start", "Add closing brace", etc.
- Parameters:
rncDocument- the parsed RNC document (AST).range- the range for which code actions are requested.context- the code action context containing diagnostics.snippetSupported- whether the client supports snippet text edits.resolveSupported- whether the client supports lazy resolution.cancelChecker- used to abort if the request is cancelled.- Returns:
- the list of code actions.
-
resolveCodeAction
public org.eclipse.lsp4j.CodeAction resolveCodeAction(RNCDocument rncDocument, org.eclipse.lsp4j.CodeAction unresolved, boolean snippetSupported) Resolves a code action by computing its workspace edit lazily.Use case: for code actions like "Extract define" that require computing edits on demand rather than up front.
- Parameters:
rncDocument- the parsed RNC document (AST).unresolved- the code action to resolve.snippetSupported- whether the client supports snippet text edits.- Returns:
- the resolved code action with its edit populated.