@codingame/monaco-vscode-testing-service-override 4.0.0 → 4.1.0

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 (37) hide show
  1. package/package.json +2 -2
  2. package/testing.js +5 -5
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/vscode/src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.js +0 -591
  6. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/display.js +0 -3
  7. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/index.js +0 -83
  8. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.js +0 -186
  9. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testItemContextOverlay.js +0 -18
  10. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testingObjectTree.js +0 -46
  11. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testingViewState.js +0 -17
  12. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.js +0 -224
  13. package/vscode/src/vs/workbench/contrib/testing/browser/icons.js +0 -184
  14. package/vscode/src/vs/workbench/contrib/testing/browser/media/testMessageColorizer.css.js +0 -6
  15. package/vscode/src/vs/workbench/contrib/testing/browser/media/testing.css.js +0 -6
  16. package/vscode/src/vs/workbench/contrib/testing/browser/testCoverageBars.js +0 -240
  17. package/vscode/src/vs/workbench/contrib/testing/browser/testCoverageView.js +0 -564
  18. package/vscode/src/vs/workbench/contrib/testing/browser/testExplorerActions.js +0 -1673
  19. package/vscode/src/vs/workbench/contrib/testing/browser/testMessageColorizer.js +0 -73
  20. package/vscode/src/vs/workbench/contrib/testing/browser/testing.contribution.js +0 -225
  21. package/vscode/src/vs/workbench/contrib/testing/browser/testingConfigurationUi.js +0 -120
  22. package/vscode/src/vs/workbench/contrib/testing/browser/testingDecorations.js +0 -970
  23. package/vscode/src/vs/workbench/contrib/testing/browser/testingExplorerFilter.js +0 -236
  24. package/vscode/src/vs/workbench/contrib/testing/browser/testingExplorerView.js +0 -1241
  25. package/vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.css.js +0 -6
  26. package/vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.js +0 -2110
  27. package/vscode/src/vs/workbench/contrib/testing/browser/testingProgressUiService.js +0 -142
  28. package/vscode/src/vs/workbench/contrib/testing/browser/testingViewPaneContainer.js +0 -47
  29. package/vscode/src/vs/workbench/contrib/testing/browser/theme.js +0 -337
  30. package/vscode/src/vs/workbench/contrib/testing/common/configuration.js +0 -276
  31. package/vscode/src/vs/workbench/contrib/testing/common/constants.js +0 -59
  32. package/vscode/src/vs/workbench/contrib/testing/common/mainThreadTestCollection.js +0 -129
  33. package/vscode/src/vs/workbench/contrib/testing/common/observableUtils.js +0 -20
  34. package/vscode/src/vs/workbench/contrib/testing/common/testExclusions.js +0 -48
  35. package/vscode/src/vs/workbench/contrib/testing/common/testServiceImpl.js +0 -296
  36. package/vscode/src/vs/workbench/contrib/testing/common/testingContentProvider.js +0 -125
  37. package/vscode/src/vs/workbench/contrib/testing/common/testingUri.js +0 -67
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-testing-service-override",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,7 +18,7 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@4.0.0",
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.1.0",
22
22
  "@xterm/addon-canvas": "0.7.0-beta.12",
23
23
  "@xterm/addon-image": "0.8.0-beta.12",
24
24
  "@xterm/addon-search": "0.15.0-beta.12",
package/testing.js CHANGED
@@ -3,16 +3,16 @@ import { ITestProfileService, TestProfileService } from 'vscode/vscode/vs/workbe
3
3
  import { ITestResultService, TestResultService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultService';
4
4
  import { ITestResultStorage, TestResultStorage } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultStorage';
5
5
  import { ITestService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testService';
6
- import { TestService } from './vscode/src/vs/workbench/contrib/testing/common/testServiceImpl.js';
6
+ import { TestService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testServiceImpl';
7
7
  import { ITestingDecorationsService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingDecorations';
8
- import { TestingDecorationService } from './vscode/src/vs/workbench/contrib/testing/browser/testingDecorations.js';
8
+ import { TestingDecorationService } from 'vscode/vscode/vs/workbench/contrib/testing/browser/testingDecorations';
9
9
  import { ITestingPeekOpener } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingPeekOpener';
10
10
  import { ITestingContinuousRunService, TestingContinuousRunService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingContinuousRunService';
11
11
  import { ITestExplorerFilterState, TestExplorerFilterState } from 'vscode/vscode/vs/workbench/contrib/testing/common/testExplorerFilterState';
12
- import { TestingPeekOpener } from './vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.js';
12
+ import { TestingPeekOpener } from 'vscode/vscode/vs/workbench/contrib/testing/browser/testingOutputPeek';
13
13
  import { ITestCoverageService, TestCoverageService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testCoverageService';
14
- import './vscode/src/vs/workbench/contrib/testing/browser/testing.contribution.js';
15
- import './vscode/src/vs/workbench/contrib/testing/browser/testingConfigurationUi.js';
14
+ import 'vscode/vscode/vs/workbench/contrib/testing/browser/testing.contribution';
15
+ import 'vscode/vscode/vs/workbench/contrib/testing/browser/testingConfigurationUi';
16
16
 
17
17
  function getServiceOverride() {
18
18
  return {
@@ -1,3 +0,0 @@
1
- var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=( Object.keys(r.attributes)),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
2
-
3
- export { n as default };
@@ -1,11 +0,0 @@
1
- function __decorate(decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- }
7
- function __param(paramIndex, decorator) {
8
- return function (target, key) { decorator(target, key, paramIndex); }
9
- }
10
-
11
- export { __decorate, __param };
@@ -1,591 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { $, append, clearNode } from 'vscode/vscode/vs/base/browser/dom';
3
- import { HoverWidget } from 'vscode/vscode/vs/base/browser/ui/hover/hoverWidget';
4
- import { mapFindFirst } from 'vscode/vscode/vs/base/common/arraysFind';
5
- import { assertNever } from 'vscode/vscode/vs/base/common/assert';
6
- import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
7
- import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
8
- import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
9
- import { Lazy } from 'vscode/vscode/vs/base/common/lazy';
10
- import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
11
- import { observableValue } from 'vscode/vscode/vs/base/common/observableInternal/base';
12
- import { derived } from 'vscode/vscode/vs/base/common/observableInternal/derived';
13
- import { autorun } from 'vscode/vscode/vs/base/common/observableInternal/autorun';
14
- import { observableFromEvent } from 'vscode/vscode/vs/base/common/observableInternal/utils';
15
- import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
16
- import { MarkdownRenderer } from 'vscode/vscode/vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
17
- import { Position } from 'vscode/vscode/vs/editor/common/core/position';
18
- import { Range } from 'vscode/vscode/vs/editor/common/core/range';
19
- import { InjectedTextCursorStops } from 'vscode/vscode/vs/editor/common/model';
20
- import { HoverOperation } from 'vscode/vscode/vs/editor/contrib/hover/browser/hoverOperation';
21
- import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
22
- import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
23
- import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
24
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
25
- import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
26
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
27
- import { testingCoverageMissingBranch } from './icons.js';
28
- import { ITestCoverageService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testCoverageService';
29
- import { TestingContextKeys } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingContextKeys';
30
-
31
- var CodeCoverageDecorations_1, LineHoverWidget_1;
32
- const MAX_HOVERED_LINES = 30;
33
- const CLASS_HIT = 'coverage-deco-hit';
34
- const CLASS_MISS = 'coverage-deco-miss';
35
- const TOGGLE_INLINE_COMMAND_TEXT = ( localizeWithPath(
36
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
37
- 'testing.toggleInlineCoverage',
38
- 'Toggle Inline Coverage'
39
- ));
40
- const TOGGLE_INLINE_COMMAND_ID = 'testing.toggleInlineCoverage';
41
- const BRANCH_MISS_INDICATOR_CHARS = 4;
42
- let CodeCoverageDecorations = class CodeCoverageDecorations extends Disposable {
43
- static { CodeCoverageDecorations_1 = this; }
44
- static { this.showInline = observableValue('inlineCoverage', false); }
45
- static { this.fileCoverageDecorations = ( new WeakMap()); }
46
- constructor(editor, instantiationService, coverage, log) {
47
- super();
48
- this.editor = editor;
49
- this.log = log;
50
- this.displayedStore = this._register(( new DisposableStore()));
51
- this.hoveredStore = this._register(( new DisposableStore()));
52
- this.decorationIds = ( new Map());
53
- this.lineHoverWidget = ( new Lazy(
54
- () => this._register(instantiationService.createInstance(LineHoverWidget, this.editor))
55
- ));
56
- const modelObs = observableFromEvent(editor.onDidChangeModel, () => editor.getModel());
57
- const configObs = observableFromEvent(editor.onDidChangeConfiguration, i => i);
58
- const fileCoverage = derived(reader => {
59
- const report = coverage.selected.read(reader);
60
- if (!report) {
61
- return;
62
- }
63
- const model = modelObs.read(reader);
64
- if (!model) {
65
- return;
66
- }
67
- const file = report.getUri(model.uri);
68
- if (file) {
69
- return file;
70
- }
71
- report.didAddCoverage.read(reader);
72
- return undefined;
73
- });
74
- this._register(autorun(reader => {
75
- const c = fileCoverage.read(reader);
76
- if (c) {
77
- this.apply(editor.getModel(), c, CodeCoverageDecorations_1.showInline.read(reader));
78
- }
79
- else {
80
- this.clear();
81
- }
82
- }));
83
- this._register(autorun(reader => {
84
- const c = fileCoverage.read(reader);
85
- if (c) {
86
- const evt = configObs.read(reader);
87
- if (evt?.hasChanged(67 ) !== false) {
88
- this.updateEditorStyles();
89
- }
90
- }
91
- }));
92
- this._register(editor.onMouseMove(e => {
93
- const model = editor.getModel();
94
- if (e.target.type === 3 && model) {
95
- this.hoverLineNumber(editor.getModel(), e.target.position.lineNumber);
96
- }
97
- else if (this.lineHoverWidget.hasValue && this.lineHoverWidget.value.getDomNode().contains(e.target.element)) ;
98
- else if (CodeCoverageDecorations_1.showInline.get() && e.target.type === 6 && model) {
99
- this.hoverInlineDecoration(model, e.target.position);
100
- }
101
- else {
102
- this.hoveredStore.clear();
103
- }
104
- }));
105
- this._register(editor.onWillChangeModel(() => {
106
- const model = editor.getModel();
107
- if (!this.details || !model) {
108
- return;
109
- }
110
- for (const decoration of model.getAllDecorations()) {
111
- const own = this.decorationIds.get(decoration.id);
112
- if (own) {
113
- own.detail.range = decoration.range;
114
- }
115
- }
116
- }));
117
- }
118
- updateEditorStyles() {
119
- const lineHeight = this.editor.getOption(67 );
120
- const { style } = this.editor.getContainerDomNode();
121
- style.setProperty('--vscode-testing-coverage-lineHeight', `${lineHeight}px`);
122
- }
123
- hoverInlineDecoration(model, position) {
124
- const allDecorations = model.getDecorationsInRange(Range.fromPositions(position));
125
- const decoration = mapFindFirst(allDecorations, ({ id }) => ( this.decorationIds.has(id)) ? { id, deco: this.decorationIds.get(id) } : undefined);
126
- if (decoration === this.hoveredSubject) {
127
- return;
128
- }
129
- this.hoveredStore.clear();
130
- this.hoveredSubject = decoration;
131
- if (!decoration) {
132
- return;
133
- }
134
- model.changeDecorations(e => {
135
- e.changeDecorationOptions(decoration.id, {
136
- ...decoration.deco.options,
137
- className: `${decoration.deco.options.className} coverage-deco-hovered`,
138
- });
139
- });
140
- this.hoveredStore.add(toDisposable(() => {
141
- this.hoveredSubject = undefined;
142
- model.changeDecorations(e => {
143
- e.changeDecorationOptions(decoration.id, decoration.deco.options);
144
- });
145
- }));
146
- }
147
- hoverLineNumber(model, lineNumber) {
148
- if (lineNumber === this.hoveredSubject || !this.details) {
149
- return;
150
- }
151
- this.hoveredStore.clear();
152
- this.hoveredSubject = lineNumber;
153
- const todo = [{ line: lineNumber, dir: 0 }];
154
- const toEnable = ( new Set());
155
- const inlineEnabled = CodeCoverageDecorations_1.showInline.get();
156
- if (!CodeCoverageDecorations_1.showInline.get()) {
157
- for (let i = 0; i < todo.length && i < MAX_HOVERED_LINES; i++) {
158
- const { line, dir } = todo[i];
159
- let found = false;
160
- for (const decoration of model.getLineDecorations(line)) {
161
- if (( this.decorationIds.has(decoration.id))) {
162
- toEnable.add(decoration.id);
163
- found = true;
164
- }
165
- }
166
- if (found) {
167
- if (dir <= 0) {
168
- todo.push({ line: line - 1, dir: -1 });
169
- }
170
- if (dir >= 0) {
171
- todo.push({ line: line + 1, dir: 1 });
172
- }
173
- }
174
- }
175
- model.changeDecorations(e => {
176
- for (const id of toEnable) {
177
- const { applyHoverOptions, options } = this.decorationIds.get(id);
178
- const dup = { ...options };
179
- applyHoverOptions(dup);
180
- e.changeDecorationOptions(id, dup);
181
- }
182
- });
183
- }
184
- if (toEnable.size || inlineEnabled) {
185
- this.lineHoverWidget.value.startShowingAt(lineNumber);
186
- }
187
- this.hoveredStore.add(this.editor.onMouseLeave(() => {
188
- this.hoveredStore.clear();
189
- }));
190
- this.hoveredStore.add(toDisposable(() => {
191
- this.lineHoverWidget.value.hide();
192
- this.hoveredSubject = undefined;
193
- model.changeDecorations(e => {
194
- for (const id of toEnable) {
195
- const deco = this.decorationIds.get(id);
196
- if (deco) {
197
- e.changeDecorationOptions(id, deco.options);
198
- }
199
- }
200
- });
201
- }));
202
- }
203
- async apply(model, coverage, showInlineByDefault) {
204
- const details = this.details = await this.loadDetails(coverage, model);
205
- if (!details) {
206
- return this.clear();
207
- }
208
- this.displayedStore.clear();
209
- model.changeDecorations(e => {
210
- for (const detailRange of details.ranges) {
211
- const { metadata: { detail, description }, range, primary } = detailRange;
212
- if (detail.type === 2 ) {
213
- const hits = detail.detail.branches[detail.branch].count;
214
- const cls = hits ? CLASS_HIT : CLASS_MISS;
215
- const showMissIndicator = !hits && range.isEmpty() && ( detail.detail.branches.some(b => b.count));
216
- const options = {
217
- showIfCollapsed: showMissIndicator,
218
- description: 'coverage-gutter',
219
- lineNumberClassName: `coverage-deco-gutter ${cls}`,
220
- };
221
- const applyHoverOptions = (target) => {
222
- target.hoverMessage = description;
223
- if (showMissIndicator) {
224
- target.after = {
225
- content: '\xa0'.repeat(BRANCH_MISS_INDICATOR_CHARS),
226
- inlineClassName: `coverage-deco-branch-miss-indicator ${ThemeIcon.asClassName(testingCoverageMissingBranch)}`,
227
- inlineClassNameAffectsLetterSpacing: true,
228
- cursorStops: InjectedTextCursorStops.None,
229
- };
230
- }
231
- else {
232
- target.className = `coverage-deco-inline ${cls}`;
233
- if (primary && typeof hits === 'number') {
234
- target.before = countBadge(hits);
235
- }
236
- }
237
- };
238
- if (showInlineByDefault) {
239
- applyHoverOptions(options);
240
- }
241
- this.decorationIds.set(e.addDecoration(range, options), { options, applyHoverOptions, detail: detailRange });
242
- }
243
- else if (detail.type === 1 ) {
244
- const cls = detail.count ? CLASS_HIT : CLASS_MISS;
245
- const options = {
246
- showIfCollapsed: false,
247
- description: 'coverage-inline',
248
- lineNumberClassName: `coverage-deco-gutter ${cls}`,
249
- };
250
- const applyHoverOptions = (target) => {
251
- target.className = `coverage-deco-inline ${cls}`;
252
- target.hoverMessage = description;
253
- if (primary && typeof detail.count === 'number') {
254
- target.before = countBadge(detail.count);
255
- }
256
- };
257
- if (showInlineByDefault) {
258
- applyHoverOptions(options);
259
- }
260
- this.decorationIds.set(e.addDecoration(range, options), { options, applyHoverOptions, detail: detailRange });
261
- }
262
- }
263
- });
264
- this.displayedStore.add(toDisposable(() => {
265
- model.changeDecorations(e => {
266
- for (const decoration of ( this.decorationIds.keys())) {
267
- e.removeDecoration(decoration);
268
- }
269
- this.decorationIds.clear();
270
- });
271
- }));
272
- }
273
- clear() {
274
- this.loadingCancellation?.cancel();
275
- this.loadingCancellation = undefined;
276
- this.displayedStore.clear();
277
- this.hoveredStore.clear();
278
- }
279
- async loadDetails(coverage, textModel) {
280
- const existing = CodeCoverageDecorations_1.fileCoverageDecorations.get(coverage);
281
- if (existing) {
282
- return existing;
283
- }
284
- const cts = this.loadingCancellation = ( new CancellationTokenSource());
285
- this.displayedStore.add(this.loadingCancellation);
286
- try {
287
- const details = await coverage.details(this.loadingCancellation.token);
288
- if (cts.token.isCancellationRequested) {
289
- return;
290
- }
291
- const model = CodeCoverageDecorations_1.fileCoverageDecorations.get(coverage)
292
- || ( new CoverageDetailsModel(details, textModel));
293
- CodeCoverageDecorations_1.fileCoverageDecorations.set(coverage, model);
294
- return model;
295
- }
296
- catch (e) {
297
- this.log.error('Error loading coverage details', e);
298
- }
299
- return undefined;
300
- }
301
- };
302
- CodeCoverageDecorations = CodeCoverageDecorations_1 = ( __decorate([
303
- ( __param(1, IInstantiationService)),
304
- ( __param(2, ITestCoverageService)),
305
- ( __param(3, ILogService))
306
- ], CodeCoverageDecorations));
307
- const countBadge = (count) => {
308
- if (count === 0) {
309
- return undefined;
310
- }
311
- return {
312
- content: `${count > 99 ? '99+' : count}x`,
313
- cursorStops: InjectedTextCursorStops.None,
314
- inlineClassName: `coverage-deco-inline-count`,
315
- inlineClassNameAffectsLetterSpacing: true,
316
- };
317
- };
318
- class CoverageDetailsModel {
319
- constructor(details, textModel) {
320
- this.details = details;
321
- this.ranges = [];
322
- const detailRanges = ( details.map(detail => ({
323
- range: tidyLocation(detail.location),
324
- primary: true,
325
- metadata: { detail, description: this.describe(detail, textModel) }
326
- })));
327
- for (const { range, metadata: { detail } } of detailRanges) {
328
- if (detail.type === 1 && detail.branches) {
329
- for (let i = 0; i < detail.branches.length; i++) {
330
- const branch = { type: 2 , branch: i, detail };
331
- detailRanges.push({
332
- range: tidyLocation(detail.branches[i].location || Range.fromPositions(range.getEndPosition())),
333
- primary: true,
334
- metadata: {
335
- detail: branch,
336
- description: this.describe(branch, textModel),
337
- },
338
- });
339
- }
340
- }
341
- }
342
- detailRanges.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range) || a.metadata.detail.type - b.metadata.detail.type);
343
- const stack = [];
344
- const result = this.ranges = [];
345
- const pop = () => {
346
- const next = stack.pop();
347
- const prev = stack[stack.length - 1];
348
- if (prev) {
349
- prev.range = prev.range.setStartPosition(next.range.endLineNumber, next.range.endColumn);
350
- }
351
- result.push(next);
352
- };
353
- for (const item of detailRanges) {
354
- const start = item.range.getStartPosition();
355
- while (stack[stack.length - 1]?.range.containsPosition(start) === false) {
356
- pop();
357
- }
358
- if (item.range.isEmpty()) {
359
- result.push(item);
360
- continue;
361
- }
362
- const prev = stack[stack.length - 1];
363
- if (prev) {
364
- const primary = prev.primary;
365
- const si = prev.range.setEndPosition(start.lineNumber, start.column);
366
- prev.range = prev.range.setStartPosition(item.range.endLineNumber, item.range.endColumn);
367
- prev.primary = false;
368
- if (prev.range.isEmpty()) {
369
- stack.pop();
370
- }
371
- result.push({ range: si, primary, metadata: prev.metadata });
372
- }
373
- stack.push(item);
374
- }
375
- while (stack.length) {
376
- pop();
377
- }
378
- }
379
- describe(detail, model) {
380
- if (detail.type === 0 ) {
381
- return namedDetailLabel(detail.name, detail);
382
- }
383
- else if (detail.type === 1 ) {
384
- const text = wrapName(model.getValueInRange(tidyLocation(detail.location)).trim() || `<empty statement>`);
385
- if (detail.branches?.length) {
386
- const covered = detail.branches.filter(b => !!b.count).length;
387
- return ( new MarkdownString()).appendMarkdown(( localizeWithPath(
388
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
389
- 'coverage.branches',
390
- '{0} of {1} of branches in {2} were covered.',
391
- covered,
392
- detail.branches.length,
393
- text
394
- )));
395
- }
396
- else {
397
- return namedDetailLabel(text, detail);
398
- }
399
- }
400
- else if (detail.type === 2 ) {
401
- const text = wrapName(model.getValueInRange(tidyLocation(detail.detail.location)).trim() || `<empty statement>`);
402
- const { count, label } = detail.detail.branches[detail.branch];
403
- const label2 = label ? wrapInBackticks(label) : `#${detail.branch + 1}`;
404
- if (!count) {
405
- return ( new MarkdownString()).appendMarkdown(( localizeWithPath(
406
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
407
- 'coverage.branchNotCovered',
408
- 'Branch {0} in {1} was not covered.',
409
- label2,
410
- text
411
- )));
412
- }
413
- else if (count === true) {
414
- return ( new MarkdownString()).appendMarkdown(( localizeWithPath(
415
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
416
- 'coverage.branchCoveredYes',
417
- 'Branch {0} in {1} was executed.',
418
- label2,
419
- text
420
- )));
421
- }
422
- else {
423
- return ( new MarkdownString()).appendMarkdown(( localizeWithPath(
424
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
425
- 'coverage.branchCovered',
426
- 'Branch {0} in {1} was executed {2} time(s).',
427
- label2,
428
- text,
429
- count
430
- )));
431
- }
432
- }
433
- assertNever();
434
- }
435
- }
436
- function namedDetailLabel(name, detail) {
437
- return ( new MarkdownString()).appendMarkdown(!detail.count
438
- ? ( localizeWithPath(
439
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
440
- 'coverage.declExecutedNo',
441
- '`{0}` was not executed.',
442
- name
443
- ))
444
- : typeof detail.count === 'number'
445
- ? ( localizeWithPath(
446
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
447
- 'coverage.declExecutedCount',
448
- '`{0}` was executed {1} time(s).',
449
- name,
450
- detail.count
451
- ))
452
- : ( localizeWithPath(
453
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
454
- 'coverage.declExecutedYes',
455
- '`{0}` was executed.',
456
- name
457
- )));
458
- }
459
- function tidyLocation(location) {
460
- if (location instanceof Position) {
461
- return Range.fromPositions(location, ( new Position(location.lineNumber, 0x7FFFFFFF)));
462
- }
463
- return location;
464
- }
465
- let LineHoverComputer = class LineHoverComputer {
466
- constructor(keybindingService) {
467
- this.keybindingService = keybindingService;
468
- this.line = -1;
469
- }
470
- computeSync() {
471
- const strs = [];
472
- const s = ( new MarkdownString()).appendMarkdown(`[${TOGGLE_INLINE_COMMAND_TEXT}](command:${TOGGLE_INLINE_COMMAND_ID})`);
473
- s.isTrusted = true;
474
- const binding = this.keybindingService.lookupKeybinding(TOGGLE_INLINE_COMMAND_ID);
475
- if (binding) {
476
- s.appendText(` (${binding.getLabel()})`);
477
- }
478
- strs.push(s);
479
- return strs;
480
- }
481
- };
482
- LineHoverComputer = ( __decorate([
483
- ( __param(0, IKeybindingService))
484
- ], LineHoverComputer));
485
- function wrapInBackticks(str) {
486
- return '`' + str.replace(/[\n\r`]/g, '') + '`';
487
- }
488
- function wrapName(functionNameOrCode) {
489
- if (functionNameOrCode.length > 50) {
490
- functionNameOrCode = functionNameOrCode.slice(0, 40) + '...';
491
- }
492
- return wrapInBackticks(functionNameOrCode);
493
- }
494
- let LineHoverWidget = class LineHoverWidget extends Disposable {
495
- static { LineHoverWidget_1 = this; }
496
- static { this.ID = 'editor.contrib.testingCoverageLineHoverWidget'; }
497
- constructor(editor, instantiationService) {
498
- super();
499
- this.editor = editor;
500
- this.hover = this._register(( new HoverWidget()));
501
- this.renderDisposables = this._register(( new DisposableStore()));
502
- this.computer = instantiationService.createInstance(LineHoverComputer);
503
- this.markdownRenderer = this._register(instantiationService.createInstance(MarkdownRenderer, { editor: this.editor }));
504
- this.hoverOperation = this._register(( new HoverOperation(this.editor, this.computer)));
505
- this.hover.containerDomNode.classList.add('hidden');
506
- this.hoverOperation.onResult(result => {
507
- if (result.value.length) {
508
- this.render(result.value);
509
- }
510
- else {
511
- this.hide();
512
- }
513
- });
514
- this.editor.addOverlayWidget(this);
515
- }
516
- getId() {
517
- return LineHoverWidget_1.ID;
518
- }
519
- getDomNode() {
520
- return this.hover.containerDomNode;
521
- }
522
- getPosition() {
523
- return null;
524
- }
525
- dispose() {
526
- this.editor.removeOverlayWidget(this);
527
- super.dispose();
528
- }
529
- startShowingAt(lineNumber) {
530
- this.hide();
531
- const textModel = this.editor.getModel();
532
- if (!textModel) {
533
- return;
534
- }
535
- this.computer.line = lineNumber;
536
- this.hoverOperation.start(0 );
537
- }
538
- hide() {
539
- this.hoverOperation.cancel();
540
- this.hover.containerDomNode.classList.add('hidden');
541
- }
542
- render(elements) {
543
- const { hover: h, editor: editor } = this;
544
- const fragment = document.createDocumentFragment();
545
- for (const msg of elements) {
546
- const markdownHoverElement = $('div.hover-row.markdown-hover');
547
- const hoverContentsElement = append(markdownHoverElement, $('div.hover-contents'));
548
- const renderedContents = this.renderDisposables.add(this.markdownRenderer.render(msg));
549
- hoverContentsElement.appendChild(renderedContents.element);
550
- fragment.appendChild(markdownHoverElement);
551
- }
552
- clearNode(h.contentsDomNode);
553
- h.contentsDomNode.appendChild(fragment);
554
- h.containerDomNode.classList.remove('hidden');
555
- const editorLayout = editor.getLayoutInfo();
556
- const topForLineNumber = editor.getTopForLineNumber(this.computer.line);
557
- const editorScrollTop = editor.getScrollTop();
558
- const lineHeight = editor.getOption(67 );
559
- const nodeHeight = h.containerDomNode.clientHeight;
560
- const top = topForLineNumber - editorScrollTop - ((nodeHeight - lineHeight) / 2);
561
- const left = editorLayout.lineNumbersLeft + editorLayout.lineNumbersWidth;
562
- h.containerDomNode.style.left = `${left}px`;
563
- h.containerDomNode.style.top = `${Math.max(Math.round(top), 0)}px`;
564
- }
565
- };
566
- LineHoverWidget = LineHoverWidget_1 = ( __decorate([
567
- ( __param(1, IInstantiationService))
568
- ], LineHoverWidget));
569
- registerAction2(class ToggleInlineCoverage extends Action2 {
570
- constructor() {
571
- super({
572
- id: TOGGLE_INLINE_COMMAND_ID,
573
- title: ( localize2WithPath(
574
- 'vs/workbench/contrib/testing/browser/codeCoverageDecorations',
575
- 'coverage.toggleInline',
576
- "Toggle Inline Coverage"
577
- )),
578
- category: Categories.Test,
579
- keybinding: {
580
- weight: 200 ,
581
- primary: KeyChord(2048 | 85 , 2048 | 1024 | 39 ),
582
- },
583
- precondition: TestingContextKeys.isTestCoverageOpen,
584
- });
585
- }
586
- run() {
587
- CodeCoverageDecorations.showInline.set(!CodeCoverageDecorations.showInline.get(), undefined);
588
- }
589
- });
590
-
591
- export { CodeCoverageDecorations, CoverageDetailsModel };
@@ -1,3 +0,0 @@
1
- const flatTestItemDelimiter = ' \u203A ';
2
-
3
- export { flatTestItemDelimiter };