Skip to content

Commit 531cb00

Browse files
authored
Display python debug config ui when editing launch.json (#5016)
For #3321
1 parent 56d44da commit 531cb00

File tree

21 files changed

+1005
-306
lines changed

21 files changed

+1005
-306
lines changed

gulpfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,6 @@ function getFilesToProcess(fileList) {
811811
* @param {hygieneOptions} options
812812
*/
813813
function getFileListToProcess(options) {
814-
return [];
815814
const mode = options ? options.mode : 'all';
816815
const gulpSrcOptions = { base: '.' };
817816

news/1 Enhancements/3321.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Launch the `Python` debug configuration UI when manually adding entries into the `launch.json` file.

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,7 @@
22702270
"hash.js": "^1.1.7",
22712271
"iconv-lite": "^0.4.21",
22722272
"inversify": "^4.11.1",
2273+
"jsonc-parser": "^2.0.3",
22732274
"line-by-line": "^0.1.6",
22742275
"lodash": "^4.17.11",
22752276
"md5": "^2.2.1",

package.nls.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@
182182
"Common.loadingPythonExtension": "Python extension loading...",
183183
"debug.selectConfigurationTitle": "Select a debug configuration",
184184
"debug.selectConfigurationPlaceholder": "Debug Configuration",
185+
"debug.launchJsonConfigurationsCompletionLabel": "Python",
186+
"debug.launchJsonConfigurationsCompletionDescription": "Select Python Launch Configuration",
185187
"debug.debugFileConfigurationLabel": "Python File",
186188
"debug.debugFileConfigurationDescription": "Debug Python file",
187189
"debug.debugModuleConfigurationLabel": "Module",
@@ -229,5 +231,5 @@
229231
"DataScience.noRowsInDataViewer" : "Fetching data ...",
230232
"DataScience.pandasTooOldForViewingFormat" : "Python package 'pandas' is version {0}. Version 0.20 or greater is required for viewing data.",
231233
"DataScience.pandasRequiredForViewing" : "Python package 'pandas' is required for viewing data.",
232-
"DataScience.valuesColumn": "values"
234+
"DataScience.valuesColumn": "values"
233235
}

src/client/activation/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ export interface IExtensionActivationManager extends IDisposable {
1717
}
1818

1919
export const IExtensionActivationService = Symbol('IExtensionActivationService');
20+
/**
21+
* Classes implementing this interface will have their `activate` methods
22+
* invoked during the actiavtion of the extension.
23+
* This is a great hook for extension activation code, i.e. you don't need to modify
24+
* the `extension.ts` file to invoke some code when extension gets activated.
25+
* @export
26+
* @interface IExtensionActivationService
27+
*/
2028
export interface IExtensionActivationService {
2129
activate(resource: Resource): Promise<void>;
2230
}

src/client/common/application/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
'use strict';
55

6-
import { CancellationToken, Uri } from 'vscode';
6+
import { CancellationToken, Position, TextDocument, Uri } from 'vscode';
77
import { Commands as DSCommands } from '../../datascience/constants';
88
import { CommandSource } from '../../unittests/common/constants';
99
import { TestFunction, TestsToRun } from '../../unittests/common/types';
@@ -63,6 +63,7 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
6363
['setContext']: [string, boolean];
6464
['revealLine']: [{ lineNumber: number; at: 'top' | 'center' | 'bottom' }];
6565
['python._loadLanguageServerExtension']: {}[];
66+
['python.SelectAndInsertDebugConfiguration']: [TextDocument, Position, CancellationToken];
6667
[Commands.Build_Workspace_Symbols]: [boolean, CancellationToken];
6768
[Commands.Sort_Imports]: [undefined, Uri];
6869
[Commands.Exec_In_Terminal]: [undefined, Uri];
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
import { injectable } from 'inversify';
7+
import { CompletionItemProvider, DocumentSelector, languages } from 'vscode';
8+
import { Disposable } from 'vscode-jsonrpc';
9+
import { ILanguageService } from './types';
10+
11+
@injectable()
12+
export class LanguageService implements ILanguageService {
13+
public registerCompletionItemProvider(selector: DocumentSelector, provider: CompletionItemProvider, ...triggerCharacters: string[]): Disposable {
14+
return languages.registerCompletionItemProvider(selector, provider, ...triggerCharacters);
15+
}
16+
}

src/client/common/application/types.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import {
55
Breakpoint,
66
BreakpointsChangeEvent,
77
CancellationToken,
8+
CompletionItemProvider,
89
ConfigurationChangeEvent,
910
DebugConfiguration,
1011
DebugConfigurationProvider,
1112
DebugConsole,
1213
DebugSession,
1314
DebugSessionCustomEvent,
1415
Disposable,
16+
DocumentSelector,
1517
Event,
1618
FileSystemWatcher,
1719
GlobPattern,
@@ -904,3 +906,22 @@ export interface ILiveShareTestingApi extends ILiveShareApi {
904906
startSession(): Promise<void>;
905907
stopSession(): Promise<void>;
906908
}
909+
910+
export const ILanguageService = Symbol('ILanguageService');
911+
export interface ILanguageService {
912+
/**
913+
* Register a completion provider.
914+
*
915+
* Multiple providers can be registered for a language. In that case providers are sorted
916+
* by their [score](#languages.match) and groups of equal score are sequentially asked for
917+
* completion items. The process stops when one or many providers of a group return a
918+
* result. A failing provider (rejected promise or exception) will not fail the whole
919+
* operation.
920+
*
921+
* @param selector A selector that defines the documents this provider is applicable to.
922+
* @param provider A completion provider.
923+
* @param triggerCharacters Trigger completion when the user types one of the characters, like `.` or `:`.
924+
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
925+
*/
926+
registerCompletionItemProvider(selector: DocumentSelector, provider: CompletionItemProvider, ...triggerCharacters: string[]): Disposable;
927+
}

src/client/common/serviceRegistry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ import { CommandManager } from './application/commandManager';
1010
import { DebugService } from './application/debugService';
1111
import { DocumentManager } from './application/documentManager';
1212
import { Extensions } from './application/extensions';
13+
import { LanguageService } from './application/languageService';
1314
import { TerminalManager } from './application/terminalManager';
1415
import {
1516
IApplicationEnvironment,
1617
IApplicationShell,
1718
ICommandManager,
1819
IDebugService,
1920
IDocumentManager,
21+
ILanguageService,
2022
ILiveShareApi,
2123
ITerminalManager,
2224
IWorkspaceService
@@ -91,6 +93,7 @@ export function registerTypes(serviceManager: IServiceManager) {
9193
serviceManager.addSingleton<ITerminalManager>(ITerminalManager, TerminalManager);
9294
serviceManager.addSingleton<IDebugService>(IDebugService, DebugService);
9395
serviceManager.addSingleton<IApplicationEnvironment>(IApplicationEnvironment, ApplicationEnvironment);
96+
serviceManager.addSingleton<ILanguageService>(ILanguageService, LanguageService);
9497
serviceManager.addSingleton<IBrowserService>(IBrowserService, BrowserService);
9598
serviceManager.addSingleton<IHttpClient>(IHttpClient, HttpClient);
9699
serviceManager.addSingleton<IEditorUtils>(IEditorUtils, EditorUtils);

0 commit comments

Comments
 (0)