Class XMLReferenceCollector
java.lang.Object
org.eclipse.lemminx.extensions.index.XMLReferenceCollector
Collects grammar references and symbol names from XML content using
LemMinX's own
XMLScanner. No DOM is built — only the relevant
token values are extracted via a lightweight token scan.
Uses the XMLScanner which is fault-tolerant (handles malformed XML) and lighter than SAX (no factory, no JDK XML parser stack).
All comparisons on token text are done char-by-char on the source
CharSequence — no intermediate String allocations for checks.
Strings are only created for values that are actually collected into
the result set.
Collects:
<?xml-model href="..."?>— grammar file pathxsi:schemaLocation— grammar file paths (namespace-URI pairs)xsi:noNamespaceSchemaLocation— grammar file pathxs:include/xs:import schemaLocation— grammar file path<!DOCTYPE ... SYSTEM "...">— DTD file pathhrefandlocationattributes (XInclude, XSLT import/include, XLink, WSDL import)- Element names (for symbol-level cross-file references)
type,ref,base,name,substitutionGroupattribute values (for XSD cross-file)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncollect(CharSequence text) Extracts all reference tokens from XML content and returns them as a name set.collect(CharSequence text, List<IGrammarReferenceContributor> contributors)
-
Constructor Details
-
XMLReferenceCollector
public XMLReferenceCollector()
-
-
Method Details
-
collect
Extracts all reference tokens from XML content and returns them as a name set.Use case: When indexing
order.xmlwhose content is:<?xml-model href="schemas/order.xsd"?> <root xsi:noNamespaceSchemaLocation="common.xsd"/>
returns{"schemas/order.xsd", "order.xsd", "common.xsd", "root", …}. This set is fed toBloomFilter.create(java.util.Collection<? extends java.lang.CharSequence>)so that later queries likemightContain("order.xsd")returntruein O(1) time.- Parameters:
text- raw XML content, possibly truncated to the first 64 KB for large files.- Returns:
- the set of collected names (file paths, element names, attribute values).
-
collect
public static Set<String> collect(CharSequence text, List<IGrammarReferenceContributor> contributors)
-