java.lang.Object
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.utils.RNCIncludeUtils

public class RNCIncludeUtils extends Object
Utilities for resolving and parsing included/external RNC files.

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 Details

    • resolveAndParse

      public static RNCDocument resolveAndParse(RNCFileReferenceNode ref, String documentUri)
      Resolves the URI of a file reference and parses the target RNC file.

      Use case: hover over a define reference inside an include body 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, or null if the URI cannot be resolved or the file cannot be parsed.
    • resolveUri

      public static String resolveUri(RNCFileReferenceNode ref, String documentUri)
      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 null if resolution fails.
    • parseFile

      public static RNCDocument parseFile(String resolvedUri)
      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, or null if the file does not exist or cannot be parsed.