Skip to content

Add command for loading of LS extensions #1914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Jun 8, 2018
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a764bc9
Undo changes
Feb 13, 2018
9d1b2cc
Test fixes
Feb 13, 2018
a91291a
Increase timeout
Mar 2, 2018
bf266af
Remove double event listening
Mar 7, 2018
7bc6bd6
Remove test
Mar 7, 2018
8ce8b48
Revert "Remove test"
Mar 7, 2018
e3a549e
Revert "Remove double event listening"
Mar 7, 2018
92e8c1e
#1096 The if statement is automatically formatted incorrectly
Mar 27, 2018
b540a1d
Merge fix
Mar 27, 2018
7b0573e
Add more tests
Mar 27, 2018
facb106
More tests
Mar 27, 2018
f113881
Typo
Mar 27, 2018
3e76718
Test
Mar 28, 2018
6e85dc6
Also better handle multiline arguments
Mar 28, 2018
99e037c
Add a couple missing periods
brettcannon Mar 28, 2018
3caeab7
Undo changes
Feb 13, 2018
eeb1f11
Test fixes
Feb 13, 2018
f5f78c7
Increase timeout
Mar 2, 2018
88744da
Remove double event listening
Mar 7, 2018
65dde44
Remove test
Mar 7, 2018
c513f71
Revert "Remove test"
Mar 7, 2018
ccb3886
Revert "Remove double event listening"
Mar 7, 2018
106f4db
Merge fix
Mar 27, 2018
9e5cb43
Merge branch 'master' of https://github.com/MikhailArkhipov/vscode-py…
Apr 5, 2018
e1da6a6
#1257 On type formatting errors for args and kwargs
Apr 5, 2018
e78f0fb
Handle f-strings
Apr 5, 2018
725cf71
Stop importing from test code
Apr 5, 2018
5cd6d45
#1308 Single line statements leading to an indentation on the next line
Apr 5, 2018
27613db
#726 editing python after inline if statement invalid indent
Apr 5, 2018
8061a20
Undo change
Apr 5, 2018
17dc292
Move constant
Apr 5, 2018
65964b9
Harden LS startup error checks
Apr 10, 2018
4bf5a4c
#1364 Intellisense doesn't work after specific const string
Apr 10, 2018
6f7212c
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Apr 12, 2018
ddbd295
Telemetry for the analysis enging
Apr 12, 2018
ffd1d3f
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Apr 12, 2018
d4afb6c
PR feedback
Apr 13, 2018
12186b8
Fix typo
Apr 16, 2018
ca90529
Test baseline update
Apr 16, 2018
a06fd79
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Apr 26, 2018
ef7c5c7
Improve function argument detection
Apr 26, 2018
f4e88c0
Specify markdown
Apr 27, 2018
d420c34
Merge branch 'master' of https://github.com/Microsoft/vscode-python
May 3, 2018
e0fe469
Merge branch 'master' of https://github.com/Microsoft/vscode-python
May 11, 2018
d9ebbd1
Remove Pythia
May 17, 2018
96441b7
Merge master
Jun 7, 2018
c3b4f9d
Load extension command
Jun 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/client/activation/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { inject, injectable } from 'inversify';
import * as path from 'path';
import { ExtensionContext, OutputChannel } from 'vscode';
import { Disposable, LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient';
import { IApplicationShell } from '../common/application/types';
import { IApplicationShell, ICommandManager } from '../common/application/types';
import { isTestExecution, STANDARD_OUTPUT_CHANNEL } from '../common/constants';
import { createDeferred, Deferred } from '../common/helpers';
import { IFileSystem, IPlatformService } from '../common/platform/types';
import { StopWatch } from '../common/stopWatch';
import { IConfigurationService, IExtensionContext, IOutputChannel } from '../common/types';
Expand All @@ -28,6 +29,7 @@ const PYTHON = 'python';
const dotNetCommand = 'dotnet';
const languageClientName = 'Python Tools';
const analysisEngineFolder = 'analysis';
const loadExtensionCommand = 'python._loadLanguageServerExtension';

@injectable()
export class AnalysisExtensionActivator implements IExtensionActivator {
Expand All @@ -38,7 +40,9 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
private readonly sw = new StopWatch();
private readonly platformData: PlatformData;
private readonly interpreterService: IInterpreterService;
private readonly startupCompleted: Deferred<void>;
private readonly disposables: Disposable[] = [];

private languageClient: LanguageClient | undefined;
private readonly context: ExtensionContext;
private interpreterHash: string = '';
Expand All @@ -51,6 +55,17 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
this.fs = this.services.get<IFileSystem>(IFileSystem);
this.platformData = new PlatformData(services.get<IPlatformService>(IPlatformService), this.fs);
this.interpreterService = this.services.get<IInterpreterService>(IInterpreterService);

this.startupCompleted = createDeferred<void>();
const commandManager = this.services.get<ICommandManager>(ICommandManager);
this.disposables.push(commandManager.registerCommand(loadExtensionCommand,
async (args) => {
if (this.languageClient) {
await this.startupCompleted.promise;
this.languageClient.sendRequest('python/loadExtension', args);
}
}
));
}

public async activate(): Promise<boolean> {
Expand Down Expand Up @@ -119,9 +134,15 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
}

private async startLanguageClient(context: ExtensionContext): Promise<void> {
this.languageClient!.onReady()
.then(() => {
this.startupCompleted.resolve();
})
.catch(error => this.startupCompleted.reject(error));

context.subscriptions.push(this.languageClient!.start());
if (isTestExecution()) {
await this.languageClient!.onReady();
await this.startupCompleted.promise;
}
}

Expand Down