提交 7c66baa9 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #18251 from Ikuyadeu/re_use_readonly

Re use readonly #12732 #13863
......@@ -45,47 +45,35 @@ declare module 'vscode' {
/**
* The zero-based line number.
*
* @readonly
*/
lineNumber: number;
readonly lineNumber: number;
/**
* The text of this line without the line separator characters.
*
* @readonly
*/
text: string;
readonly text: string;
/**
* The range this line covers without the line separator characters.
*
* @readonly
*/
range: Range;
readonly range: Range;
/**
* The range this line covers with the line separator characters.
*
* @readonly
*/
rangeIncludingLineBreak: Range;
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 whitespaces the length of the line is returned.
*
* @readonly
*/
firstNonWhitespaceCharacterIndex: number;
readonly firstNonWhitespaceCharacterIndex: number;
/**
* Whether this line is whitespace only, shorthand
* for [TextLine.firstNonWhitespaceCharacterIndex](#TextLine.firstNonWhitespaceCharacterIndex) === [TextLine.text.length](#TextLine.text).
*
* @readonly
*/
isEmptyOrWhitespace: boolean;
readonly isEmptyOrWhitespace: boolean;
}
/**
......@@ -98,47 +86,35 @@ declare module 'vscode' {
* 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
*/
uri: Uri;
readonly uri: Uri;
/**
* The file system path of the associated resource. Shorthand
* notation for [TextDocument.uri.fsPath](#TextDocument.uri). Independent of the uri scheme.
*
* @readonly
*/
fileName: string;
readonly fileName: string;
/**
* Is this document representing an untitled file.
*
* @readonly
*/
isUntitled: boolean;
readonly isUntitled: boolean;
/**
* The identifier of the language associated with this document.
*
* @readonly
*/
languageId: string;
readonly languageId: string;
/**
* The version number of this document (it will strictly increase after each
* change, including undo/redo).
*
* @readonly
*/
version: number;
readonly version: number;
/**
* true if there are unpersisted changes.
*
* @readonly
*/
isDirty: boolean;
readonly isDirty: boolean;
/**
* Save the underlying file.
......@@ -151,10 +127,8 @@ declare module 'vscode' {
/**
* The number of lines in this document.
*
* @readonly
*/
lineCount: number;
readonly lineCount: number;
/**
* Returns a text line denoted by the line number. Note
......@@ -249,15 +223,13 @@ declare module 'vscode' {
/**
* The zero-based line value.
* @readonly
*/
line: number;
readonly line: number;
/**
* The zero-based character value.
* @readonly
*/
character: number;
readonly character: number;
/**
* @param line A zero-based line value.
......@@ -370,15 +342,13 @@ declare module 'vscode' {
/**
* The start position. It is before or equal to [end](#Range.end).
* @readonly
*/
start: Position;
readonly start: Position;
/**
* The end position. It is after or equal to [start](#Range.start).
* @readonly
*/
end: Position;
readonly end: Position;
/**
* Create a new range from two positions. If `start` is not
......@@ -656,9 +626,8 @@ declare module 'vscode' {
/**
* Internal representation of the handle.
* @readonly
*/
key: string;
readonly key: string;
/**
* Remove this decoration type and all decorations on all text editors using it.
......@@ -1542,10 +1511,8 @@ declare module 'vscode' {
/**
* An array of diagnostics.
*
* @readonly
*/
diagnostics: Diagnostic[];
readonly diagnostics: Diagnostic[];
}
/**
......@@ -1593,10 +1560,8 @@ declare module 'vscode' {
/**
* `true` when there is a command associated.
*
* @readonly
*/
isResolved: boolean;
readonly isResolved: boolean;
/**
* Creates a new code lens object.
......@@ -2004,10 +1969,8 @@ declare module 'vscode' {
/**
* The number of affected resources.
*
* @readonly
*/
size: number;
readonly size: number;
/**
* Replace the given range with given text for the given resource.
......@@ -2850,9 +2813,8 @@ declare module 'vscode' {
/**
* Readable dictionary that backs this configuration.
* @readonly
*/
[key: string]: any;
readonly [key: string]: any;
}
/**
......@@ -2965,9 +2927,8 @@ declare module 'vscode' {
* The name of this diagnostic collection, for instance `typescript`. Every diagnostic
* from this collection will be associated with this name. Also, the task framework uses this
* name when defining [problem matchers](https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher).
* @readonly
*/
name: string;
readonly name: string;
/**
* Assign diagnostics for given resource. Will replace
......@@ -3057,9 +3018,8 @@ declare module 'vscode' {
/**
* The human-readable name of this output channel.
* @readonly
*/
name: string;
readonly name: string;
/**
* Append the given value to the channel.
......@@ -3134,18 +3094,14 @@ declare module 'vscode' {
/**
* The alignment of this item.
*
* @readonly
*/
alignment: StatusBarAlignment;
readonly alignment: StatusBarAlignment;
/**
* The priority of this item. Higher value means the item should
* be shown more to the left.
*
* @readonly
*/
priority: number;
readonly priority: number;
/**
* The text to show for the entry. You can embed icons in the text by leveraging the syntax:
......@@ -3197,17 +3153,13 @@ declare module 'vscode' {
/**
* The name of the terminal.
*
* @readonly
*/
name: string;
readonly name: string;
/**
* The process ID of the shell process.
*
* @readonly
*/
processId: Thenable<number>;
readonly processId: Thenable<number>;
/**
* Send text to the terminal. The text is written to the stdin of the underlying pty process
......@@ -3247,39 +3199,29 @@ declare module 'vscode' {
/**
* The canonical extension identifier in the form of: `publisher.name`.
*
* @readonly
*/
id: string;
readonly id: string;
/**
* The absolute file path of the directory containing this extension.
*
* @readonly
*/
extensionPath: string;
readonly extensionPath: string;
/**
* `true` if the extension has been activated.
*
* @readonly
*/
isActive: boolean;
readonly isActive: boolean;
/**
* The parsed contents of the extension's package.json.
*
* @readonly
*/
packageJSON: any;
readonly packageJSON: any;
/**
* The public API exported by this extension. It is an invalid action
* to access this field before this extension has been activated.
*
* @readonly
*/
exports: T;
readonly exports: T;
/**
* Activates this extension and returns its public API.
......
......@@ -67,7 +67,6 @@ suite('ExtHostConfiguration', function () {
assert.equal(config.get('config4'), '');
assert.equal(config['config0'], true);
assert.equal(config['config4'], '');
assert.throws(() => config['config4'] = 'valuevalue');
assert.ok(config.has('nested.config1'));
assert.equal(config.get('nested.config1'), 42);
......
......@@ -38,20 +38,9 @@ suite('ExtHostDocument', () => {
], '\n', 'text', 1, false);
});
test('readonly-ness', function () {
assert.throws(() => data.document.uri = null);
assert.throws(() => data.document.fileName = 'foofile');
assert.throws(() => data.document.isDirty = false);
assert.throws(() => data.document.isUntitled = false);
assert.throws(() => data.document.languageId = 'dddd');
assert.throws(() => data.document.lineCount = 9);
});
test('lines', function () {
assert.equal(data.document.lineCount, 4);
assert.throws(() => data.document.lineCount = 9);
assert.throws(() => data.lineAt(-1));
assert.throws(() => data.lineAt(data.document.lineCount));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册