@opensumi/ide-debug 2.21.9-rc-1671176957.0 → 2.21.9

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 (182) hide show
  1. package/lib/browser/debug-configuration-manager.js +1 -1
  2. package/lib/browser/debug-configuration-manager.js.map +1 -1
  3. package/lib/browser/debug-session-manager.js +1 -1
  4. package/lib/browser/debug-session-manager.js.map +1 -1
  5. package/lib/browser/debug-session.d.ts.map +1 -1
  6. package/lib/browser/debug-session.js +1 -5
  7. package/lib/browser/debug-session.js.map +1 -1
  8. package/lib/browser/index.d.ts.map +1 -1
  9. package/lib/browser/index.js +9 -2
  10. package/lib/browser/index.js.map +1 -1
  11. package/lib/browser/preferences/launch-folder-preference-provider.d.ts +2 -2
  12. package/lib/browser/preferences/launch-folder-preference-provider.d.ts.map +1 -1
  13. package/lib/browser/preferences/launch-folder-preference-provider.js +2 -2
  14. package/lib/browser/preferences/launch-folder-preference-provider.js.map +1 -1
  15. package/lib/browser/view/configuration/debug-configuration.module.less +5 -5
  16. package/lib/browser/view/configuration/debug-configuration.view.d.ts.map +1 -1
  17. package/lib/browser/view/configuration/debug-configuration.view.js +1 -1
  18. package/lib/browser/view/configuration/debug-configuration.view.js.map +1 -1
  19. package/lib/browser/view/configuration/debug-toolbar.view.js +2 -2
  20. package/lib/browser/view/configuration/debug-toolbar.view.js.map +1 -1
  21. package/lib/browser/view/console/debug-console.module.less +1 -2
  22. package/lib/browser/view/console/debug-console.view.js +2 -2
  23. package/lib/browser/view/console/debug-console.view.js.map +1 -1
  24. package/lib/browser/view/frames/debug-call-stack-frame.view.d.ts.map +1 -1
  25. package/lib/browser/view/frames/debug-call-stack-frame.view.js +24 -32
  26. package/lib/browser/view/frames/debug-call-stack-frame.view.js.map +1 -1
  27. package/lib/browser/view/frames/debug-call-stack-session.view.d.ts.map +1 -1
  28. package/lib/browser/view/frames/debug-call-stack-session.view.js +5 -8
  29. package/lib/browser/view/frames/debug-call-stack-session.view.js.map +1 -1
  30. package/lib/browser/view/frames/debug-call-stack-thread.view.d.ts.map +1 -1
  31. package/lib/browser/view/frames/debug-call-stack-thread.view.js +7 -12
  32. package/lib/browser/view/frames/debug-call-stack-thread.view.js.map +1 -1
  33. package/lib/browser/view/variables/debug-variables.module.less +1 -2
  34. package/lib/browser/view/variables/debug-variables.view.js +1 -1
  35. package/lib/browser/view/variables/debug-variables.view.js.map +1 -1
  36. package/lib/browser/view/watch/debug-watch.module.less +1 -2
  37. package/lib/browser/view/watch/debug-watch.view.js +1 -1
  38. package/lib/browser/view/watch/debug-watch.view.js.map +1 -1
  39. package/package.json +24 -25
  40. package/src/browser/assets/breakpoint-conditional-disabled.svg +0 -4
  41. package/src/browser/assets/breakpoint-conditional-unverified.svg +0 -4
  42. package/src/browser/assets/breakpoint-conditional.svg +0 -4
  43. package/src/browser/assets/breakpoint-disabled.svg +0 -4
  44. package/src/browser/assets/breakpoint-hint.svg +0 -4
  45. package/src/browser/assets/breakpoint-log-disabled.svg +0 -4
  46. package/src/browser/assets/breakpoint-log-unverified.svg +0 -4
  47. package/src/browser/assets/breakpoint-log.svg +0 -4
  48. package/src/browser/assets/breakpoint-unsupported.svg +0 -4
  49. package/src/browser/assets/breakpoint-unverified.svg +0 -4
  50. package/src/browser/assets/breakpoint.svg +0 -4
  51. package/src/browser/assets/breakpoints-activate-inverse.svg +0 -4
  52. package/src/browser/assets/breakpoints-activate.svg +0 -4
  53. package/src/browser/assets/configure-inverse.svg +0 -4
  54. package/src/browser/assets/configure.svg +0 -4
  55. package/src/browser/assets/continue-inverse.svg +0 -4
  56. package/src/browser/assets/current-and-breakpoint.svg +0 -4
  57. package/src/browser/assets/current-arrow.svg +0 -4
  58. package/src/browser/assets/remove-all-inverse.svg +0 -4
  59. package/src/browser/assets/remove-all.svg +0 -4
  60. package/src/browser/assets/repl-inverse.svg +0 -4
  61. package/src/browser/assets/repl.svg +0 -4
  62. package/src/browser/assets/restart-inverse.svg +0 -4
  63. package/src/browser/assets/stackframe-and-breakpoint.svg +0 -4
  64. package/src/browser/assets/stackframe-arrow.svg +0 -4
  65. package/src/browser/assets/start-inverse.svg +0 -4
  66. package/src/browser/breakpoint/breakpoint-decoration.ts +0 -57
  67. package/src/browser/breakpoint/breakpoint-manager.ts +0 -348
  68. package/src/browser/breakpoint/breakpoint-marker.ts +0 -70
  69. package/src/browser/breakpoint/index.ts +0 -3
  70. package/src/browser/components/debug-action/index.module.less +0 -73
  71. package/src/browser/components/debug-action/index.tsx +0 -40
  72. package/src/browser/components/debug-exception-widget.less +0 -42
  73. package/src/browser/components/floating-click-widget/index.module.less +0 -5
  74. package/src/browser/components/floating-click-widget/index.tsx +0 -21
  75. package/src/browser/components/index.ts +0 -1
  76. package/src/browser/contextkeys/debug-call-stack-item-type-key.ts +0 -4
  77. package/src/browser/contextkeys/debug-contextkey.service.ts +0 -54
  78. package/src/browser/contextkeys/index.ts +0 -1
  79. package/src/browser/debug-ansi-handle.ts +0 -521
  80. package/src/browser/debug-configuration-manager.ts +0 -513
  81. package/src/browser/debug-configuration-model.ts +0 -66
  82. package/src/browser/debug-contribution.ts +0 -904
  83. package/src/browser/debug-exception-widget.tsx +0 -89
  84. package/src/browser/debug-link-detector.ts +0 -234
  85. package/src/browser/debug-memory.ts +0 -220
  86. package/src/browser/debug-preferences.ts +0 -70
  87. package/src/browser/debug-progress.service.ts +0 -122
  88. package/src/browser/debug-schema-updater.ts +0 -67
  89. package/src/browser/debug-service.ts +0 -42
  90. package/src/browser/debug-session-connection.ts +0 -333
  91. package/src/browser/debug-session-contribution.ts +0 -57
  92. package/src/browser/debug-session-manager.ts +0 -622
  93. package/src/browser/debug-session.ts +0 -1182
  94. package/src/browser/debug-style.less +0 -128
  95. package/src/browser/debugUtils.ts +0 -110
  96. package/src/browser/editor/debug-breakpoint-widget.ts +0 -99
  97. package/src/browser/editor/debug-breakpoint-zone-widget.tsx +0 -262
  98. package/src/browser/editor/debug-breakpoint.module.less +0 -31
  99. package/src/browser/editor/debug-editor-contribution.ts +0 -590
  100. package/src/browser/editor/debug-expression-provider.ts +0 -101
  101. package/src/browser/editor/debug-hover-model.ts +0 -38
  102. package/src/browser/editor/debug-hover-source.ts +0 -107
  103. package/src/browser/editor/debug-hover-tree.model.service.ts +0 -332
  104. package/src/browser/editor/debug-hover-widget.tsx +0 -200
  105. package/src/browser/editor/debug-hover.module.less +0 -29
  106. package/src/browser/editor/debug-hover.view.tsx +0 -147
  107. package/src/browser/editor/debug-model-manager.ts +0 -220
  108. package/src/browser/editor/debug-model.ts +0 -853
  109. package/src/browser/editor/debug-run-to-cursor.service.ts +0 -180
  110. package/src/browser/editor/debug-styles.ts +0 -66
  111. package/src/browser/editor/evaluatable-expression.ts +0 -47
  112. package/src/browser/editor/index.ts +0 -6
  113. package/src/browser/index.ts +0 -121
  114. package/src/browser/markers/index.ts +0 -2
  115. package/src/browser/markers/marker-manager.ts +0 -201
  116. package/src/browser/markers/marker.ts +0 -20
  117. package/src/browser/model/debug-source.ts +0 -144
  118. package/src/browser/model/debug-stack-frame.ts +0 -111
  119. package/src/browser/model/debug-thread.ts +0 -186
  120. package/src/browser/model/debug-watch.ts +0 -130
  121. package/src/browser/model/index.ts +0 -4
  122. package/src/browser/preferences/launch-folder-preference-provider.ts +0 -23
  123. package/src/browser/preferences/launch-preferences-contribution.ts +0 -9
  124. package/src/browser/preferences/launch-preferences.ts +0 -16
  125. package/src/browser/tree/debug-console-tree-node.define.tsx +0 -76
  126. package/src/browser/tree/debug-tree-node.define.ts +0 -768
  127. package/src/browser/tree/index.ts +0 -2
  128. package/src/browser/view/breakpoints/debug-breakpoints.module.less +0 -72
  129. package/src/browser/view/breakpoints/debug-breakpoints.service.ts +0 -217
  130. package/src/browser/view/breakpoints/debug-breakpoints.view.tsx +0 -174
  131. package/src/browser/view/configuration/debug-configuration.module.less +0 -110
  132. package/src/browser/view/configuration/debug-configuration.service.ts +0 -170
  133. package/src/browser/view/configuration/debug-configuration.view.tsx +0 -252
  134. package/src/browser/view/configuration/debug-toolbar.service.ts +0 -167
  135. package/src/browser/view/configuration/debug-toolbar.view.tsx +0 -335
  136. package/src/browser/view/console/debug-console-filter.model.ts +0 -49
  137. package/src/browser/view/console/debug-console-filter.service.ts +0 -81
  138. package/src/browser/view/console/debug-console-filter.view.tsx +0 -78
  139. package/src/browser/view/console/debug-console-model.ts +0 -48
  140. package/src/browser/view/console/debug-console-session.ts +0 -164
  141. package/src/browser/view/console/debug-console-toolbar.view.tsx +0 -28
  142. package/src/browser/view/console/debug-console-tree.model.service.ts +0 -550
  143. package/src/browser/view/console/debug-console.contribution.ts +0 -181
  144. package/src/browser/view/console/debug-console.module.less +0 -373
  145. package/src/browser/view/console/debug-console.service.ts +0 -433
  146. package/src/browser/view/console/debug-console.view.tsx +0 -500
  147. package/src/browser/view/debug-view-model.ts +0 -182
  148. package/src/browser/view/frames/debug-call-stack-frame.view.tsx +0 -238
  149. package/src/browser/view/frames/debug-call-stack-session.view.tsx +0 -253
  150. package/src/browser/view/frames/debug-call-stack-thread.view.tsx +0 -103
  151. package/src/browser/view/frames/debug-call-stack.contribution.ts +0 -88
  152. package/src/browser/view/frames/debug-call-stack.module.less +0 -193
  153. package/src/browser/view/frames/debug-call-stack.operation.tsx +0 -97
  154. package/src/browser/view/frames/debug-call-stack.service.ts +0 -105
  155. package/src/browser/view/frames/debug-call-stack.view.tsx +0 -43
  156. package/src/browser/view/variables/debug-variables-model.ts +0 -38
  157. package/src/browser/view/variables/debug-variables-tree.model.service.ts +0 -467
  158. package/src/browser/view/variables/debug-variables.contribution.ts +0 -244
  159. package/src/browser/view/variables/debug-variables.module.less +0 -149
  160. package/src/browser/view/variables/debug-variables.view.tsx +0 -303
  161. package/src/browser/view/watch/debug-watch-model.ts +0 -38
  162. package/src/browser/view/watch/debug-watch-tree.model.service.ts +0 -567
  163. package/src/browser/view/watch/debug-watch.contribution.ts +0 -167
  164. package/src/browser/view/watch/debug-watch.module.less +0 -189
  165. package/src/browser/view/watch/debug-watch.view.tsx +0 -337
  166. package/src/common/constants.ts +0 -81
  167. package/src/common/debug-breakpoint.ts +0 -43
  168. package/src/common/debug-configuration.ts +0 -68
  169. package/src/common/debug-editor.ts +0 -4
  170. package/src/common/debug-hover.ts +0 -31
  171. package/src/common/debug-model.ts +0 -247
  172. package/src/common/debug-progress.ts +0 -8
  173. package/src/common/debug-schema-updater.ts +0 -1
  174. package/src/common/debug-service.ts +0 -176
  175. package/src/common/debug-session-options.ts +0 -19
  176. package/src/common/debug-session.ts +0 -200
  177. package/src/common/evaluatable-expression.ts +0 -43
  178. package/src/common/index.ts +0 -14
  179. package/src/common/inline-values.ts +0 -77
  180. package/src/common/terminal.ts +0 -163
  181. package/src/common/types.ts +0 -86
  182. 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,252 +0,0 @@
1
- import cls from 'classnames';
2
- import { observer } from 'mobx-react-lite';
3
- import React from 'react';
4
-
5
- import { Select, Option } from '@opensumi/ide-components';
6
- import { useInjectable, localize, isElectronRenderer, URI } from '@opensumi/ide-core-browser';
7
- import { Select as NativeSelect } from '@opensumi/ide-core-browser/lib/components/select';
8
-
9
- import {
10
- DEFAULT_ADD_CONFIGURATION_KEY,
11
- DEFAULT_NO_CONFIGURATION_KEY,
12
- DEFAULT_CONFIGURATION_INDEX_SEPARATOR,
13
- DEFAULT_CONFIGURATION_NAME_SEPARATOR,
14
- DebugSessionOptions,
15
- } from '../../../common';
16
- import { DebugAction } from '../../components';
17
-
18
- import styles from './debug-configuration.module.less';
19
- import { DebugConfigurationService } from './debug-configuration.service';
20
- import { DebugToolbarView } from './debug-toolbar.view';
21
-
22
- interface ConfigurationSelectorProps {
23
- currentValue: string;
24
- options: DebugSessionOptions[];
25
- isMultiRootWorkspace: boolean;
26
- addConfigurationLabel: string;
27
- workspaceRoots: string[];
28
- toValue: (option: DebugSessionOptions) => string;
29
- onChangeConfiguration(event: React.ChangeEvent<HTMLSelectElement> | string): void;
30
- }
31
-
32
- const ConfigurationSelector = React.memo(
33
- ({
34
- currentValue,
35
- options,
36
- onChangeConfiguration,
37
- isMultiRootWorkspace,
38
- addConfigurationLabel,
39
- toValue,
40
- workspaceRoots,
41
- }: ConfigurationSelectorProps) => {
42
- const renderConfigurationOptions = React.useCallback(
43
- (options) => {
44
- if (options && options.length) {
45
- return options.map((option, index) => {
46
- const label = isMultiRootWorkspace
47
- ? `${option.configuration.name} (${new URI(option.workspaceFolderUri).displayName})`
48
- : option.configuration.name;
49
- return isElectronRenderer() ? (
50
- <option key={index} value={toValue(option)} label={label}>
51
- {label}
52
- </option>
53
- ) : (
54
- <Option key={index} value={toValue(option)} label={label}>
55
- {label}
56
- </Option>
57
- );
58
- });
59
- } else {
60
- return isElectronRenderer()
61
- ? [
62
- <option
63
- value={DEFAULT_NO_CONFIGURATION_KEY}
64
- key={DEFAULT_NO_CONFIGURATION_KEY}
65
- label={localize('debug.action.no.configuration')}
66
- >
67
- {localize('debug.action.no.configuration')}
68
- </option>,
69
- ]
70
- : [
71
- <Option
72
- value={DEFAULT_NO_CONFIGURATION_KEY}
73
- key={DEFAULT_NO_CONFIGURATION_KEY}
74
- label={localize('debug.action.no.configuration')}
75
- >
76
- {localize('debug.action.no.configuration')}
77
- </Option>,
78
- ];
79
- }
80
- },
81
- [isMultiRootWorkspace],
82
- );
83
-
84
- const renderAddConfigurationOptions = React.useCallback(() => {
85
- if (isMultiRootWorkspace) {
86
- let longName: string = addConfigurationLabel;
87
- const addonOptions = workspaceRoots.map((root, index) => {
88
- const label = `${addConfigurationLabel} (${new URI(root).displayName})`;
89
- if (longName.length < label.length) {
90
- longName = label;
91
- }
92
- return isElectronRenderer() ? (
93
- <option
94
- value={`${DEFAULT_ADD_CONFIGURATION_KEY}${index}`}
95
- key={`${DEFAULT_ADD_CONFIGURATION_KEY}${index}`}
96
- label={label}
97
- >
98
- {label}
99
- </option>
100
- ) : (
101
- <Option
102
- value={`${DEFAULT_ADD_CONFIGURATION_KEY}${index}`}
103
- key={`${DEFAULT_ADD_CONFIGURATION_KEY}${index}`}
104
- label={label}
105
- >
106
- {label}
107
- </Option>
108
- );
109
- });
110
- const disabledOption = isElectronRenderer()
111
- ? [
112
- <option disabled key={'--'} value={longName!.replace(/./g, '-')}>
113
- {longName!.replace(/./g, '-')}
114
- </option>,
115
- ]
116
- : [
117
- <Option disabled key={'--'} value={longName!.replace(/./g, '-')}>
118
- {longName!.replace(/./g, '-')}
119
- </Option>,
120
- ];
121
- return disabledOption.concat(addonOptions);
122
- } else {
123
- const label = addConfigurationLabel;
124
- return isElectronRenderer()
125
- ? [
126
- <option disabled key={'--'} value={label!.replace(/./g, '-')}>
127
- {label!.replace(/./g, '-')}
128
- </option>,
129
- <option value={DEFAULT_ADD_CONFIGURATION_KEY} key={DEFAULT_ADD_CONFIGURATION_KEY} label={label}>
130
- {label}
131
- </option>,
132
- ]
133
- : [
134
- <Option disabled key={'--'} value={label!.replace(/./g, '-')}>
135
- {label!.replace(/./g, '-')}
136
- </Option>,
137
- <Option value={DEFAULT_ADD_CONFIGURATION_KEY} key={DEFAULT_ADD_CONFIGURATION_KEY} label={label}>
138
- {label}
139
- </Option>,
140
- ];
141
- }
142
- }, [isMultiRootWorkspace, addConfigurationLabel]);
143
-
144
- if (isElectronRenderer()) {
145
- return (
146
- <NativeSelect
147
- value={currentValue}
148
- onChange={onChangeConfiguration}
149
- className={cls(styles.debug_selection, styles.special_radius)}
150
- >
151
- {renderConfigurationOptions(options)}
152
- {renderAddConfigurationOptions()}
153
- </NativeSelect>
154
- );
155
- }
156
-
157
- return (
158
- <Select
159
- value={currentValue}
160
- onChange={onChangeConfiguration}
161
- className={cls(styles.debug_selection, styles.special_radius)}
162
- >
163
- {renderConfigurationOptions(options)}
164
- {renderAddConfigurationOptions()}
165
- </Select>
166
- );
167
- },
168
- );
169
-
170
- interface DebugActionBarProps {
171
- runDebug(): void;
172
- openConfiguration(): void;
173
- openDebugConsole(): void;
174
- }
175
-
176
- export const DebugActionBar = React.memo(({ runDebug, openConfiguration, openDebugConsole }: DebugActionBarProps) => (
177
- <div className={styles.debug_actions}>
178
- <DebugAction
179
- id='debug.action.start'
180
- icon={'start'}
181
- label={localize('debug.action.start')}
182
- run={runDebug}
183
- ></DebugAction>
184
- <DebugAction
185
- id='debug.action.open.configuration'
186
- icon={'setting'}
187
- label={localize('debug.action.open.configuration')}
188
- run={openConfiguration}
189
- ></DebugAction>
190
- <DebugAction
191
- id='debug.action.debug.console'
192
- icon={'terminal'}
193
- label={localize('debug.action.debug.console')}
194
- run={openDebugConsole}
195
- ></DebugAction>
196
- </div>
197
- ));
198
-
199
- export const DebugConfigurationView = observer((props) => {
200
- const {
201
- configurationOptions,
202
- toValue,
203
- currentValue,
204
- openConfiguration,
205
- addConfiguration,
206
- openDebugConsole,
207
- updateConfiguration,
208
- start,
209
- float,
210
- isMultiRootWorkspace,
211
- workspaceRoots,
212
- } = useInjectable<DebugConfigurationService>(DebugConfigurationService);
213
- const addConfigurationLabel = localize('debug.action.add.configuration');
214
- const setCurrentConfiguration = React.useCallback((event: React.ChangeEvent<HTMLSelectElement> | string) => {
215
- let value: React.ChangeEvent<HTMLSelectElement> | string;
216
- if (typeof event === 'object') {
217
- value = event.target.value;
218
- } else {
219
- value = event;
220
- }
221
- if (value.startsWith(DEFAULT_ADD_CONFIGURATION_KEY)) {
222
- const index = value.slice(DEFAULT_ADD_CONFIGURATION_KEY.length);
223
- if (index) {
224
- addConfiguration(workspaceRoots[index]);
225
- } else {
226
- addConfiguration(workspaceRoots[0]);
227
- }
228
- } else {
229
- const [name, workspaceAndIndex] = value.split(DEFAULT_CONFIGURATION_NAME_SEPARATOR);
230
- const [workspaceFolderUri, index] = workspaceAndIndex.split(DEFAULT_CONFIGURATION_INDEX_SEPARATOR);
231
- updateConfiguration(name, workspaceFolderUri, +index);
232
- }
233
- }, []);
234
-
235
- return (
236
- <div>
237
- <div className={styles.debug_configuration_toolbar}>
238
- <ConfigurationSelector
239
- currentValue={currentValue}
240
- options={configurationOptions}
241
- onChangeConfiguration={setCurrentConfiguration}
242
- isMultiRootWorkspace={isMultiRootWorkspace}
243
- addConfigurationLabel={addConfigurationLabel}
244
- toValue={toValue}
245
- workspaceRoots={workspaceRoots}
246
- />
247
- <DebugActionBar runDebug={start} openConfiguration={openConfiguration} openDebugConsole={openDebugConsole} />
248
- </div>
249
- {!float && <DebugToolbarView float={false} />}
250
- </div>
251
- );
252
- });
@@ -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
- }