Record Class LspPosition
java.lang.Object
java.lang.Record
smile.util.lsp.LspPosition
- Record Components:
line- the 1-based line number (first line = 1).character- the 1-based character offset (first column = 1).
A 1-based position inside a text document, as displayed in editors.
The LSP specification uses 0-based lines and characters internally.
This record stores the editor-friendly 1-based values and provides
toLspLine() / toLspCharacter() helpers for conversion.
-
Constructor Summary
ConstructorsConstructorDescriptionLspPosition(int line, int character) Validates that both coordinates are positive (≥ 1). -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecharacterrecord component.final booleanIndicates whether some other object is "equal to" this one.static LspPositionfromProtocol(org.eclipse.lsp4j.Position pos) Creates anLspPositionfrom an LSP4JPosition(0-based) by adding 1 to both coordinates.final inthashCode()Returns a hash code value for this object.intline()Returns the value of thelinerecord component.intReturns the 0-based character offset required by the LSP specification.intReturns the 0-based line index required by the LSP specification.org.eclipse.lsp4j.PositionConverts this position to the LSP4JPosition.toString()Returns a string representation of this record class.
-
Constructor Details
-
LspPosition
public LspPosition(int line, int character) Validates that both coordinates are positive (≥ 1).
-
-
Method Details
-
toLspLine
public int toLspLine()Returns the 0-based line index required by the LSP specification.- Returns:
line - 1.
-
toLspCharacter
public int toLspCharacter()Returns the 0-based character offset required by the LSP specification.- Returns:
character - 1.
-
toProtocol
public org.eclipse.lsp4j.Position toProtocol()Converts this position to the LSP4JPosition.- Returns:
- a new LSP4J
Positionwith 0-based coordinates.
-
fromProtocol
Creates anLspPositionfrom an LSP4JPosition(0-based) by adding 1 to both coordinates.- Parameters:
pos- the 0-based LSP4J position.- Returns:
- the equivalent 1-based position.
-
toString
-
hashCode
-
equals
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. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
line
-
character
-