From 3ac1c2463acb92c966e900c41ea4b816d5a45047 Mon Sep 17 00:00:00 2001 From: bschnurr Date: Tue, 29 Jul 2025 10:27:15 -0700 Subject: [PATCH 1/2] Add a new pylance api to grab the outputChannel --- src/client/api.ts | 2 ++ src/client/browser/api.ts | 5 ++++- src/client/browser/extension.ts | 4 +++- src/client/pylanceApi.ts | 3 +++ vscode-python.sln | 24 ++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 vscode-python.sln diff --git a/src/client/api.ts b/src/client/api.ts index 908da4be7103..ea552491acbf 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -145,7 +145,9 @@ export function buildApi( }, }, pylance: { + getOutputChannel: () => outputChannel.channel, createClient: (...args: any[]): BaseLanguageClient => { + //deprecated // Make sure we share output channel so that we can share one with // Jedi as well. const clientOptions = args[1] as LanguageClientOptions; diff --git a/src/client/browser/api.ts b/src/client/browser/api.ts index ac2df8d0ffed..c197e234bdb2 100644 --- a/src/client/browser/api.ts +++ b/src/client/browser/api.ts @@ -7,6 +7,7 @@ import { BaseLanguageClient } from 'vscode-languageclient'; import { LanguageClient } from 'vscode-languageclient/browser'; import { PYTHON_LANGUAGE } from '../common/constants'; import { ApiForPylance, TelemetryReporter } from '../pylanceApi'; +import { LogOutputChannel } from 'vscode'; export interface IBrowserExtensionApi { /** @@ -16,10 +17,12 @@ export interface IBrowserExtensionApi { pylance: ApiForPylance; } -export function buildApi(reporter: TelemetryReporter): IBrowserExtensionApi { +export function buildApi(reporter: TelemetryReporter, outputChannel: LogOutputChannel): IBrowserExtensionApi { const api: IBrowserExtensionApi = { pylance: { + getOutputChannel: () => outputChannel, // eslint-disable-next-line @typescript-eslint/no-explicit-any + // deprecated createClient: (...args: any[]): BaseLanguageClient => new LanguageClient(PYTHON_LANGUAGE, 'Python Language Server', args[0], args[1]), start: (client: BaseLanguageClient): Promise => client.start(), diff --git a/src/client/browser/extension.ts b/src/client/browser/extension.ts index 132618430551..fc393489bdbd 100644 --- a/src/client/browser/extension.ts +++ b/src/client/browser/extension.ts @@ -12,6 +12,7 @@ import { EventName } from '../telemetry/constants'; import { createStatusItem } from './intellisenseStatus'; import { PylanceApi } from '../activation/node/pylanceApi'; import { buildApi, IBrowserExtensionApi } from './api'; +import { OutputChannelNames } from '../common/utils/localize'; interface BrowserConfig { distUrl: string; // URL to Pylance's dist folder. @@ -23,7 +24,8 @@ let pylanceApi: PylanceApi | undefined; export function activate(context: vscode.ExtensionContext): Promise { const reporter = getTelemetryReporter(); - const activationPromise = Promise.resolve(buildApi(reporter)); + const outputChannel = vscode.window.createOutputChannel(OutputChannelNames.python, { log: true }); + const activationPromise = Promise.resolve(buildApi(reporter, outputChannel)); const pylanceExtension = vscode.extensions.getExtension(PYLANCE_EXTENSION_ID); if (pylanceExtension) { // Make sure we run pylance once we activated core extension. diff --git a/src/client/pylanceApi.ts b/src/client/pylanceApi.ts index b839d0d9c2b7..af47581607eb 100644 --- a/src/client/pylanceApi.ts +++ b/src/client/pylanceApi.ts @@ -3,6 +3,7 @@ import { TelemetryEventMeasurements, TelemetryEventProperties } from '@vscode/extension-telemetry'; import { BaseLanguageClient } from 'vscode-languageclient'; +import { LogOutputChannel } from 'vscode'; export interface TelemetryReporter { sendTelemetryEvent( @@ -18,7 +19,9 @@ export interface TelemetryReporter { } export interface ApiForPylance { + getOutputChannel(): LogOutputChannel; // eslint-disable-next-line @typescript-eslint/no-explicit-any + // deprecated createClient(...args: any[]): BaseLanguageClient; start(client: BaseLanguageClient): Promise; stop(client: BaseLanguageClient): Promise; diff --git a/vscode-python.sln b/vscode-python.sln new file mode 100644 index 000000000000..fdb37b1d6944 --- /dev/null +++ b/vscode-python.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vscode-python-signing", "vscode-python-signing.csproj", "{823C528B-3AFE-A8BD-2399-4E1F9CB64B43}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {823C528B-3AFE-A8BD-2399-4E1F9CB64B43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {823C528B-3AFE-A8BD-2399-4E1F9CB64B43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {823C528B-3AFE-A8BD-2399-4E1F9CB64B43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {823C528B-3AFE-A8BD-2399-4E1F9CB64B43}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {26F89413-CF2F-476E-8C99-5CBE59062416} + EndGlobalSection +EndGlobal From 68118d377588acb8a751702129947f25474531ff Mon Sep 17 00:00:00 2001 From: bschnurr Date: Tue, 29 Jul 2025 10:50:55 -0700 Subject: [PATCH 2/2] update comments --- src/client/api.ts | 2 +- src/client/browser/api.ts | 2 +- vscode-python.sln | 24 ------------------------ 3 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 vscode-python.sln diff --git a/src/client/api.ts b/src/client/api.ts index ea552491acbf..845bd4858a8b 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -146,8 +146,8 @@ export function buildApi( }, pylance: { getOutputChannel: () => outputChannel.channel, + //deprecated: Pyance now creates client createClient: (...args: any[]): BaseLanguageClient => { - //deprecated // Make sure we share output channel so that we can share one with // Jedi as well. const clientOptions = args[1] as LanguageClientOptions; diff --git a/src/client/browser/api.ts b/src/client/browser/api.ts index c197e234bdb2..3dfc485bd971 100644 --- a/src/client/browser/api.ts +++ b/src/client/browser/api.ts @@ -22,7 +22,7 @@ export function buildApi(reporter: TelemetryReporter, outputChannel: LogOutputCh pylance: { getOutputChannel: () => outputChannel, // eslint-disable-next-line @typescript-eslint/no-explicit-any - // deprecated + //deprecated: Pyance now creates client createClient: (...args: any[]): BaseLanguageClient => new LanguageClient(PYTHON_LANGUAGE, 'Python Language Server', args[0], args[1]), start: (client: BaseLanguageClient): Promise => client.start(), diff --git a/vscode-python.sln b/vscode-python.sln deleted file mode 100644 index fdb37b1d6944..000000000000 --- a/vscode-python.sln +++ /dev/null @@ -1,24 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.2.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vscode-python-signing", "vscode-python-signing.csproj", "{823C528B-3AFE-A8BD-2399-4E1F9CB64B43}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {823C528B-3AFE-A8BD-2399-4E1F9CB64B43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {823C528B-3AFE-A8BD-2399-4E1F9CB64B43}.Debug|Any CPU.Build.0 = Debug|Any CPU - {823C528B-3AFE-A8BD-2399-4E1F9CB64B43}.Release|Any CPU.ActiveCfg = Release|Any CPU - {823C528B-3AFE-A8BD-2399-4E1F9CB64B43}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {26F89413-CF2F-476E-8C99-5CBE59062416} - EndGlobalSection -EndGlobal