From dcb47d6e1101ce5e452d5cbf8cd7a331762e18c0 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 7 Oct 2021 12:44:32 -0700 Subject: [PATCH] Update vscode types in package.json to 1.60 --- package-lock.json | 6 +- package.json | 2 +- src/client/activation/node/activator.ts | 4 +- src/test/mockClasses.ts | 2 + src/test/mocks/mementos.ts | 4 + types/vscode-proposed/index.d.ts | 50 ++++++++--- types/vscode.proposed.d.ts | 114 ++---------------------- 7 files changed, 58 insertions(+), 124 deletions(-) diff --git a/package-lock.json b/package-lock.json index 73c5addfccd5..f9301dcbfe3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -542,9 +542,9 @@ "dev": true }, "@types/vscode": { - "version": "1.53.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.53.0.tgz", - "integrity": "sha512-XjFWbSPOM0EKIT2XhhYm3D3cx3nn3lshMUcWNy1eqefk+oqRuBq8unVb6BYIZqXy9lQZyeUl7eaBCOZWv+LcXQ==", + "version": "1.60.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.60.0.tgz", + "integrity": "sha512-wZt3VTmzYrgZ0l/3QmEbCq4KAJ71K3/hmMQ/nfpv84oH8e81KKwPEoQ5v8dNCxfHFVJ1JabHKmCvqdYOoVm1Ow==", "dev": true }, "@types/webpack": { diff --git a/package.json b/package.json index 7d6d2f76af60..9c03f08c8a80 100644 --- a/package.json +++ b/package.json @@ -1936,7 +1936,7 @@ "@types/tmp": "0.0.33", "@types/untildify": "^3.0.0", "@types/uuid": "^3.4.3", - "@types/vscode": "~1.53.0", + "@types/vscode": "~1.60.0", "@types/winreg": "^1.2.30", "@types/xml2js": "^0.4.2", "@typescript-eslint/eslint-plugin": "^3.7.0", diff --git a/src/client/activation/node/activator.ts b/src/client/activation/node/activator.ts index fa3a99e2df01..f0de5687c44c 100644 --- a/src/client/activation/node/activator.ts +++ b/src/client/activation/node/activator.ts @@ -70,7 +70,9 @@ export class NodeLanguageServerActivator extends LanguageServerActivatorBase { if (languageClient) { // Turn our item into a ProtocolCompletionItem before we convert it. This preserves the .data // attribute that it has and is needed to match on the language server side. - const protoItem: ProtocolCompletionItem = new ProtocolCompletionItem(item.label); + const protoItem: ProtocolCompletionItem = new ProtocolCompletionItem( + typeof item.label === 'string' ? item.label : item.label.label, + ); Object.assign(protoItem, item); const args = languageClient.code2ProtocolConverter.asCompletionItem(protoItem); diff --git a/src/test/mockClasses.ts b/src/test/mockClasses.ts index 16d4c32b077d..8836b06d876d 100644 --- a/src/test/mockClasses.ts +++ b/src/test/mockClasses.ts @@ -46,6 +46,8 @@ export class MockStatusBarItem implements vscode.StatusBarItem { public tooltip!: string; public color!: string; public command!: string; + public id: string = ''; + public name: string = ''; public show(): void {} diff --git a/src/test/mocks/mementos.ts b/src/test/mocks/mementos.ts index 707ff8c886f3..1ffa09884262 100644 --- a/src/test/mocks/mementos.ts +++ b/src/test/mocks/mementos.ts @@ -9,6 +9,10 @@ export class MockMemento implements Memento { // eslint-disable-next-line @typescript-eslint/no-explicit-any private _value: Record = {}; + public keys(): string[] { + return Object.keys(this._value); + } + // @ts-ignore Ignore the return value warning // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any public get(key: any, defaultValue?: any); diff --git a/types/vscode-proposed/index.d.ts b/types/vscode-proposed/index.d.ts index 91ca6f811ecd..204daba5c32d 100644 --- a/types/vscode-proposed/index.d.ts +++ b/types/vscode-proposed/index.d.ts @@ -24,7 +24,7 @@ import { //#region https://github.com/microsoft/vscode/issues/106744, Notebooks (misc) export enum NotebookCellKind { - Markdown = 1, + Markup = 1, Code = 2, } @@ -410,19 +410,6 @@ export class NotebookCellOutputItem { constructor(mime: string, value: unknown, metadata?: Record); } -// @jrieken -// todo@API think about readonly... -//TODO@API add execution count to cell output? -export class NotebookCellOutput { - readonly id: string; - readonly outputs: NotebookCellOutputItem[]; - readonly metadata?: Record; - - constructor(outputs: NotebookCellOutputItem[], metadata?: Record); - - constructor(outputs: NotebookCellOutputItem[], id: string, metadata?: Record); -} - //#endregion //#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorEdit @@ -681,6 +668,41 @@ export interface NotebookKernelPreload { uri: Uri; } +/** + * Notebook cell output represents a result of executing a cell. It is a container type for multiple + * {@link NotebookCellOutputItem output items} where contained items represent the same result but + * use different MIME types. + */ +export class NotebookCellOutput { + /** + * The output items of this output. Each item must represent the same result. _Note_ that repeated + * MIME types per output is invalid and that the editor will just pick one of them. + * + * ```ts + * new vscode.NotebookCellOutput([ + * vscode.NotebookCellOutputItem.text('Hello', 'text/plain'), + * vscode.NotebookCellOutputItem.text('Hello', 'text/html'), + * vscode.NotebookCellOutputItem.text('_Hello_', 'text/markdown'), + * vscode.NotebookCellOutputItem.text('Hey', 'text/plain'), // INVALID: repeated type, editor will pick just one + * ]) + * ``` + */ + items: NotebookCellOutputItem[]; + + /** + * Arbitrary metadata for this cell output. Can be anything but must be JSON-stringifyable. + */ + metadata?: { [key: string]: any }; + + /** + * Create new notebook output. + * + * @param items Notebook output items. + * @param metadata Optional metadata. + */ + constructor(items: NotebookCellOutputItem[], metadata?: { [key: string]: any }); +} + export interface NotebookKernel { // todo@API make this mandatory? readonly id?: string; diff --git a/types/vscode.proposed.d.ts b/types/vscode.proposed.d.ts index 3550b5c667e9..159b3af72063 100644 --- a/types/vscode.proposed.d.ts +++ b/types/vscode.proposed.d.ts @@ -6,11 +6,6 @@ declare module 'vscode' { //#region https://github.com/microsoft/vscode/issues/106744, Notebooks (misc) - export enum NotebookCellKind { - Markdown = 1, - Code = 2, - } - export class NotebookCellMetadata { /** * Whether a code cell's editor is collapsed @@ -43,24 +38,6 @@ declare module 'vscode' { }): NotebookCellMetadata; } - export interface NotebookCellExecutionSummary { - executionOrder?: number; - success?: boolean; - startTime?: number; - endTime?: number; - } - - // todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md - export interface NotebookCell { - readonly index: number; - readonly notebook: NotebookDocument; - readonly kind: NotebookCellKind; - readonly document: TextDocument; - readonly metadata: NotebookCellMetadata; - readonly outputs: ReadonlyArray; - readonly latestExecutionSummary: NotebookCellExecutionSummary | undefined; - } - export class NotebookDocumentMetadata { /** * @deprecated @@ -114,8 +91,6 @@ declare module 'vscode' { */ readonly isClosed: boolean; - readonly metadata: NotebookDocumentMetadata; - // todo@API should we really expose this? readonly notebookType: string; @@ -263,29 +238,6 @@ declare module 'vscode' { readonly cell: NotebookCell; readonly executionState: NotebookCellExecutionState; } - - // todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md - export class NotebookCellData { - // todo@API should they all be readonly? - kind: NotebookCellKind; - // todo@API better names: value? text? - source: string; - // todo@API how does language and MD relate? - language: string; - // todo@API ReadonlyArray? - outputs?: NotebookCellOutput[]; - metadata?: NotebookCellMetadata; - latestExecutionSummary?: NotebookCellExecutionSummary; - constructor( - kind: NotebookCellKind, - source: string, - language: string, - outputs?: NotebookCellOutput[], - metadata?: NotebookCellMetadata, - latestExecutionSummary?: NotebookCellExecutionSummary, - ); - } - export class NotebookData { // todo@API should they all be readonly? cells: NotebookCellData[]; @@ -393,19 +345,6 @@ declare module 'vscode' { constructor(mime: string, value: unknown, metadata?: Record); } - // @jrieken - // todo@API think about readonly... - //TODO@API add execution count to cell output? - export class NotebookCellOutput { - readonly id: string; - readonly outputs: NotebookCellOutputItem[]; - readonly metadata?: Record; - - constructor(outputs: NotebookCellOutputItem[], metadata?: Record); - - constructor(outputs: NotebookCellOutputItem[], id: string, metadata?: Record); - } - //#endregion //#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorEdit @@ -528,20 +467,9 @@ declare module 'vscode' { label: string; description?: string; isPreferred?: boolean; - - supportedLanguages: string[]; hasExecutionOrder?: boolean; preloads?: NotebookKernelPreload[]; - /** - * The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All, - * Run Selection etc. - */ - readonly executeHandler: (cells: NotebookCell[], controller: NotebookController) => void; - - // optional kernel interrupt command - interruptHandler?: (notebook: NotebookDocument) => void; - // remove kernel dispose(): void; @@ -751,16 +679,16 @@ declare module 'vscode' { } export interface QuickPick extends QuickInput { - /** - * An optional flag to sort the final results by index of first query match in label. Defaults to true. - */ - sortByLabel: boolean; + /** + * An optional flag to sort the final results by index of first query match in label. Defaults to true. + */ + sortByLabel: boolean; - /* - * An optional flag that can be set to true to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false. - */ - keepScrollPosition?: boolean; - } + /* + * An optional flag that can be set to true to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false. + */ + keepScrollPosition?: boolean; + } export enum NotebookCellExecutionState { Idle = 1, @@ -854,21 +782,6 @@ declare module 'vscode' { //#region https://github.com/microsoft/vscode/issues/106744, NotebookCellStatusBarItem - /** - * Represents the alignment of status bar items. - */ - export enum NotebookCellStatusBarAlignment { - /** - * Aligned to the left side. - */ - Left = 1, - - /** - * Aligned to the right side. - */ - Right = 2, - } - export class NotebookCellStatusBarItem { readonly text: string; readonly alignment: NotebookCellStatusBarAlignment; @@ -1052,15 +965,6 @@ declare module 'vscode' { export const testResults: ReadonlyArray; } - /** - * The kind of executions that {@link TestRunProfile TestRunProfiles} control. - */ - export enum TestRunProfileKind { - Run = 1, - Debug = 2, - Coverage = 3, - } - /** * A TestRunProfile describes one way to execute tests in a {@link TestController}. */