Skip to content

Commit

Permalink
Remove inversify dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Sep 4, 2024
1 parent 8d8281f commit 19150aa
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 346 deletions.
532 changes: 242 additions & 290 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,8 @@
"@vscode/python-extension": "^1.0.5",
"fs-extra": "^11.2.0",
"iconv-lite": "^0.6.3",
"inversify": "^6.0.1",
"jsonc-parser": "^3.2.0",
"lodash": "^4.17.21",
"reflect-metadata": "^0.1.13",
"vscode-languageclient": "^8.0.2"
}
}
7 changes: 0 additions & 7 deletions src/extension/common/promiseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@
export function ignoreErrors<T>(promise: Promise<T>) {
return promise.catch(() => {});
}

// if (!String.prototype.format) {
// String.prototype.format = function (this: string) {
// const args = arguments;
// return this.replace(/{(\d+)}/g, (match, number) => (args[number] === undefined ? match : args[number]));
// };
// }
4 changes: 1 addition & 3 deletions src/extension/debugger/adapter/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

'use strict';

import { inject, injectable } from 'inversify';
import * as path from 'path';
import {
DebugAdapterDescriptor,
Expand All @@ -31,9 +30,8 @@ export enum debugStateKeys {
doNotShowAgain = 'doNotShowPython36DebugDeprecatedAgain',
}

@injectable()
export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFactory {
constructor(@inject(IPersistentStateFactory) private persistentState: IPersistentStateFactory) {}
constructor(private persistentState: IPersistentStateFactory) {}

public async createDebugAdapterDescriptor(
session: DebugSession,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import { inject, injectable, named } from 'inversify';
import { cloneDeep } from 'lodash';
import { CancellationToken, DebugConfiguration, QuickPickItem, WorkspaceFolder } from 'vscode';
import { DebugConfigStrings } from '../../common/utils/localize';
Expand All @@ -21,18 +18,13 @@ import { buildRemoteAttachConfiguration } from './providers/remoteAttach';
import { IDebugConfigurationResolver } from './types';
import { buildFileWithArgsLaunchDebugConfiguration } from './providers/fileLaunchWithArgs';

@injectable()
export class PythonDebugConfigurationService implements IDebugConfigurationService {
private cacheDebugConfig: DebugConfiguration | undefined = undefined;

constructor(
@inject(IDebugConfigurationResolver)
@named('attach')
private readonly attachResolver: IDebugConfigurationResolver<AttachRequestArguments>,
@inject(IDebugConfigurationResolver)
@named('launch')
private readonly launchResolver: IDebugConfigurationResolver<LaunchRequestArguments>,
@inject(IMultiStepInputFactory) private readonly multiStepFactory: IMultiStepInputFactory,
private readonly multiStepFactory: IMultiStepInputFactory,
) {}

public async provideDebugConfigurations(
Expand Down
9 changes: 2 additions & 7 deletions src/extension/debugger/hooks/childProcessAttachHandler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import { inject, injectable } from 'inversify';
import { DebugConfiguration, DebugSessionCustomEvent } from 'vscode';
import { swallowExceptions } from '../../common/utils/decorators';
import { AttachRequestArguments } from '../../types';
Expand All @@ -18,11 +15,9 @@ import { DebuggerTypeName } from '../../constants';
* @class ChildProcessAttachEventHandler
* @implements {IDebugSessionEventHandlers}
*/
@injectable()

export class ChildProcessAttachEventHandler implements IDebugSessionEventHandlers {
constructor(
@inject(IChildProcessAttachService) private readonly childProcessAttachService: IChildProcessAttachService,
) {}
constructor(private readonly childProcessAttachService: IChildProcessAttachService) {}

@swallowExceptions('Handle child process launch')
public async handleCustomEvent(event: DebugSessionCustomEvent): Promise<void> {
Expand Down
6 changes: 1 addition & 5 deletions src/extension/debugger/hooks/debugpySocketsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

'use strict';

import { inject, injectable } from 'inversify';
import { DebugSessionCustomEvent } from 'vscode';
import { swallowExceptions } from '../../common/utils/decorators';
import { DebuggerEvents } from './constants';
Expand All @@ -18,11 +17,8 @@ import { traceLog } from '../../common/log/logging';
* @class ChildProcessAttachEventHandler
* @implements {IDebugSessionEventHandlers}
*/
@injectable()
export class DebugpySocketsHandler implements IDebugSessionEventHandlers {
constructor(
@inject(DebugPortAttributesProvider) private readonly debugPortAttributesProvider: DebugPortAttributesProvider,
) {}
constructor(private readonly debugPortAttributesProvider: DebugPortAttributesProvider) {}

@swallowExceptions('Handle child process launch')
public async handleCustomEvent(event: DebugSessionCustomEvent): Promise<void> {
Expand Down
27 changes: 4 additions & 23 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
'use strict';

// import * as vscode from 'vscode';

// This line should always be right on top.

if ((Reflect as any).metadata === undefined) {
require('reflect-metadata');
}

import { registerDebugger } from './extensionInit';
import { IExtensionContext } from './common/types';
import { createOutputChannel, registerCommand } from './common/vscodeapi';
import { Commands } from './common/constants';
import { registerLogger, traceError, traceLog } from './common/log/logging';
import { registerLogger, traceError } 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<IExtensionApi> {
let api: IExtensionApi;
// Setup logging
export async function activate(context: IExtensionContext): Promise<IExtensionApi | undefined> {
const outputChannel = createOutputChannel('Python Debugger');
context.subscriptions.push(outputChannel, registerLogger(outputChannel));
context.subscriptions.push(registerCommand(Commands.ViewOutput, () => outputChannel.show()));

traceLog(`Name: Python Debugger`);
traceLog(`Module: debugpy`);

try {
api = await registerDebugger(context);
const api = await registerDebugger(context);
sendTelemetryEvent(EventName.DEBUG_SUCCESS_ACTIVATION);
return api;
} catch (ex) {
traceError('sendDebugpySuccessActivationTelemetry() failed.', ex);
throw ex; // re-raise
}

return api;
}

// this method is called when your extension is deactivated
export function deactivate() {}

0 comments on commit 19150aa

Please sign in to comment.