Class: LSP::Position

Inherits:
LSPBase show all
Defined in:
lib/lsp/lsp_types.rb

Overview

export interface Position

/**
 * Line position in a document (zero-based).
 * If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.
 * If a line number is negative, it defaults to 0.
 */
line: number;
/**
 * Character offset on a line in a document (zero-based). Assuming that the line is
 * represented as a string, the `character` value represents the gap between the
 * `character` and `character + 1`.
 *
 * If the character value is greater than the line length it defaults back to the
 * line length.
 * If a line number is negative, it defaults to 0.
 */
character: number;

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LSPBase

#initialize, #to_h, #to_json

Constructor Details

This class inherits a constructor from LSP::LSPBase

Instance Attribute Details

#characterObject

type: number # type: number



30
31
32
# File 'lib/lsp/lsp_types.rb', line 30

def character
  @character
end

#lineObject

type: number # type: number



30
31
32
# File 'lib/lsp/lsp_types.rb', line 30

def line
  @line
end

Instance Method Details

#from_h!(value) ⇒ Object



32
33
34
35
36
37
# File 'lib/lsp/lsp_types.rb', line 32

def from_h!(value)
  value = {} if value.nil?
  self.line = value['line']
  self.character = value['character']
  self
end