Interface: TextDocument
libs/common/types/TextDocument.TextDocument
Implemented by
Properties
languageId
• Readonly
languageId: string
The identifier of the language associated with this document.
Defined in
libs/common/types/TextDocument.ts:16
lineCount
• Readonly
lineCount: number
The number of lines in this document.
Defined in
libs/common/types/TextDocument.ts:27
range
• Readonly
range: Range
The range of the text document.
Defined in
libs/common/types/TextDocument.ts:32
uri
• Readonly
uri: URI
The associated uri for this document.
Note that most documents use the file
-scheme, which means they are files on disk. However, not all documents are
saved on disk and therefore the scheme
must be checked before trying to access the underlying file or siblings on disk.
Defined in
libs/common/types/TextDocument.ts:11
version
• Readonly
version: number
The version number of this document (it will strictly increase after each change, including undo/redo).
Defined in
libs/common/types/TextDocument.ts:22
Methods
getText
▸ getText(range?
): string
Get the text of this document. A substring can be retrieved by providing a range.
The range will be adjusted if it extends outside TextDocument.range.
Parameters
Name | Type | Description |
---|---|---|
range? | Range | Include only the text included by the range. |
Returns
string
The text inside the provided range or the entire text.
Defined in
libs/common/types/TextDocument.ts:85
lineAt
▸ lineAt(line
): TextLine
Returns a text line denoted by the line number. Note that the returned object is not live and changes to the document are not reflected.
Parameters
Name | Type | Description |
---|---|---|
line | number | A line number in [0, lineCount). |
Returns
A line.
Defined in
libs/common/types/TextDocument.ts:42
▸ lineAt(position
): TextLine
Returns a text line denoted by the position. Note that the returned object is not live and changes to the document are not reflected.
The position will be adjusted if it is outside range.
Parameters
Name | Type | Description |
---|---|---|
position | Position | A position. |
Returns
A line.
Defined in
libs/common/types/TextDocument.ts:56
offsetAt
▸ offsetAt(position
): number
Converts the position to a zero-based offset.
The position will be adjusted if it is outside range.
Parameters
Name | Type | Description |
---|---|---|
position | Position | A position. |
Returns
number
A valid zero-based offset.
Defined in
libs/common/types/TextDocument.ts:66
positionAt
▸ positionAt(offset
): Position
Converts a zero-based offset to a position.
Parameters
Name | Type | Description |
---|---|---|
offset | number | A zero-based offset. |
Returns
A valid Position.
Defined in
libs/common/types/TextDocument.ts:74