123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- /**
- * A tagging type for string properties that are actually URIs.
- */
- export declare type DocumentUri = string;
- /**
- * Position in a text document expressed as zero-based line and character offset.
- * The offsets are based on a UTF-16 string representation. So a string of the form
- * `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`
- * is 1 and the character offset of b is 3 since `𐐀` is represented using two code
- * units in UTF-16.
- *
- * Positions are line end character agnostic. So you can not specify a position that
- * denotes `\r|\n` or `\n|` where `|` represents the character offset.
- */
- export interface Position {
- /**
- * Line position in a document (zero-based).
- * 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.
- * If a line number is negative, it defaults to 0.
- */
- line: number;
- /**
- * Character offset on a line in a document (zero-based). Assuming that the line is
- * represented as a string, the `character` value represents the gap between the
- * `character` and `character + 1`.
- *
- * If the character value is greater than the line length it defaults back to the
- * line length.
- * If a line number is negative, it defaults to 0.
- */
- character: number;
- }
- /**
- * A range in a text document expressed as (zero-based) start and end positions.
- *
- * If you want to specify a range that contains a line including the line ending
- * character(s) then use an end position denoting the start of the next line.
- * For example:
- * ```ts
- * {
- * start: { line: 5, character: 23 }
- * end : { line 6, character : 0 }
- * }
- * ```
- */
- export interface Range {
- /**
- * The range's start position
- */
- start: Position;
- /**
- * The range's end position.
- */
- end: Position;
- }
- /**
- * A text edit applicable to a text document.
- */
- export interface TextEdit {
- /**
- * The range of the text document to be manipulated. To insert
- * text into a document create a range where start === end.
- */
- range: Range;
- /**
- * The string to be inserted. For delete operations use an
- * empty string.
- */
- newText: string;
- }
- /**
- * An event describing a change to a text document. If range and rangeLength are omitted
- * the new text is considered to be the full content of the document.
- */
- export declare type TextDocumentContentChangeEvent = {
- /**
- * The range of the document that changed.
- */
- range: Range;
- /**
- * The optional length of the range that got replaced.
- *
- * @deprecated use range instead.
- */
- rangeLength?: number;
- /**
- * The new text for the provided range.
- */
- text: string;
- } | {
- /**
- * The new text of the whole document.
- */
- text: string;
- };
- /**
- * A simple text document. Not to be implemented. The document keeps the content
- * as string.
- */
- export interface TextDocument {
- /**
- * The associated URI for this document. Most documents have the __file__-scheme, indicating that they
- * represent files on disk. However, some documents may have other schemes indicating that they are not
- * available on disk.
- *
- * @readonly
- */
- readonly uri: DocumentUri;
- /**
- * The identifier of the language associated with this document.
- *
- * @readonly
- */
- readonly languageId: string;
- /**
- * The version number of this document (it will increase after each
- * change, including undo/redo).
- *
- * @readonly
- */
- readonly version: number;
- /**
- * Get the text of this document. A substring can be retrieved by
- * providing a range.
- *
- * @param range (optional) An range within the document to return.
- * If no range is passed, the full content is returned.
- * Invalid range positions are adjusted as described in [Position.line](#Position.line)
- * and [Position.character](#Position.character).
- * If the start range position is greater than the end range position,
- * then the effect of getText is as if the two positions were swapped.
- * @return The text of this document or a substring of the text if a
- * range is provided.
- */
- getText(range?: Range): string;
- /**
- * Converts a zero-based offset to a position.
- *
- * @param offset A zero-based offset.
- * @return A valid [position](#Position).
- */
- positionAt(offset: number): Position;
- /**
- * Converts the position to a zero-based offset.
- * Invalid positions are adjusted as described in [Position.line](#Position.line)
- * and [Position.character](#Position.character).
- *
- * @param position A position.
- * @return A valid zero-based offset.
- */
- offsetAt(position: Position): number;
- /**
- * The number of lines in this document.
- *
- * @readonly
- */
- readonly lineCount: number;
- }
- export declare namespace TextDocument {
- /**
- * Creates a new text document.
- *
- * @param uri The document's uri.
- * @param languageId The document's language Id.
- * @param version The document's initial version number.
- * @param content The document's content.
- */
- function create(uri: DocumentUri, languageId: string, version: number, content: string): TextDocument;
- /**
- * Updates a TextDocument by modifing its content.
- *
- * @param document the document to update. Only documents created by TextDocument.create are valid inputs.
- * @param changes the changes to apply to the document.
- * @returns The updated TextDocument. Note: That's the same document instance passed in as first parameter.
- *
- */
- function update(document: TextDocument, changes: TextDocumentContentChangeEvent[], version: number): TextDocument;
- function applyEdits(document: TextDocument, edits: TextEdit[]): string;
- }
|