Class WorkspaceIndexCodeLensSupport
This class is called by both WorkspaceIndexCodeLensParticipant (for
grammar files opened via the XML language service) and directly by the RNC code
lens provider (which runs through a separate text document service and therefore
cannot go through the XML extension registry).
Use case: The user opens order.rnc or types.xsd. The
code lens provider for that file type calls
buildWorkspaceReferenceLens(org.eclipse.lemminx.extensions.index.WorkspaceIndex, java.lang.String, org.eclipse.lsp4j.Range, boolean, org.eclipse.lsp4j.jsonrpc.CancelChecker) to create a "N references" lens at the
position of the first significant token. Clicking the lens triggers
textDocument/references → WorkspaceIndexReferenceParticipant.
Range: Each caller supplies the lens Range because the
grammar AST differs per file type:
- XSD/RNG/DTD: range of the root DOM element's start tag
- RNC: position
(0,0)(no DOM available)
No file I/O: Reference counts come directly from the
GrammarReference list cached in each FileBloomEntry during
indexing. Files are never re-read during code lens computation.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.lsp4j.CodeLensbuildCatalogWorkspaceReferenceLens(WorkspaceIndex workspaceIndex, String catalogUri, String catalogIdentifier, org.eclipse.lsp4j.Range range, boolean supportedByClient, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Builds a "N references" code lens for a catalog entry pointing to the grammar aturi.static org.eclipse.lsp4j.CodeLensbuildWorkspaceReferenceLens(WorkspaceIndex workspaceIndex, String uri, org.eclipse.lsp4j.Range range, boolean supportedByClient, boolean excludeGrammarFiles, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Builds a "N references" code lens for the grammar file identified byuri, optionally excluding grammar-to-grammar references from the count.static org.eclipse.lsp4j.CodeLensbuildWorkspaceReferenceLens(WorkspaceIndex workspaceIndex, String uri, org.eclipse.lsp4j.Range range, boolean supportedByClient, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Builds a "N references" code lens for the grammar file identified byuri.
-
Constructor Details
-
WorkspaceIndexCodeLensSupport
public WorkspaceIndexCodeLensSupport()
-
-
Method Details
-
buildWorkspaceReferenceLens
public static org.eclipse.lsp4j.CodeLens buildWorkspaceReferenceLens(WorkspaceIndex workspaceIndex, String uri, org.eclipse.lsp4j.Range range, boolean supportedByClient, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Builds a "N references" code lens for the grammar file identified byuri.Use case:
types.xsdis referenced by three XML files in the workspace. The lens shows "3 references" at the position supplied by the caller. Clicking it opens the references panel.Returns
nullwhen no workspace files reference this grammar, so the caller can omit it from the list without adding an empty lens.- Parameters:
workspaceIndex- the populated Bloom index.uri- URI of the grammar file being viewed.range- position where the lens should appear (caller-supplied, differs per grammar file type).supportedByClient-trueif the client supports theeditor.action.showReferencescommand.cancelChecker- unused — kept for API compatibility.- Returns:
- a
CodeLenswith aReferenceCommand, ornullif no references are found.
-
buildWorkspaceReferenceLens
public static org.eclipse.lsp4j.CodeLens buildWorkspaceReferenceLens(WorkspaceIndex workspaceIndex, String uri, org.eclipse.lsp4j.Range range, boolean supportedByClient, boolean excludeGrammarFiles, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Builds a "N references" code lens for the grammar file identified byuri, optionally excluding grammar-to-grammar references from the count.Use case —
excludeGrammarFiles = true: A catalog entry<uri name="http://foo" uri="schema.xsd"/>should only count XML instance documents, not other XSD files that importschema.xsd. Passingtruefilters out XSD/DTD/RNG/RNC/XSL/XSLT candidates.- Parameters:
excludeGrammarFiles- whentrue, grammar files are excluded from the reference count — used by catalog code lenses.
-
buildCatalogWorkspaceReferenceLens
public static org.eclipse.lsp4j.CodeLens buildCatalogWorkspaceReferenceLens(WorkspaceIndex workspaceIndex, String catalogUri, String catalogIdentifier, org.eclipse.lsp4j.Range range, boolean supportedByClient, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Builds a "N references" code lens for a catalog entry pointing to the grammar aturi.Only XML instance files that reference the grammar via the catalog identifier are counted. Direct references to the grammar file by filename (e.g.
xsi:noNamespaceSchemaLocation="data2.xsd") are intentionally excluded because they bypass the catalog mapping and do not use the catalog entry.- Parameters:
workspaceIndex- the populated Bloom index.catalogUri- URI of the catalog file containing the entry. Used as the target for theReferenceCommandso that clicking the lens triggerstextDocument/referenceson the catalog file.catalogIdentifier- the catalog key attribute (systemId / publicId / URI name).range- position where the lens should appear.supportedByClient-trueif the client supports the references command.cancelChecker- unused — kept for API compatibility.- Returns:
- a
CodeLenswith aReferenceCommand, ornullif no references are found.
-