@opensumi/ide-debug 2.21.4-rc-1668395886.0 → 2.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/lib/browser/debug-contribution.d.ts +148 -2
  2. package/lib/browser/debug-contribution.d.ts.map +1 -1
  3. package/lib/browser/debug-contribution.js +204 -49
  4. package/lib/browser/debug-contribution.js.map +1 -1
  5. package/lib/browser/debug-session-manager.d.ts +3 -2
  6. package/lib/browser/debug-session-manager.d.ts.map +1 -1
  7. package/lib/browser/debug-session-manager.js +3 -2
  8. package/lib/browser/debug-session-manager.js.map +1 -1
  9. package/lib/browser/debug-session.d.ts +4 -3
  10. package/lib/browser/debug-session.d.ts.map +1 -1
  11. package/lib/browser/debug-session.js.map +1 -1
  12. package/lib/browser/debug-style.less +7 -3
  13. package/lib/browser/editor/debug-breakpoint-zone-widget.js +2 -2
  14. package/lib/browser/editor/debug-breakpoint-zone-widget.js.map +1 -1
  15. package/lib/browser/editor/debug-breakpoint.module.less +4 -2
  16. package/lib/browser/editor/debug-editor-contribution.d.ts +2 -2
  17. package/lib/browser/editor/debug-editor-contribution.d.ts.map +1 -1
  18. package/lib/browser/editor/debug-editor-contribution.js +3 -2
  19. package/lib/browser/editor/debug-editor-contribution.js.map +1 -1
  20. package/lib/browser/editor/debug-model-manager.d.ts +9 -2
  21. package/lib/browser/editor/debug-model-manager.d.ts.map +1 -1
  22. package/lib/browser/editor/debug-model-manager.js +15 -8
  23. package/lib/browser/editor/debug-model-manager.js.map +1 -1
  24. package/lib/browser/index.d.ts +14 -0
  25. package/lib/browser/index.d.ts.map +1 -1
  26. package/lib/browser/index.js +15 -6
  27. package/lib/browser/index.js.map +1 -1
  28. package/lib/browser/model/debug-source.d.ts +3 -3
  29. package/lib/browser/model/debug-source.d.ts.map +1 -1
  30. package/lib/browser/model/debug-source.js.map +1 -1
  31. package/lib/browser/model/debug-watch.d.ts.map +1 -1
  32. package/lib/browser/model/debug-watch.js +2 -1
  33. package/lib/browser/model/debug-watch.js.map +1 -1
  34. package/lib/browser/view/breakpoints/debug-breakpoints.service.d.ts.map +1 -1
  35. package/lib/browser/view/breakpoints/debug-breakpoints.service.js +1 -1
  36. package/lib/browser/view/breakpoints/debug-breakpoints.service.js.map +1 -1
  37. package/lib/browser/view/console/debug-console-session.d.ts +1 -2
  38. package/lib/browser/view/console/debug-console-session.d.ts.map +1 -1
  39. package/lib/browser/view/console/debug-console-session.js.map +1 -1
  40. package/lib/browser/view/console/debug-console.contribution.d.ts.map +1 -1
  41. package/lib/browser/view/console/debug-console.contribution.js +23 -21
  42. package/lib/browser/view/console/debug-console.contribution.js.map +1 -1
  43. package/lib/browser/view/console/debug-console.module.less +4 -1
  44. package/lib/browser/view/console/debug-console.view.js +2 -2
  45. package/lib/browser/view/console/debug-console.view.js.map +1 -1
  46. package/lib/browser/view/frames/debug-call-stack.contribution.js +5 -5
  47. package/lib/browser/view/frames/debug-call-stack.contribution.js.map +1 -1
  48. package/lib/browser/view/variables/debug-variables.contribution.d.ts.map +1 -1
  49. package/lib/browser/view/variables/debug-variables.contribution.js +13 -12
  50. package/lib/browser/view/variables/debug-variables.contribution.js.map +1 -1
  51. package/lib/browser/view/variables/debug-variables.module.less +1 -1
  52. package/lib/browser/view/variables/debug-variables.view.js +1 -1
  53. package/lib/browser/view/variables/debug-variables.view.js.map +1 -1
  54. package/lib/browser/view/watch/debug-watch.contribution.d.ts.map +1 -1
  55. package/lib/browser/view/watch/debug-watch.contribution.js +19 -21
  56. package/lib/browser/view/watch/debug-watch.contribution.js.map +1 -1
  57. package/lib/browser/view/watch/debug-watch.module.less +1 -1
  58. package/lib/browser/view/watch/debug-watch.view.js +1 -1
  59. package/lib/browser/view/watch/debug-watch.view.js.map +1 -1
  60. package/lib/common/debug-model.d.ts +2 -17
  61. package/lib/common/debug-model.d.ts.map +1 -1
  62. package/lib/common/debug-model.js +1 -9
  63. package/lib/common/debug-model.js.map +1 -1
  64. package/lib/common/index.d.ts +0 -2
  65. package/lib/common/index.d.ts.map +1 -1
  66. package/lib/common/index.js +0 -2
  67. package/lib/common/index.js.map +1 -1
  68. package/package.json +24 -25
  69. package/lib/common/commands.d.ts +0 -46
  70. package/lib/common/commands.d.ts.map +0 -1
  71. package/lib/common/commands.js +0 -149
  72. package/lib/common/commands.js.map +0 -1
  73. package/lib/common/debug-console.d.ts +0 -18
  74. package/lib/common/debug-console.d.ts.map +0 -1
  75. package/lib/common/debug-console.js +0 -5
  76. package/lib/common/debug-console.js.map +0 -1
  77. package/src/browser/assets/breakpoint-conditional-disabled.svg +0 -4
  78. package/src/browser/assets/breakpoint-conditional-unverified.svg +0 -4
  79. package/src/browser/assets/breakpoint-conditional.svg +0 -4
  80. package/src/browser/assets/breakpoint-disabled.svg +0 -4
  81. package/src/browser/assets/breakpoint-hint.svg +0 -4
  82. package/src/browser/assets/breakpoint-log-disabled.svg +0 -4
  83. package/src/browser/assets/breakpoint-log-unverified.svg +0 -4
  84. package/src/browser/assets/breakpoint-log.svg +0 -4
  85. package/src/browser/assets/breakpoint-unsupported.svg +0 -4
  86. package/src/browser/assets/breakpoint-unverified.svg +0 -4
  87. package/src/browser/assets/breakpoint.svg +0 -4
  88. package/src/browser/assets/breakpoints-activate-inverse.svg +0 -4
  89. package/src/browser/assets/breakpoints-activate.svg +0 -4
  90. package/src/browser/assets/configure-inverse.svg +0 -4
  91. package/src/browser/assets/configure.svg +0 -4
  92. package/src/browser/assets/continue-inverse.svg +0 -4
  93. package/src/browser/assets/current-and-breakpoint.svg +0 -4
  94. package/src/browser/assets/current-arrow.svg +0 -4
  95. package/src/browser/assets/remove-all-inverse.svg +0 -4
  96. package/src/browser/assets/remove-all.svg +0 -4
  97. package/src/browser/assets/repl-inverse.svg +0 -4
  98. package/src/browser/assets/repl.svg +0 -4
  99. package/src/browser/assets/restart-inverse.svg +0 -4
  100. package/src/browser/assets/stackframe-and-breakpoint.svg +0 -4
  101. package/src/browser/assets/stackframe-arrow.svg +0 -4
  102. package/src/browser/assets/start-inverse.svg +0 -4
  103. package/src/browser/breakpoint/breakpoint-decoration.ts +0 -57
  104. package/src/browser/breakpoint/breakpoint-manager.ts +0 -348
  105. package/src/browser/breakpoint/breakpoint-marker.ts +0 -70
  106. package/src/browser/breakpoint/index.ts +0 -3
  107. package/src/browser/components/debug-action/index.module.less +0 -73
  108. package/src/browser/components/debug-action/index.tsx +0 -40
  109. package/src/browser/components/debug-exception-widget.less +0 -42
  110. package/src/browser/components/floating-click-widget/index.module.less +0 -5
  111. package/src/browser/components/floating-click-widget/index.tsx +0 -21
  112. package/src/browser/components/index.ts +0 -1
  113. package/src/browser/contextkeys/debug-call-stack-item-type-key.ts +0 -4
  114. package/src/browser/contextkeys/debug-contextkey.service.ts +0 -54
  115. package/src/browser/contextkeys/index.ts +0 -1
  116. package/src/browser/debug-ansi-handle.ts +0 -521
  117. package/src/browser/debug-configuration-manager.ts +0 -513
  118. package/src/browser/debug-configuration-model.ts +0 -66
  119. package/src/browser/debug-contribution.ts +0 -751
  120. package/src/browser/debug-exception-widget.tsx +0 -89
  121. package/src/browser/debug-link-detector.ts +0 -234
  122. package/src/browser/debug-memory.ts +0 -220
  123. package/src/browser/debug-preferences.ts +0 -70
  124. package/src/browser/debug-progress.service.ts +0 -122
  125. package/src/browser/debug-schema-updater.ts +0 -67
  126. package/src/browser/debug-service.ts +0 -42
  127. package/src/browser/debug-session-connection.ts +0 -333
  128. package/src/browser/debug-session-contribution.ts +0 -57
  129. package/src/browser/debug-session-manager.ts +0 -622
  130. package/src/browser/debug-session.ts +0 -1178
  131. package/src/browser/debug-style.less +0 -124
  132. package/src/browser/debugUtils.ts +0 -110
  133. package/src/browser/editor/debug-breakpoint-widget.ts +0 -99
  134. package/src/browser/editor/debug-breakpoint-zone-widget.tsx +0 -262
  135. package/src/browser/editor/debug-breakpoint.module.less +0 -29
  136. package/src/browser/editor/debug-editor-contribution.ts +0 -589
  137. package/src/browser/editor/debug-expression-provider.ts +0 -101
  138. package/src/browser/editor/debug-hover-model.ts +0 -38
  139. package/src/browser/editor/debug-hover-source.ts +0 -107
  140. package/src/browser/editor/debug-hover-tree.model.service.ts +0 -332
  141. package/src/browser/editor/debug-hover-widget.tsx +0 -200
  142. package/src/browser/editor/debug-hover.module.less +0 -29
  143. package/src/browser/editor/debug-hover.view.tsx +0 -147
  144. package/src/browser/editor/debug-model-manager.ts +0 -219
  145. package/src/browser/editor/debug-model.ts +0 -853
  146. package/src/browser/editor/debug-run-to-cursor.service.ts +0 -180
  147. package/src/browser/editor/debug-styles.ts +0 -66
  148. package/src/browser/editor/evaluatable-expression.ts +0 -47
  149. package/src/browser/editor/index.ts +0 -6
  150. package/src/browser/index.ts +0 -127
  151. package/src/browser/markers/index.ts +0 -2
  152. package/src/browser/markers/marker-manager.ts +0 -201
  153. package/src/browser/markers/marker.ts +0 -20
  154. package/src/browser/model/debug-source.ts +0 -144
  155. package/src/browser/model/debug-stack-frame.ts +0 -111
  156. package/src/browser/model/debug-thread.ts +0 -186
  157. package/src/browser/model/debug-watch.ts +0 -129
  158. package/src/browser/model/index.ts +0 -4
  159. package/src/browser/preferences/launch-folder-preference-provider.ts +0 -23
  160. package/src/browser/preferences/launch-preferences-contribution.ts +0 -9
  161. package/src/browser/preferences/launch-preferences.ts +0 -16
  162. package/src/browser/tree/debug-console-tree-node.define.tsx +0 -76
  163. package/src/browser/tree/debug-tree-node.define.ts +0 -768
  164. package/src/browser/tree/index.ts +0 -2
  165. package/src/browser/view/breakpoints/debug-breakpoints.module.less +0 -72
  166. package/src/browser/view/breakpoints/debug-breakpoints.service.ts +0 -216
  167. package/src/browser/view/breakpoints/debug-breakpoints.view.tsx +0 -174
  168. package/src/browser/view/configuration/debug-configuration.module.less +0 -110
  169. package/src/browser/view/configuration/debug-configuration.service.ts +0 -170
  170. package/src/browser/view/configuration/debug-configuration.view.tsx +0 -253
  171. package/src/browser/view/configuration/debug-toolbar.service.ts +0 -167
  172. package/src/browser/view/configuration/debug-toolbar.view.tsx +0 -335
  173. package/src/browser/view/console/debug-console-filter.model.ts +0 -49
  174. package/src/browser/view/console/debug-console-filter.service.ts +0 -81
  175. package/src/browser/view/console/debug-console-filter.view.tsx +0 -78
  176. package/src/browser/view/console/debug-console-model.ts +0 -48
  177. package/src/browser/view/console/debug-console-session.ts +0 -165
  178. package/src/browser/view/console/debug-console-toolbar.view.tsx +0 -28
  179. package/src/browser/view/console/debug-console-tree.model.service.ts +0 -550
  180. package/src/browser/view/console/debug-console.contribution.ts +0 -179
  181. package/src/browser/view/console/debug-console.module.less +0 -369
  182. package/src/browser/view/console/debug-console.service.ts +0 -433
  183. package/src/browser/view/console/debug-console.view.tsx +0 -500
  184. package/src/browser/view/debug-view-model.ts +0 -182
  185. package/src/browser/view/frames/debug-call-stack-frame.view.tsx +0 -224
  186. package/src/browser/view/frames/debug-call-stack-session.view.tsx +0 -237
  187. package/src/browser/view/frames/debug-call-stack-thread.view.tsx +0 -93
  188. package/src/browser/view/frames/debug-call-stack.contribution.ts +0 -88
  189. package/src/browser/view/frames/debug-call-stack.module.less +0 -193
  190. package/src/browser/view/frames/debug-call-stack.operation.tsx +0 -97
  191. package/src/browser/view/frames/debug-call-stack.service.ts +0 -105
  192. package/src/browser/view/frames/debug-call-stack.view.tsx +0 -43
  193. package/src/browser/view/variables/debug-variables-model.ts +0 -38
  194. package/src/browser/view/variables/debug-variables-tree.model.service.ts +0 -467
  195. package/src/browser/view/variables/debug-variables.contribution.ts +0 -243
  196. package/src/browser/view/variables/debug-variables.module.less +0 -148
  197. package/src/browser/view/variables/debug-variables.view.tsx +0 -303
  198. package/src/browser/view/watch/debug-watch-model.ts +0 -38
  199. package/src/browser/view/watch/debug-watch-tree.model.service.ts +0 -567
  200. package/src/browser/view/watch/debug-watch.contribution.ts +0 -170
  201. package/src/browser/view/watch/debug-watch.module.less +0 -188
  202. package/src/browser/view/watch/debug-watch.view.tsx +0 -337
  203. package/src/common/commands.ts +0 -146
  204. package/src/common/constants.ts +0 -81
  205. package/src/common/debug-breakpoint.ts +0 -43
  206. package/src/common/debug-configuration.ts +0 -68
  207. package/src/common/debug-console.ts +0 -20
  208. package/src/common/debug-editor.ts +0 -4
  209. package/src/common/debug-hover.ts +0 -31
  210. package/src/common/debug-model.ts +0 -272
  211. package/src/common/debug-progress.ts +0 -8
  212. package/src/common/debug-schema-updater.ts +0 -1
  213. package/src/common/debug-service.ts +0 -176
  214. package/src/common/debug-session-options.ts +0 -19
  215. package/src/common/debug-session.ts +0 -200
  216. package/src/common/evaluatable-expression.ts +0 -43
  217. package/src/common/index.ts +0 -16
  218. package/src/common/inline-values.ts +0 -77
  219. package/src/common/terminal.ts +0 -163
  220. package/src/common/types.ts +0 -86
  221. package/src/index.ts +0 -1
@@ -1,170 +0,0 @@
1
- import { observable, action } from 'mobx';
2
-
3
- import { Injectable, Autowired } from '@opensumi/di';
4
- import { URI, PreferenceService, isUndefined } from '@opensumi/ide-core-browser';
5
- import { IWorkspaceService } from '@opensumi/ide-workspace';
6
-
7
- import {
8
- DebugSessionOptions,
9
- DEFAULT_ADD_CONFIGURATION_KEY,
10
- DEFAULT_CONFIGURATION_NAME_SEPARATOR,
11
- DEFAULT_CONFIGURATION_INDEX_SEPARATOR,
12
- } from '../../../common';
13
- import { IDebugSessionManager } from '../../../common/debug-session';
14
- import { DebugConfigurationManager } from '../../debug-configuration-manager';
15
- import { DebugSessionManager } from '../../debug-session-manager';
16
- import { DebugConsoleService } from '../console/debug-console.service';
17
- import { DebugViewModel } from '../debug-view-model';
18
-
19
- @Injectable()
20
- export class DebugConfigurationService {
21
- @Autowired(IWorkspaceService)
22
- protected workspaceService: IWorkspaceService;
23
-
24
- @Autowired(DebugConfigurationManager)
25
- protected debugConfigurationManager: DebugConfigurationManager;
26
-
27
- @Autowired(IDebugSessionManager)
28
- protected debugSessionManager: DebugSessionManager;
29
-
30
- @Autowired(DebugViewModel)
31
- protected debugViewModel: DebugViewModel;
32
-
33
- @Autowired(DebugConsoleService)
34
- protected debugConsoleService: DebugConsoleService;
35
-
36
- @Autowired(PreferenceService)
37
- private readonly preferenceService: PreferenceService;
38
-
39
- private _whenReady: Promise<void>;
40
-
41
- constructor() {
42
- this._whenReady = this.init();
43
- }
44
-
45
- @observable
46
- currentValue: string = DEFAULT_ADD_CONFIGURATION_KEY;
47
-
48
- @observable
49
- float = true;
50
-
51
- @observable
52
- isMultiRootWorkspace: boolean;
53
-
54
- @observable
55
- workspaceRoots: string[] = [];
56
-
57
- @observable.shallow
58
- configurationOptions: DebugSessionOptions[];
59
-
60
- get whenReady() {
61
- return this._whenReady;
62
- }
63
-
64
- async init() {
65
- await this.debugConfigurationManager.whenReady;
66
- await this.updateConfigurationOptions();
67
- // await this.initCurrentConfiguration();
68
- this.debugConfigurationManager.onDidChange(async () => {
69
- this.updateConfigurationOptions();
70
- // await this.initCurrentConfiguration();
71
- });
72
- this.preferenceService.onPreferenceChanged((event) => {
73
- const { preferenceName, newValue } = event;
74
- if (preferenceName === 'debug.toolbar.float') {
75
- if (this.float !== newValue) {
76
- this.updateFloat(newValue);
77
- }
78
- }
79
- });
80
- await this.updateWorkspaceState();
81
- // onWorkspaceLocationChanged 事件不能满足实时更新workspaceRoots的需求
82
- // onWorkspaceChanged 能获取到在工作区状态添加文件夹的节点变化
83
- this.workspaceService.onWorkspaceChanged(async () => {
84
- await this.updateWorkspaceState();
85
- });
86
- this.updateFloat(!!this.preferenceService.get<boolean>('debug.toolbar.float'));
87
- }
88
-
89
- @action
90
- async updateWorkspaceState() {
91
- this.isMultiRootWorkspace = this.workspaceService.isMultiRootWorkspaceOpened;
92
- this.workspaceRoots = (await this.workspaceService.tryGetRoots()).map((root) => root.uri);
93
- }
94
-
95
- @action
96
- updateFloat(value: boolean) {
97
- this.float = value;
98
- }
99
-
100
- @action
101
- updateCurrentValue(value: string) {
102
- this.currentValue = value;
103
- }
104
-
105
- @action
106
- updateConfigurationOptions() {
107
- this.configurationOptions = this.debugConfigurationManager.all;
108
- const { current } = this.debugConfigurationManager;
109
- if (current) {
110
- const currentValue = this.toValue(current);
111
- this.updateCurrentValue(currentValue);
112
- } else {
113
- this.updateCurrentValue(DEFAULT_ADD_CONFIGURATION_KEY);
114
- }
115
- }
116
-
117
- start = async () => {
118
- const configuration = this.debugConfigurationManager.current;
119
- if (configuration) {
120
- this.debugSessionManager.start(configuration);
121
- } else {
122
- this.debugConfigurationManager.addConfiguration();
123
- }
124
- };
125
-
126
- openConfiguration = () => {
127
- const { current } = this.debugConfigurationManager;
128
- const uri = current?.workspaceFolderUri;
129
- this.debugConfigurationManager.openConfiguration(uri);
130
- };
131
-
132
- openDebugConsole = () => {
133
- this.debugConsoleService.activate();
134
- };
135
-
136
- addConfiguration = (eventOrUri?: React.MouseEvent<HTMLElement, MouseEvent> | string) => {
137
- this.debugConfigurationManager.addConfiguration(typeof eventOrUri === 'string' ? eventOrUri : undefined);
138
- };
139
-
140
- updateConfiguration = (name: string, workspaceFolderUri: string, index: number) => {
141
- this.debugConfigurationManager.current = this.debugConfigurationManager.find(name, workspaceFolderUri, index);
142
- };
143
-
144
- toValue({ configuration, workspaceFolderUri, index }: DebugSessionOptions) {
145
- if (!workspaceFolderUri) {
146
- return configuration.name;
147
- }
148
- if (isUndefined(index)) {
149
- const options = this.debugConfigurationManager.find(configuration.name, workspaceFolderUri);
150
- if (options && options.index) {
151
- return this.toValue(options);
152
- }
153
- return this.currentValue;
154
- }
155
- return (
156
- configuration.name +
157
- DEFAULT_CONFIGURATION_NAME_SEPARATOR +
158
- workspaceFolderUri +
159
- DEFAULT_CONFIGURATION_INDEX_SEPARATOR +
160
- index
161
- );
162
- }
163
-
164
- toName = ({ configuration, workspaceFolderUri }: DebugSessionOptions) => {
165
- if (!workspaceFolderUri || !this.workspaceService.isMultiRootWorkspaceEnabled) {
166
- return configuration.name;
167
- }
168
- return configuration.name + ' (' + new URI(workspaceFolderUri).path.base + ')';
169
- };
170
- }
@@ -1,253 +0,0 @@
1
- import cls from 'classnames';
2
- import { observer } from 'mobx-react-lite';
3
- import React from 'react';
4
-
5
-
6
- import { Select, Option } from '@opensumi/ide-components';
7
- import { useInjectable, localize, isElectronRenderer, URI } from '@opensumi/ide-core-browser';
8
- import { Select as NativeSelect } from '@opensumi/ide-core-browser/lib/components/select';
9
-
10
- import {
11
- DEFAULT_ADD_CONFIGURATION_KEY,
12
- DEFAULT_NO_CONFIGURATION_KEY,
13
- DEFAULT_CONFIGURATION_INDEX_SEPARATOR,
14
- DEFAULT_CONFIGURATION_NAME_SEPARATOR,
15
- DebugSessionOptions,
16
- } from '../../../common';
17
- import { DebugAction } from '../../components';
18
-
19
- import styles from './debug-configuration.module.less';
20
- import { DebugConfigurationService } from './debug-configuration.service';
21
- import { DebugToolbarView } from './debug-toolbar.view';
22
-
23
- interface ConfigurationSelectorProps {
24
- currentValue: string;
25
- options: DebugSessionOptions[];
26
- isMultiRootWorkspace: boolean;
27
- addConfigurationLabel: string;
28
- workspaceRoots: string[];
29
- toValue: (option: DebugSessionOptions) => string;
30
- onChangeConfiguration(event: React.ChangeEvent<HTMLSelectElement> | string): void;
31
- }
32
-
33
- const ConfigurationSelector = React.memo(
34
- ({
35
- currentValue,
36
- options,
37
- onChangeConfiguration,
38
- isMultiRootWorkspace,
39
- addConfigurationLabel,
40
- toValue,
41
- workspaceRoots,
42
- }: ConfigurationSelectorProps) => {
43
- const renderConfigurationOptions = React.useCallback(
44
- (options) => {
45
- if (options && options.length) {
46
- return options.map((option, index) => {
47
- const label = isMultiRootWorkspace
48
- ? `${option.configuration.name} (${new URI(option.workspaceFolderUri).displayName})`
49
- : option.configuration.name;
50
- return isElectronRenderer() ? (
51
- <option key={index} value={toValue(option)} label={label}>
52
- {label}
53
- </option>
54
- ) : (
55
- <Option key={index} value={toValue(option)} label={label}>
56
- {label}
57
- </Option>
58
- );
59
- });
60
- } else {
61
- return isElectronRenderer()
62
- ? [
63
- <option
64
- value={DEFAULT_NO_CONFIGURATION_KEY}
65
- key={DEFAULT_NO_CONFIGURATION_KEY}
66
- label={localize('debug.action.no.configuration')}
67
- >
68
- {localize('debug.action.no.configuration')}
69
- </option>,
70
- ]
71
- : [
72
- <Option
73
- value={DEFAULT_NO_CONFIGURATION_KEY}
74
- key={DEFAULT_NO_CONFIGURATION_KEY}
75
- label={localize('debug.action.no.configuration')}
76
- >
77
- {localize('debug.action.no.configuration')}
78
- </Option>,
79
- ];
80
- }
81
- },
82
- [isMultiRootWorkspace],
83
- );
84
-
85
- const renderAddConfigurationOptions = React.useCallback(() => {
86
- if (isMultiRootWorkspace) {
87
- let longName: string = addConfigurationLabel;
88
- const addonOptions = workspaceRoots.map((root, index) => {
89
- const label = `${addConfigurationLabel} (${new URI(root).displayName})`;
90
- if (longName.length < label.length) {
91
- longName = label;
92
- }
93
- return isElectronRenderer() ? (
94
- <option
95
- value={`${DEFAULT_ADD_CONFIGURATION_KEY}${index}`}
96
- key={`${DEFAULT_ADD_CONFIGURATION_KEY}${index}`}
97
- label={label}
98
- >
99
- {label}
100
- </option>
101
- ) : (
102
- <Option
103
- value={`${DEFAULT_ADD_CONFIGURATION_KEY}${index}`}
104
- key={`${DEFAULT_ADD_CONFIGURATION_KEY}${index}`}
105
- label={label}
106
- >
107
- {label}
108
- </Option>
109
- );
110
- });
111
- const disabledOption = isElectronRenderer()
112
- ? [
113
- <option disabled key={'--'} value={longName!.replace(/./g, '-')}>
114
- {longName!.replace(/./g, '-')}
115
- </option>,
116
- ]
117
- : [
118
- <Option disabled key={'--'} value={longName!.replace(/./g, '-')}>
119
- {longName!.replace(/./g, '-')}
120
- </Option>,
121
- ];
122
- return disabledOption.concat(addonOptions);
123
- } else {
124
- const label = addConfigurationLabel;
125
- return isElectronRenderer()
126
- ? [
127
- <option disabled key={'--'} value={label!.replace(/./g, '-')}>
128
- {label!.replace(/./g, '-')}
129
- </option>,
130
- <option value={DEFAULT_ADD_CONFIGURATION_KEY} key={DEFAULT_ADD_CONFIGURATION_KEY} label={label}>
131
- {label}
132
- </option>,
133
- ]
134
- : [
135
- <Option disabled key={'--'} value={label!.replace(/./g, '-')}>
136
- {label!.replace(/./g, '-')}
137
- </Option>,
138
- <Option value={DEFAULT_ADD_CONFIGURATION_KEY} key={DEFAULT_ADD_CONFIGURATION_KEY} label={label}>
139
- {label}
140
- </Option>,
141
- ];
142
- }
143
- }, [isMultiRootWorkspace, addConfigurationLabel]);
144
-
145
- if (isElectronRenderer()) {
146
- return (
147
- <NativeSelect
148
- value={currentValue}
149
- onChange={onChangeConfiguration}
150
- className={cls(styles.debug_selection, styles.special_radius)}
151
- >
152
- {renderConfigurationOptions(options)}
153
- {renderAddConfigurationOptions()}
154
- </NativeSelect>
155
- );
156
- }
157
-
158
- return (
159
- <Select
160
- value={currentValue}
161
- onChange={onChangeConfiguration}
162
- className={cls(styles.debug_selection, styles.special_radius)}
163
- >
164
- {renderConfigurationOptions(options)}
165
- {renderAddConfigurationOptions()}
166
- </Select>
167
- );
168
- },
169
- );
170
-
171
- interface DebugActionBarProps {
172
- runDebug(): void;
173
- openConfiguration(): void;
174
- openDebugConsole(): void;
175
- }
176
-
177
- export const DebugActionBar = React.memo(({ runDebug, openConfiguration, openDebugConsole }: DebugActionBarProps) => (
178
- <div className={styles.kt_debug_actions}>
179
- <DebugAction
180
- id='debug.action.start'
181
- icon={'start'}
182
- label={localize('debug.action.start')}
183
- run={runDebug}
184
- ></DebugAction>
185
- <DebugAction
186
- id='debug.action.open.configuration'
187
- icon={'setting'}
188
- label={localize('debug.action.open.configuration')}
189
- run={openConfiguration}
190
- ></DebugAction>
191
- <DebugAction
192
- id='debug.action.debug.console'
193
- icon={'terminal'}
194
- label={localize('debug.action.debug.console')}
195
- run={openDebugConsole}
196
- ></DebugAction>
197
- </div>
198
- ));
199
-
200
- export const DebugConfigurationView = observer((props) => {
201
- const {
202
- configurationOptions,
203
- toValue,
204
- currentValue,
205
- openConfiguration,
206
- addConfiguration,
207
- openDebugConsole,
208
- updateConfiguration,
209
- start,
210
- float,
211
- isMultiRootWorkspace,
212
- workspaceRoots,
213
- } = useInjectable<DebugConfigurationService>(DebugConfigurationService);
214
- const addConfigurationLabel = localize('debug.action.add.configuration');
215
- const setCurrentConfiguration = React.useCallback((event: React.ChangeEvent<HTMLSelectElement> | string) => {
216
- let value: React.ChangeEvent<HTMLSelectElement> | string;
217
- if (typeof event === 'object') {
218
- value = event.target.value;
219
- } else {
220
- value = event;
221
- }
222
- if (value.startsWith(DEFAULT_ADD_CONFIGURATION_KEY)) {
223
- const index = value.slice(DEFAULT_ADD_CONFIGURATION_KEY.length);
224
- if (index) {
225
- addConfiguration(workspaceRoots[index]);
226
- } else {
227
- addConfiguration(workspaceRoots[0]);
228
- }
229
- } else {
230
- const [name, workspaceAndIndex] = value.split(DEFAULT_CONFIGURATION_NAME_SEPARATOR);
231
- const [workspaceFolderUri, index] = workspaceAndIndex.split(DEFAULT_CONFIGURATION_INDEX_SEPARATOR);
232
- updateConfiguration(name, workspaceFolderUri, +index);
233
- }
234
- }, []);
235
-
236
- return (
237
- <div>
238
- <div className={styles.debug_configuration_toolbar}>
239
- <ConfigurationSelector
240
- currentValue={currentValue}
241
- options={configurationOptions}
242
- onChangeConfiguration={setCurrentConfiguration}
243
- isMultiRootWorkspace={isMultiRootWorkspace}
244
- addConfigurationLabel={addConfigurationLabel}
245
- toValue={toValue}
246
- workspaceRoots={workspaceRoots}
247
- />
248
- <DebugActionBar runDebug={start} openConfiguration={openConfiguration} openDebugConsole={openDebugConsole} />
249
- </div>
250
- {!float && <DebugToolbarView float={false} />}
251
- </div>
252
- );
253
- });
@@ -1,167 +0,0 @@
1
- import { observable, action } from 'mobx';
2
-
3
- import { Injectable, Autowired, INJECTOR_TOKEN, Injector } from '@opensumi/di';
4
- import { IContextKeyService, IReporterService, memoize } from '@opensumi/ide-core-browser';
5
- import { AbstractContextMenuService, MenuId } from '@opensumi/ide-core-browser/lib/menu/next';
6
- import { IContextMenu } from '@opensumi/ide-core-browser/lib/menu/next';
7
- import { IElectronMainUIService } from '@opensumi/ide-core-common/lib/electron';
8
-
9
- import { DebugState, DEBUG_REPORT_NAME } from '../../../common';
10
- import { DebugSession } from '../../debug-session';
11
- import { DebugViewModel } from '../debug-view-model';
12
-
13
- @Injectable()
14
- export class DebugToolbarService {
15
- @Autowired(IContextKeyService)
16
- private readonly contextKeyService: IContextKeyService;
17
-
18
- @Autowired(AbstractContextMenuService)
19
- private readonly contextMenuService: AbstractContextMenuService;
20
-
21
- @Autowired(DebugViewModel)
22
- protected readonly model: DebugViewModel;
23
-
24
- @Autowired(IReporterService)
25
- protected readonly reporterService: IReporterService;
26
-
27
- @Autowired(INJECTOR_TOKEN)
28
- private readonly injector: Injector;
29
-
30
- @observable
31
- state: DebugState;
32
-
33
- @observable
34
- sessionCount: number;
35
-
36
- @observable
37
- currentSession: DebugSession | undefined;
38
-
39
- @observable.shallow
40
- sessions: DebugSession[] = [];
41
-
42
- public readonly toolBarMenuMap: Map<string, IContextMenu> = new Map();
43
-
44
- constructor() {
45
- this.model.onDidChange(() => {
46
- this.updateToolBarMenu();
47
- this.updateModel();
48
- });
49
- }
50
-
51
- @memoize
52
- get mainUIService() {
53
- return this.injector.get(IElectronMainUIService);
54
- }
55
-
56
- @action
57
- updateModel() {
58
- this.state = this.model.state;
59
- this.currentSession = this.model.currentSession;
60
- this.sessions = Array.from(this.model.sessions).filter(
61
- (session: DebugSession) => session && session.state > DebugState.Inactive,
62
- );
63
- this.sessionCount = this.sessions.length;
64
- }
65
-
66
- @action
67
- updateToolBarMenu() {
68
- if (this.currentSession && this.currentSession.id && !this.toolBarMenuMap.has(this.currentSession.id)) {
69
- const contextMenu = this.contextMenuService.createMenu({
70
- id: MenuId.DebugToolBar,
71
- contextKeyService: this.contextKeyService.createScoped(),
72
- });
73
- this.currentSession.on('terminated', () => {
74
- this.toolBarMenuMap.delete(this.currentSession?.id!);
75
- });
76
-
77
- this.toolBarMenuMap.set(this.currentSession.id, contextMenu);
78
- }
79
- }
80
-
81
- private instrumentReporter(name: string): () => void {
82
- const session = this.model.currentSession!;
83
- const languageType = session.configuration?.type;
84
- const currentThread = this.model.currentThread;
85
- const threadId = currentThread?.raw?.id;
86
- this.model.reportAction(session.id, threadId, name);
87
- const extra = {
88
- type: languageType,
89
- request: this.currentSession?.configuration.request,
90
- sessionId: session.id,
91
- threadId,
92
- };
93
- this.model.report(DEBUG_REPORT_NAME.DEBUG_TOOLBAR_OPERATION, name, extra);
94
- const reportTime = this.model.reportTime(DEBUG_REPORT_NAME.DEBUG_TOOLBAR_OPERATION_TIME, extra);
95
- return () => {
96
- reportTime(name);
97
- };
98
- }
99
-
100
- doStart = () => this.model.start();
101
-
102
- doRestart = async () => {
103
- const reportTimeEnd = this.instrumentReporter('restart');
104
- const terminated = await this.model.restart();
105
- reportTimeEnd();
106
- return terminated;
107
- };
108
-
109
- doStop = async () => {
110
- if (!this.model.currentSession) {
111
- return;
112
- }
113
- const reportTimeEnd = this.instrumentReporter('stop');
114
- const terminated = await this.model.currentSession.terminate();
115
- reportTimeEnd();
116
- return terminated;
117
- };
118
- doContinue = async () => {
119
- if (!this.model.currentThread) {
120
- return;
121
- }
122
- const reportTimeEnd = this.instrumentReporter('continue');
123
- const terminated = await this.model.currentThread.continue();
124
- reportTimeEnd();
125
- return terminated;
126
- };
127
- doPause = async () => {
128
- if (!this.model.currentThread) {
129
- return;
130
- }
131
- const reportTimeEnd = this.instrumentReporter('pause');
132
- const terminated = await this.model.currentThread.pause();
133
- reportTimeEnd();
134
- return terminated;
135
- };
136
- doStepOver = async () => {
137
- if (!this.model.currentThread) {
138
- return;
139
- }
140
- const reportTimeEnd = this.instrumentReporter('stepOver');
141
- const terminated = await this.model.currentThread.stepOver();
142
- reportTimeEnd();
143
- return terminated;
144
- };
145
- doStepIn = async () => {
146
- if (!this.model.currentThread) {
147
- return;
148
- }
149
- const reportTimeEnd = this.instrumentReporter('stepIn');
150
- const terminated = await this.model.currentThread.stepIn();
151
- reportTimeEnd();
152
- return terminated;
153
- };
154
- doStepOut = async () => {
155
- if (!this.model.currentThread) {
156
- return;
157
- }
158
- const reportTimeEnd = this.instrumentReporter('stepOut');
159
- const terminated = await this.model.currentThread.stepOut();
160
- reportTimeEnd();
161
- return terminated;
162
- };
163
-
164
- updateCurrentSession = (session: DebugSession) => {
165
- this.model.currentSession = session;
166
- };
167
- }