Skip to content

Commit e07c5fb

Browse files
author
Mikhail Arkhipov
authored
WIP: Rename LS to 'Microsoft Python Language Server' (#2122)
* LS symbol providers * Different ready wait * Progress reporting * Options hookup * Add diagnostic trace logging setting (hidden) * Rename analysis engine -> language server * Fix language server binary name * Finish renames * Add news * Undo * Baseline update * Rename and baseline * Fix contributions * Baseline
1 parent b72ff96 commit e07c5fb

33 files changed

+817
-813
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ coverage/
1515
.venv
1616
pythonFiles/experimental/ptvsd/**
1717
debug_coverage*/**
18-
analysis/**
18+
languageServer/**
1919
bin/**
2020
obj/**
2121
.pytest_cache

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"preLaunchTask": "Compile"
105105
},
106106
{
107-
"name": "Launch Analysis Engine Tests",
107+
"name": "Launch Language Server Tests",
108108
"type": "extensionHost",
109109
"request": "launch",
110110
"runtimeExecutable": "${execPath}",
@@ -120,7 +120,7 @@
120120
],
121121
"preLaunchTask": "Compile",
122122
"env": {
123-
"VSC_PYTHON_ANALYSIS": "1"
123+
"VSC_PYTHON_LANGUAGE_SERVER": "1"
124124
}
125125
},
126126
{

.vscodeignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ yarn.lock
2626
.nvm/**
2727
.vscode/**
2828
.vscode-test/**
29-
analysis/publish*.*
29+
languageServer/publish*.*
3030
bin/**
3131
BuildOutput/**
3232
coverage/**
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Contributing to Microsoft Python Analysis Engine
1+
# Contributing to Microsoft Python Language Server
22
[![Contributing to Python Tools for Visual Studio](https://github.com/Microsoft/PTVS/blob/master/CONTRIBUTING.md)]
33

44
[![Build Status (Travis)](https://travis-ci.org/Microsoft/vscode-python.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-python) [![Build status (AppVeyor)](https://ci.appveyor.com/api/projects/status/s0pt8d79gqw222j7?svg=true)](https://ci.appveyor.com/project/DonJayamanne/vscode-python-v3vd6) [![codecov](https://codecov.io/gh/Microsoft/vscode-python/branch/master/graph/badge.svg)](https://codecov.io/gh/Microsoft/vscode-python)
@@ -30,9 +30,9 @@ Visual Studio 2017:
3030
1. Open solution in Python/Product/VsCode
3131
2. Build AnalysisVsc project
3232
3. Binaries arrive in *Python/BuildOutput/VsCode/raw*
33-
4. Delete contents of the *analysis* folder in the Python Extension folder
34-
5. Copy *.dll, *.pdb, *.json fron *Python/BuildOutput/VsCode/raw* to *analysis*
35-
6. In VS Code set setting *python.downloadCodeAnalysis* to *false*
33+
4. Delete contents of the *languageServer* folder in the Python Extension folder
34+
5. Copy *.dll, *.pdb, *.json fron *Python/BuildOutput/VsCode/raw* to *languageServer*
35+
6. In VS Code set setting *python.downloadLanguageServer* to *false*
3636
7. In VS Code set setting *python.jediEnabled* to *false*
3737

3838
### Debugging code in Python Extension to VS Code
@@ -44,7 +44,7 @@ Folow regular TypeScript debugging steps
4444
3. Python Analysis Engine code is in *Python/Product/VsCode/Analysis*
4545
4. Run extension from VS Code
4646
5. In the instance with C# code select Dotnet Attach launch task.
47-
6. Attach to *dotnet* process running *Microsoft.PythonTools.VsCode.dll*
47+
6. Attach to *dotnet* process running *Microsoft.Python.languageServer.dll*
4848

4949
On Windows you can also attach from Visual Studio 2017.
5050

news/1 Enhancements/2107.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Messages changes to reflect name of the language server: 'Microsoft Python Language Server'.
2+
Folder name changed from 'analysis' to 'languageServer'.

src/client/activation/activationService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { inject, injectable } from 'inversify';
77
import { ConfigurationChangeEvent, Disposable, OutputChannel, Uri } from 'vscode';
88
import { IApplicationShell, ICommandManager, IWorkspaceService } from '../common/application/types';
9-
import { isPythonAnalysisEngineTest, STANDARD_OUTPUT_CHANNEL } from '../common/constants';
9+
import { isLanguageServerTest, STANDARD_OUTPUT_CHANNEL } from '../common/constants';
1010
import '../common/extensions';
1111
import { IConfigurationService, IDisposableRegistry, IOutputChannel, IPythonSettings } from '../common/types';
1212
import { IServiceContainer } from '../ioc/types';
@@ -38,8 +38,8 @@ export class ExtensionActivationService implements IExtensionActivationService,
3838

3939
const jedi = this.useJedi();
4040

41-
const engineName = jedi ? 'classic analysis engine' : 'analysis engine';
42-
this.output.appendLine(`Starting the ${engineName}.`);
41+
const engineName = jedi ? 'Jedi Python language engine' : 'Microsoft Python language server';
42+
this.output.appendLine(`Starting ${engineName}.`);
4343
const activatorName = jedi ? ExtensionActivators.Jedi : ExtensionActivators.DotNet;
4444
const activator = this.serviceContainer.get<IExtensionActivator>(IExtensionActivator, activatorName);
4545
this.currentActivator = { jedi, activator };
@@ -61,7 +61,7 @@ export class ExtensionActivationService implements IExtensionActivationService,
6161
return;
6262
}
6363

64-
const item = await this.appShell.showInformationMessage('Please reload the window switching between the analysis engines.', 'Reload');
64+
const item = await this.appShell.showInformationMessage('Please reload the window switching between language engines.', 'Reload');
6565
if (item === 'Reload') {
6666
this.serviceContainer.get<ICommandManager>(ICommandManager).executeCommand('workbench.action.reloadWindow');
6767
}
@@ -70,6 +70,6 @@ export class ExtensionActivationService implements IExtensionActivationService,
7070
const workspacesUris: (Uri | undefined)[] = this.workspaceService.hasWorkspaceFolders ? this.workspaceService.workspaceFolders!.map(item => item.uri) : [undefined];
7171
const configuraionService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
7272
const jediEnabledForAnyWorkspace = workspacesUris.filter(uri => configuraionService.getSettings(uri).jediEnabled).length > 0;
73-
return !isPythonAnalysisEngineTest() && jediEnabledForAnyWorkspace;
73+
return !isLanguageServerTest() && jediEnabledForAnyWorkspace;
7474
}
7575
}

src/client/activation/downloader.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import { PlatformData } from './platformData';
1717
// tslint:disable-next-line:no-require-imports no-var-requires
1818
const StreamZip = require('node-stream-zip');
1919

20-
const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-analysis';
21-
const downloadBaseFileName = 'Python-Analysis-VSCode';
20+
const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-language-server';
21+
const downloadBaseFileName = 'Python-Language-Server';
2222
const downloadVersion = '0.1.0';
2323
const downloadFileExtension = '.nupkg';
2424

25-
export class AnalysisEngineDownloader {
25+
export class LanguageServerDownloader {
2626
private readonly output: OutputChannel;
2727
private readonly platform: IPlatformService;
2828
private readonly platformData: PlatformData;
@@ -35,7 +35,7 @@ export class AnalysisEngineDownloader {
3535
this.platformData = new PlatformData(this.platform, this.fs);
3636
}
3737

38-
public async downloadAnalysisEngine(context: IExtensionContext): Promise<void> {
38+
public async downloadLanguageServer(context: IExtensionContext): Promise<void> {
3939
const platformString = await this.platformData.getPlatformName();
4040
const enginePackageFileName = `${downloadBaseFileName}-${platformString}.${downloadVersion}${downloadFileExtension}`;
4141

@@ -142,6 +142,8 @@ export class AnalysisEngineDownloader {
142142
}).on('extract', (entry, file) => {
143143
extractedFiles += 1;
144144
progress.report({ message: `${title}${Math.round(100 * extractedFiles / totalFiles)}%` });
145+
}).on('error', e => {
146+
deferred.reject(e);
145147
});
146148
return deferred.promise;
147149
});
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
2-
// Licensed under the MIT License.
3-
4-
import { inject, injectable } from 'inversify';
5-
import { DocumentFilter, languages } from 'vscode';
6-
import { PYTHON } from '../common/constants';
7-
import { IConfigurationService, IExtensionContext, ILogger } from '../common/types';
8-
import { IShebangCodeLensProvider } from '../interpreter/contracts';
9-
import { IServiceContainer, IServiceManager } from '../ioc/types';
10-
import { JediFactory } from '../languageServices/jediProxyFactory';
11-
import { PythonCompletionItemProvider } from '../providers/completionProvider';
12-
import { PythonDefinitionProvider } from '../providers/definitionProvider';
13-
import { PythonHoverProvider } from '../providers/hoverProvider';
14-
import { activateGoToObjectDefinitionProvider } from '../providers/objectDefinitionProvider';
15-
import { PythonReferenceProvider } from '../providers/referenceProvider';
16-
import { PythonRenameProvider } from '../providers/renameProvider';
17-
import { PythonSignatureProvider } from '../providers/signatureProvider';
18-
import { PythonSymbolProvider } from '../providers/symbolProvider';
19-
import { IUnitTestManagementService } from '../unittests/types';
20-
import { WorkspaceSymbols } from '../workspaceSymbols/main';
21-
import { IExtensionActivator } from './types';
22-
23-
@injectable()
24-
export class ClassicExtensionActivator implements IExtensionActivator {
25-
private readonly context: IExtensionContext;
26-
private jediFactory?: JediFactory;
27-
private readonly documentSelector: DocumentFilter[];
28-
constructor(@inject(IServiceManager) private serviceManager: IServiceManager) {
29-
this.context = this.serviceManager.get<IExtensionContext>(IExtensionContext);
30-
this.documentSelector = PYTHON;
31-
}
32-
33-
public async activate(): Promise<boolean> {
34-
const context = this.context;
35-
36-
const jediFactory = this.jediFactory = new JediFactory(context.asAbsolutePath('.'), this.serviceManager);
37-
context.subscriptions.push(jediFactory);
38-
context.subscriptions.push(...activateGoToObjectDefinitionProvider(jediFactory));
39-
40-
context.subscriptions.push(jediFactory);
41-
context.subscriptions.push(languages.registerRenameProvider(this.documentSelector, new PythonRenameProvider(this.serviceManager)));
42-
const definitionProvider = new PythonDefinitionProvider(jediFactory);
43-
44-
context.subscriptions.push(languages.registerDefinitionProvider(this.documentSelector, definitionProvider));
45-
context.subscriptions.push(languages.registerHoverProvider(this.documentSelector, new PythonHoverProvider(jediFactory)));
46-
context.subscriptions.push(languages.registerReferenceProvider(this.documentSelector, new PythonReferenceProvider(jediFactory)));
47-
context.subscriptions.push(languages.registerCompletionItemProvider(this.documentSelector, new PythonCompletionItemProvider(jediFactory, this.serviceManager), '.'));
48-
context.subscriptions.push(languages.registerCodeLensProvider(this.documentSelector, this.serviceManager.get<IShebangCodeLensProvider>(IShebangCodeLensProvider)));
49-
50-
const serviceContainer = this.serviceManager.get<IServiceContainer>(IServiceContainer);
51-
context.subscriptions.push(new WorkspaceSymbols(serviceContainer));
52-
53-
const symbolProvider = new PythonSymbolProvider(serviceContainer, jediFactory);
54-
context.subscriptions.push(languages.registerDocumentSymbolProvider(this.documentSelector, symbolProvider));
55-
56-
const pythonSettings = this.serviceManager.get<IConfigurationService>(IConfigurationService).getSettings();
57-
if (pythonSettings.devOptions.indexOf('DISABLE_SIGNATURE') === -1) {
58-
context.subscriptions.push(languages.registerSignatureHelpProvider(this.documentSelector, new PythonSignatureProvider(jediFactory), '(', ','));
59-
}
60-
61-
const testManagementService = this.serviceManager.get<IUnitTestManagementService>(IUnitTestManagementService);
62-
testManagementService.activate()
63-
.then(() => testManagementService.activateCodeLenses(symbolProvider))
64-
.catch(ex => this.serviceManager.get<ILogger>(ILogger).logError('Failed to activate Unit Tests', ex));
65-
66-
return true;
67-
}
68-
69-
public async deactivate(): Promise<void> {
70-
if (this.jediFactory) {
71-
this.jediFactory.dispose();
72-
}
73-
}
74-
}
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
import { inject, injectable } from 'inversify';
5+
import { DocumentFilter, languages } from 'vscode';
6+
import { PYTHON } from '../common/constants';
7+
import { IConfigurationService, IExtensionContext, ILogger } from '../common/types';
8+
import { IShebangCodeLensProvider } from '../interpreter/contracts';
9+
import { IServiceContainer, IServiceManager } from '../ioc/types';
10+
import { JediFactory } from '../languageServices/jediProxyFactory';
11+
import { PythonCompletionItemProvider } from '../providers/completionProvider';
12+
import { PythonDefinitionProvider } from '../providers/definitionProvider';
13+
import { PythonHoverProvider } from '../providers/hoverProvider';
14+
import { activateGoToObjectDefinitionProvider } from '../providers/objectDefinitionProvider';
15+
import { PythonReferenceProvider } from '../providers/referenceProvider';
16+
import { PythonRenameProvider } from '../providers/renameProvider';
17+
import { PythonSignatureProvider } from '../providers/signatureProvider';
18+
import { PythonSymbolProvider } from '../providers/symbolProvider';
19+
import { IUnitTestManagementService } from '../unittests/types';
20+
import { WorkspaceSymbols } from '../workspaceSymbols/main';
21+
import { IExtensionActivator } from './types';
22+
23+
@injectable()
24+
export class JediExtensionActivator implements IExtensionActivator {
25+
private readonly context: IExtensionContext;
26+
private jediFactory?: JediFactory;
27+
private readonly documentSelector: DocumentFilter[];
28+
constructor(@inject(IServiceManager) private serviceManager: IServiceManager) {
29+
this.context = this.serviceManager.get<IExtensionContext>(IExtensionContext);
30+
this.documentSelector = PYTHON;
31+
}
32+
33+
public async activate(): Promise<boolean> {
34+
const context = this.context;
35+
36+
const jediFactory = this.jediFactory = new JediFactory(context.asAbsolutePath('.'), this.serviceManager);
37+
context.subscriptions.push(jediFactory);
38+
context.subscriptions.push(...activateGoToObjectDefinitionProvider(jediFactory));
39+
40+
context.subscriptions.push(jediFactory);
41+
context.subscriptions.push(languages.registerRenameProvider(this.documentSelector, new PythonRenameProvider(this.serviceManager)));
42+
const definitionProvider = new PythonDefinitionProvider(jediFactory);
43+
44+
context.subscriptions.push(languages.registerDefinitionProvider(this.documentSelector, definitionProvider));
45+
context.subscriptions.push(languages.registerHoverProvider(this.documentSelector, new PythonHoverProvider(jediFactory)));
46+
context.subscriptions.push(languages.registerReferenceProvider(this.documentSelector, new PythonReferenceProvider(jediFactory)));
47+
context.subscriptions.push(languages.registerCompletionItemProvider(this.documentSelector, new PythonCompletionItemProvider(jediFactory, this.serviceManager), '.'));
48+
context.subscriptions.push(languages.registerCodeLensProvider(this.documentSelector, this.serviceManager.get<IShebangCodeLensProvider>(IShebangCodeLensProvider)));
49+
50+
const serviceContainer = this.serviceManager.get<IServiceContainer>(IServiceContainer);
51+
context.subscriptions.push(new WorkspaceSymbols(serviceContainer));
52+
53+
const symbolProvider = new PythonSymbolProvider(serviceContainer, jediFactory);
54+
context.subscriptions.push(languages.registerDocumentSymbolProvider(this.documentSelector, symbolProvider));
55+
56+
const pythonSettings = this.serviceManager.get<IConfigurationService>(IConfigurationService).getSettings();
57+
if (pythonSettings.devOptions.indexOf('DISABLE_SIGNATURE') === -1) {
58+
context.subscriptions.push(languages.registerSignatureHelpProvider(this.documentSelector, new PythonSignatureProvider(jediFactory), '(', ','));
59+
}
60+
61+
const testManagementService = this.serviceManager.get<IUnitTestManagementService>(IUnitTestManagementService);
62+
testManagementService.activate()
63+
.then(() => testManagementService.activateCodeLenses(symbolProvider))
64+
.catch(ex => this.serviceManager.get<ILogger>(ILogger).logError('Failed to activate Unit Tests', ex));
65+
66+
return true;
67+
}
68+
69+
public async deactivate(): Promise<void> {
70+
if (this.jediFactory) {
71+
this.jediFactory.dispose();
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)