Represents a text document, such as a source file. Text documents have {@link TextLine lines} and knowledge about an underlying resource like a file.
Represents a text document, such as a source file. Text documents have {@link TextLine lines} and knowledge about an underlying resource like a file.
(closed? text-document)
true
if the document has been closed. A closed document isn't synchronized anymore
and won't be re-used when the same resource is opened again.
`true` if the document has been closed. A closed document isn't synchronized anymore and won't be re-used when the same resource is opened again.
(dirty? text-document)
true
if there are unpersisted changes.
`true` if there are unpersisted changes.
(eol text-document)
The {@link EndOfLine end of line} sequence that is predominately used in this document.
The {@link EndOfLine end of line} sequence that is predominately used in this document.
(file-name text-document)
The file system path of the associated resource. Shorthand notation for {@link TextDocument.uri TextDocument.uri.fsPath}. Independent of the uri scheme.
The file system path of the associated resource. Shorthand notation for {@link TextDocument.uri TextDocument.uri.fsPath}. Independent of the uri scheme.
(language-id text-document)
The identifier of the language associated with this document.
The identifier of the language associated with this document.
(line-at text-document line)
(line-at text-document position)
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. 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 {@link TextDocument.validatePosition adjusted}.
Parameters:
line
: number
- A line number in [0, lineCount).position
: Position
- A position.Returns: TextLine
- A {@link TextLineline}.
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. 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 {@link TextDocument.validatePosition adjusted}. **Parameters:** - `line`: `number` - A line number in [0, lineCount). - `position`: `Position` - A position. **Returns:** `TextLine` - A {@link TextLineline}.
(line-count text-document)
The number of lines in this document.
The number of lines in this document.
(offset-at text-document position)
Converts the position to a zero-based offset.
The position will be {@link TextDocument.validatePosition adjusted}.
Parameters:
position
: Position
- A position.Returns: number
- A valid zero-based offset.
Converts the position to a zero-based offset. The position will be {@link TextDocument.validatePosition adjusted}. **Parameters:** - `position`: `Position` - A position. **Returns:** `number` - A valid zero-based offset.
(position-at text-document offset)
Converts a zero-based offset to a position.
Parameters:
offset
: number
- A zero-based offset.Returns: Position
- A valid {@link Position}.
Converts a zero-based offset to a position. **Parameters:** - `offset`: `number` - A zero-based offset. **Returns:** `Position` - A valid {@link Position}.
(save text-document)
Save the underlying file.
Returns: Thenable<boolean>
- A promise that will resolve to true
when the file
has been saved. If the save failed, will return false
.
Save the underlying file. **Returns:** `Thenable<boolean>` - A promise that will resolve to `true` when the file has been saved. If the save failed, will return `false`.
(text text-document)
(text text-document range)
Get the text of this document. A substring can be retrieved by providing a range. The range will be {@link TextDocument.validateRange adjusted}.
Parameters:
range
: Range | undefined
- Include only the text included by the range.Returns: string
- The text inside the provided range or the entire text.
Get the text of this document. A substring can be retrieved by providing a range. The range will be {@link TextDocument.validateRange adjusted}. **Parameters:** - `range`: `Range | undefined` - Include only the text included by the range. **Returns:** `string` - The text inside the provided range or the entire text.
(untitled? text-document)
Is this document representing an untitled file which has never been saved yet. Note that
this does not mean the document will be saved to disk, use {@linkcode Uri.scheme }
to figure out where a document will be {@link FileSystemProvider saved}, e.g. file
, ftp
etc.
Is this document representing an untitled file which has never been saved yet. *Note* that this does not mean the document will be saved to disk, use {@linkcode Uri.scheme } to figure out where a document will be {@link FileSystemProvider saved}, e.g. `file`, `ftp` etc.
(uri text-document)
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.
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.
(validate-position text-document position)
Ensure a position is contained in the range of this document.
Parameters:
position
: Position
- A position.Returns: Position
- The given position or a new, adjusted position.
Ensure a position is contained in the range of this document. **Parameters:** - `position`: `Position` - A position. **Returns:** `Position` - The given position or a new, adjusted position.
(validate-range text-document range)
Ensure a range is completely contained in this document.
Parameters:
range
: Range
- A range.Returns: Range
- The given range or a new, adjusted range.
Ensure a range is completely contained in this document. **Parameters:** - `range`: `Range` - A range. **Returns:** `Range` - The given range or a new, adjusted range.
(version text-document)
The version number of this document (it will strictly increase after each change, including undo/redo).
The version number of this document (it will strictly increase after each change, including undo/redo).
(word-range-at-position text-document position)
(word-range-at-position text-document position regex)
Get a word-range at the given position. By default words are defined by common separators, like space, -, _, etc. In addition, per language custom [word definitions] can be defined. It is also possible to provide a custom regular expression.
The position will be {@link TextDocument.validatePosition adjusted}.
Parameters:
position
: Position
- A position.regex
: RegExp | undefined
- Optional regular expression that describes what a word is.Returns: Range | undefined
- A range spanning a word, or undefined
.
Get a word-range at the given position. By default words are defined by common separators, like space, -, _, etc. In addition, per language custom [word definitions] can be defined. It is also possible to provide a custom regular expression. * *Note 1:* A custom regular expression must not match the empty string and if it does, it will be ignored. * *Note 2:* A custom regular expression will fail to match multiline strings and in the name of speed regular expressions should not match words with spaces. Use {@linkcode TextLine.text } for more complex, non-wordy, scenarios. The position will be {@link TextDocument.validatePosition adjusted}. **Parameters:** - `position`: `Position` - A position. - `regex`: `RegExp | undefined` - Optional regular expression that describes what a word is. **Returns:** `Range | undefined` - A range spanning a word, or `undefined`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close