Skip to content

Commit 5d54ea6

Browse files
fix lint
1 parent 8f46833 commit 5d54ea6

File tree

2 files changed

+180
-23
lines changed

2 files changed

+180
-23
lines changed

src/test/mocks/vsc/extHostedTypes.ts

Lines changed: 178 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66

77
'use strict';
88

9+
import { isNumber } from 'lodash';
910
import { relative } from 'path';
10-
import type * as vscode from 'vscode';
11+
import * as vscode from 'vscode';
1112
import * as vscMockHtmlContent from './htmlContent';
1213
import * as vscMockStrings from './strings';
1314
import * as vscUri from './uri';
1415
import { generateUuid } from './uuid';
1516

1617
export enum NotebookCellKind {
17-
Markdown = 1,
18+
Markup = 1,
1819
Code = 2,
1920
}
2021

@@ -237,6 +238,121 @@ export class Position {
237238
}
238239
}
239240

241+
export class NotebookCellOutputItem {
242+
static text(value: any, mime?: string): NotebookCellOutputItem {
243+
return mime ? new NotebookCellOutputItem(value, mime) : new NotebookCellOutputItem(value, '');
244+
}
245+
246+
static json(value: any, mime?: string): NotebookCellOutputItem {
247+
return mime ? new NotebookCellOutputItem(value, mime) : new NotebookCellOutputItem(value, '');
248+
}
249+
250+
static stdout(value: any): NotebookCellOutputItem {
251+
return new NotebookCellOutputItem(value, '');
252+
}
253+
254+
static stderr(value: any): NotebookCellOutputItem {
255+
return new NotebookCellOutputItem(value, '');
256+
}
257+
258+
static error(value: any): NotebookCellOutputItem {
259+
return new NotebookCellOutputItem(value, '');
260+
}
261+
262+
mime: string;
263+
264+
data: Uint8Array;
265+
266+
constructor(data: Uint8Array, mime: string) {
267+
this.data = data;
268+
this.mime = mime;
269+
}
270+
}
271+
272+
export class NotebookCellOutput implements vscode.NotebookCellOutput {
273+
items: NotebookCellOutputItem[];
274+
275+
metadata?: { [key: string]: any };
276+
277+
constructor(items: NotebookCellOutputItem[], metadata?: { [key: string]: any }) {
278+
this.items = items;
279+
this.metadata = metadata;
280+
}
281+
}
282+
283+
export interface NotebookCellExecutionSummary {
284+
readonly executionOrder?: number;
285+
readonly success?: boolean;
286+
readonly timing?: { readonly startTime: number; readonly endTime: number };
287+
}
288+
289+
export class NotebookCellData implements vscode.NotebookCellData {
290+
kind: NotebookCellKind;
291+
292+
value: string;
293+
294+
languageId: string;
295+
296+
outputs?: NotebookCellOutput[];
297+
298+
metadata?: { [key: string]: any };
299+
300+
executionSummary?: NotebookCellExecutionSummary;
301+
302+
constructor(kind: NotebookCellKind, value: string, languageId: string) {
303+
this.kind = kind;
304+
this.value = value;
305+
this.languageId = languageId;
306+
}
307+
}
308+
309+
export class NotebookRange implements vscode.NotebookRange {
310+
readonly start: number;
311+
312+
readonly end: number;
313+
314+
readonly isEmpty: boolean = false;
315+
316+
constructor(start: number, end: number) {
317+
this.start = start;
318+
this.end = end;
319+
if (end === start) {
320+
this.isEmpty = true;
321+
}
322+
}
323+
324+
with(change: { start?: number; end?: number }) {
325+
if (change.start === null || change.end === null) {
326+
throw illegalArgument();
327+
}
328+
329+
let start: number;
330+
331+
if (!change.start) {
332+
start = this.start;
333+
} else if (isNumber(change.start)) {
334+
start = change.start;
335+
} else {
336+
start = change.start || this.start;
337+
}
338+
339+
let end: number;
340+
if (!change.end) {
341+
end = this.end;
342+
} else if (isNumber(change.end)) {
343+
end = change.end;
344+
} else {
345+
end = change.end || this.end;
346+
}
347+
348+
if (start === this.start && end === this.end) {
349+
return this;
350+
}
351+
352+
return new NotebookRange(start, end);
353+
}
354+
}
355+
240356
export class Range {
241357
static isRange(thing: unknown): thing is vscode.Range {
242358
if (thing instanceof Range) {
@@ -464,6 +580,45 @@ export enum EndOfLine {
464580
CRLF = 2,
465581
}
466582

583+
// export class NotebookEdit implements vscode.NotebookEdit {
584+
// static replaceCells(range: NotebookRange, newCells: NotebookCellData[]) {
585+
// return new NotebookEdit(range, newCells);
586+
// }
587+
588+
// static insertCells(index: number, newCells: NotebookCellData[]) {
589+
// return NotebookEdit.replaceCells(new NotebookRange(index, index), newCells);
590+
// }
591+
592+
// static deleteCells(range: NotebookRange) {
593+
// return NotebookEdit.replaceCells(range, [new NotebookCellData(NotebookCellKind.Code, '', '')]);
594+
// }
595+
596+
// static updateCellMetadata(index: number, newCellMetadata: { [key: string]: any }) {
597+
// const notebookEdit = NotebookEdit.replaceCells(new NotebookRange(index, index), []);
598+
// notebookEdit.newCellMetadata = newCellMetadata;
599+
// return notebookEdit;
600+
// }
601+
602+
// static updateNotebookMetadata(newNotebookMetadata: { [key: string]: any }) {
603+
// const notebookEdit = NotebookEdit.replaceCells(new NotebookRange(0, 0), []);
604+
// notebookEdit.newCellMetadata = newNotebookMetadata;
605+
// return notebookEdit;
606+
// }
607+
608+
// range: NotebookRange;
609+
610+
// newCells: NotebookCellData[];
611+
612+
// newCellMetadata?: { [key: string]: any };
613+
614+
// newNotebookMetadata?: { [key: string]: any };
615+
616+
// constructor(range: NotebookRange, newCells: NotebookCellData[]) {
617+
// this.range = range;
618+
// this.newCells = newCells;
619+
// }
620+
// }
621+
467622
export class TextEdit {
468623
static isTextEdit(thing: unknown): thing is TextEdit {
469624
if (thing instanceof TextEdit) {
@@ -493,11 +648,11 @@ export class TextEdit {
493648
return ret;
494649
}
495650

496-
protected _range: Range = new Range(new Position(0, 0), new Position(0, 0));
651+
_range: Range = new Range(new Position(0, 0), new Position(0, 0));
497652

498-
protected _newText = '';
653+
newText = '';
499654

500-
protected _newEol: EndOfLine = EndOfLine.LF;
655+
_newEol: EndOfLine = EndOfLine.LF;
501656

502657
get range(): Range {
503658
return this._range;
@@ -510,16 +665,16 @@ export class TextEdit {
510665
this._range = value;
511666
}
512667

513-
get newText(): string {
514-
return this._newText || '';
515-
}
668+
// get newText(): string {
669+
// return this._newText || '';
670+
// }
516671

517-
set newText(value: string) {
518-
if (value && typeof value !== 'string') {
519-
throw illegalArgument('newText');
520-
}
521-
this._newText = value;
522-
}
672+
// set newText(value: string) {
673+
// if (value && typeof value !== 'string') {
674+
// throw illegalArgument('newText');
675+
// }
676+
// this._newText = value;
677+
// }
523678

524679
get newEol(): EndOfLine {
525680
return this._newEol;
@@ -537,13 +692,13 @@ export class TextEdit {
537692
this.newText = newText;
538693
}
539694

540-
toJSON(): { range: Range; newText: string; newEol: EndOfLine } {
541-
return {
542-
range: this.range,
543-
newText: this.newText,
544-
newEol: this._newEol,
545-
};
546-
}
695+
// toJSON(): { range: Range; newText: string; newEol: EndOfLine } {
696+
// return {
697+
// range: this.range,
698+
// newText: this.newText,
699+
// newEol: this.newEol,
700+
// };
701+
// }
547702
}
548703

549704
export class WorkspaceEdit implements vscode.WorkspaceEdit {
@@ -664,7 +819,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
664819
return this._textEdits.has(uri.toString());
665820
}
666821

667-
set(uri: vscUri.URI, edits: TextEdit[]): void {
822+
set(uri: vscUri.URI, edits: unknown[]): void {
668823
let data = this._textEdits.get(uri.toString());
669824
if (!data) {
670825
data = { seq: this._seqPool += 1, uri, edits: [] };
@@ -673,7 +828,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
673828
if (!edits) {
674829
data.edits = [];
675830
} else {
676-
data.edits = edits.slice(0);
831+
data.edits = edits.slice(0) as TextEdit[];
677832
}
678833
}
679834

src/test/mocks/vsc/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ export class CodeActionKind {
302302

303303
public static readonly RefactorInline: CodeActionKind = new CodeActionKind('refactor.inline');
304304

305+
public static readonly RefactorMove: CodeActionKind = new CodeActionKind('refactor.move');
306+
305307
public static readonly RefactorRewrite: CodeActionKind = new CodeActionKind('refactor.rewrite');
306308

307309
public static readonly Source: CodeActionKind = new CodeActionKind('source');

0 commit comments

Comments
 (0)