mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
strict null work in extHostTypes, #61543
This commit is contained in:
parent
917a2c58ce
commit
0ac0c45b29
|
@ -876,7 +876,7 @@ export interface DocumentSymbolProvider {
|
|||
provideDocumentSymbols(model: model.ITextModel, token: CancellationToken): ProviderResult<DocumentSymbol[]>;
|
||||
}
|
||||
|
||||
export type TextEdit = { range: IRange; text: string; eol?: model.EndOfLineSequence; } | { range: undefined; text: undefined; eol: model.EndOfLineSequence; };
|
||||
export type TextEdit = { range: IRange; text: string; eol?: model.EndOfLineSequence; };
|
||||
|
||||
/**
|
||||
* Interface used to format a model
|
||||
|
|
|
@ -425,8 +425,8 @@ export abstract class BaseEditorSimpleWorker {
|
|||
lastEol = eol;
|
||||
}
|
||||
|
||||
if (!range) {
|
||||
// eol-change only
|
||||
if (Range.isEmpty(range) && !text) {
|
||||
// empty change
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ export abstract class BaseEditorSimpleWorker {
|
|||
}
|
||||
|
||||
if (typeof lastEol === 'number') {
|
||||
result.push({ eol: lastEol, text: undefined, range: undefined });
|
||||
result.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });
|
||||
}
|
||||
|
||||
return Promise.resolve(result);
|
||||
|
|
4
src/vs/monaco.d.ts
vendored
4
src/vs/monaco.d.ts
vendored
|
@ -5148,10 +5148,6 @@ declare namespace monaco.languages {
|
|||
range: IRange;
|
||||
text: string;
|
||||
eol?: editor.EndOfLineSequence;
|
||||
} | {
|
||||
range: undefined;
|
||||
text: undefined;
|
||||
eol: editor.EndOfLineSequence;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -447,7 +447,7 @@ export class TextEdit {
|
|||
}
|
||||
|
||||
static setEndOfLine(eol: EndOfLine): TextEdit {
|
||||
let ret = new TextEdit(undefined, undefined);
|
||||
let ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
|
||||
ret.newEol = eol;
|
||||
return ret;
|
||||
}
|
||||
|
@ -513,8 +513,8 @@ export interface IFileOperationOptions {
|
|||
|
||||
export interface IFileOperation {
|
||||
_type: 1;
|
||||
from: URI;
|
||||
to: URI;
|
||||
from?: URI;
|
||||
to?: URI;
|
||||
options?: IFileOperationOptions;
|
||||
}
|
||||
|
||||
|
@ -567,7 +567,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
|||
for (let i = 0; i < this._edits.length; i++) {
|
||||
const element = this._edits[i];
|
||||
if (element._type === 2 && element.uri.toString() === uri.toString()) {
|
||||
this._edits[i] = undefined;
|
||||
this._edits[i] = undefined!; // will be coalesced down below
|
||||
}
|
||||
}
|
||||
this._edits = coalesce(this._edits);
|
||||
|
@ -606,8 +606,8 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
|||
return values(textEdits);
|
||||
}
|
||||
|
||||
_allEntries(): ([URI, TextEdit[]] | [URI, URI, IFileOperationOptions])[] {
|
||||
let res: ([URI, TextEdit[]] | [URI, URI, IFileOperationOptions])[] = [];
|
||||
_allEntries(): ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] {
|
||||
let res: ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] = [];
|
||||
for (let edit of this._edits) {
|
||||
if (edit._type === 1) {
|
||||
res.push([edit.from, edit.to, edit.options]);
|
||||
|
@ -938,7 +938,7 @@ export class SymbolInformation {
|
|||
if (locationOrUri instanceof Location) {
|
||||
this.location = locationOrUri;
|
||||
} else if (rangeOrContainer instanceof Range) {
|
||||
this.location = new Location(locationOrUri, rangeOrContainer);
|
||||
this.location = new Location(locationOrUri!, rangeOrContainer);
|
||||
}
|
||||
|
||||
SymbolInformation.validate(this);
|
||||
|
|
|
@ -384,12 +384,12 @@ suite('ExtHostTypes', function () {
|
|||
const all = edit._allEntries();
|
||||
assert.equal(all.length, 4);
|
||||
|
||||
function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, URI, { overwrite?: boolean }] {
|
||||
function isFileChange(thing: [URI, types.TextEdit[]] | [URI?, URI?, { overwrite?: boolean }?]): thing is [URI?, URI?, { overwrite?: boolean }?] {
|
||||
const [f, s] = thing;
|
||||
return URI.isUri(f) && URI.isUri(s);
|
||||
}
|
||||
|
||||
function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, types.TextEdit[]] {
|
||||
function isTextChange(thing: [URI, types.TextEdit[]] | [URI?, URI?, { overwrite?: boolean }?]): thing is [URI, types.TextEdit[]] {
|
||||
const [f, s] = thing;
|
||||
return URI.isUri(f) && Array.isArray(s);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue