| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,7 +85,8 @@ | |||
| 85 | 85 | "onCommand:python.setLinter", | |
| 86 | 86 | "onCommand:python.enableLinting", | |
| 87 | 87 | "onCommand:python.createTerminal", | |
| 88 | - "onCommand:python.discoverTests" | ||
| 88 | + "onCommand:python.discoverTests", | ||
| 89 | + "onCommand:python.datascience" | ||
| 89 | 90 | ], | |
| 90 | 91 | "main": "./out/client/extension", | |
| 91 | 92 | "contributes": { | |
@@ -222,6 +223,11 @@ | |||
| 222 | 223 | "command": "python.runLinting", | |
| 223 | 224 | "title": "%python.command.python.runLinting.title%", | |
| 224 | 225 | "category": "Python" | |
| 226 | + }, | ||
| 227 | + { | ||
| 228 | + "command": "python.datascience", | ||
| 229 | + "title": "Datascience Command", | ||
| 230 | + "category": "Python Datascience" | ||
| 225 | 231 | } | |
| 226 | 232 | ], | |
| 227 | 233 | "menus": { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT License. | ||
| 3 | + | ||
| 4 | + 'use strict'; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT License. | ||
| 3 | + | ||
| 4 | + 'use strict'; | ||
| 5 | + | ||
| 6 | + import { inject, injectable } from 'inversify'; | ||
| 7 | + import { Disposable, ExtensionContext } from 'vscode'; | ||
| 8 | + import { IApplicationShell, ICommandManager } from '../common/application/types'; | ||
| 9 | + import { IDisposableRegistry } from '../common/types'; | ||
| 10 | + import { IDataScience } from './types'; | ||
| 11 | + | ||
| 12 | + @injectable() | ||
| 13 | + export class DataScience implements IDataScience { | ||
| 14 | + constructor(@inject(ICommandManager) private commandManager: ICommandManager, | ||
| 15 | + @inject(IDisposableRegistry) private disposableRegistry: Disposable[], | ||
| 16 | + @inject(IApplicationShell) private appShell: IApplicationShell) { | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public async activate(context: ExtensionContext): Promise<void> { | ||
| 20 | + this.registerCommands(); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + private registerCommands(): void { | ||
| 24 | + const disposable = this.commandManager.registerCommand('python.datascience', this.executeDataScience, this); | ||
| 25 | + this.disposableRegistry.push(disposable); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + private async executeDataScience(): Promise<void> { | ||
| 29 | + await this.appShell.showInformationMessage('Hello Data Science'); | ||
| 30 | + } | ||
| 31 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT License. | ||
| 3 | + | ||
| 4 | + 'use strict'; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT License. | ||
| 3 | + | ||
| 4 | + 'use strict'; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT License. | ||
| 3 | + | ||
| 4 | + 'use strict'; | ||
| 5 | + | ||
| 6 | + import { injectable } from 'inversify'; | ||
| 7 | + import { IJupyterServer, IJupyterServerProvider } from './types'; | ||
| 8 | + | ||
| 9 | + @injectable() | ||
| 10 | + export class JupyterServerProvider implements IJupyterServerProvider { | ||
| 11 | + public start(notebookFile: string | undefined): Promise<IJupyterServer> { | ||
| 12 | + return new Promise<IJupyterServer>((resolve, reject) => { | ||
| 13 | + resolve(undefined); | ||
| 14 | + }); | ||
| 15 | + } | ||
| 16 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT License. | ||
| 3 | + | ||
| 4 | + 'use strict'; | ||
| 5 | + | ||
| 6 | + import { IServiceManager } from '../ioc/types'; | ||
| 7 | + import { DataScience } from './datascience'; | ||
| 8 | + import { JupyterServerProvider } from './jupyterserverprovider'; | ||
| 9 | + import { IDataScience, IJupyterServerProvider } from './types'; | ||
| 10 | + | ||
| 11 | + export function registerTypes(serviceManager: IServiceManager) { | ||
| 12 | + serviceManager.addSingleton<IDataScience>(IDataScience, DataScience); | ||
| 13 | + serviceManager.addSingleton<IJupyterServerProvider>(IJupyterServerProvider, JupyterServerProvider); | ||
| 14 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,50 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT License. | ||
| 3 | + | ||
| 4 | + 'use strict'; | ||
| 5 | + | ||
| 6 | + import { ExtensionContext } from 'vscode'; | ||
| 7 | + | ||
| 8 | + // Main interface | ||
| 9 | + export const IDataScience = Symbol('IDataScience'); | ||
| 10 | + export interface IDataScience { | ||
| 11 | + activate(context: ExtensionContext): Promise<void>; | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + // Factory for jupyter servers | ||
| 15 | + export const IJupyterServerProvider = Symbol('IJupyterServerFactory'); | ||
| 16 | + export interface IJupyterServerProvider { | ||
| 17 | + start(notebookFile: string | undefined): Promise<IJupyterServer>; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + // Talks to a jupyter kernel to retrieve data for cells | ||
| 21 | + export const IJupyterServer = Symbol('IJupyterServer'); | ||
| 22 | + export interface IJupyterServer { | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + // Wraps the VS Code api for creating a web panel | ||
| 26 | + export const IWebPanelProvider = Symbol('IWebPanelProvider'); | ||
| 27 | + export interface IWebPanelProvider { | ||
| 28 | + create(): IWebPanel; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + // Wraps the VS Code webview panel | ||
| 32 | + export const IWebPanel = Symbol('IWebPanel'); | ||
| 33 | + export interface IWebPanel { | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + // Wraps the vscode API in order to send messages back and forth from a webview | ||
| 37 | + export const IPostOffice = Symbol('IPostOffice'); | ||
| 38 | + export interface IPostOffice { | ||
| 39 | + // tslint:disable-next-line:no-any | ||
| 40 | + post(message: string, params: any[] | undefined); | ||
| 41 | + // tslint:disable-next-line:no-any | ||
| 42 | + listen(message: string, listener: (args: any[] | undefined) => void); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + // Basic structure for a cell from a notebook | ||
| 46 | + export interface ICell { | ||
| 47 | + input: string; | ||
| 48 | + output: string; | ||
| 49 | + id: number; | ||
| 50 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,8 @@ import { | |||
| 30 | 30 | IMemento, IOutputChannel, WORKSPACE_MEMENTO | |
| 31 | 31 | } from './common/types'; | |
| 32 | 32 | import { registerTypes as variableRegisterTypes } from './common/variables/serviceRegistry'; | |
| 33 | + import { registerTypes as dataScienceRegisterTypes } from './datascience/serviceRegistry'; | ||
| 34 | + import { IDataScience } from './datascience/types'; | ||
| 33 | 35 | import { AttachRequestArguments, LaunchRequestArguments } from './debugger/Common/Contracts'; | |
| 34 | 36 | import { BaseConfigurationProvider } from './debugger/configProviders/baseProvider'; | |
| 35 | 37 | import { registerTypes as debugConfigurationRegisterTypes } from './debugger/configProviders/serviceRegistry'; | |
@@ -105,6 +107,10 @@ export async function activate(context: ExtensionContext): Promise<IExtensionApi | |||
| 105 | 107 | const lintingEngine = serviceManager.get<ILintingEngine>(ILintingEngine); | |
| 106 | 108 | lintingEngine.linkJupiterExtension(jupyterExtension).ignoreErrors(); | |
| 107 | 109 | ||
| 110 | + // Activate the data science features | ||
| 111 | + const dataScience = serviceManager.get<IDataScience>(IDataScience); | ||
| 112 | + await dataScience.activate(context); | ||
| 113 | + | ||
| 108 | 114 | context.subscriptions.push(new LinterCommands(serviceManager)); | |
| 109 | 115 | const linterProvider = new LinterProvider(context, serviceManager); | |
| 110 | 116 | context.subscriptions.push(linterProvider); | |
@@ -185,6 +191,7 @@ function registerServices(context: ExtensionContext, serviceManager: ServiceMana | |||
| 185 | 191 | platformRegisterTypes(serviceManager); | |
| 186 | 192 | installerRegisterTypes(serviceManager); | |
| 187 | 193 | commonRegisterTerminalTypes(serviceManager); | |
| 194 | + dataScienceRegisterTypes(serviceManager); | ||
| 188 | 195 | debugConfigurationRegisterTypes(serviceManager); | |
| 189 | 196 | debuggerRegisterTypes(serviceManager); | |
| 190 | 197 | appRegisterTypes(serviceManager); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments