Class RNCIndexFileScannerContributor

java.lang.Object
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCIndexFileScannerContributor
All Implemented Interfaces:
IIndexFileScannerContributor

public class RNCIndexFileScannerContributor extends Object implements IIndexFileScannerContributor
Workspace index scanner contributor for RELAX NG Compact Syntax (RNC) files.

RNC uses a non-XML compact syntax, so the standard XML-based index scanner cannot parse it. This contributor uses RNCScanner to find include "..." and external "..." directives and records them as GrammarReference.Kind.HREF references in the workspace Bloom index.

Example — given include "base.rnc", this contributor adds a reference to base.rnc so that the workspace index can answer "which RNC files include base.rnc?" without opening any files at query time.

  • Constructor Details

    • RNCIndexFileScannerContributor

      public RNCIndexFileScannerContributor()
  • Method Details

    • getOpenDocumentContent

      public String getOpenDocumentContent(String uri)
      Description copied from interface: IIndexFileScannerContributor
      Returns the in-memory text content of the given URI if the file is currently open in the editor and tracked by this contributor, or null if the file is not open or this contributor does not track open documents.

      The default implementation returns null. Override to supply live content from the contributor's own text-document service so that reference positions remain accurate for files with unsaved edits.

      Specified by:
      getOpenDocumentContent in interface IIndexFileScannerContributor
      Parameters:
      uri - the document URI to look up.
      Returns:
      live content, or null if unavailable.
    • canScan

      public boolean canScan(Path path)
      Description copied from interface: IIndexFileScannerContributor
      Returns true if this contributor can scan the given file.

      Implementations typically check the file extension. The check must be cheap (no I/O).

      Specified by:
      canScan in interface IIndexFileScannerContributor
      Parameters:
      path - the absolute path of the file to be indexed.
      Returns:
      true to claim the file; false to pass.
    • scan

      public boolean scan(Path path, int maxChars, List<GrammarReference> refs, Set<String> names) throws IOException
      Description copied from interface: IIndexFileScannerContributor
      Scans the file and populates refs and names.

      The scan must be streaming: never load the whole file into memory. Stop reading after maxChars characters and return true to signal that the file is only partially indexed.

      Specified by:
      scan in interface IIndexFileScannerContributor
      Parameters:
      path - the absolute path of the file to scan.
      maxChars - maximum characters to consume; Integer.MAX_VALUE means no limit.
      refs - output — located grammar references with line/column positions.
      names - output — token names for the Bloom filter.
      Returns:
      true if scanning stopped early due to maxChars.
      Throws:
      IOException - if the file cannot be opened or read.
    • scan

      public void scan(String content, Path path, List<GrammarReference> refs, Set<String> names)
      Description copied from interface: IIndexFileScannerContributor
      Scans the given in-memory content and populates refs and names.

      Called when the file is open in the editor with unsaved changes, so that reference positions stay accurate even before the file is saved and the workspace index is re-indexed. The default implementation falls back to IIndexFileScannerContributor.scan(Path, int, List, Set), ignoring the in-memory content.

      Specified by:
      scan in interface IIndexFileScannerContributor
      Parameters:
      content - in-memory file content (may differ from disk).
      path - absolute path of the file (used for resolving relative references).
      refs - output — located grammar references with line/column positions.
      names - output — token names for the Bloom filter.