@@ -11,9 +11,69 @@ import { WeakValueSet } from "./utils";
11
11
const DEBUG_ADAPTER_DEFAULT_TCP_PORT = 6611 ;
12
12
const DEBUG_ADAPTER_DEFAULT_HOST = "127.0.0.1" ;
13
13
14
+ const DEBUG_CONFIGURATIONS = [
15
+ {
16
+ label : "RobotCode: Run Current" ,
17
+ description : "Run the current RobotFramework file." ,
18
+ body : {
19
+ name : "RobotCode: Run Current" ,
20
+ type : "robotcode" ,
21
+ request : "launch" ,
22
+ cwd : "${workspaceFolder}" ,
23
+ target : "${file}" ,
24
+ } ,
25
+ } ,
26
+ {
27
+ label : "RobotCode: Run All" ,
28
+ description : "Run all RobotFramework files." ,
29
+ body : {
30
+ name : "RobotCode: Run All" ,
31
+ type : "robotcode" ,
32
+ request : "launch" ,
33
+ cwd : "${workspaceFolder}" ,
34
+ target : "." ,
35
+ } ,
36
+ } ,
37
+ ] ;
38
+
14
39
class RobotCodeDebugConfigurationProvider implements vscode . DebugConfigurationProvider {
15
40
constructor ( private readonly pythonManager : PythonManager ) { }
16
41
42
+ resolveDebugConfiguration (
43
+ folder : vscode . WorkspaceFolder | undefined ,
44
+ debugConfiguration : vscode . DebugConfiguration ,
45
+ token ?: vscode . CancellationToken
46
+ ) : vscode . ProviderResult < vscode . DebugConfiguration > {
47
+ return this . _resolveDebugConfiguration ( folder , debugConfiguration , token ) ;
48
+ }
49
+
50
+ // eslint-disable-next-line class-methods-use-this
51
+ async _resolveDebugConfiguration (
52
+ _folder : vscode . WorkspaceFolder | undefined ,
53
+ debugConfiguration : vscode . DebugConfiguration ,
54
+ token ?: vscode . CancellationToken
55
+ ) : Promise < vscode . DebugConfiguration > {
56
+ if ( ! debugConfiguration . type && ! debugConfiguration . request && ! debugConfiguration . name ) {
57
+ const editor = vscode . window . activeTextEditor ;
58
+ if ( editor && editor . document . languageId === "robotframework" && editor . document . fileName . endsWith ( ".robot" ) ) {
59
+ const result = await vscode . window . showQuickPick (
60
+ DEBUG_CONFIGURATIONS . map ( ( v ) => v ) ,
61
+ { canPickMany : false } ,
62
+ token
63
+ ) ;
64
+
65
+ if ( result !== undefined ) {
66
+ debugConfiguration = {
67
+ ...result ?. body ,
68
+ ...debugConfiguration ,
69
+ } ;
70
+ }
71
+ }
72
+ }
73
+
74
+ return debugConfiguration ;
75
+ }
76
+
17
77
resolveDebugConfigurationWithSubstitutedVariables (
18
78
folder : vscode . WorkspaceFolder | undefined ,
19
79
debugConfiguration : vscode . DebugConfiguration ,
@@ -161,22 +221,7 @@ export class DebugManager {
161
221
_folder : vscode . WorkspaceFolder | undefined ,
162
222
_token ?: vscode . CancellationToken
163
223
) : vscode . ProviderResult < vscode . DebugConfiguration [ ] > {
164
- return [
165
- {
166
- name : "RobotCode: Run .robot file" ,
167
- type : "robotcode" ,
168
- request : "launch" ,
169
- cwd : "${workspaceFolder}" ,
170
- target : "${file}" ,
171
- } ,
172
- {
173
- name : "RobotCode: Run all tests" ,
174
- type : "robotcode" ,
175
- request : "launch" ,
176
- cwd : "${workspaceFolder}" ,
177
- target : "." ,
178
- } ,
179
- ] ;
224
+ return DEBUG_CONFIGURATIONS . map ( ( v ) => v . body ) ;
180
225
} ,
181
226
} ,
182
227
vscode . DebugConfigurationProviderTriggerKind . Dynamic
0 commit comments