From 997635ac0d79a9f6e0cc45458c77a1e5ff0c7b07 Mon Sep 17 00:00:00 2001 From: MikhailArkhipov Date: Fri, 8 Jun 2018 14:07:24 -0700 Subject: [PATCH 1/4] LS symbol providers --- src/client/activation/classic.ts | 6 +++++- src/client/extension.ts | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/activation/classic.ts b/src/client/activation/classic.ts index 17ca5c929047..72745cab86be 100644 --- a/src/client/activation/classic.ts +++ b/src/client/activation/classic.ts @@ -17,6 +17,7 @@ import { PythonRenameProvider } from '../providers/renameProvider'; import { PythonSignatureProvider } from '../providers/signatureProvider'; import { PythonSymbolProvider } from '../providers/symbolProvider'; import { IUnitTestManagementService } from '../unittests/types'; +import { WorkspaceSymbols } from '../workspaceSymbols/main'; import { IExtensionActivator } from './types'; @injectable() @@ -46,7 +47,10 @@ export class ClassicExtensionActivator implements IExtensionActivator { context.subscriptions.push(languages.registerCompletionItemProvider(this.documentSelector, new PythonCompletionItemProvider(jediFactory, this.serviceManager), '.')); context.subscriptions.push(languages.registerCodeLensProvider(this.documentSelector, this.serviceManager.get(IShebangCodeLensProvider))); - const symbolProvider = new PythonSymbolProvider(this.serviceManager.get(IServiceContainer), jediFactory); + const serviceContainer = this.serviceManager.get(IServiceContainer); + context.subscriptions.push(new WorkspaceSymbols(serviceContainer)); + + const symbolProvider = new PythonSymbolProvider(serviceContainer, jediFactory); context.subscriptions.push(languages.registerDocumentSymbolProvider(this.documentSelector, symbolProvider)); const pythonSettings = this.serviceManager.get(IConfigurationService).getSettings(); diff --git a/src/client/extension.ts b/src/client/extension.ts index 2228cca81495..43d42ac389a6 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -56,7 +56,6 @@ import { BlockFormatProviders } from './typeFormatters/blockFormatProvider'; import { OnEnterFormatter } from './typeFormatters/onEnterFormatter'; import { TEST_OUTPUT_CHANNEL } from './unittests/common/constants'; import { registerTypes as unitTestsRegisterTypes } from './unittests/serviceRegistry'; -import { WorkspaceSymbols } from './workspaceSymbols/main'; const activationDeferred = createDeferred(); export const activated = activationDeferred.promise; @@ -143,7 +142,6 @@ export async function activate(context: ExtensionContext) { context.subscriptions.push(new ReplProvider(serviceContainer)); context.subscriptions.push(new TerminalProvider(serviceContainer)); - context.subscriptions.push(new WorkspaceSymbols(serviceContainer)); type ConfigurationProvider = BaseConfigurationProvider; serviceContainer.getAll(IDebugConfigurationProvider).forEach(debugConfig => { From efb84ae153ee13fd40910ae33799c8081cb52783 Mon Sep 17 00:00:00 2001 From: MikhailArkhipov Date: Thu, 21 Jun 2018 14:37:08 -0700 Subject: [PATCH 2/4] Typeshed paths --- package.json | 9 +++++++++ src/client/activation/analysis.ts | 4 +++- src/client/common/configSettings.ts | 3 ++- src/client/common/types.ts | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 854b86447122..4bd7fa61c640 100644 --- a/package.json +++ b/package.json @@ -1173,6 +1173,15 @@ "description": "Controls appearance of methods with double underscores in the completion list.", "scope": "resource" }, + "python.autoComplete.typeshedPaths": { + "type": "array", + "items": { + "type": "string" + }, + "default": [], + "description": "Specifies paths to local typeshed repository clone(s) for the Python language server.", + "scope": "resource" + }, "python.disableInstallationCheck": { "type": "boolean", "default": false, diff --git a/src/client/activation/analysis.ts b/src/client/activation/analysis.ts index 536530d74050..408a211fa2fd 100644 --- a/src/client/activation/analysis.ts +++ b/src/client/activation/analysis.ts @@ -190,7 +190,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator { const interpreterDataService = new InterpreterDataService(this.context, this.services); interpreterData = await interpreterDataService.getInterpreterData(); } catch (ex) { - this.appShell.showErrorMessage('Unable to determine path to the Python interpreter. IntelliSense will be limited.'); + this.appShell.showWarningMessage('Unable to determine path to the Python interpreter. IntelliSense will be limited.'); } this.interpreterHash = interpreterData ? interpreterData.hash : ''; @@ -245,6 +245,8 @@ export class AnalysisExtensionActivator implements IExtensionActivator { trimDocumentationText: false, maxDocumentationTextLength: 0 }, + searchPaths, + typeshedPaths: settings.autoComplete.typeshedPaths, asyncStartup: true, excludeFiles: excludeFiles, testEnvironment: isTestExecution() diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index d15bfefee183..4c55c4a2b3a3 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -233,7 +233,8 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { extraPaths: [], addBrackets: false, preloadModules: [], - showAdvancedMembers: false + showAdvancedMembers: false, + typeshedPaths: [] }; // tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion diff --git a/src/client/common/types.ts b/src/client/common/types.ts index 733f0ffbee84..c671ae4e3bd5 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -221,6 +221,7 @@ export interface IAutoCompleteSettings { readonly extraPaths: string[]; readonly preloadModules: string[]; readonly showAdvancedMembers: boolean; + readonly typeshedPaths: string[]; } export interface IWorkspaceSymbolSettings { readonly enabled: boolean; @@ -237,6 +238,7 @@ export interface ITerminalSettings { } export interface IPythonAnalysisEngineSettings { readonly showAdvancedMembers: boolean; + readonly typeshedPaths: string[]; } export const IConfigurationService = Symbol('IConfigurationService'); From 69c7d5f532221665f384d44c5749ab7af5d2f0ac Mon Sep 17 00:00:00 2001 From: MikhailArkhipov Date: Thu, 21 Jun 2018 14:51:36 -0700 Subject: [PATCH 3/4] Typeshed submodule --- .gitmodules | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000000..e3e61d18b9c1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "typeshed"] + path = typeshed + url = https://github.com/python/typeshed + branch = master \ No newline at end of file From 5bf6f47cf9cb9ba2ad0f2752efedccbd6a8c4ebb Mon Sep 17 00:00:00 2001 From: MikhailArkhipov Date: Thu, 21 Jun 2018 16:08:17 -0700 Subject: [PATCH 4/4] Add submodule --- .gitmodules | 2 +- src/client/activation/analysis.ts | 17 ++++++++++++----- typeshed | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) create mode 160000 typeshed diff --git a/.gitmodules b/.gitmodules index e3e61d18b9c1..a57bae098756 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "typeshed"] path = typeshed - url = https://github.com/python/typeshed + url = https://github.com/python/typeshed.git branch = master \ No newline at end of file diff --git a/src/client/activation/analysis.ts b/src/client/activation/analysis.ts index 408a211fa2fd..01d2e911e902 100644 --- a/src/client/activation/analysis.ts +++ b/src/client/activation/analysis.ts @@ -204,13 +204,16 @@ export class AnalysisExtensionActivator implements IExtensionActivator { properties['PrefixPath'] = interpreterData.prefix; } - let searchPaths = interpreterData ? interpreterData.searchPaths : ''; + let searchPathsString = interpreterData ? interpreterData.searchPaths : ''; + let typeshedPaths: string[] = []; + const settings = this.configuration.getSettings(); if (settings.autoComplete) { const extraPaths = settings.autoComplete.extraPaths; if (extraPaths && extraPaths.length > 0) { - searchPaths = `${searchPaths};${extraPaths.join(';')}`; + searchPathsString = `${searchPathsString};${extraPaths.join(';')}`; } + typeshedPaths = settings.autoComplete.typeshedPaths; } // tslint:disable-next-line:no-string-literal @@ -219,9 +222,13 @@ export class AnalysisExtensionActivator implements IExtensionActivator { // Make sure paths do not contain multiple slashes so file URIs // in VS Code (Node.js) and in the language server (.NET) match. // Note: for the language server paths separator is always ; - searchPaths = searchPaths.split(path.delimiter).map(p => path.normalize(p)).join(';'); + const searchPaths = searchPathsString.split(path.delimiter).map(p => path.normalize(p)); // tslint:disable-next-line:no-string-literal - properties['SearchPaths'] = `${searchPaths};${pythonPath}`; + properties['SearchPaths'] = `${searchPaths.join(';')};${pythonPath}`; + + if (!typeshedPaths || typeshedPaths.length === 0) { + typeshedPaths = [path.join(this.context.extensionPath, 'typeshed')]; + } const selector = [{ language: PYTHON, scheme: 'file' }]; const excludeFiles = this.getExcludedFiles(); @@ -246,7 +253,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator { maxDocumentationTextLength: 0 }, searchPaths, - typeshedPaths: settings.autoComplete.typeshedPaths, + typeStubSearchPaths: typeshedPaths, asyncStartup: true, excludeFiles: excludeFiles, testEnvironment: isTestExecution() diff --git a/typeshed b/typeshed new file mode 160000 index 000000000000..95eff73ab209 --- /dev/null +++ b/typeshed @@ -0,0 +1 @@ +Subproject commit 95eff73ab2092f2c3158198d404a921447172418