Record Class ShortBasedSymbolOccurrence

java.lang.Object
java.lang.Record
com.github._1c_syntax.bsl.languageserver.references.model.ShortBasedSymbolOccurrence
Record Components:
symbol - Символ, к которому происходит обращение.
uri - URI файла, в котором расположено обращение.
typedStartLine - Строка начала обращения, у определения — её побитовое дополнение.
startCharacterShort - Столбец начала обращения.
endLineShort - Строка конца обращения.
endCharacterShort - Столбец конца обращения.
All Implemented Interfaces:
SymbolOccurrence, Comparable<SymbolOccurrence>

public record ShortBasedSymbolOccurrence(Symbol symbol, URI uri, short typedStartLine, short startCharacterShort, short endLineShort, short endCharacterShort) extends Record implements SymbolOccurrence
Компактная реализация SymbolOccurrence с координатами диапазона в short.

Четыре short вместо четырёх int экономят 8 байт на экземпляр (40 → 32 байта при сжатых указателях), что заметно на миллионах вхождений reference-индекса. Подходит для файлов, где строки и столбцы укладываются в short (<= Short.MAX_VALUE); выбор реализации делает фабрика SymbolOccurrence.of(OccurrenceType, Symbol, URI, Range).

Тип обращения отдельным полем не хранится, а закодирован знаком строки начала: у определения в typedStartLine лежит побитовое дополнение строки, у ссылки — сама строка. Координаты неотрицательные, поэтому знак свободен. С компактными заголовками объектов это убирает последнюю ссылку сверх 16 байт полей, и вхождение занимает 24 байта вместо 32; с обычными заголовками размер прежний.

Компоненты хранятся как short, но аксессоры startLine() и прочие расширяют их до int по контракту SymbolOccurrence.

  • Constructor Details

    • ShortBasedSymbolOccurrence

      public ShortBasedSymbolOccurrence(OccurrenceType occurrenceType, Symbol symbol, URI uri, short startLine, short startCharacter, short endLine, short endCharacter)
      Создать обращение по типу и координатам, укладывающимся в short.
      Parameters:
      occurrenceType - Тип обращения к символу.
      symbol - Символ, к которому происходит обращение.
      uri - URI файла.
      startLine - Строка начала обращения.
      startCharacter - Столбец начала обращения.
      endLine - Строка конца обращения.
      endCharacter - Столбец конца обращения.
    • ShortBasedSymbolOccurrence

      public ShortBasedSymbolOccurrence(Symbol symbol, URI uri, short typedStartLine, short startCharacterShort, short endLineShort, short endCharacterShort)
      Creates an instance of a ShortBasedSymbolOccurrence record class.
      Parameters:
      symbol - the value for the symbol record component
      uri - the value for the uri record component
      typedStartLine - the value for the typedStartLine record component
      startCharacterShort - the value for the startCharacterShort record component
      endLineShort - the value for the endLineShort record component
      endCharacterShort - the value for the endCharacterShort record component
  • Method Details

    • occurrenceType

      public OccurrenceType occurrenceType()
      Specified by:
      occurrenceType in interface SymbolOccurrence
      Returns:
      Тип обращения к символу.
    • startLine

      public int startLine()
      Specified by:
      startLine in interface SymbolOccurrence
      Returns:
      Строка начала обращения.
    • startCharacter

      public int startCharacter()
      Specified by:
      startCharacter in interface SymbolOccurrence
      Returns:
      Столбец начала обращения.
    • endLine

      public int endLine()
      Specified by:
      endLine in interface SymbolOccurrence
      Returns:
      Строка конца обращения.
    • endCharacter

      public int endCharacter()
      Specified by:
      endCharacter in interface SymbolOccurrence
      Returns:
      Столбец конца обращения.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • symbol

      public Symbol symbol()
      Returns the value of the symbol record component.
      Specified by:
      symbol in interface SymbolOccurrence
      Returns:
      the value of the symbol record component
    • uri

      public URI uri()
      Returns the value of the uri record component.
      Specified by:
      uri in interface SymbolOccurrence
      Returns:
      the value of the uri record component
    • typedStartLine

      public short typedStartLine()
      Returns the value of the typedStartLine record component.
      Returns:
      the value of the typedStartLine record component
    • startCharacterShort

      public short startCharacterShort()
      Returns the value of the startCharacterShort record component.
      Returns:
      the value of the startCharacterShort record component
    • endLineShort

      public short endLineShort()
      Returns the value of the endLineShort record component.
      Returns:
      the value of the endLineShort record component
    • endCharacterShort

      public short endCharacterShort()
      Returns the value of the endCharacterShort record component.
      Returns:
      the value of the endCharacterShort record component