forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* working without inversify * Working command with service manager * Initial interfaces
- Loading branch information
Showing
10 changed files
with
158 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<void> { | ||
this.registerCommands(); | ||
} | ||
|
||
private registerCommands(): void { | ||
const disposable = this.commandManager.registerCommand('python.datascience', this.executeDataScience, this); | ||
this.disposableRegistry.push(disposable); | ||
} | ||
|
||
private async executeDataScience(): Promise<void> { | ||
await this.appShell.showInformationMessage('Hello Data Science'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IJupyterServer> { | ||
return new Promise<IJupyterServer>((resolve, reject) => { | ||
resolve(undefined); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>(IDataScience, DataScience); | ||
serviceManager.addSingleton<IJupyterServerProvider>(IJupyterServerProvider, JupyterServerProvider); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<void>; | ||
} | ||
|
||
// Factory for jupyter servers | ||
export const IJupyterServerProvider = Symbol('IJupyterServerFactory'); | ||
export interface IJupyterServerProvider { | ||
start(notebookFile: string | undefined): Promise<IJupyterServer>; | ||
} | ||
|
||
// 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters