2 * A tagging type for string properties that are actually URIs.
4 export declare type DocumentUri = string;
6 * Position in a text document expressed as zero-based line and character offset.
7 * The offsets are based on a UTF-16 string representation. So a string of the form
8 * `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`
9 * is 1 and the character offset of b is 3 since `𐐀` is represented using two code
12 * Positions are line end character agnostic. So you can not specify a position that
13 * denotes `\r|\n` or `\n|` where `|` represents the character offset.
15 export interface Position {
17 * Line position in a document (zero-based).
18 * If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.
19 * If a line number is negative, it defaults to 0.
23 * Character offset on a line in a document (zero-based). Assuming that the line is
24 * represented as a string, the `character` value represents the gap between the
25 * `character` and `character + 1`.
27 * If the character value is greater than the line length it defaults back to the
29 * If a line number is negative, it defaults to 0.
34 * A range in a text document expressed as (zero-based) start and end positions.
36 * If you want to specify a range that contains a line including the line ending
37 * character(s) then use an end position denoting the start of the next line.
41 * start: { line: 5, character: 23 }
42 * end : { line 6, character : 0 }
46 export interface Range {
48 * The range's start position
52 * The range's end position.
57 * A text edit applicable to a text document.
59 export interface TextEdit {
61 * The range of the text document to be manipulated. To insert
62 * text into a document create a range where start === end.
66 * The string to be inserted. For delete operations use an
72 * An event describing a change to a text document. If range and rangeLength are omitted
73 * the new text is considered to be the full content of the document.
75 export declare type TextDocumentContentChangeEvent = {
77 * The range of the document that changed.
81 * The optional length of the range that got replaced.
83 * @deprecated use range instead.
87 * The new text for the provided range.
92 * The new text of the whole document.
97 * A simple text document. Not to be implemented. The document keeps the content
100 export interface TextDocument {
102 * The associated URI for this document. Most documents have the __file__-scheme, indicating that they
103 * represent files on disk. However, some documents may have other schemes indicating that they are not
108 readonly uri: DocumentUri;
110 * The identifier of the language associated with this document.
114 readonly languageId: string;
116 * The version number of this document (it will increase after each
117 * change, including undo/redo).
121 readonly version: number;
123 * Get the text of this document. A substring can be retrieved by
126 * @param range (optional) An range within the document to return.
127 * If no range is passed, the full content is returned.
128 * Invalid range positions are adjusted as described in [Position.line](#Position.line)
129 * and [Position.character](#Position.character).
130 * If the start range position is greater than the end range position,
131 * then the effect of getText is as if the two positions were swapped.
133 * @return The text of this document or a substring of the text if a
136 getText(range?: Range): string;
138 * Converts a zero-based offset to a position.
140 * @param offset A zero-based offset.
141 * @return A valid [position](#Position).
143 positionAt(offset: number): Position;
145 * Converts the position to a zero-based offset.
146 * Invalid positions are adjusted as described in [Position.line](#Position.line)
147 * and [Position.character](#Position.character).
149 * @param position A position.
150 * @return A valid zero-based offset.
152 offsetAt(position: Position): number;
154 * The number of lines in this document.
158 readonly lineCount: number;
160 export declare namespace TextDocument {
162 * Creates a new text document.
164 * @param uri The document's uri.
165 * @param languageId The document's language Id.
166 * @param version The document's initial version number.
167 * @param content The document's content.
169 function create(uri: DocumentUri, languageId: string, version: number, content: string): TextDocument;
171 * Updates a TextDocument by modifying its content.
173 * @param document the document to update. Only documents created by TextDocument.create are valid inputs.
174 * @param changes the changes to apply to the document.
175 * @param version the changes version for the document.
176 * @returns The updated TextDocument. Note: That's the same document instance passed in as first parameter.
179 function update(document: TextDocument, changes: TextDocumentContentChangeEvent[], version: number): TextDocument;
180 function applyEdits(document: TextDocument, edits: TextEdit[]): string;