Skip to content

Commit dd19fbc

Browse files
Add api and send debugpy path (#278)
* add api and send debugpy path * fix lint
1 parent 1a88f20 commit dd19fbc

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

Diff for: src/extension/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function buildApi(): IExtensionApi {
2020
waitUntilDebuggerAttaches,
2121
});
2222
},
23-
async getDebuggerPackagePath(): Promise<string | undefined> {
23+
async getDebuggerPackagePath(): Promise<string> {
2424
return getDebugpyPackagePath();
2525
},
2626
},

Diff for: src/extension/apiTypes.ts

-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
/*
5-
* Do not introduce any breaking changes to this API.
6-
* This is the public API for other extensions to interact with this extension.
7-
*/
8-
94
export interface IExtensionApi {
10-
/**
11-
* Promise indicating whether all parts of the extension have completed loading or not.
12-
* @type {Promise<void>}
13-
* @memberof IExtensionApi
14-
*/
155
debug: {
166
/**
177
* Generate an array of strings for commands to pass to the Python executable to launch the debugger for remote debugging.

Diff for: src/extension/extension.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import { Commands } from './common/constants';
1515
import { registerLogger, traceError, traceLog } from './common/log/logging';
1616
import { sendTelemetryEvent } from './telemetry';
1717
import { EventName } from './telemetry/constants';
18+
import { IExtensionApi } from './apiTypes';
1819

1920
// this method is called when your extension is activated
2021
// your extension is activated the very first time the command is executed
21-
export async function activate(context: IExtensionContext): Promise<void> {
22+
export async function activate(context: IExtensionContext): Promise<IExtensionApi> {
23+
let api: IExtensionApi;
2224
// Setup logging
2325
const outputChannel = createOutputChannel('Python Debugger');
2426
context.subscriptions.push(outputChannel, registerLogger(outputChannel));
@@ -28,11 +30,14 @@ export async function activate(context: IExtensionContext): Promise<void> {
2830
traceLog(`Module: debugpy`);
2931

3032
try {
31-
await registerDebugger(context);
33+
api = await registerDebugger(context);
3234
sendTelemetryEvent(EventName.DEBUG_SUCCESS_ACTIVATION);
3335
} catch (ex) {
3436
traceError('sendDebugpySuccessActivationTelemetry() failed.', ex);
37+
throw ex; // re-raise
3538
}
39+
40+
return api;
3641
}
3742

3843
// this method is called when your extension is deactivated

Diff for: src/extension/extensionInit.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ import { DebugPortAttributesProvider } from './debugger/debugPort/portAttributes
3535
import { getConfigurationsByUri } from './debugger/configuration/launch.json/launchJsonReader';
3636
import { DebugpySocketsHandler } from './debugger/hooks/debugpySocketsHandler';
3737
import { openReportIssue } from './common/application/commands/reportIssueCommand';
38+
import { buildApi } from './api';
39+
import { IExtensionApi } from './apiTypes';
3840

39-
export async function registerDebugger(context: IExtensionContext): Promise<void> {
41+
export async function registerDebugger(context: IExtensionContext): Promise<IExtensionApi> {
4042
const childProcessAttachService = new ChildProcessAttachService();
4143
const childProcessAttachEventHandler = new ChildProcessAttachEventHandler(childProcessAttachService);
4244

@@ -172,4 +174,6 @@ export async function registerDebugger(context: IExtensionContext): Promise<void
172174
debugPortAttributesProvider.resetPortAttribute();
173175
}),
174176
);
177+
178+
return buildApi();
175179
}

Diff for: tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"ES2019",
1010
"ES2020"
1111
],
12+
"typeRoots": ["./node_modules/@types"],
1213
"sourceMap": true,
1314
"typeRoots": [
1415
"./node_modules/@types"

0 commit comments

Comments
 (0)