diff --git a/package-lock.json b/package-lock.json index 0eec5cce06c2..0fbb97d27655 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2808,12 +2808,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2828,17 +2830,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2955,7 +2960,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2967,6 +2973,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2981,6 +2988,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2988,12 +2996,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -3012,6 +3022,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3092,7 +3103,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3104,6 +3116,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3225,6 +3238,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/package.json b/package.json index 01c4c394ab1c..24ea71934374 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,8 @@ "onCommand:python.setLinter", "onCommand:python.enableLinting", "onCommand:python.createTerminal", - "onCommand:python.discoverTests" + "onCommand:python.discoverTests", + "onCommand:python.datascience" ], "main": "./out/client/extension", "contributes": { @@ -222,6 +223,11 @@ "command": "python.runLinting", "title": "%python.command.python.runLinting.title%", "category": "Python" + }, + { + "command": "python.datascience", + "title": "Datascience Command", + "category": "Python Datascience" } ], "menus": { diff --git a/src/client/datascience/codewatcher.ts b/src/client/datascience/codewatcher.ts new file mode 100644 index 000000000000..a6dc6eb2297c --- /dev/null +++ b/src/client/datascience/codewatcher.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; diff --git a/src/client/datascience/datascience.ts b/src/client/datascience/datascience.ts new file mode 100644 index 000000000000..69d4765c6df9 --- /dev/null +++ b/src/client/datascience/datascience.ts @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { inject, injectable } from 'inversify'; +import { Disposable, ExtensionContext } from 'vscode'; +import { IApplicationShell, ICommandManager } from '../common/application/types'; +import { IDisposableRegistry } from '../common/types'; +import { IDataScience } from './types'; + +@injectable() +export class DataScience implements IDataScience { + constructor(@inject(ICommandManager) private commandManager: ICommandManager, + @inject(IDisposableRegistry) private disposableRegistry: Disposable[], + @inject(IApplicationShell) private appShell: IApplicationShell) { + } + + public async activate(context: ExtensionContext): Promise { + this.registerCommands(); + } + + private registerCommands(): void { + const disposable = this.commandManager.registerCommand('python.datascience', this.executeDataScience, this); + this.disposableRegistry.push(disposable); + } + + private async executeDataScience(): Promise { + await this.appShell.showInformationMessage('Hello Data Science'); + } +} diff --git a/src/client/datascience/history.ts b/src/client/datascience/history.ts new file mode 100644 index 000000000000..a6dc6eb2297c --- /dev/null +++ b/src/client/datascience/history.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; diff --git a/src/client/datascience/historypostoffice.ts b/src/client/datascience/historypostoffice.ts new file mode 100644 index 000000000000..a6dc6eb2297c --- /dev/null +++ b/src/client/datascience/historypostoffice.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; diff --git a/src/client/datascience/jupyterserverprovider.ts b/src/client/datascience/jupyterserverprovider.ts new file mode 100644 index 000000000000..d3a07d747ee3 --- /dev/null +++ b/src/client/datascience/jupyterserverprovider.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { injectable } from 'inversify'; +import { IJupyterServer, IJupyterServerProvider } from './types'; + +@injectable() +export class JupyterServerProvider implements IJupyterServerProvider { + public start(notebookFile: string | undefined): Promise { + return new Promise((resolve, reject) => { + resolve(undefined); + }); + } +} diff --git a/src/client/datascience/serviceRegistry.ts b/src/client/datascience/serviceRegistry.ts new file mode 100644 index 000000000000..0c1d2e6bdeea --- /dev/null +++ b/src/client/datascience/serviceRegistry.ts @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { IServiceManager } from '../ioc/types'; +import { DataScience } from './datascience'; +import { JupyterServerProvider } from './jupyterserverprovider'; +import { IDataScience, IJupyterServerProvider } from './types'; + +export function registerTypes(serviceManager: IServiceManager) { + serviceManager.addSingleton(IDataScience, DataScience); + serviceManager.addSingleton(IJupyterServerProvider, JupyterServerProvider); +} diff --git a/src/client/datascience/types.ts b/src/client/datascience/types.ts new file mode 100644 index 000000000000..a246fd0ab627 --- /dev/null +++ b/src/client/datascience/types.ts @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { ExtensionContext } from 'vscode'; + +// Main interface +export const IDataScience = Symbol('IDataScience'); +export interface IDataScience { + activate(context: ExtensionContext): Promise; +} + +// Factory for jupyter servers +export const IJupyterServerProvider = Symbol('IJupyterServerFactory'); +export interface IJupyterServerProvider { + start(notebookFile: string | undefined): Promise; +} + +// Talks to a jupyter kernel to retrieve data for cells +export const IJupyterServer = Symbol('IJupyterServer'); +export interface IJupyterServer { +} + +// Wraps the VS Code api for creating a web panel +export const IWebPanelProvider = Symbol('IWebPanelProvider'); +export interface IWebPanelProvider { + create(): IWebPanel; +} + +// Wraps the VS Code webview panel +export const IWebPanel = Symbol('IWebPanel'); +export interface IWebPanel { +} + +// Wraps the vscode API in order to send messages back and forth from a webview +export const IPostOffice = Symbol('IPostOffice'); +export interface IPostOffice { + // tslint:disable-next-line:no-any + post(message: string, params: any[] | undefined); + // tslint:disable-next-line:no-any + listen(message: string, listener: (args: any[] | undefined) => void); +} + +// Basic structure for a cell from a notebook +export interface ICell { + input: string; + output: string; + id: number; +} diff --git a/src/client/extension.ts b/src/client/extension.ts index 66986f0996c1..1036d293f06c 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -30,6 +30,8 @@ import { IMemento, IOutputChannel, WORKSPACE_MEMENTO } from './common/types'; import { registerTypes as variableRegisterTypes } from './common/variables/serviceRegistry'; +import { registerTypes as dataScienceRegisterTypes } from './datascience/serviceRegistry'; +import { IDataScience } from './datascience/types'; import { AttachRequestArguments, LaunchRequestArguments } from './debugger/Common/Contracts'; import { BaseConfigurationProvider } from './debugger/configProviders/baseProvider'; import { registerTypes as debugConfigurationRegisterTypes } from './debugger/configProviders/serviceRegistry'; @@ -105,6 +107,10 @@ export async function activate(context: ExtensionContext): Promise(ILintingEngine); lintingEngine.linkJupiterExtension(jupyterExtension).ignoreErrors(); + // Activate the data science features + const dataScience = serviceManager.get(IDataScience); + await dataScience.activate(context); + context.subscriptions.push(new LinterCommands(serviceManager)); const linterProvider = new LinterProvider(context, serviceManager); context.subscriptions.push(linterProvider); @@ -185,6 +191,7 @@ function registerServices(context: ExtensionContext, serviceManager: ServiceMana platformRegisterTypes(serviceManager); installerRegisterTypes(serviceManager); commonRegisterTerminalTypes(serviceManager); + dataScienceRegisterTypes(serviceManager); debugConfigurationRegisterTypes(serviceManager); debuggerRegisterTypes(serviceManager); appRegisterTypes(serviceManager);