From f6a24319dab2b63f99c77fb4c8b06feebb2bc4d8 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Fri, 22 Mar 2024 11:25:34 -0700 Subject: [PATCH 1/2] add api and send debugpy path --- src/extension/api.ts | 2 +- src/extension/apiTypes.ts | 9 --------- src/extension/extension.ts | 9 +++++++-- src/extension/extensionInit.ts | 6 +++++- tsconfig.json | 1 + 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/extension/api.ts b/src/extension/api.ts index acc4164e..e355b0f5 100644 --- a/src/extension/api.ts +++ b/src/extension/api.ts @@ -20,7 +20,7 @@ export function buildApi(): IExtensionApi { waitUntilDebuggerAttaches, }); }, - async getDebuggerPackagePath(): Promise { + async getDebuggerPackagePath(): Promise { return getDebugpyPackagePath(); }, }, diff --git a/src/extension/apiTypes.ts b/src/extension/apiTypes.ts index 409d41ef..abf20e23 100644 --- a/src/extension/apiTypes.ts +++ b/src/extension/apiTypes.ts @@ -1,17 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -/* - * Do not introduce any breaking changes to this API. - * This is the public API for other extensions to interact with this extension. - */ export interface IExtensionApi { - /** - * Promise indicating whether all parts of the extension have completed loading or not. - * @type {Promise} - * @memberof IExtensionApi - */ debug: { /** * Generate an array of strings for commands to pass to the Python executable to launch the debugger for remote debugging. diff --git a/src/extension/extension.ts b/src/extension/extension.ts index 1829bc61..248d77d9 100644 --- a/src/extension/extension.ts +++ b/src/extension/extension.ts @@ -15,10 +15,12 @@ import { Commands } from './common/constants'; import { registerLogger, traceError, traceLog } from './common/log/logging'; import { sendTelemetryEvent } from './telemetry'; import { EventName } from './telemetry/constants'; +import { IExtensionApi } from './apiTypes'; // this method is called when your extension is activated // your extension is activated the very first time the command is executed -export async function activate(context: IExtensionContext): Promise { +export async function activate(context: IExtensionContext): Promise { + let api: IExtensionApi; // Setup logging const outputChannel = createOutputChannel('Python Debugger'); context.subscriptions.push(outputChannel, registerLogger(outputChannel)); @@ -28,11 +30,14 @@ export async function activate(context: IExtensionContext): Promise { traceLog(`Module: debugpy`); try { - await registerDebugger(context); + api = await registerDebugger(context); sendTelemetryEvent(EventName.DEBUG_SUCCESS_ACTIVATION); } catch (ex) { traceError('sendDebugpySuccessActivationTelemetry() failed.', ex); + throw ex; // re-raise } + + return api; } // this method is called when your extension is deactivated diff --git a/src/extension/extensionInit.ts b/src/extension/extensionInit.ts index 92128dfa..5a1c2bd6 100644 --- a/src/extension/extensionInit.ts +++ b/src/extension/extensionInit.ts @@ -35,8 +35,10 @@ import { DebugPortAttributesProvider } from './debugger/debugPort/portAttributes import { getConfigurationsByUri } from './debugger/configuration/launch.json/launchJsonReader'; import { DebugpySocketsHandler } from './debugger/hooks/debugpySocketsHandler'; import { openReportIssue } from './common/application/commands/reportIssueCommand'; +import { buildApi } from './api'; +import { IExtensionApi } from './apiTypes'; -export async function registerDebugger(context: IExtensionContext): Promise { +export async function registerDebugger(context: IExtensionContext): Promise { const childProcessAttachService = new ChildProcessAttachService(); const childProcessAttachEventHandler = new ChildProcessAttachEventHandler(childProcessAttachService); @@ -172,4 +174,6 @@ export async function registerDebugger(context: IExtensionContext): Promise Date: Fri, 22 Mar 2024 11:39:06 -0700 Subject: [PATCH 2/2] fix lint --- src/extension/apiTypes.ts | 1 - src/extension/extensionInit.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/extension/apiTypes.ts b/src/extension/apiTypes.ts index abf20e23..6de5eb4a 100644 --- a/src/extension/apiTypes.ts +++ b/src/extension/apiTypes.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. - export interface IExtensionApi { debug: { /** diff --git a/src/extension/extensionInit.ts b/src/extension/extensionInit.ts index 5a1c2bd6..7112941b 100644 --- a/src/extension/extensionInit.ts +++ b/src/extension/extensionInit.ts @@ -175,5 +175,5 @@ export async function registerDebugger(context: IExtensionContext): Promise