Class RNCSearchUtils
java.lang.Object
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.utils.RNCSearchUtils
Utility methods for searching RNC (RELAX NG Compact Syntax) documents.
Use case: finding all references to a define name across the document for "Go to References" and "Find All References" LSP operations.
Example: given this RNC document:
start = root
root = element root {
inline*
}
inline = element span { text }
Finding references for root returns: the reference at start = root
(and optionally the declaration at root = element root).
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<org.eclipse.lsp4j.Location> findReferences(TextDocument textDocument, RNCDefine define, boolean includeDeclaration) Finds all pattern-usage references to a given define in the RNC document.
-
Method Details
-
findReferences
public static List<org.eclipse.lsp4j.Location> findReferences(TextDocument textDocument, RNCDefine define, boolean includeDeclaration) Finds all pattern-usage references to a given define in the RNC document.Scans the document tokens and identifies identifiers that match the define name, excluding:
- Element/attribute names (identifiers preceded by
elementorattributekeywords) - All assignment forms (
=,|=,&=) — these are declarations, not pattern usages. This keeps unused-define detection in the validator correct: a define with only extends but no pattern usage is still considered unused. - The define's own declaration position (unless
includeDeclarationistrue)
Callers that need to include extend declarations (e.g. code lens, rename) must collect same-name defines from
rncDocument.getDefines()separately.- Parameters:
textDocument- the RNC text document.define- the define whose references to find.includeDeclaration- whether to include the define's own declaration in the results.- Returns:
- a list of
Locationobjects for each pattern-usage reference found.
- Element/attribute names (identifiers preceded by
-