forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06d9887
commit def2d14
Showing
24 changed files
with
51 additions
and
3,432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/client/debugger/extension/configuration/launch.json/interpreterPathCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { inject, injectable } from 'inversify'; | ||
import { Uri } from 'vscode'; | ||
import { IExtensionSingleActivationService } from '../../../../activation/types'; | ||
import { Commands } from '../../../../common/constants'; | ||
import { IDisposable, IDisposableRegistry } from '../../../../common/types'; | ||
import { registerCommand } from '../../../../common/vscodeApis/commandApis'; | ||
import { IInterpreterService } from '../../../../interpreter/contracts'; | ||
|
||
@injectable() | ||
export class InterpreterPathCommand implements IExtensionSingleActivationService { | ||
public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: false }; | ||
|
||
constructor( | ||
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService, | ||
@inject(IDisposableRegistry) private readonly disposables: IDisposable[], | ||
) {} | ||
|
||
public async activate(): Promise<void> { | ||
this.disposables.push( | ||
registerCommand(Commands.GetSelectedInterpreterPath, (args) => this._getSelectedInterpreterPath(args)), | ||
); | ||
} | ||
|
||
public async _getSelectedInterpreterPath(args: { workspaceFolder: string } | string[]): Promise<string> { | ||
// If `launch.json` is launching this command, `args.workspaceFolder` carries the workspaceFolder | ||
// If `tasks.json` is launching this command, `args[1]` carries the workspaceFolder | ||
let workspaceFolder; | ||
if ('workspaceFolder' in args) { | ||
workspaceFolder = args.workspaceFolder; | ||
} else if (args[1]) { | ||
const [, second] = args; | ||
workspaceFolder = second; | ||
} else { | ||
workspaceFolder = undefined; | ||
} | ||
|
||
let workspaceFolderUri; | ||
try { | ||
workspaceFolderUri = workspaceFolder ? Uri.file(workspaceFolder) : undefined; | ||
} catch (ex) { | ||
workspaceFolderUri = undefined; | ||
} | ||
|
||
return (await this.interpreterService.getActiveInterpreter(workspaceFolderUri))?.path ?? 'python'; | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
src/test/debugger/extension/adapter/activator.unit.test.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.