Document

in-memory representation of a file at any given URI. Not thread-safe.

Constructors

this
this(DocumentUri uri)

Creates a new D document at the given document URI, with version 0 and no text.

this
this(TextDocumentItem doc)

Creates a new document at the given document URI, with the given version and language and creates a copy of the text to use.

Members

Functions

applyChange
void applyChange(TextRange range, const(char)[] newContent)
bytesToOffset
size_t bytesToOffset(size_t bytes)

Converts a byte offset to an LSP offset.

bytesToPosition
Position bytesToPosition(size_t bytes)

Converts a byte offset to a line/column position.

clone
immutable(Document) clone()
Undocumented in source. Be warned that the author may not have intended to support it.
eolAt
EolType eolAt(int line)

Returns how a line is terminated at the given 0-based line number.

getLanguageId
string getLanguageId()
Undocumented in source. Be warned that the author may not have intended to support it.
length
size_t length()
lineAt
string lineAt(Position position)

Returns the text of a line at the given position.

lineAt
string lineAt(uint line)

Returns the text of a line starting at line 0.

lineAtScope
const(char)[] lineAtScope(Position position)

Returns the line text which is only in this scope if text isn't modified

lineAtScope
const(char)[] lineAtScope(uint line)

Returns the line text which is only in this scope if text isn't modified

lineByteRangeAt
size_t[2] lineByteRangeAt(uint line)

Returns a byte offset range as [start, end] of the given 0-based line number.

lineColumnBytesToPosition
Position lineColumnBytesToPosition(uint line, uint column)

Converts a line/column byte offset to a line/column position.

movePositionBytes
Position movePositionBytes(Position src, size_t start, size_t end)

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.

nextPositionBytes
Position nextPositionBytes(Position src, size_t start, size_t end)
Undocumented in source. Be warned that the author may not have intended to support it.
offsetToBytes
size_t offsetToBytes(size_t offset)

Converts an LSP offset to a byte offset for using for example in array slicing.

offsetToPosition
Position offsetToPosition(size_t offset)

Converts an LSP offset to a line/column position.

positionToBytes
size_t positionToBytes(Position position)

Converts a line/column position to a byte offset.

positionToOffset
size_t positionToOffset(Position position)

Converts a line/column position to an LSP offset.

rawText
const(char)[] rawText()

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.

rawText
string rawText()
Undocumented in source. Be warned that the author may not have intended to support it.
setContent
void setContent(const(char)[] newContent)

Sets the content of this document to the given content. Copies the data from newContent into this text buffer.

wordRangeAt
TextRange wordRangeAt(Position position)

Returns the word range at a given line/column position.

wordRangeAt
size_t[2] wordRangeAt(size_t bytes)

Returns the word range at a given byte position.

Static functions

nullDocument
Document nullDocument(const(char)[] content)

Creates a document with no URI and no language ID and copies the content into the text buffer using setContent.

Variables

languageId
string languageId;

The language ID as reported by the client. Should not be changed.

uri
DocumentUri uri;

The URI of this document. Should not be changed.

version_
long version_;

The document version as reported by the client. Should not be changed.

Meta