Class WorkspaceIndexCodeLensParticipant
- All Implemented Interfaces:
ICodeLensParticipant
RNC files go through a separate text document service and therefore
cannot reach this participant. Their "N references" lens is added by the
RNC code lens provider, which calls the shared
WorkspaceIndexCodeLensSupport.buildWorkspaceReferenceLens(org.eclipse.lemminx.extensions.index.WorkspaceIndex, java.lang.String, org.eclipse.lsp4j.Range, boolean, org.eclipse.lsp4j.jsonrpc.CancelChecker) directly.
Use case (UC19 — Browse backlinks from a grammar file):
The user opens order-schema.xsd. The root element shows:
3 references <xs:schema ...>Clicking the lens opens the references panel listing all three XML files and the exact attribute values that point to this grammar.
Prerequisite: Code lens must be enabled (xml.codeLens.enabled: true
in VS Code settings). The workspace scan must have populated WorkspaceIndex.
If the scan is still running when the lens is first requested, a
workspace/codeLens/refresh is sent once it completes so the count updates.
Two-pass approach (delegated to WorkspaceIndexCodeLensSupport):
WorkspaceIndex.findReferencingFiles(java.lang.String)— Bloom filter O(n) pre-filterGrammarReferenceLocator.locateReferencesTo(java.lang.CharSequence, java.lang.String)— exact count per candidate
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoCodeLens(ICodeLensRequest request, List<org.eclipse.lsp4j.CodeLens> lenses, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Emits a "N references" lens on the root element of grammar files.
-
Constructor Details
-
WorkspaceIndexCodeLensParticipant
-
-
Method Details
-
doCodeLens
public void doCodeLens(ICodeLensRequest request, List<org.eclipse.lsp4j.CodeLens> lenses, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Emits a "N references" lens on the root element of grammar files.Use case: opening
types.xsdwhen two XML files reference it viaxsi:noNamespaceSchemaLocation="types.xsd"→ shows "2 references". Clicking triggerstextDocument/referencesat the root element position, whichWorkspaceIndexReferenceParticipantresolves to all referencing locations across the workspace.The lens range is the start tag of the DOM root element (or
(0,0)as fallback). RNC uses(0,0)always since no DOM is available there.- Specified by:
doCodeLensin interfaceICodeLensParticipant
-