Class: LSP::TextDocument

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

Overview

export interface TextDocument

/**
 * The associated URI for this document. Most documents have the __file__-scheme, indicating that they
 * represent files on disk. However, some documents may have other schemes indicating that they are not
 * available on disk.
 *
 * @readonly
 */
readonly uri: DocumentUri;
/**
 * The identifier of the language associated with this document.
 *
 * @readonly
 */
readonly languageId: string;
/**
 * The version number of this document (it will increase after each
 * change, including undo/redo).
 *
 * @readonly
 */
readonly version: number;
/**
 * Get the text of this document. A substring can be retrieved by
 * providing a range.
 *
 * @param range (optional) An range within the document to return.
 * If no range is passed, the full content is returned.
 * Invalid range positions are adjusted as described in [Position.line](#Position.line)
 * and [Position.character](#Position.character).
 * If the start range position is greater than the end range position,
 * then the effect of getText is as if the two positions were swapped.

 * @return The text of this document or a substring of the text if a
 *         range is provided.
 */
getText(range?: Range): string;
/**
 * Converts a zero-based offset to a position.
 *
 * @param offset A zero-based offset.
 * @return A valid [position](#Position).
 */
positionAt(offset: number): Position;
/**
 * Converts the position to a zero-based offset.
 * Invalid positions are adjusted as described in [Position.line](#Position.line)
 * and [Position.character](#Position.character).
 *
 * @param position A position.
 * @return A valid zero-based offset.
 */
offsetAt(position: Position): number;
/**
 * The number of lines in this document.
 *
 * @readonly
 */
readonly lineCount: 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

#languageIdObject

type: DocumentUri # type: string # type: number # type: number



1481
1482
1483
# File 'lib/lsp/lsp_types.rb', line 1481

def languageId
  @languageId
end

#lineCountObject

type: DocumentUri # type: string # type: number # type: number



1481
1482
1483
# File 'lib/lsp/lsp_types.rb', line 1481

def lineCount
  @lineCount
end

#uriObject

type: DocumentUri # type: string # type: number # type: number



1481
1482
1483
# File 'lib/lsp/lsp_types.rb', line 1481

def uri
  @uri
end

#versionObject

type: DocumentUri # type: string # type: number # type: number



1481
1482
1483
# File 'lib/lsp/lsp_types.rb', line 1481

def version
  @version
end

Instance Method Details

#from_h!(value) ⇒ Object



1483
1484
1485
1486
1487
1488
1489
1490
# File 'lib/lsp/lsp_types.rb', line 1483

def from_h!(value)
  value = {} if value.nil?
  self.uri = value['uri'] # Unknown type
  self.languageId = value['languageId']
  self.version = value['version']
  self.lineCount = value['lineCount']
  self
end