Skip to content

Commit

Permalink
Add api and send debugpy path (#278)
Browse files Browse the repository at this point in the history
* add api and send debugpy path

* fix lint
  • Loading branch information
paulacamargo25 authored Apr 8, 2024
1 parent 1a88f20 commit dd19fbc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/extension/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function buildApi(): IExtensionApi {
waitUntilDebuggerAttaches,
});
},
async getDebuggerPackagePath(): Promise<string | undefined> {
async getDebuggerPackagePath(): Promise<string> {
return getDebugpyPackagePath();
},
},
Expand Down
10 changes: 0 additions & 10 deletions src/extension/apiTypes.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// 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<void>}
* @memberof IExtensionApi
*/
debug: {
/**
* Generate an array of strings for commands to pass to the Python executable to launch the debugger for remote debugging.
Expand Down
9 changes: 7 additions & 2 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
export async function activate(context: IExtensionContext): Promise<IExtensionApi> {
let api: IExtensionApi;
// Setup logging
const outputChannel = createOutputChannel('Python Debugger');
context.subscriptions.push(outputChannel, registerLogger(outputChannel));
Expand All @@ -28,11 +30,14 @@ export async function activate(context: IExtensionContext): Promise<void> {
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
Expand Down
6 changes: 5 additions & 1 deletion src/extension/extensionInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
export async function registerDebugger(context: IExtensionContext): Promise<IExtensionApi> {
const childProcessAttachService = new ChildProcessAttachService();
const childProcessAttachEventHandler = new ChildProcessAttachEventHandler(childProcessAttachService);

Expand Down Expand Up @@ -172,4 +174,6 @@ export async function registerDebugger(context: IExtensionContext): Promise<void
debugPortAttributesProvider.resetPortAttribute();
}),
);

return buildApi();
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"ES2019",
"ES2020"
],
"typeRoots": ["./node_modules/@types"],
"sourceMap": true,
"typeRoots": [
"./node_modules/@types"
Expand Down

0 comments on commit dd19fbc

Please sign in to comment.