Class RNCIncludeUtils
Use case: when computing hover, completion, definition, or references for
an include or external directive, the referenced RNC file
must be resolved (relative URI → absolute URI) and parsed into an
RNCDocument so that its defines are available for cross-file features.
Example: given include "types.rnc" in /schemas/main.rnc,
resolveUri(org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCFileReferenceNode, java.lang.String) expands the relative path to
file:///schemas/types.rnc, and parseFile(java.lang.String) reads and parses it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic RNCDocumentReads and parses an RNC file from the filesystem.static RNCDocumentresolveAndParse(RNCFileReferenceNode ref, String documentUri) Resolves the URI of a file reference and parses the target RNC file.static StringresolveUri(RNCFileReferenceNode ref, String documentUri) Resolves the relative URI from a file reference node against the base document URI.
-
Method Details
-
resolveAndParse
Resolves the URI of a file reference and parses the target RNC file.Use case: hover over a define reference inside an
includebody needs the included file's AST to show the define's text.- Parameters:
ref- the include or external reference node.documentUri- the URI of the document containing the reference (used as base for relative resolution).- Returns:
- the parsed
RNCDocument, ornullif the URI cannot be resolved or the file cannot be parsed.
-
resolveUri
Resolves the relative URI from a file reference node against the base document URI.Use case: document links and definition navigation need the absolute URI to create clickable links or to locate the target file on disk.
- Parameters:
ref- the include or external reference node containing the relative URI (e.g."types.rnc").documentUri- the absolute URI of the current document.- Returns:
- the resolved absolute URI, or
nullif resolution fails.
-
parseFile
Reads and parses an RNC file from the filesystem.Use case: after resolving an include URI, the file content must be loaded and parsed to make its defines available for cross-file completion, hover, references, and rename.
- Parameters:
resolvedUri- the absolute file URI (e.g."file:///path/to/types.rnc").- Returns:
- the parsed
RNCDocument, ornullif the file does not exist or cannot be parsed.
-