Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface TextDocument

A text document, such as a file in a repository.

Hierarchy

  • TextDocument

Index

Properties

Readonly languageId

languageId: string

The language of the text document.

Readonly text

text: string | undefined

The text contents of the text document.

When using the Sourcegraph browser extension, the value is undefined because determining the text contents (in general) is not possible without additional access to the code host API. In the future, this limitation may be removed.

Readonly uri

uri: string

The URI of the text document.

Methods

getWordRangeAtPosition

  • Get the range of the word at the given position.

    The position will be adjusted using {@link TextDocument#validatePosition}.

    Parameters

    Returns Range | undefined

    A range spanning a word, or undefined.

offsetAt

  • Convert the position to a zero-based offset.

    The position will be adjusted using {@link TextDocument#validatePosition}.

    throws

    if {@link TextDocument#text} is undefined.

    Parameters

    Returns number

    A valid zero-based offset.

positionAt

  • Convert a zero-based offset to a position.

    throws

    if {@link TextDocument#text} is undefined.

    Parameters

    • offset: number

      A zero-based offset.

    Returns Position

    A valid Position.

validatePosition

  • Ensure a position is contained in the range of this document. If not, adjust it so that it is.

    throws

    if {@link TextDocument#text} is undefined.

    Parameters

    Returns Position

    The given position or a new, adjusted position.

validateRange

  • Ensure a range is completely contained in this document.

    throws

    if {@link TextDocument#text} is undefined.

    Parameters

    Returns Range

    The given range or a new, adjusted range.

Generated using TypeDoc