Creates a new document at the given document URI, with version 0 and no text and guessed language ID. See getLanguageId
Creates a new document at the given document URI, with the given version and language and creates a copy of the text to use.
Converts a byte offset to an LSP offset.
Converts a byte offset to a line/column position.
Returns a copy of this document with the text memory duplicated. May safely be cast to immutable.
Returns how a line is terminated at the given 0-based line number. Defaults to LF for the last line / no line terminator.
Returns the language ID or guesses it given the filename's extension. Returns null if none is set and can't be guessed.
Returns the text length.
Returns the text of a line at the given position.
Returns the text of a line starting at line 0.
Returns the line text at the given position. The memory content may be modified by the setContent method by other code in the same context or in a different context.
Returns a byte offset range as [start, end] of the given 0-based line number. Contains the line terminator, if it exists.
Converts a line/column byte offset to a line/column position.
Returns the position at "end" starting from the given "src" position which is assumed to be at byte "start" Faster to quickly calculate nearby positions of known byte positions. Falls back to bytesToPosition if end is before start.
Calls movePositionBytes, updates src to be the return value and updates start to become end. This reduces boilerplate in common calling scenarios.
Converts an LSP offset to a byte offset for using for example in array slicing.
Converts an LSP offset to a line/column position.
Converts a line/column position to a byte offset.
Converts a line/column position to an LSP offset.
Returns a read-only view of the text. The text may however be changed by other operations, so this slice should be used directly and not after any context yield or API call potentially modifying the data.
Sets the content of this document to the given content. Copies the data from newContent into this text buffer.
Returns the word range at a given line/column position.
Returns the word range at a given byte position.
Creates a document with no URI and no language ID and copies the content into the text buffer using setContent.
The language ID as reported by the client. Should not be changed.
The URI of this document. Should not be changed.
The document version as reported by the client. Should not be changed.
in-memory representation of a file at any given URI. Not thread-safe.