Langium - v4.3.0
    Preparing search index...

    Interface TextDocument

    A simple text document. Not to be implemented. The document keeps the content as string.

    interface TextDocument {
        languageId: string;
        lineCount: number;
        uri: string;
        version: number;
        getEOLCharacters(line: number): string;
        getLineRange(line: number): Range;
        getText(range?: Range): string;
        offsetAt(position: Position): number;
        positionAt(offset: number): Position;
    }
    Index

    Properties

    languageId: string

    The identifier of the language associated with this document.

    lineCount: number

    The number of lines in this document.

    uri: string

    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.

    version: number

    The version number of this document (it will increase after each change, including undo/redo).

    Methods

    • Gets the end of line character(s) for a line.

      Parameters

      • line: number

        the line number.

      Returns string

      The end of line character(s) for the line. The result will be an empty string if the line number is out of bounds.

    • Gets the range of the entire line, without any newline characters.

      Parameters

      • line: number

        the line number.

      Returns Range

      A range covering the entire line. The range will be valid even if the line number is out of bounds. The range will contain a start and end position that are equal if the line is empty or the line number is negative. If the line number is greater than the number of lines in the document, the range will cover the remaining text after the last line.

    • Get the text of this document. A substring can be retrieved by providing a range.

      Parameters

      • Optionalrange: 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 and 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.

      Returns string

      The text of this document or a substring of the text if a range is provided.

    • Converts the position to a zero-based offset. Invalid positions are adjusted as described in Position.line and Position.character.

      Parameters

      • position: Position

        A position.

      Returns number

      A valid zero-based offset.

    • Converts a zero-based offset to a position.

      Parameters

      • offset: number

        A zero-based offset.

      Returns Position

      A valid Position position.

      The text document "ab\ncd" produces:
      * position { line: 0, character: 0 } for `offset` 0.
      * position { line: 0, character: 1 } for `offset` 1.
      * position { line: 0, character: 2 } for `offset` 2.
      * position { line: 1, character: 0 } for `offset` 3.
      * position { line: 1, character: 1 } for `offset` 4.