Class GrammarReference

java.lang.Object
org.eclipse.lemminx.extensions.index.GrammarReference

public final class GrammarReference extends Object
A located grammar reference within an XML file, stored as a line/column range so that callers can build LSP Locations and TextEdits without re-reading the file.

Grammar references are always single-line (attribute values, DOCTYPE system/public IDs, PI content), so only one line number is stored. endLine is omitted — it is always equal to line.

Example: In <?xml-model href="schema.xsd"?> on line 0, the GrammarReference would be:

   line      =  0  (zero-based)
   startChar = 22  (start of schema.xsd, after the opening ")
   endChar   = 32  (exclusive, before the closing ")
   value     = "schema.xsd"
   kind      = XML_MODEL_HREF
 

All fields are populated once during GrammarReferenceLocator.locate(org.eclipse.lemminx.commons.TextDocument) and cached in FileBloomEntry. After indexing, files are never re-read to build Locations or TextEdits — the cached line/column positions are used directly.

See Also:
  • Constructor Details

  • Method Details

    • offset

      public int offset()
      Absolute character offset from the start of the document.
    • line

      public int line()
      Zero-based line number. Equal to endLine — grammar refs are always single-line.
    • startChar

      public int startChar()
      Zero-based start column (inclusive).
    • endChar

      public int endChar()
      Zero-based end column (exclusive).
    • length

      public int length()
      Character length of the value: endChar - startChar.
    • value

      public String value()
    • kind

      public GrammarReference.Kind kind()