Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ export function buildApi(
},
},
pylance: {
getOutputChannel: () => outputChannel.channel,
//deprecated: Pyance now creates client
createClient: (...args: any[]): BaseLanguageClient => {
// Make sure we share output channel so that we can share one with
// Jedi as well.
Expand Down
5 changes: 4 additions & 1 deletion src/client/browser/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand All @@ -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: Pyance now creates client
createClient: (...args: any[]): BaseLanguageClient =>
new LanguageClient(PYTHON_LANGUAGE, 'Python Language Server', args[0], args[1]),
start: (client: BaseLanguageClient): Promise<void> => client.start(),
Expand Down
4 changes: 3 additions & 1 deletion src/client/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,7 +24,8 @@ let pylanceApi: PylanceApi | undefined;
export function activate(context: vscode.ExtensionContext): Promise<IBrowserExtensionApi> {
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<PylanceApi>(PYLANCE_EXTENSION_ID);
if (pylanceExtension) {
// Make sure we run pylance once we activated core extension.
Expand Down
3 changes: 3 additions & 0 deletions src/client/pylanceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { TelemetryEventMeasurements, TelemetryEventProperties } from '@vscode/extension-telemetry';
import { BaseLanguageClient } from 'vscode-languageclient';
import { LogOutputChannel } from 'vscode';

export interface TelemetryReporter {
sendTelemetryEvent(
Expand All @@ -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<void>;
stop(client: BaseLanguageClient): Promise<void>;
Expand Down
Loading