make INotebookKernel2 extends INotebookKernel

上级 6b9bd789
......@@ -89,8 +89,13 @@ abstract class MainThreadKernel implements INotebookKernel2 {
this._onDidChange.fire(event);
}
abstract executeNotebookCellsRequest(uri: URI, ranges: ICellRange[]): void;
abstract cancelNotebookCellExecution(uri: URI, ranges: ICellRange[]): void;
abstract executeNotebookCellsRequest(uri: URI, ranges: ICellRange[]): Promise<void>;
abstract cancelNotebookCellExecution(uri: URI, ranges: ICellRange[]): Promise<void>;
// old stuff
readonly resolve = () => Promise.resolve();
get friendlyId() { return this.id; }
get providerHandle() { return undefined; }
}
@extHostNamedCustomer(MainContext.MainThreadNotebookKernels)
......@@ -185,11 +190,11 @@ export class MainThreadNotebookKernels implements MainThreadNotebookKernelsShape
async $addKernel(handle: number, data: INotebookKernelDto2): Promise<void> {
const that = this;
const kernel = new class extends MainThreadKernel {
executeNotebookCellsRequest(uri: URI, ranges: ICellRange[]): void {
that._proxy.$executeCells(handle, uri, ranges);
async executeNotebookCellsRequest(uri: URI, ranges: ICellRange[]): Promise<void> {
await that._proxy.$executeCells(handle, uri, ranges);
}
cancelNotebookCellExecution(uri: URI, ranges: ICellRange[]): void {
that._proxy.$cancelCells(handle, uri, ranges);
async cancelNotebookCellExecution(uri: URI, ranges: ICellRange[]): Promise<void> {
await that._proxy.$cancelCells(handle, uri, ranges);
}
}(data);
const registration = this._notebookKernelService.registerKernel(kernel);
......
......@@ -1964,8 +1964,8 @@ export interface ExtHostNotebookEditorsShape {
export interface ExtHostNotebookKernelsShape {
$acceptSelection(handle: number, uri: UriComponents, value: boolean): void;
$executeCells(handle: number, uri: UriComponents, ranges: ICellRange[]): void;
$cancelCells(handle: number, uri: UriComponents, ranges: ICellRange[]): void;
$executeCells(handle: number, uri: UriComponents, ranges: ICellRange[]): Promise<void>;
$cancelCells(handle: number, uri: UriComponents, ranges: ICellRange[]): Promise<void>;
$acceptRendererMessage(handle: number, editorId: string, message: any): void;
}
......
......@@ -199,7 +199,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
}
}
$executeCells(handle: number, uri: UriComponents, ranges: ICellRange[]): void {
async $executeCells(handle: number, uri: UriComponents, ranges: ICellRange[]): Promise<void> {
const obj = this._kernelData.get(handle);
if (!obj) {
// extension can dispose kernels in the meantime
......@@ -223,7 +223,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
}
}
$cancelCells(handle: number, uri: UriComponents, ranges: ICellRange[]): void {
async $cancelCells(handle: number, uri: UriComponents, ranges: ICellRange[]): Promise<void> {
const obj = this._kernelData.get(handle);
if (!obj) {
// extension can dispose kernels in the meantime
......
......@@ -5,7 +5,7 @@
import { Event, Emitter } from 'vs/base/common/event';
import { DisposableStore, dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { ICellRange, INotebookKernel, INotebookTextModel } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookTextModel } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookKernelBindEvent, INotebookKernel2, INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { score } from 'vs/workbench/contrib/notebook/common/notebookSelector';
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
......@@ -143,31 +143,11 @@ class KernelAdaptorBridge implements IWorkbenchContribution {
providerExtensionId: 'notAnExtension',
selector: { filenamePattern: '**/*' },
async provideKernels(uri: URI) {
const model = notebookService.getNotebookTextModel(uri);
if (!model) {
return [];
}
return notebookKernelService.getMatchingKernels(model).map((kernel: INotebookKernel2): INotebookKernel => {
return {
id: kernel.id,
friendlyId: kernel.id,
label: kernel.label,
description: kernel.description,
detail: kernel.detail,
isPreferred: kernel.isPreferred,
preloadUris: kernel.preloadUris,
preloadProvides: kernel.preloadProvides,
localResourceRoot: kernel.localResourceRoot,
supportedLanguages: kernel.supportedLanguages,
implementsInterrupt: kernel.implementsInterrupt,
implementsExecutionOrder: kernel.implementsExecutionOrder,
extension: kernel.extension,
async resolve() { },
async executeNotebookCellsRequest(uri: URI, ranges: ICellRange[]): Promise<void> { kernel.executeNotebookCellsRequest(uri, ranges); },
async cancelNotebookCellExecution(uri: URI, ranges: ICellRange[]): Promise<void> { kernel.cancelNotebookCellExecution(uri, ranges); },
};
});
return notebookKernelService.getMatchingKernels(model);
}
});
......
......@@ -764,12 +764,17 @@ export function notebookDocumentFilterMatch(filter: INotebookDocumentFilter, vie
}
export interface INotebookKernel {
/** @deprecated */
providerHandle?: number;
/** @deprecated */
resolve(uri: URI, editorId: string, token: CancellationToken): Promise<void>;
id?: string;
friendlyId: string;
label: string;
extension: ExtensionIdentifier;
localResourceRoot: URI;
providerHandle?: number;
description?: string;
detail?: string;
isPreferred?: boolean;
......@@ -779,7 +784,6 @@ export interface INotebookKernel {
implementsInterrupt?: boolean;
implementsExecutionOrder?: boolean;
resolve(uri: URI, editorId: string, token: CancellationToken): Promise<void>;
executeNotebookCellsRequest(uri: URI, ranges: ICellRange[]): Promise<void>;
cancelNotebookCellExecution(uri: URI, ranges: ICellRange[]): Promise<void>;
}
......
......@@ -8,7 +8,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ICellRange, INotebookTextModel } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookKernel, INotebookTextModel } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { NotebookSelector } from 'vs/workbench/contrib/notebook/common/notebookSelector';
export interface INotebookKernel2ChangeEvent {
......@@ -20,28 +20,13 @@ export interface INotebookKernel2ChangeEvent {
hasExecutionOrder?: true;
}
export interface INotebookKernel2 {
export interface INotebookKernel2 extends INotebookKernel {
readonly id: string;
readonly selector: NotebookSelector
readonly extension: ExtensionIdentifier;
readonly onDidChange: Event<INotebookKernel2ChangeEvent>;
label: string;
description?: string;
detail?: string;
isPreferred?: boolean;
supportedLanguages: string[];
implementsExecutionOrder: boolean;
implementsInterrupt: boolean;
localResourceRoot: URI;
preloadUris: URI[];
preloadProvides: string[];
executeNotebookCellsRequest(uri: URI, ranges: ICellRange[]): void;
cancelNotebookCellExecution(uri: URI, ranges: ICellRange[]): void
}
export interface INotebookKernelBindEvent {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册