Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re use readonly #12732 #13863 #18251

Merged
merged 5 commits into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 33 additions & 91 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1542,10 +1511,8 @@ declare module 'vscode' {

/**
* An array of diagnostics.
*
* @readonly
*/
diagnostics: Diagnostic[];
readonly diagnostics: Diagnostic[];
}

/**
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -2850,9 +2813,8 @@ declare module 'vscode' {

/**
* Readable dictionary that backs this configuration.
* @readonly
*/
[key: string]: any;
readonly [key: string]: any;
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 0 additions & 11 deletions src/vs/workbench/test/node/api/extHostDocuments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down