feat: Command、TextLine、TextDocument

youngjuning-patch-1
youngjuning 2 years ago
parent 8374d258e1
commit 5f7ad41ec5

@ -8,10 +8,6 @@ API 列表使用 Typedoc 从 [vscode.d.ts](https://github.com/youngjuning/vscode
## 贡献指南
- [专业术语](https://github.com/vscode-cn/vscode-api-cn/issues/27)
### 成为译者
*vscode.d.ts* 文件的注释进行翻译,然后提交 PR 即可。
### 本地预览

331
vscode.d.ts vendored

@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENCE in the project root for license information.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module vscode {
@ -9,185 +9,162 @@ declare module vscode {
*/
export const version: string;
/**
* UI
*
*
* Represents a reference to a command. Provides a title which
* will be used to represent a command in the UI and, optionally,
* an array of arguments which will be passed to the command handler
* function when invoked.
/**
* UI
*
*
* @maintainer {@link https://github.com/youngjuning @youngjuning}
*/
* @maintainer {@link https://youngjuning.js.org @youngjuning}
*/
export interface Command {
/**
* `save`
*
* Title of the command, like `save`.
*/
/**
* `save`
*/
title: string;
/**
*
*
* The identifier of the actual command handler.
*
* @see {@link commands.registerCommand}
*/
/**
*
* @see {@link commands.registerCommand}
*/
command: string;
/**
* UI
*
* A tooltip for the command, when represented in the UI.
*/
tooltip?: string;
/**
*
*
* Arguments that the command handler should be
* invoked with.
*/
arguments?: any[];
}
/**
* Represents a line of text, such as a line of source code.
*
* TextLine objects are __immutable__. When a {@link TextDocument document} changes,
* previously retrieved lines will not represent the latest state.
*/
/**
*
*
* TextLine __immutable__ {@link TextDocument document}
*
*
* @maintainer {@link https://youngjuning.js.org @youngjuning}
*/
export interface TextLine {
/**
* The zero-based line number.
*/
/**
* 0
*/
readonly lineNumber: number;
/**
* The text of this line without the line separator characters.
*/
/**
*
*/
readonly text: string;
/**
* The range this line covers without the line separator characters.
*/
/**
*
*/
readonly range: Range;
/**
* The range this line covers with the line separator characters.
*/
/**
*
*/
readonly rangeIncludingLineBreak: Range;
/**
* The offset of the first character which is not a whitespace character as defined
* by `/\s/`. **Note** that if a line is all whitespace the length of the line is returned.
*/
/**
* `/\s/`
*/
readonly firstNonWhitespaceCharacterIndex: number;
/**
* Whether this line is whitespace only, shorthand
* for {@link TextLine.firstNonWhitespaceCharacterIndex} === {@link TextLine.text TextLine.text.length}.
*/
/**
* `/\s/`
* {@link TextLine.firstNonWhitespaceCharacterIndex} === {@link TextLine.text TextLine.text.length}
*/
readonly isEmptyOrWhitespace: boolean;
}
/**
* Represents a text document, such as a source file. Text documents have
* {@link TextLine lines} and knowledge about an underlying resource like a file.
*/
/**
* {@link TextLine lines}
*
* @maintainer {@link https://youngjuning.js.org @youngjuning}
*/
export interface TextDocument {
/**
* 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.
*
* @see {@link FileSystemProvider}
* @see {@link TextDocumentContentProvider}
*/
/**
* uri
*
* ** 使 `file`-scheme****
* 访 `scheme`
*
* @see {@link FileSystemProvider}
* @see {@link TextDocumentContentProvider}
*/
readonly uri: Uri;
/**
* The file system path of the associated resource. Shorthand
* notation for {@link TextDocument.uri TextDocument.uri.fsPath}. Independent of the uri scheme.
*/
/**
* {@link TextDocument.uri TextDocument.uri.fsPath}
* uri scheme
*/
readonly fileName: string;
/**
* 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.
*/
/**
* **
* 使 {@linkcode Uri.scheme} {@link FileSystemProvider saved} `file``ftp`
*/
readonly isUntitled: boolean;
/**
* The identifier of the language associated with this document.
*/
/**
*
*/
readonly languageId: string;
/**
* The version number of this document (it will strictly increase after each
* change, including undo/redo).
*/
/**
* /
*/
readonly version: number;
/**
* `true` if there are unpersisted changes.
*/
/**
* `true`
*/
readonly isDirty: boolean;
/**
* `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`
*/
readonly isClosed: boolean;
/**
* Save the underlying file.
*
* @return A promise that will resolve to true when the file
* has been saved. If the file was not dirty or the save failed,
* will return false.
*/
/**
*
*
* @return promise resolve `true` `false`
*/
save(): Thenable<boolean>;
/**
* The {@link EndOfLine end of line} sequence that is predominately
* used in this document.
*/
/**
* 使 {@link EndOfLine end of line}
*/
readonly eol: EndOfLine;
/**
* The number of lines in this document.
*/
/**
*
*/
readonly lineCount: number;
/**
* 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.
*
* @param line A line number in [0, lineCount).
* @return A {@link TextLine line}.
*/
/**
* **
*
* @param line [0, lineCount)
* @return {@link TextLine line}
*/
lineAt(line: number): TextLine;
/**
* 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}.
*
* @see {@link TextDocument.lineAt}
*
* @param position A position.
* @return A {@link TextLine line}.
*/
/**
* **
*
* {@link TextDocument.validatePosition adjusted}
*
* @see {@link TextDocument.lineAt}
*
* @param position
* @return {@link TextLine line}
*/
lineAt(position: Position): TextLine;
/**
@ -198,70 +175,69 @@ declare module vscode {
* @param position A position.
* @return A valid zero-based offset.
*/
/**
* 0
*
* {@link TextDocument.validatePosition adjusted}
*
* @param position
* @return 0
*/
offsetAt(position: Position): number;
/**
* Converts a zero-based offset to a position.
*
* @param offset A zero-based offset.
* @return A valid {@link Position}.
*/
/**
* 0
*
* @param offset 0
* @return {@link Position}
*/
positionAt(offset: number): Position;
/**
* Get the text of this document. A substring can be retrieved by providing
* a range. The range will be {@link TextDocument.validateRange adjusted}.
*
* @param range Include only the text included by the range.
* @return The text inside the provided range or the entire text.
*/
/**
* {@link TextDocument.validateRange adjusted}
*/
getText(range?: Range): string;
/**
* 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}.
*
* @param position A position.
* @param regex Optional regular expression that describes what a word is.
* @return A range spanning a word, or `undefined`.
*/
/**
* -_
* []
*
* * * 1:*
*
* * * 2:* 使 {@linkcode TextLine.text}
*
* {@link TextDocument.validatePosition adjusted}
*
* @param position
* @param regex
* @return `undefined`
*/
getWordRangeAtPosition(position: Position, regex?: RegExp): Range | undefined;
/**
* Ensure a range is completely contained in this document.
*
* @param range A range.
* @return The given range or a new, adjusted range.
*/
/**
*
*
* @param range
* @return
*/
validateRange(range: Range): Range;
/**
* Ensure a position is contained in the range of this document.
*
* @param position A position.
* @return The given position or a new, adjusted position.
*/
/**
*
*
* @param position
* @return
*/
validatePosition(position: Position): Position;
}
/**
* Represents a line and character position, such as
* the position of the cursor.
*
* Position objects are __immutable__. Use the {@link Position.with with} or
* {@link Position.translate translate} methods to derive new positions
* from an existing position.
*/
/**
*
*
* Position 使 {@link Position.with with} {@link Position.translate translate}
*
* @maintainer {@link https://youngjuning.js.org @youngjuning}
*/
export class Position {
/**
@ -381,6 +357,11 @@ declare module vscode {
* {@link Range.intersection intersection}, or {@link Range.union union} methods
* to derive new ranges from an existing range.
*/
/**
*
*
* 使 {@link Range.with with} {@link Range.intersection intersection}{@link Range.union union}
*/
export class Range {
/**

Loading…
Cancel
Save