Class RNCIndexFileScannerContributor
- All Implemented Interfaces:
IIndexFileScannerContributor
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif this contributor can scan the given file.Returns the in-memory text content of the given URI if the file is currently open in the editor and tracked by this contributor, ornullif the file is not open or this contributor does not track open documents.voidScans the given in-memory content and populatesrefsandnames.booleanScans the file and populatesrefsandnames.
-
Constructor Details
-
RNCIndexFileScannerContributor
public RNCIndexFileScannerContributor()
-
-
Method Details
-
getOpenDocumentContent
Description copied from interface:IIndexFileScannerContributorReturns the in-memory text content of the given URI if the file is currently open in the editor and tracked by this contributor, ornullif 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:
getOpenDocumentContentin interfaceIIndexFileScannerContributor- Parameters:
uri- the document URI to look up.- Returns:
- live content, or
nullif unavailable.
-
canScan
Description copied from interface:IIndexFileScannerContributorReturnstrueif this contributor can scan the given file.Implementations typically check the file extension. The check must be cheap (no I/O).
- Specified by:
canScanin interfaceIIndexFileScannerContributor- Parameters:
path- the absolute path of the file to be indexed.- Returns:
trueto claim the file;falseto pass.
-
scan
public boolean scan(Path path, int maxChars, List<GrammarReference> refs, Set<String> names) throws IOException Description copied from interface:IIndexFileScannerContributorScans the file and populatesrefsandnames.The scan must be streaming: never load the whole file into memory. Stop reading after
maxCharscharacters and returntrueto signal that the file is only partially indexed.- Specified by:
scanin interfaceIIndexFileScannerContributor- Parameters:
path- the absolute path of the file to scan.maxChars- maximum characters to consume;Integer.MAX_VALUEmeans no limit.refs- output — located grammar references with line/column positions.names- output — token names for the Bloom filter.- Returns:
trueif scanning stopped early due tomaxChars.- Throws:
IOException- if the file cannot be opened or read.
-
scan
Description copied from interface:IIndexFileScannerContributorScans the given in-memory content and populatesrefsandnames.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:
scanin interfaceIIndexFileScannerContributor- 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.
-