Implement Session support through the extension host (#3228)

Full plumb through of Session support. Also fixed some test issues

- Load session and get necessary information in kernels list
- Run Cell button now works as expected
- Added a ToggleAction base class which can be used for anything that switches icons. I'd still prefer to have this be dynamic and as clean as the extension classes
- Fixed account test unhandled promise rejections (caused by incorrect / invalid tests) that made it hard to see all the test run output.
This commit is contained in:
Kevin Cunnane
2018-11-16 10:35:03 -08:00
committed by GitHub
parent f3525cc555
commit 90dc788893
23 changed files with 939 additions and 212 deletions

View File

@@ -2,8 +2,11 @@
import { nb } from 'sqlops';
import { localize } from 'vs/nls';
import { FutureInternal } from 'sql/parts/notebook/models/modelInterfaces';
const noKernel: string = localize('noKernel', 'No Kernel');
const runNotebookDisabled = localize('runNotebookDisabled', 'Cannot run cells as no kernel has been configured');
let noKernelSpec: nb.IKernelSpec = ({
name: noKernel,
language: 'python',
@@ -130,7 +133,7 @@ class EmptyKernel implements nb.IKernel {
}
requestExecute(content: nb.IExecuteRequest, disposeOnDone?: boolean): nb.IFuture {
throw new Error('Method not implemented.');
return new EmptyFuture();
}
requestComplete(content: nb.ICompleteRequest): Thenable<nb.ICompleteReplyMsg> {
@@ -138,4 +141,72 @@ class EmptyKernel implements nb.IKernel {
return Promise.resolve(response as nb.ICompleteReplyMsg);
}
interrupt(): Thenable<void> {
return Promise.resolve(undefined);
}
}
class EmptyFuture implements FutureInternal {
get inProgress(): boolean {
return false;
}
get msg(): nb.IMessage {
return undefined;
}
get done(): Thenable<nb.IShellMessage> {
let msg: nb.IShellMessage = {
channel: 'shell',
type: 'shell',
content: runNotebookDisabled,
header: undefined,
metadata: undefined,
parent_header: undefined
};
return Promise.resolve(msg);
}
sendInputReply(content: nb.IInputReply): void {
// no-op
}
dispose() {
// No-op
}
setReplyHandler(handler: nb.MessageHandler<nb.IShellMessage>): void {
// no-op
}
setStdInHandler(handler: nb.MessageHandler<nb.IStdinMessage>): void {
// no-op
}
setIOPubHandler(handler: nb.MessageHandler<nb.IIOPubMessage>): void {
setTimeout(() => {
let msg: nb.IIOPubMessage = {
channel: 'iopub',
type: 'iopub',
header: <nb.IHeader> {
msg_id: '0',
msg_type: 'error'
},
content: <nb.IErrorResult> {
ename: localize('errorName', 'Error'),
evalue: runNotebookDisabled,
output_type: 'error'
},
metadata: undefined,
parent_header: undefined
};
handler.handle(msg);
}, 10);
}
registerMessageHook(hook: (msg: nb.IIOPubMessage) => boolean | Thenable<boolean>): void {
// no-op
}
removeMessageHook(hook: (msg: nb.IIOPubMessage) => boolean | Thenable<boolean>): void {
// no-op
}
}