@theia/debug 1.34.3 → 1.34.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 (250) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +62 -62
  3. package/bin/download-adapters.js +76 -76
  4. package/lib/browser/breakpoint/breakpoint-manager.d.ts +69 -69
  5. package/lib/browser/breakpoint/breakpoint-manager.js +311 -311
  6. package/lib/browser/breakpoint/breakpoint-marker.d.ts +40 -40
  7. package/lib/browser/breakpoint/breakpoint-marker.js +73 -73
  8. package/lib/browser/console/debug-console-contribution.d.ts +40 -40
  9. package/lib/browser/console/debug-console-contribution.js +227 -227
  10. package/lib/browser/console/debug-console-items.d.ts +93 -93
  11. package/lib/browser/console/debug-console-items.js +318 -318
  12. package/lib/browser/console/debug-console-session.d.ts +31 -31
  13. package/lib/browser/console/debug-console-session.js +199 -199
  14. package/lib/browser/debug-call-stack-item-type-key.d.ts +3 -3
  15. package/lib/browser/debug-call-stack-item-type-key.js +19 -19
  16. package/lib/browser/debug-configuration-manager.d.ts +101 -101
  17. package/lib/browser/debug-configuration-manager.js +521 -521
  18. package/lib/browser/debug-configuration-model.d.ts +29 -29
  19. package/lib/browser/debug-configuration-model.js +79 -79
  20. package/lib/browser/debug-contribution.d.ts +22 -22
  21. package/lib/browser/debug-contribution.js +19 -19
  22. package/lib/browser/debug-frontend-application-contribution.d.ts +214 -214
  23. package/lib/browser/debug-frontend-application-contribution.js +1351 -1351
  24. package/lib/browser/debug-frontend-module.d.ts +4 -4
  25. package/lib/browser/debug-frontend-module.js +108 -108
  26. package/lib/browser/debug-keybinding-contexts.d.ts +24 -24
  27. package/lib/browser/debug-keybinding-contexts.js +85 -85
  28. package/lib/browser/debug-package.spec.js +18 -18
  29. package/lib/browser/debug-preferences.d.ts +17 -17
  30. package/lib/browser/debug-preferences.js +89 -89
  31. package/lib/browser/debug-prefix-configuration.d.ts +50 -50
  32. package/lib/browser/debug-prefix-configuration.js +204 -204
  33. package/lib/browser/debug-resource.d.ts +14 -14
  34. package/lib/browser/debug-resource.js +65 -65
  35. package/lib/browser/debug-schema-updater.d.ts +15 -15
  36. package/lib/browser/debug-schema-updater.js +168 -168
  37. package/lib/browser/debug-session-connection.d.ts +110 -110
  38. package/lib/browser/debug-session-connection.js +258 -258
  39. package/lib/browser/debug-session-contribution.d.ts +73 -73
  40. package/lib/browser/debug-session-contribution.js +145 -145
  41. package/lib/browser/debug-session-manager.d.ts +137 -137
  42. package/lib/browser/debug-session-manager.js +593 -593
  43. package/lib/browser/debug-session-options.d.ts +48 -48
  44. package/lib/browser/debug-session-options.js +85 -85
  45. package/lib/browser/debug-session.d.ts +178 -178
  46. package/lib/browser/debug-session.js +859 -859
  47. package/lib/browser/debug-tab-bar-decorator.d.ts +16 -16
  48. package/lib/browser/debug-tab-bar-decorator.js +70 -70
  49. package/lib/browser/debug-watch-manager.d.ts +21 -21
  50. package/lib/browser/debug-watch-manager.js +93 -93
  51. package/lib/browser/disassembly-view/disassembly-view-accessibility-provider.d.ts +6 -6
  52. package/lib/browser/disassembly-view/disassembly-view-accessibility-provider.js +38 -38
  53. package/lib/browser/disassembly-view/disassembly-view-breakpoint-renderer.d.ts +19 -19
  54. package/lib/browser/disassembly-view/disassembly-view-breakpoint-renderer.js +110 -110
  55. package/lib/browser/disassembly-view/disassembly-view-contribution.d.ts +24 -24
  56. package/lib/browser/disassembly-view/disassembly-view-contribution.js +131 -131
  57. package/lib/browser/disassembly-view/disassembly-view-instruction-renderer.d.ts +38 -38
  58. package/lib/browser/disassembly-view/disassembly-view-instruction-renderer.js +222 -222
  59. package/lib/browser/disassembly-view/disassembly-view-table-delegate.d.ts +15 -15
  60. package/lib/browser/disassembly-view/disassembly-view-table-delegate.js +38 -38
  61. package/lib/browser/disassembly-view/disassembly-view-utilities.d.ts +37 -37
  62. package/lib/browser/disassembly-view/disassembly-view-utilities.js +17 -17
  63. package/lib/browser/disassembly-view/disassembly-view-widget.d.ts +60 -60
  64. package/lib/browser/disassembly-view/disassembly-view-widget.js +452 -452
  65. package/lib/browser/editor/debug-breakpoint-widget.d.ts +51 -51
  66. package/lib/browser/editor/debug-breakpoint-widget.js +245 -245
  67. package/lib/browser/editor/debug-editor-model.d.ts +91 -91
  68. package/lib/browser/editor/debug-editor-model.js +497 -497
  69. package/lib/browser/editor/debug-editor-service.d.ts +37 -37
  70. package/lib/browser/editor/debug-editor-service.js +214 -214
  71. package/lib/browser/editor/debug-editor.d.ts +3 -3
  72. package/lib/browser/editor/debug-editor.js +19 -19
  73. package/lib/browser/editor/debug-exception-widget.d.ts +28 -28
  74. package/lib/browser/editor/debug-exception-widget.js +111 -111
  75. package/lib/browser/editor/debug-expression-provider.d.ts +11 -11
  76. package/lib/browser/editor/debug-expression-provider.js +81 -81
  77. package/lib/browser/editor/debug-hover-source.d.ts +18 -18
  78. package/lib/browser/editor/debug-hover-source.js +117 -117
  79. package/lib/browser/editor/debug-hover-widget.d.ts +47 -47
  80. package/lib/browser/editor/debug-hover-widget.js +267 -267
  81. package/lib/browser/editor/debug-inline-value-decorator.d.ts +21 -21
  82. package/lib/browser/editor/debug-inline-value-decorator.js +337 -337
  83. package/lib/browser/model/debug-breakpoint.d.ts +47 -47
  84. package/lib/browser/model/debug-breakpoint.js +109 -109
  85. package/lib/browser/model/debug-function-breakpoint.d.ts +18 -18
  86. package/lib/browser/model/debug-function-breakpoint.js +92 -92
  87. package/lib/browser/model/debug-instruction-breakpoint.d.ts +14 -14
  88. package/lib/browser/model/debug-instruction-breakpoint.js +65 -65
  89. package/lib/browser/model/debug-source-breakpoint.d.ts +37 -37
  90. package/lib/browser/model/debug-source-breakpoint.js +211 -211
  91. package/lib/browser/model/debug-source.d.ts +24 -24
  92. package/lib/browser/model/debug-source.js +80 -80
  93. package/lib/browser/model/debug-stack-frame.d.ts +41 -41
  94. package/lib/browser/model/debug-stack-frame.js +146 -146
  95. package/lib/browser/model/debug-thread.d.ts +60 -60
  96. package/lib/browser/model/debug-thread.js +200 -200
  97. package/lib/browser/preferences/launch-preferences.d.ts +4 -4
  98. package/lib/browser/preferences/launch-preferences.js +38 -38
  99. package/lib/browser/view/debug-action.d.ts +16 -16
  100. package/lib/browser/view/debug-action.js +43 -43
  101. package/lib/browser/view/debug-breakpoints-source.d.ts +9 -9
  102. package/lib/browser/view/debug-breakpoints-source.js +70 -70
  103. package/lib/browser/view/debug-breakpoints-widget.d.ts +22 -22
  104. package/lib/browser/view/debug-breakpoints-widget.js +87 -87
  105. package/lib/browser/view/debug-configuration-select.d.ts +61 -61
  106. package/lib/browser/view/debug-configuration-select.js +204 -204
  107. package/lib/browser/view/debug-configuration-widget.d.ts +30 -30
  108. package/lib/browser/view/debug-configuration-widget.js +135 -135
  109. package/lib/browser/view/debug-exception-breakpoint.d.ts +13 -13
  110. package/lib/browser/view/debug-exception-breakpoint.js +34 -34
  111. package/lib/browser/view/debug-session-widget.d.ts +28 -28
  112. package/lib/browser/view/debug-session-widget.js +134 -134
  113. package/lib/browser/view/debug-stack-frames-source.d.ts +17 -17
  114. package/lib/browser/view/debug-stack-frames-source.js +89 -89
  115. package/lib/browser/view/debug-stack-frames-widget.d.ts +24 -24
  116. package/lib/browser/view/debug-stack-frames-widget.js +154 -154
  117. package/lib/browser/view/debug-threads-source.d.ts +8 -8
  118. package/lib/browser/view/debug-threads-source.js +63 -63
  119. package/lib/browser/view/debug-threads-widget.d.ts +26 -26
  120. package/lib/browser/view/debug-threads-widget.js +145 -145
  121. package/lib/browser/view/debug-toolbar-widget.d.ts +34 -34
  122. package/lib/browser/view/debug-toolbar-widget.js +156 -156
  123. package/lib/browser/view/debug-variables-source.d.ts +9 -9
  124. package/lib/browser/view/debug-variables-source.js +60 -60
  125. package/lib/browser/view/debug-variables-widget.d.ts +16 -16
  126. package/lib/browser/view/debug-variables-widget.js +78 -78
  127. package/lib/browser/view/debug-view-model.d.ts +51 -51
  128. package/lib/browser/view/debug-view-model.js +220 -220
  129. package/lib/browser/view/debug-watch-expression.d.ts +30 -30
  130. package/lib/browser/view/debug-watch-expression.js +73 -73
  131. package/lib/browser/view/debug-watch-source.d.ts +9 -9
  132. package/lib/browser/view/debug-watch-source.js +58 -58
  133. package/lib/browser/view/debug-watch-widget.d.ts +16 -16
  134. package/lib/browser/view/debug-watch-widget.js +78 -78
  135. package/lib/browser/view/debug-widget.d.ts +23 -23
  136. package/lib/browser/view/debug-widget.js +108 -108
  137. package/lib/common/debug-adapter-contribution-registry.d.ts +59 -59
  138. package/lib/common/debug-adapter-contribution-registry.js +212 -212
  139. package/lib/common/debug-adapter-session.d.ts +18 -18
  140. package/lib/common/debug-adapter-session.js +78 -78
  141. package/lib/common/debug-common.d.ts +1 -1
  142. package/lib/common/debug-common.js +29 -29
  143. package/lib/common/debug-compound.d.ts +14 -14
  144. package/lib/common/debug-compound.js +27 -27
  145. package/lib/common/debug-configuration.d.ts +58 -58
  146. package/lib/common/debug-configuration.js +31 -31
  147. package/lib/common/debug-model.d.ts +152 -152
  148. package/lib/common/debug-model.js +35 -35
  149. package/lib/common/debug-service.d.ts +123 -123
  150. package/lib/common/debug-service.js +66 -66
  151. package/lib/common/debug-uri-utils.d.ts +23 -23
  152. package/lib/common/debug-uri-utils.js +26 -26
  153. package/lib/common/inline-debug-adapter.d.ts +18 -18
  154. package/lib/common/inline-debug-adapter.js +44 -44
  155. package/lib/node/debug-adapter-factory.d.ts +19 -19
  156. package/lib/node/debug-adapter-factory.js +96 -96
  157. package/lib/node/debug-adapter-session-manager.d.ts +37 -37
  158. package/lib/node/debug-adapter-session-manager.js +111 -111
  159. package/lib/node/debug-backend-module.d.ts +3 -3
  160. package/lib/node/debug-backend-module.js +41 -41
  161. package/lib/node/debug-service-impl.d.ts +30 -30
  162. package/lib/node/debug-service-impl.js +124 -124
  163. package/lib/node/stream-debug-adapter.d.ts +36 -36
  164. package/lib/node/stream-debug-adapter.js +112 -112
  165. package/lib/node/vscode/vscode-debug-adapter-contribution.d.ts +47 -47
  166. package/lib/node/vscode/vscode-debug-adapter-contribution.js +221 -221
  167. package/package.json +15 -15
  168. package/src/browser/breakpoint/breakpoint-manager.ts +351 -351
  169. package/src/browser/breakpoint/breakpoint-marker.ts +102 -102
  170. package/src/browser/console/debug-console-contribution.tsx +239 -239
  171. package/src/browser/console/debug-console-items.tsx +383 -383
  172. package/src/browser/console/debug-console-session.ts +205 -205
  173. package/src/browser/debug-call-stack-item-type-key.ts +20 -20
  174. package/src/browser/debug-configuration-manager.ts +559 -559
  175. package/src/browser/debug-configuration-model.ts +100 -100
  176. package/src/browser/debug-contribution.ts +43 -43
  177. package/src/browser/debug-frontend-application-contribution.ts +1503 -1503
  178. package/src/browser/debug-frontend-module.ts +136 -136
  179. package/src/browser/debug-keybinding-contexts.ts +75 -75
  180. package/src/browser/debug-package.spec.ts +20 -20
  181. package/src/browser/debug-preferences.ts +98 -98
  182. package/src/browser/debug-prefix-configuration.ts +190 -190
  183. package/src/browser/debug-resource.ts +59 -59
  184. package/src/browser/debug-schema-updater.ts +149 -149
  185. package/src/browser/debug-session-connection.ts +357 -357
  186. package/src/browser/debug-session-contribution.ts +150 -150
  187. package/src/browser/debug-session-manager.ts +681 -681
  188. package/src/browser/debug-session-options.ts +114 -114
  189. package/src/browser/debug-session.tsx +936 -936
  190. package/src/browser/debug-tab-bar-decorator.ts +57 -57
  191. package/src/browser/debug-watch-manager.ts +93 -93
  192. package/src/browser/disassembly-view/disassembly-view-accessibility-provider.ts +43 -43
  193. package/src/browser/disassembly-view/disassembly-view-breakpoint-renderer.ts +119 -119
  194. package/src/browser/disassembly-view/disassembly-view-contribution.ts +109 -109
  195. package/src/browser/disassembly-view/disassembly-view-instruction-renderer.ts +245 -245
  196. package/src/browser/disassembly-view/disassembly-view-table-delegate.ts +39 -39
  197. package/src/browser/disassembly-view/disassembly-view-utilities.ts +55 -55
  198. package/src/browser/disassembly-view/disassembly-view-widget.ts +463 -463
  199. package/src/browser/editor/debug-breakpoint-widget.tsx +275 -275
  200. package/src/browser/editor/debug-editor-model.ts +508 -508
  201. package/src/browser/editor/debug-editor-service.ts +206 -206
  202. package/src/browser/editor/debug-editor.ts +20 -20
  203. package/src/browser/editor/debug-exception-widget.tsx +118 -118
  204. package/src/browser/editor/debug-expression-provider.ts +78 -78
  205. package/src/browser/editor/debug-hover-source.tsx +105 -105
  206. package/src/browser/editor/debug-hover-widget.ts +280 -280
  207. package/src/browser/editor/debug-inline-value-decorator.ts +377 -377
  208. package/src/browser/model/debug-breakpoint.tsx +151 -151
  209. package/src/browser/model/debug-function-breakpoint.tsx +101 -101
  210. package/src/browser/model/debug-instruction-breakpoint.tsx +68 -68
  211. package/src/browser/model/debug-source-breakpoint.tsx +237 -237
  212. package/src/browser/model/debug-source.ts +93 -93
  213. package/src/browser/model/debug-stack-frame.tsx +170 -170
  214. package/src/browser/model/debug-thread.tsx +240 -240
  215. package/src/browser/preferences/launch-preferences.ts +38 -38
  216. package/src/browser/style/index.css +445 -445
  217. package/src/browser/view/debug-action.tsx +57 -57
  218. package/src/browser/view/debug-breakpoints-source.tsx +53 -53
  219. package/src/browser/view/debug-breakpoints-widget.ts +71 -71
  220. package/src/browser/view/debug-configuration-select.tsx +256 -256
  221. package/src/browser/view/debug-configuration-widget.tsx +121 -121
  222. package/src/browser/view/debug-exception-breakpoint.tsx +43 -43
  223. package/src/browser/view/debug-session-widget.ts +124 -124
  224. package/src/browser/view/debug-stack-frames-source.tsx +75 -75
  225. package/src/browser/view/debug-stack-frames-widget.ts +135 -135
  226. package/src/browser/view/debug-threads-source.tsx +48 -48
  227. package/src/browser/view/debug-threads-widget.ts +125 -125
  228. package/src/browser/view/debug-toolbar-widget.tsx +145 -145
  229. package/src/browser/view/debug-variables-source.ts +43 -43
  230. package/src/browser/view/debug-variables-widget.ts +61 -61
  231. package/src/browser/view/debug-view-model.ts +230 -230
  232. package/src/browser/view/debug-watch-expression.tsx +88 -88
  233. package/src/browser/view/debug-watch-source.ts +41 -41
  234. package/src/browser/view/debug-watch-widget.ts +61 -61
  235. package/src/browser/view/debug-widget.ts +97 -97
  236. package/src/common/debug-adapter-contribution-registry.ts +206 -206
  237. package/src/common/debug-adapter-session.ts +102 -102
  238. package/src/common/debug-common.ts +19 -19
  239. package/src/common/debug-compound.ts +33 -33
  240. package/src/common/debug-configuration.ts +93 -93
  241. package/src/common/debug-model.ts +200 -200
  242. package/src/common/debug-service.ts +184 -184
  243. package/src/common/debug-uri-utils.ts +24 -24
  244. package/src/common/inline-debug-adapter.ts +47 -47
  245. package/src/node/debug-adapter-factory.ts +107 -107
  246. package/src/node/debug-adapter-session-manager.ts +106 -106
  247. package/src/node/debug-backend-module.ts +57 -57
  248. package/src/node/debug-service-impl.ts +119 -119
  249. package/src/node/stream-debug-adapter.ts +126 -126
  250. package/src/node/vscode/vscode-debug-adapter-contribution.ts +252 -252
@@ -1,508 +1,508 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import debounce = require('p-debounce');
18
- import { injectable, inject, postConstruct, interfaces, Container } from '@theia/core/shared/inversify';
19
- import * as monaco from '@theia/monaco-editor-core';
20
- import { IConfigurationService } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
21
- import { StandaloneCodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
22
- import { IDecorationOptions } from '@theia/monaco-editor-core/esm/vs/editor/common/editorCommon';
23
- import { IEditorHoverOptions } from '@theia/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
24
- import URI from '@theia/core/lib/common/uri';
25
- import { Disposable, DisposableCollection, MenuPath, isOSX } from '@theia/core';
26
- import { ContextMenuRenderer } from '@theia/core/lib/browser';
27
- import { MonacoConfigurationService } from '@theia/monaco/lib/browser/monaco-frontend-module';
28
- import { BreakpointManager } from '../breakpoint/breakpoint-manager';
29
- import { DebugSourceBreakpoint } from '../model/debug-source-breakpoint';
30
- import { DebugSessionManager } from '../debug-session-manager';
31
- import { SourceBreakpoint } from '../breakpoint/breakpoint-marker';
32
- import { DebugEditor } from './debug-editor';
33
- import { DebugHoverWidget, createDebugHoverWidgetContainer } from './debug-hover-widget';
34
- import { DebugBreakpointWidget } from './debug-breakpoint-widget';
35
- import { DebugExceptionWidget } from './debug-exception-widget';
36
- import { DebugProtocol } from '@vscode/debugprotocol';
37
- import { DebugInlineValueDecorator, INLINE_VALUE_DECORATION_KEY } from './debug-inline-value-decorator';
38
-
39
- export const DebugEditorModelFactory = Symbol('DebugEditorModelFactory');
40
- export type DebugEditorModelFactory = (editor: DebugEditor) => DebugEditorModel;
41
-
42
- @injectable()
43
- export class DebugEditorModel implements Disposable {
44
-
45
- static createContainer(parent: interfaces.Container, editor: DebugEditor): Container {
46
- const child = createDebugHoverWidgetContainer(parent, editor);
47
- child.bind(DebugEditorModel).toSelf();
48
- child.bind(DebugBreakpointWidget).toSelf();
49
- child.bind(DebugExceptionWidget).toSelf();
50
- return child;
51
- }
52
- static createModel(parent: interfaces.Container, editor: DebugEditor): DebugEditorModel {
53
- return DebugEditorModel.createContainer(parent, editor).get(DebugEditorModel);
54
- }
55
-
56
- static CONTEXT_MENU: MenuPath = ['debug-editor-context-menu'];
57
-
58
- protected readonly toDispose = new DisposableCollection();
59
- protected readonly toDisposeOnUpdate = new DisposableCollection();
60
-
61
- protected uri: URI;
62
-
63
- protected breakpointDecorations: string[] = [];
64
- protected breakpointRanges = new Map<string, monaco.Range>();
65
-
66
- protected currentBreakpointDecorations: string[] = [];
67
-
68
- protected editorDecorations: string[] = [];
69
- protected topFrameRange: monaco.Range | undefined;
70
-
71
- protected updatingDecorations = false;
72
-
73
- @inject(DebugHoverWidget)
74
- readonly hover: DebugHoverWidget;
75
-
76
- @inject(DebugEditor)
77
- readonly editor: DebugEditor;
78
-
79
- @inject(BreakpointManager)
80
- readonly breakpoints: BreakpointManager;
81
-
82
- @inject(DebugSessionManager)
83
- readonly sessions: DebugSessionManager;
84
-
85
- @inject(ContextMenuRenderer)
86
- readonly contextMenu: ContextMenuRenderer;
87
-
88
- @inject(DebugBreakpointWidget)
89
- readonly breakpointWidget: DebugBreakpointWidget;
90
-
91
- @inject(DebugExceptionWidget)
92
- readonly exceptionWidget: DebugExceptionWidget;
93
-
94
- @inject(DebugInlineValueDecorator)
95
- readonly inlineValueDecorator: DebugInlineValueDecorator;
96
-
97
- @inject(MonacoConfigurationService)
98
- readonly configurationService: IConfigurationService;
99
-
100
- @postConstruct()
101
- protected init(): void {
102
- this.uri = new URI(this.editor.getControl().getModel()!.uri.toString());
103
- this.toDispose.pushAll([
104
- this.hover,
105
- this.breakpointWidget,
106
- this.exceptionWidget,
107
- this.editor.getControl().onMouseDown(event => this.handleMouseDown(event)),
108
- this.editor.getControl().onMouseMove(event => this.handleMouseMove(event)),
109
- this.editor.getControl().onMouseLeave(event => this.handleMouseLeave(event)),
110
- this.editor.getControl().onKeyDown(() => this.hover.hide({ immediate: false })),
111
- this.editor.getControl().onDidChangeModelContent(() => this.update()),
112
- this.editor.getControl().getModel()!.onDidChangeDecorations(() => this.updateBreakpoints()),
113
- this.editor.onDidResize(e => this.breakpointWidget.inputSize = e),
114
- this.sessions.onDidChange(() => this.update()),
115
- this.toDisposeOnUpdate
116
- ]);
117
- this.update();
118
- this.render();
119
- }
120
-
121
- dispose(): void {
122
- this.toDispose.dispose();
123
- }
124
-
125
- protected readonly update = debounce(async () => {
126
- if (this.toDispose.disposed) {
127
- return;
128
- }
129
- this.toDisposeOnUpdate.dispose();
130
- this.toggleExceptionWidget();
131
- await this.updateEditorDecorations();
132
- this.updateEditorHover();
133
- }, 100);
134
-
135
- /**
136
- * To disable the default editor-contribution hover from Code when
137
- * the editor has the `currentFrame`. Otherwise, both `textdocument/hover`
138
- * and the debug hovers are visible at the same time when hovering over a symbol.
139
- */
140
- protected async updateEditorHover(): Promise<void> {
141
- if (this.sessions.isCurrentEditorFrame(this.uri)) {
142
- const codeEditor = this.editor.getControl();
143
- codeEditor.updateOptions({ hover: { enabled: false } });
144
- this.toDisposeOnUpdate.push(Disposable.create(() => {
145
- const model = codeEditor.getModel()!;
146
- const overrides = {
147
- resource: model.uri,
148
- overrideIdentifier: model.getLanguageId(),
149
- };
150
- const { enabled, delay, sticky } = this.configurationService.getValue<IEditorHoverOptions>('editor.hover', overrides);
151
- codeEditor.updateOptions({
152
- hover: {
153
- enabled,
154
- delay,
155
- sticky
156
- }
157
- });
158
- }));
159
- }
160
- }
161
-
162
- protected async updateEditorDecorations(): Promise<void> {
163
- const [newFrameDecorations, inlineValueDecorations] = await Promise.all([
164
- this.createFrameDecorations(),
165
- this.createInlineValueDecorations()
166
- ]);
167
- const codeEditor = this.editor.getControl() as unknown as StandaloneCodeEditor;
168
- codeEditor.removeDecorations([INLINE_VALUE_DECORATION_KEY]);
169
- codeEditor.setDecorationsByType('Inline debug decorations', INLINE_VALUE_DECORATION_KEY, inlineValueDecorations);
170
- this.editorDecorations = this.deltaDecorations(this.editorDecorations, newFrameDecorations);
171
- }
172
-
173
- protected async createInlineValueDecorations(): Promise<IDecorationOptions[]> {
174
- if (!this.sessions.isCurrentEditorFrame(this.uri)) {
175
- return [];
176
- }
177
- const { currentFrame } = this.sessions;
178
- return this.inlineValueDecorator.calculateDecorations(this, currentFrame);
179
- }
180
-
181
- protected createFrameDecorations(): monaco.editor.IModelDeltaDecoration[] {
182
- const { currentFrame, topFrame } = this.sessions;
183
- if (!currentFrame) {
184
- return [];
185
- }
186
-
187
- if (!this.sessions.isCurrentEditorFrame(this.uri)) {
188
- return [];
189
- }
190
-
191
- const decorations: monaco.editor.IModelDeltaDecoration[] = [];
192
- const columnUntilEOLRange = new monaco.Range(currentFrame.raw.line, currentFrame.raw.column, currentFrame.raw.line, 1 << 30);
193
- const range = new monaco.Range(currentFrame.raw.line, currentFrame.raw.column, currentFrame.raw.line, currentFrame.raw.column + 1);
194
-
195
- if (topFrame === currentFrame) {
196
- decorations.push({
197
- options: DebugEditorModel.TOP_STACK_FRAME_MARGIN,
198
- range
199
- });
200
- decorations.push({
201
- options: DebugEditorModel.TOP_STACK_FRAME_DECORATION,
202
- range: columnUntilEOLRange
203
- });
204
- const { topFrameRange } = this;
205
- if (topFrameRange && topFrameRange.startLineNumber === currentFrame.raw.line && topFrameRange.startColumn !== currentFrame.raw.column) {
206
- decorations.push({
207
- options: DebugEditorModel.TOP_STACK_FRAME_INLINE_DECORATION,
208
- range: columnUntilEOLRange
209
- });
210
- }
211
- this.topFrameRange = columnUntilEOLRange;
212
- } else {
213
- decorations.push({
214
- options: DebugEditorModel.FOCUSED_STACK_FRAME_MARGIN,
215
- range
216
- });
217
- decorations.push({
218
- options: DebugEditorModel.FOCUSED_STACK_FRAME_DECORATION,
219
- range: columnUntilEOLRange
220
- });
221
- }
222
- return decorations;
223
- }
224
-
225
- protected async toggleExceptionWidget(): Promise<void> {
226
- const { currentFrame } = this.sessions;
227
- if (!currentFrame) {
228
- return;
229
- }
230
- if (!this.sessions.isCurrentEditorFrame(this.uri)) {
231
- this.exceptionWidget.hide();
232
- return;
233
- }
234
- const info = await currentFrame.thread.getExceptionInfo();
235
- if (!info) {
236
- this.exceptionWidget.hide();
237
- return;
238
- }
239
- this.exceptionWidget.show({
240
- info,
241
- lineNumber: currentFrame.raw.line,
242
- column: currentFrame.raw.column
243
- });
244
- }
245
-
246
- render(): void {
247
- this.renderBreakpoints();
248
- this.renderCurrentBreakpoints();
249
- }
250
- protected renderBreakpoints(): void {
251
- const decorations = this.createBreakpointDecorations();
252
- this.breakpointDecorations = this.deltaDecorations(this.breakpointDecorations, decorations);
253
- this.updateBreakpointRanges();
254
- }
255
- protected createBreakpointDecorations(): monaco.editor.IModelDeltaDecoration[] {
256
- const breakpoints = this.breakpoints.getBreakpoints(this.uri);
257
- return breakpoints.map(breakpoint => this.createBreakpointDecoration(breakpoint));
258
- }
259
- protected createBreakpointDecoration(breakpoint: SourceBreakpoint): monaco.editor.IModelDeltaDecoration {
260
- const lineNumber = breakpoint.raw.line;
261
- const column = breakpoint.raw.column;
262
- const range = typeof column === 'number' ? new monaco.Range(lineNumber, column, lineNumber, column + 1) : new monaco.Range(lineNumber, 1, lineNumber, 2);
263
- return {
264
- range,
265
- options: {
266
- stickiness: DebugEditorModel.STICKINESS
267
- }
268
- };
269
- }
270
- protected updateBreakpointRanges(): void {
271
- this.breakpointRanges.clear();
272
- for (const decoration of this.breakpointDecorations) {
273
- const range = this.editor.getControl().getModel()!.getDecorationRange(decoration)!;
274
- this.breakpointRanges.set(decoration, range);
275
- }
276
- }
277
-
278
- protected renderCurrentBreakpoints(): void {
279
- const decorations = this.createCurrentBreakpointDecorations();
280
- this.currentBreakpointDecorations = this.deltaDecorations(this.currentBreakpointDecorations, decorations);
281
- }
282
- protected createCurrentBreakpointDecorations(): monaco.editor.IModelDeltaDecoration[] {
283
- const breakpoints = this.sessions.getBreakpoints(this.uri);
284
- return breakpoints.map(breakpoint => this.createCurrentBreakpointDecoration(breakpoint));
285
- }
286
- protected createCurrentBreakpointDecoration(breakpoint: DebugSourceBreakpoint): monaco.editor.IModelDeltaDecoration {
287
- const lineNumber = breakpoint.line;
288
- const column = breakpoint.column;
289
- const range = typeof column === 'number' ? new monaco.Range(lineNumber, column, lineNumber, column + 1) : new monaco.Range(lineNumber, 1, lineNumber, 1);
290
- const { className, message } = breakpoint.getDecoration();
291
- const renderInline = typeof column === 'number' && (column > this.editor.getControl().getModel()!.getLineFirstNonWhitespaceColumn(lineNumber));
292
- return {
293
- range,
294
- options: {
295
- glyphMarginClassName: className,
296
- glyphMarginHoverMessage: message.map(value => ({ value })),
297
- stickiness: DebugEditorModel.STICKINESS,
298
- beforeContentClassName: renderInline ? `theia-debug-breakpoint-column codicon ${className}` : undefined
299
- }
300
- };
301
- }
302
-
303
- protected updateBreakpoints(): void {
304
- if (this.areBreakpointsAffected()) {
305
- const breakpoints = this.createBreakpoints();
306
- this.breakpoints.setBreakpoints(this.uri, breakpoints);
307
- }
308
- }
309
- protected areBreakpointsAffected(): boolean {
310
- if (this.updatingDecorations || !this.editor.getControl().getModel()) {
311
- return false;
312
- }
313
- for (const decoration of this.breakpointDecorations) {
314
- const range = this.editor.getControl().getModel()!.getDecorationRange(decoration);
315
- const oldRange = this.breakpointRanges.get(decoration)!;
316
- if (!range || !range.equalsRange(oldRange)) {
317
- return true;
318
- }
319
- }
320
- return false;
321
- }
322
- protected createBreakpoints(): SourceBreakpoint[] {
323
- const { uri } = this;
324
- const lines = new Set<number>();
325
- const breakpoints: SourceBreakpoint[] = [];
326
- for (const decoration of this.breakpointDecorations) {
327
- const range = this.editor.getControl().getModel()!.getDecorationRange(decoration);
328
- if (range && !lines.has(range.startLineNumber)) {
329
- const line = range.startLineNumber;
330
- const column = range.startColumn;
331
- const oldRange = this.breakpointRanges.get(decoration);
332
- const oldBreakpoint = oldRange && this.breakpoints.getInlineBreakpoint(uri, oldRange.startLineNumber, oldRange.startColumn);
333
- const breakpoint = SourceBreakpoint.create(uri, { line, column }, oldBreakpoint);
334
- breakpoints.push(breakpoint);
335
- lines.add(line);
336
- }
337
- }
338
- return breakpoints;
339
- }
340
-
341
- get position(): monaco.Position {
342
- return this.editor.getControl().getPosition()!;
343
- }
344
- getBreakpoint(position: monaco.Position = this.position): DebugSourceBreakpoint | undefined {
345
- return this.getInlineBreakpoint(position) || this.getLineBreakpoints(position)[0];
346
- }
347
-
348
- getInlineBreakpoint(position: monaco.Position = this.position): DebugSourceBreakpoint | undefined {
349
- return this.sessions.getInlineBreakpoint(this.uri, position.lineNumber, position.column);
350
- }
351
-
352
- protected getLineBreakpoints(position: monaco.Position = this.position): DebugSourceBreakpoint[] {
353
- return this.sessions.getLineBreakpoints(this.uri, position.lineNumber);
354
- }
355
-
356
- protected addBreakpoint(raw: DebugProtocol.SourceBreakpoint): void {
357
- this.breakpoints.addBreakpoint(SourceBreakpoint.create(this.uri, raw));
358
- }
359
-
360
- toggleBreakpoint(position: monaco.Position = this.position): void {
361
- const { lineNumber } = position;
362
- const breakpoints = this.getLineBreakpoints(position);
363
- if (breakpoints.length) {
364
- for (const breakpoint of breakpoints) {
365
- breakpoint.remove();
366
- }
367
- } else {
368
- this.addBreakpoint({ line: lineNumber });
369
- }
370
- }
371
-
372
- addInlineBreakpoint(): void {
373
- const { position } = this;
374
- const { lineNumber, column } = position;
375
- const breakpoint = this.getInlineBreakpoint(position);
376
- if (breakpoint) {
377
- return;
378
- }
379
- this.addBreakpoint({ line: lineNumber, column });
380
- }
381
-
382
- acceptBreakpoint(): void {
383
- const { position, values } = this.breakpointWidget;
384
- if (position && values) {
385
- const breakpoint = position.column > 0 ? this.getInlineBreakpoint(position) : this.getLineBreakpoints(position)[0];
386
- if (breakpoint) {
387
- breakpoint.updateOrigins(values);
388
- } else {
389
- const { lineNumber } = position;
390
- const column = position.column > 0 ? position.column : undefined;
391
- this.addBreakpoint({ line: lineNumber, column, ...values });
392
- }
393
- this.breakpointWidget.hide();
394
- }
395
- }
396
-
397
- protected handleMouseDown(event: monaco.editor.IEditorMouseEvent): void {
398
- if (event.target && event.target.type === monaco.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
399
- if (event.event.rightButton) {
400
- this.editor.focus();
401
- setTimeout(() => {
402
- this.contextMenu.render({
403
- menuPath: DebugEditorModel.CONTEXT_MENU,
404
- anchor: event.event.browserEvent,
405
- args: [event.target.position!]
406
- });
407
- });
408
- } else {
409
- this.toggleBreakpoint(event.target.position!);
410
- }
411
- }
412
- this.hintBreakpoint(event);
413
- }
414
- protected handleMouseMove(event: monaco.editor.IEditorMouseEvent): void {
415
- this.showHover(event);
416
- this.hintBreakpoint(event);
417
- }
418
- protected handleMouseLeave(event: monaco.editor.IPartialEditorMouseEvent): void {
419
- this.hideHover(event);
420
- this.deltaHintDecorations([]);
421
- }
422
-
423
- protected hintDecorations: string[] = [];
424
- protected hintBreakpoint(event: monaco.editor.IEditorMouseEvent): void {
425
- const hintDecorations = this.createHintDecorations(event);
426
- this.deltaHintDecorations(hintDecorations);
427
- }
428
- protected deltaHintDecorations(hintDecorations: monaco.editor.IModelDeltaDecoration[]): void {
429
- this.hintDecorations = this.deltaDecorations(this.hintDecorations, hintDecorations);
430
- }
431
- protected createHintDecorations(event: monaco.editor.IEditorMouseEvent): monaco.editor.IModelDeltaDecoration[] {
432
- if (event.target && event.target.type === monaco.editor.MouseTargetType.GUTTER_GLYPH_MARGIN && event.target.position) {
433
- const lineNumber = event.target.position.lineNumber;
434
- if (this.getLineBreakpoints(event.target.position).length) {
435
- return [];
436
- }
437
- return [{
438
- range: new monaco.Range(lineNumber, 1, lineNumber, 1),
439
- options: DebugEditorModel.BREAKPOINT_HINT_DECORATION
440
- }];
441
- }
442
- return [];
443
- }
444
-
445
- protected showHover(mouseEvent: monaco.editor.IEditorMouseEvent): void {
446
- const targetType = mouseEvent.target.type;
447
- const stopKey = isOSX ? 'metaKey' : 'ctrlKey';
448
-
449
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
450
- if (targetType === monaco.editor.MouseTargetType.CONTENT_WIDGET && mouseEvent.target.detail === this.hover.getId() && !(<any>mouseEvent.event)[stopKey]) {
451
- // mouse moved on top of debug hover widget
452
- return;
453
- }
454
- if (targetType === monaco.editor.MouseTargetType.CONTENT_TEXT) {
455
- this.hover.show({
456
- selection: mouseEvent.target.range!,
457
- immediate: false
458
- });
459
- } else {
460
- this.hover.hide({ immediate: false });
461
- }
462
- }
463
- protected hideHover({ event }: monaco.editor.IPartialEditorMouseEvent): void {
464
- const rect = this.hover.getDomNode().getBoundingClientRect();
465
- if (event.posx < rect.left || event.posx > rect.right || event.posy < rect.top || event.posy > rect.bottom) {
466
- this.hover.hide({ immediate: false });
467
- }
468
- }
469
-
470
- protected deltaDecorations(oldDecorations: string[], newDecorations: monaco.editor.IModelDeltaDecoration[]): string[] {
471
- this.updatingDecorations = true;
472
- try {
473
- return this.editor.getControl().getModel()!.deltaDecorations(oldDecorations, newDecorations);
474
- } finally {
475
- this.updatingDecorations = false;
476
- }
477
- }
478
-
479
- static STICKINESS = monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges;
480
-
481
- static BREAKPOINT_HINT_DECORATION: monaco.editor.IModelDecorationOptions = {
482
- glyphMarginClassName: 'codicon-debug-hint',
483
- stickiness: DebugEditorModel.STICKINESS
484
- };
485
-
486
- static TOP_STACK_FRAME_MARGIN: monaco.editor.IModelDecorationOptions = {
487
- glyphMarginClassName: 'codicon-debug-stackframe',
488
- stickiness: DebugEditorModel.STICKINESS
489
- };
490
- static FOCUSED_STACK_FRAME_MARGIN: monaco.editor.IModelDecorationOptions = {
491
- glyphMarginClassName: 'codicon-debug-stackframe-focused',
492
- stickiness: DebugEditorModel.STICKINESS
493
- };
494
- static TOP_STACK_FRAME_DECORATION: monaco.editor.IModelDecorationOptions = {
495
- isWholeLine: true,
496
- className: 'theia-debug-top-stack-frame-line',
497
- stickiness: DebugEditorModel.STICKINESS
498
- };
499
- static TOP_STACK_FRAME_INLINE_DECORATION: monaco.editor.IModelDecorationOptions = {
500
- beforeContentClassName: 'theia-debug-top-stack-frame-column'
501
- };
502
- static FOCUSED_STACK_FRAME_DECORATION: monaco.editor.IModelDecorationOptions = {
503
- isWholeLine: true,
504
- className: 'theia-debug-focused-stack-frame-line',
505
- stickiness: DebugEditorModel.STICKINESS
506
- };
507
-
508
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import debounce = require('p-debounce');
18
+ import { injectable, inject, postConstruct, interfaces, Container } from '@theia/core/shared/inversify';
19
+ import * as monaco from '@theia/monaco-editor-core';
20
+ import { IConfigurationService } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
21
+ import { StandaloneCodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
22
+ import { IDecorationOptions } from '@theia/monaco-editor-core/esm/vs/editor/common/editorCommon';
23
+ import { IEditorHoverOptions } from '@theia/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
24
+ import URI from '@theia/core/lib/common/uri';
25
+ import { Disposable, DisposableCollection, MenuPath, isOSX } from '@theia/core';
26
+ import { ContextMenuRenderer } from '@theia/core/lib/browser';
27
+ import { MonacoConfigurationService } from '@theia/monaco/lib/browser/monaco-frontend-module';
28
+ import { BreakpointManager } from '../breakpoint/breakpoint-manager';
29
+ import { DebugSourceBreakpoint } from '../model/debug-source-breakpoint';
30
+ import { DebugSessionManager } from '../debug-session-manager';
31
+ import { SourceBreakpoint } from '../breakpoint/breakpoint-marker';
32
+ import { DebugEditor } from './debug-editor';
33
+ import { DebugHoverWidget, createDebugHoverWidgetContainer } from './debug-hover-widget';
34
+ import { DebugBreakpointWidget } from './debug-breakpoint-widget';
35
+ import { DebugExceptionWidget } from './debug-exception-widget';
36
+ import { DebugProtocol } from '@vscode/debugprotocol';
37
+ import { DebugInlineValueDecorator, INLINE_VALUE_DECORATION_KEY } from './debug-inline-value-decorator';
38
+
39
+ export const DebugEditorModelFactory = Symbol('DebugEditorModelFactory');
40
+ export type DebugEditorModelFactory = (editor: DebugEditor) => DebugEditorModel;
41
+
42
+ @injectable()
43
+ export class DebugEditorModel implements Disposable {
44
+
45
+ static createContainer(parent: interfaces.Container, editor: DebugEditor): Container {
46
+ const child = createDebugHoverWidgetContainer(parent, editor);
47
+ child.bind(DebugEditorModel).toSelf();
48
+ child.bind(DebugBreakpointWidget).toSelf();
49
+ child.bind(DebugExceptionWidget).toSelf();
50
+ return child;
51
+ }
52
+ static createModel(parent: interfaces.Container, editor: DebugEditor): DebugEditorModel {
53
+ return DebugEditorModel.createContainer(parent, editor).get(DebugEditorModel);
54
+ }
55
+
56
+ static CONTEXT_MENU: MenuPath = ['debug-editor-context-menu'];
57
+
58
+ protected readonly toDispose = new DisposableCollection();
59
+ protected readonly toDisposeOnUpdate = new DisposableCollection();
60
+
61
+ protected uri: URI;
62
+
63
+ protected breakpointDecorations: string[] = [];
64
+ protected breakpointRanges = new Map<string, monaco.Range>();
65
+
66
+ protected currentBreakpointDecorations: string[] = [];
67
+
68
+ protected editorDecorations: string[] = [];
69
+ protected topFrameRange: monaco.Range | undefined;
70
+
71
+ protected updatingDecorations = false;
72
+
73
+ @inject(DebugHoverWidget)
74
+ readonly hover: DebugHoverWidget;
75
+
76
+ @inject(DebugEditor)
77
+ readonly editor: DebugEditor;
78
+
79
+ @inject(BreakpointManager)
80
+ readonly breakpoints: BreakpointManager;
81
+
82
+ @inject(DebugSessionManager)
83
+ readonly sessions: DebugSessionManager;
84
+
85
+ @inject(ContextMenuRenderer)
86
+ readonly contextMenu: ContextMenuRenderer;
87
+
88
+ @inject(DebugBreakpointWidget)
89
+ readonly breakpointWidget: DebugBreakpointWidget;
90
+
91
+ @inject(DebugExceptionWidget)
92
+ readonly exceptionWidget: DebugExceptionWidget;
93
+
94
+ @inject(DebugInlineValueDecorator)
95
+ readonly inlineValueDecorator: DebugInlineValueDecorator;
96
+
97
+ @inject(MonacoConfigurationService)
98
+ readonly configurationService: IConfigurationService;
99
+
100
+ @postConstruct()
101
+ protected init(): void {
102
+ this.uri = new URI(this.editor.getControl().getModel()!.uri.toString());
103
+ this.toDispose.pushAll([
104
+ this.hover,
105
+ this.breakpointWidget,
106
+ this.exceptionWidget,
107
+ this.editor.getControl().onMouseDown(event => this.handleMouseDown(event)),
108
+ this.editor.getControl().onMouseMove(event => this.handleMouseMove(event)),
109
+ this.editor.getControl().onMouseLeave(event => this.handleMouseLeave(event)),
110
+ this.editor.getControl().onKeyDown(() => this.hover.hide({ immediate: false })),
111
+ this.editor.getControl().onDidChangeModelContent(() => this.update()),
112
+ this.editor.getControl().getModel()!.onDidChangeDecorations(() => this.updateBreakpoints()),
113
+ this.editor.onDidResize(e => this.breakpointWidget.inputSize = e),
114
+ this.sessions.onDidChange(() => this.update()),
115
+ this.toDisposeOnUpdate
116
+ ]);
117
+ this.update();
118
+ this.render();
119
+ }
120
+
121
+ dispose(): void {
122
+ this.toDispose.dispose();
123
+ }
124
+
125
+ protected readonly update = debounce(async () => {
126
+ if (this.toDispose.disposed) {
127
+ return;
128
+ }
129
+ this.toDisposeOnUpdate.dispose();
130
+ this.toggleExceptionWidget();
131
+ await this.updateEditorDecorations();
132
+ this.updateEditorHover();
133
+ }, 100);
134
+
135
+ /**
136
+ * To disable the default editor-contribution hover from Code when
137
+ * the editor has the `currentFrame`. Otherwise, both `textdocument/hover`
138
+ * and the debug hovers are visible at the same time when hovering over a symbol.
139
+ */
140
+ protected async updateEditorHover(): Promise<void> {
141
+ if (this.sessions.isCurrentEditorFrame(this.uri)) {
142
+ const codeEditor = this.editor.getControl();
143
+ codeEditor.updateOptions({ hover: { enabled: false } });
144
+ this.toDisposeOnUpdate.push(Disposable.create(() => {
145
+ const model = codeEditor.getModel()!;
146
+ const overrides = {
147
+ resource: model.uri,
148
+ overrideIdentifier: model.getLanguageId(),
149
+ };
150
+ const { enabled, delay, sticky } = this.configurationService.getValue<IEditorHoverOptions>('editor.hover', overrides);
151
+ codeEditor.updateOptions({
152
+ hover: {
153
+ enabled,
154
+ delay,
155
+ sticky
156
+ }
157
+ });
158
+ }));
159
+ }
160
+ }
161
+
162
+ protected async updateEditorDecorations(): Promise<void> {
163
+ const [newFrameDecorations, inlineValueDecorations] = await Promise.all([
164
+ this.createFrameDecorations(),
165
+ this.createInlineValueDecorations()
166
+ ]);
167
+ const codeEditor = this.editor.getControl() as unknown as StandaloneCodeEditor;
168
+ codeEditor.removeDecorations([INLINE_VALUE_DECORATION_KEY]);
169
+ codeEditor.setDecorationsByType('Inline debug decorations', INLINE_VALUE_DECORATION_KEY, inlineValueDecorations);
170
+ this.editorDecorations = this.deltaDecorations(this.editorDecorations, newFrameDecorations);
171
+ }
172
+
173
+ protected async createInlineValueDecorations(): Promise<IDecorationOptions[]> {
174
+ if (!this.sessions.isCurrentEditorFrame(this.uri)) {
175
+ return [];
176
+ }
177
+ const { currentFrame } = this.sessions;
178
+ return this.inlineValueDecorator.calculateDecorations(this, currentFrame);
179
+ }
180
+
181
+ protected createFrameDecorations(): monaco.editor.IModelDeltaDecoration[] {
182
+ const { currentFrame, topFrame } = this.sessions;
183
+ if (!currentFrame) {
184
+ return [];
185
+ }
186
+
187
+ if (!this.sessions.isCurrentEditorFrame(this.uri)) {
188
+ return [];
189
+ }
190
+
191
+ const decorations: monaco.editor.IModelDeltaDecoration[] = [];
192
+ const columnUntilEOLRange = new monaco.Range(currentFrame.raw.line, currentFrame.raw.column, currentFrame.raw.line, 1 << 30);
193
+ const range = new monaco.Range(currentFrame.raw.line, currentFrame.raw.column, currentFrame.raw.line, currentFrame.raw.column + 1);
194
+
195
+ if (topFrame === currentFrame) {
196
+ decorations.push({
197
+ options: DebugEditorModel.TOP_STACK_FRAME_MARGIN,
198
+ range
199
+ });
200
+ decorations.push({
201
+ options: DebugEditorModel.TOP_STACK_FRAME_DECORATION,
202
+ range: columnUntilEOLRange
203
+ });
204
+ const { topFrameRange } = this;
205
+ if (topFrameRange && topFrameRange.startLineNumber === currentFrame.raw.line && topFrameRange.startColumn !== currentFrame.raw.column) {
206
+ decorations.push({
207
+ options: DebugEditorModel.TOP_STACK_FRAME_INLINE_DECORATION,
208
+ range: columnUntilEOLRange
209
+ });
210
+ }
211
+ this.topFrameRange = columnUntilEOLRange;
212
+ } else {
213
+ decorations.push({
214
+ options: DebugEditorModel.FOCUSED_STACK_FRAME_MARGIN,
215
+ range
216
+ });
217
+ decorations.push({
218
+ options: DebugEditorModel.FOCUSED_STACK_FRAME_DECORATION,
219
+ range: columnUntilEOLRange
220
+ });
221
+ }
222
+ return decorations;
223
+ }
224
+
225
+ protected async toggleExceptionWidget(): Promise<void> {
226
+ const { currentFrame } = this.sessions;
227
+ if (!currentFrame) {
228
+ return;
229
+ }
230
+ if (!this.sessions.isCurrentEditorFrame(this.uri)) {
231
+ this.exceptionWidget.hide();
232
+ return;
233
+ }
234
+ const info = await currentFrame.thread.getExceptionInfo();
235
+ if (!info) {
236
+ this.exceptionWidget.hide();
237
+ return;
238
+ }
239
+ this.exceptionWidget.show({
240
+ info,
241
+ lineNumber: currentFrame.raw.line,
242
+ column: currentFrame.raw.column
243
+ });
244
+ }
245
+
246
+ render(): void {
247
+ this.renderBreakpoints();
248
+ this.renderCurrentBreakpoints();
249
+ }
250
+ protected renderBreakpoints(): void {
251
+ const decorations = this.createBreakpointDecorations();
252
+ this.breakpointDecorations = this.deltaDecorations(this.breakpointDecorations, decorations);
253
+ this.updateBreakpointRanges();
254
+ }
255
+ protected createBreakpointDecorations(): monaco.editor.IModelDeltaDecoration[] {
256
+ const breakpoints = this.breakpoints.getBreakpoints(this.uri);
257
+ return breakpoints.map(breakpoint => this.createBreakpointDecoration(breakpoint));
258
+ }
259
+ protected createBreakpointDecoration(breakpoint: SourceBreakpoint): monaco.editor.IModelDeltaDecoration {
260
+ const lineNumber = breakpoint.raw.line;
261
+ const column = breakpoint.raw.column;
262
+ const range = typeof column === 'number' ? new monaco.Range(lineNumber, column, lineNumber, column + 1) : new monaco.Range(lineNumber, 1, lineNumber, 2);
263
+ return {
264
+ range,
265
+ options: {
266
+ stickiness: DebugEditorModel.STICKINESS
267
+ }
268
+ };
269
+ }
270
+ protected updateBreakpointRanges(): void {
271
+ this.breakpointRanges.clear();
272
+ for (const decoration of this.breakpointDecorations) {
273
+ const range = this.editor.getControl().getModel()!.getDecorationRange(decoration)!;
274
+ this.breakpointRanges.set(decoration, range);
275
+ }
276
+ }
277
+
278
+ protected renderCurrentBreakpoints(): void {
279
+ const decorations = this.createCurrentBreakpointDecorations();
280
+ this.currentBreakpointDecorations = this.deltaDecorations(this.currentBreakpointDecorations, decorations);
281
+ }
282
+ protected createCurrentBreakpointDecorations(): monaco.editor.IModelDeltaDecoration[] {
283
+ const breakpoints = this.sessions.getBreakpoints(this.uri);
284
+ return breakpoints.map(breakpoint => this.createCurrentBreakpointDecoration(breakpoint));
285
+ }
286
+ protected createCurrentBreakpointDecoration(breakpoint: DebugSourceBreakpoint): monaco.editor.IModelDeltaDecoration {
287
+ const lineNumber = breakpoint.line;
288
+ const column = breakpoint.column;
289
+ const range = typeof column === 'number' ? new monaco.Range(lineNumber, column, lineNumber, column + 1) : new monaco.Range(lineNumber, 1, lineNumber, 1);
290
+ const { className, message } = breakpoint.getDecoration();
291
+ const renderInline = typeof column === 'number' && (column > this.editor.getControl().getModel()!.getLineFirstNonWhitespaceColumn(lineNumber));
292
+ return {
293
+ range,
294
+ options: {
295
+ glyphMarginClassName: className,
296
+ glyphMarginHoverMessage: message.map(value => ({ value })),
297
+ stickiness: DebugEditorModel.STICKINESS,
298
+ beforeContentClassName: renderInline ? `theia-debug-breakpoint-column codicon ${className}` : undefined
299
+ }
300
+ };
301
+ }
302
+
303
+ protected updateBreakpoints(): void {
304
+ if (this.areBreakpointsAffected()) {
305
+ const breakpoints = this.createBreakpoints();
306
+ this.breakpoints.setBreakpoints(this.uri, breakpoints);
307
+ }
308
+ }
309
+ protected areBreakpointsAffected(): boolean {
310
+ if (this.updatingDecorations || !this.editor.getControl().getModel()) {
311
+ return false;
312
+ }
313
+ for (const decoration of this.breakpointDecorations) {
314
+ const range = this.editor.getControl().getModel()!.getDecorationRange(decoration);
315
+ const oldRange = this.breakpointRanges.get(decoration)!;
316
+ if (!range || !range.equalsRange(oldRange)) {
317
+ return true;
318
+ }
319
+ }
320
+ return false;
321
+ }
322
+ protected createBreakpoints(): SourceBreakpoint[] {
323
+ const { uri } = this;
324
+ const lines = new Set<number>();
325
+ const breakpoints: SourceBreakpoint[] = [];
326
+ for (const decoration of this.breakpointDecorations) {
327
+ const range = this.editor.getControl().getModel()!.getDecorationRange(decoration);
328
+ if (range && !lines.has(range.startLineNumber)) {
329
+ const line = range.startLineNumber;
330
+ const column = range.startColumn;
331
+ const oldRange = this.breakpointRanges.get(decoration);
332
+ const oldBreakpoint = oldRange && this.breakpoints.getInlineBreakpoint(uri, oldRange.startLineNumber, oldRange.startColumn);
333
+ const breakpoint = SourceBreakpoint.create(uri, { line, column }, oldBreakpoint);
334
+ breakpoints.push(breakpoint);
335
+ lines.add(line);
336
+ }
337
+ }
338
+ return breakpoints;
339
+ }
340
+
341
+ get position(): monaco.Position {
342
+ return this.editor.getControl().getPosition()!;
343
+ }
344
+ getBreakpoint(position: monaco.Position = this.position): DebugSourceBreakpoint | undefined {
345
+ return this.getInlineBreakpoint(position) || this.getLineBreakpoints(position)[0];
346
+ }
347
+
348
+ getInlineBreakpoint(position: monaco.Position = this.position): DebugSourceBreakpoint | undefined {
349
+ return this.sessions.getInlineBreakpoint(this.uri, position.lineNumber, position.column);
350
+ }
351
+
352
+ protected getLineBreakpoints(position: monaco.Position = this.position): DebugSourceBreakpoint[] {
353
+ return this.sessions.getLineBreakpoints(this.uri, position.lineNumber);
354
+ }
355
+
356
+ protected addBreakpoint(raw: DebugProtocol.SourceBreakpoint): void {
357
+ this.breakpoints.addBreakpoint(SourceBreakpoint.create(this.uri, raw));
358
+ }
359
+
360
+ toggleBreakpoint(position: monaco.Position = this.position): void {
361
+ const { lineNumber } = position;
362
+ const breakpoints = this.getLineBreakpoints(position);
363
+ if (breakpoints.length) {
364
+ for (const breakpoint of breakpoints) {
365
+ breakpoint.remove();
366
+ }
367
+ } else {
368
+ this.addBreakpoint({ line: lineNumber });
369
+ }
370
+ }
371
+
372
+ addInlineBreakpoint(): void {
373
+ const { position } = this;
374
+ const { lineNumber, column } = position;
375
+ const breakpoint = this.getInlineBreakpoint(position);
376
+ if (breakpoint) {
377
+ return;
378
+ }
379
+ this.addBreakpoint({ line: lineNumber, column });
380
+ }
381
+
382
+ acceptBreakpoint(): void {
383
+ const { position, values } = this.breakpointWidget;
384
+ if (position && values) {
385
+ const breakpoint = position.column > 0 ? this.getInlineBreakpoint(position) : this.getLineBreakpoints(position)[0];
386
+ if (breakpoint) {
387
+ breakpoint.updateOrigins(values);
388
+ } else {
389
+ const { lineNumber } = position;
390
+ const column = position.column > 0 ? position.column : undefined;
391
+ this.addBreakpoint({ line: lineNumber, column, ...values });
392
+ }
393
+ this.breakpointWidget.hide();
394
+ }
395
+ }
396
+
397
+ protected handleMouseDown(event: monaco.editor.IEditorMouseEvent): void {
398
+ if (event.target && event.target.type === monaco.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
399
+ if (event.event.rightButton) {
400
+ this.editor.focus();
401
+ setTimeout(() => {
402
+ this.contextMenu.render({
403
+ menuPath: DebugEditorModel.CONTEXT_MENU,
404
+ anchor: event.event.browserEvent,
405
+ args: [event.target.position!]
406
+ });
407
+ });
408
+ } else {
409
+ this.toggleBreakpoint(event.target.position!);
410
+ }
411
+ }
412
+ this.hintBreakpoint(event);
413
+ }
414
+ protected handleMouseMove(event: monaco.editor.IEditorMouseEvent): void {
415
+ this.showHover(event);
416
+ this.hintBreakpoint(event);
417
+ }
418
+ protected handleMouseLeave(event: monaco.editor.IPartialEditorMouseEvent): void {
419
+ this.hideHover(event);
420
+ this.deltaHintDecorations([]);
421
+ }
422
+
423
+ protected hintDecorations: string[] = [];
424
+ protected hintBreakpoint(event: monaco.editor.IEditorMouseEvent): void {
425
+ const hintDecorations = this.createHintDecorations(event);
426
+ this.deltaHintDecorations(hintDecorations);
427
+ }
428
+ protected deltaHintDecorations(hintDecorations: monaco.editor.IModelDeltaDecoration[]): void {
429
+ this.hintDecorations = this.deltaDecorations(this.hintDecorations, hintDecorations);
430
+ }
431
+ protected createHintDecorations(event: monaco.editor.IEditorMouseEvent): monaco.editor.IModelDeltaDecoration[] {
432
+ if (event.target && event.target.type === monaco.editor.MouseTargetType.GUTTER_GLYPH_MARGIN && event.target.position) {
433
+ const lineNumber = event.target.position.lineNumber;
434
+ if (this.getLineBreakpoints(event.target.position).length) {
435
+ return [];
436
+ }
437
+ return [{
438
+ range: new monaco.Range(lineNumber, 1, lineNumber, 1),
439
+ options: DebugEditorModel.BREAKPOINT_HINT_DECORATION
440
+ }];
441
+ }
442
+ return [];
443
+ }
444
+
445
+ protected showHover(mouseEvent: monaco.editor.IEditorMouseEvent): void {
446
+ const targetType = mouseEvent.target.type;
447
+ const stopKey = isOSX ? 'metaKey' : 'ctrlKey';
448
+
449
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
450
+ if (targetType === monaco.editor.MouseTargetType.CONTENT_WIDGET && mouseEvent.target.detail === this.hover.getId() && !(<any>mouseEvent.event)[stopKey]) {
451
+ // mouse moved on top of debug hover widget
452
+ return;
453
+ }
454
+ if (targetType === monaco.editor.MouseTargetType.CONTENT_TEXT) {
455
+ this.hover.show({
456
+ selection: mouseEvent.target.range!,
457
+ immediate: false
458
+ });
459
+ } else {
460
+ this.hover.hide({ immediate: false });
461
+ }
462
+ }
463
+ protected hideHover({ event }: monaco.editor.IPartialEditorMouseEvent): void {
464
+ const rect = this.hover.getDomNode().getBoundingClientRect();
465
+ if (event.posx < rect.left || event.posx > rect.right || event.posy < rect.top || event.posy > rect.bottom) {
466
+ this.hover.hide({ immediate: false });
467
+ }
468
+ }
469
+
470
+ protected deltaDecorations(oldDecorations: string[], newDecorations: monaco.editor.IModelDeltaDecoration[]): string[] {
471
+ this.updatingDecorations = true;
472
+ try {
473
+ return this.editor.getControl().getModel()!.deltaDecorations(oldDecorations, newDecorations);
474
+ } finally {
475
+ this.updatingDecorations = false;
476
+ }
477
+ }
478
+
479
+ static STICKINESS = monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges;
480
+
481
+ static BREAKPOINT_HINT_DECORATION: monaco.editor.IModelDecorationOptions = {
482
+ glyphMarginClassName: 'codicon-debug-hint',
483
+ stickiness: DebugEditorModel.STICKINESS
484
+ };
485
+
486
+ static TOP_STACK_FRAME_MARGIN: monaco.editor.IModelDecorationOptions = {
487
+ glyphMarginClassName: 'codicon-debug-stackframe',
488
+ stickiness: DebugEditorModel.STICKINESS
489
+ };
490
+ static FOCUSED_STACK_FRAME_MARGIN: monaco.editor.IModelDecorationOptions = {
491
+ glyphMarginClassName: 'codicon-debug-stackframe-focused',
492
+ stickiness: DebugEditorModel.STICKINESS
493
+ };
494
+ static TOP_STACK_FRAME_DECORATION: monaco.editor.IModelDecorationOptions = {
495
+ isWholeLine: true,
496
+ className: 'theia-debug-top-stack-frame-line',
497
+ stickiness: DebugEditorModel.STICKINESS
498
+ };
499
+ static TOP_STACK_FRAME_INLINE_DECORATION: monaco.editor.IModelDecorationOptions = {
500
+ beforeContentClassName: 'theia-debug-top-stack-frame-column'
501
+ };
502
+ static FOCUSED_STACK_FRAME_DECORATION: monaco.editor.IModelDecorationOptions = {
503
+ isWholeLine: true,
504
+ className: 'theia-debug-focused-stack-frame-line',
505
+ stickiness: DebugEditorModel.STICKINESS
506
+ };
507
+
508
+ }