@codingame/monaco-vscode-testing-service-override 3.2.3 → 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.
- package/package.json +8 -8
- package/testing.js +5 -4
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/external/tslib/tslib.es6.js +0 -11
- package/vscode/src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.js +0 -567
- package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/display.js +0 -3
- package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/index.js +0 -83
- package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.js +0 -186
- package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testItemContextOverlay.js +0 -18
- package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testingObjectTree.js +0 -46
- package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testingViewState.js +0 -17
- package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.js +0 -225
- package/vscode/src/vs/workbench/contrib/testing/browser/icons.js +0 -174
- package/vscode/src/vs/workbench/contrib/testing/browser/media/testing.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/testing/browser/testCoverageBars.js +0 -227
- package/vscode/src/vs/workbench/contrib/testing/browser/testCoverageView.js +0 -545
- package/vscode/src/vs/workbench/contrib/testing/browser/testExplorerActions.js +0 -1662
- package/vscode/src/vs/workbench/contrib/testing/browser/testing.contribution.js +0 -219
- package/vscode/src/vs/workbench/contrib/testing/browser/testingDecorations.js +0 -970
- package/vscode/src/vs/workbench/contrib/testing/browser/testingExplorerFilter.js +0 -236
- package/vscode/src/vs/workbench/contrib/testing/browser/testingExplorerView.js +0 -1227
- package/vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.js +0 -2091
- package/vscode/src/vs/workbench/contrib/testing/browser/testingProgressUiService.js +0 -142
- package/vscode/src/vs/workbench/contrib/testing/browser/testingViewPaneContainer.js +0 -47
- package/vscode/src/vs/workbench/contrib/testing/browser/theme.js +0 -259
- package/vscode/src/vs/workbench/contrib/testing/common/configuration.js +0 -273
- package/vscode/src/vs/workbench/contrib/testing/common/constants.js +0 -59
- package/vscode/src/vs/workbench/contrib/testing/common/mainThreadTestCollection.js +0 -129
- package/vscode/src/vs/workbench/contrib/testing/common/testExclusions.js +0 -48
- package/vscode/src/vs/workbench/contrib/testing/common/testServiceImpl.js +0 -296
- package/vscode/src/vs/workbench/contrib/testing/common/testingContentProvider.js +0 -125
- package/vscode/src/vs/workbench/contrib/testing/common/testingUri.js +0 -67
|
@@ -1,970 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { $ } from 'vscode/vscode/vs/base/browser/dom';
|
|
3
|
-
import { renderStringAsPlaintext } from 'vscode/vscode/vs/base/browser/markdownRenderer';
|
|
4
|
-
import { Action, Separator, SubmenuAction } from 'vscode/vscode/vs/base/common/actions';
|
|
5
|
-
import { equals } from 'vscode/vscode/vs/base/common/arrays';
|
|
6
|
-
import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
|
|
7
|
-
import { Event, Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
8
|
-
import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
|
|
9
|
-
import { stripIcons } from 'vscode/vscode/vs/base/common/iconLabels';
|
|
10
|
-
import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
|
|
11
|
-
import { Disposable, MutableDisposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
12
|
-
import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
|
|
13
|
-
import { isMacintosh } from 'vscode/vscode/vs/base/common/platform';
|
|
14
|
-
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
15
|
-
import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
|
|
16
|
-
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
17
|
-
import { overviewRulerError, overviewRulerInfo } from 'vscode/vscode/vs/editor/common/core/editorColorRegistry';
|
|
18
|
-
import { GlyphMarginLane, OverviewRulerLane } from 'vscode/vscode/vs/editor/common/model';
|
|
19
|
-
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
20
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
21
|
-
import { createAndFillInContextMenuActions } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
|
|
22
|
-
import { MenuId, IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
23
|
-
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
24
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
25
|
-
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
26
|
-
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
27
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
28
|
-
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
|
|
29
|
-
import { themeColorFromId } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
30
|
-
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
31
|
-
import { GutterActionsRegistry, EditorLineNumberContextMenu } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/editorLineNumberMenu';
|
|
32
|
-
import { getTestItemContextOverlay } from './explorerProjections/testItemContextOverlay.js';
|
|
33
|
-
import { testingRunAllIcon, testingRunIcon, testingStatesToIcons } from './icons.js';
|
|
34
|
-
import { getTestingConfiguration } from '../common/configuration.js';
|
|
35
|
-
import { labelForTestInState } from '../common/constants.js';
|
|
36
|
-
import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
|
|
37
|
-
import { ITestProfileService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testProfileService';
|
|
38
|
-
import { LiveTestResult } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResult';
|
|
39
|
-
import { ITestResultService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultService';
|
|
40
|
-
import { testsInFile, ITestService, getContextForTestItem } from 'vscode/vscode/vs/workbench/contrib/testing/common/testService';
|
|
41
|
-
import { TestDecorations, ITestingDecorationsService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingDecorations';
|
|
42
|
-
import { ITestingPeekOpener } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingPeekOpener';
|
|
43
|
-
import { isFailedState, maxPriority } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingStates';
|
|
44
|
-
import { parseTestUri, buildTestUri } from '../common/testingUri.js';
|
|
45
|
-
|
|
46
|
-
var TestMessageDecoration_1;
|
|
47
|
-
const MAX_INLINE_MESSAGE_LENGTH = 128;
|
|
48
|
-
const MAX_TESTS_IN_SUBMENU = 30;
|
|
49
|
-
const GLYPH_MARGIN_LANE = GlyphMarginLane.Center;
|
|
50
|
-
function isOriginalInDiffEditor(codeEditorService, codeEditor) {
|
|
51
|
-
const diffEditors = codeEditorService.listDiffEditors();
|
|
52
|
-
for (const diffEditor of diffEditors) {
|
|
53
|
-
if (diffEditor.getOriginalEditor() === codeEditor) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
class CachedDecorations {
|
|
60
|
-
constructor() {
|
|
61
|
-
this.runByIdKey = ( new Map());
|
|
62
|
-
this.messages = ( new Map());
|
|
63
|
-
}
|
|
64
|
-
get size() {
|
|
65
|
-
return this.runByIdKey.size + this.messages.size;
|
|
66
|
-
}
|
|
67
|
-
getForExactTests(testIds) {
|
|
68
|
-
const key = testIds.sort().join('\0\0');
|
|
69
|
-
return this.runByIdKey.get(key);
|
|
70
|
-
}
|
|
71
|
-
getMessage(message) {
|
|
72
|
-
return this.messages.get(message);
|
|
73
|
-
}
|
|
74
|
-
removeMessage(message) {
|
|
75
|
-
this.messages.delete(message);
|
|
76
|
-
}
|
|
77
|
-
addMessage(d) {
|
|
78
|
-
this.messages.set(d.testMessage, d);
|
|
79
|
-
}
|
|
80
|
-
addTest(d) {
|
|
81
|
-
const key = d.testIds.sort().join('\0\0');
|
|
82
|
-
this.runByIdKey.set(key, d);
|
|
83
|
-
}
|
|
84
|
-
getById(decorationId) {
|
|
85
|
-
for (const d of ( this.runByIdKey.values())) {
|
|
86
|
-
if (d.id === decorationId) {
|
|
87
|
-
return d;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
for (const d of ( this.messages.values())) {
|
|
91
|
-
if (d.id === decorationId) {
|
|
92
|
-
return d;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
*[Symbol.iterator]() {
|
|
98
|
-
for (const d of ( this.runByIdKey.values())) {
|
|
99
|
-
yield d;
|
|
100
|
-
}
|
|
101
|
-
for (const d of ( this.messages.values())) {
|
|
102
|
-
yield d;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
let TestingDecorationService = class TestingDecorationService extends Disposable {
|
|
107
|
-
constructor(codeEditorService, configurationService, testService, results, instantiationService, modelService) {
|
|
108
|
-
super();
|
|
109
|
-
this.configurationService = configurationService;
|
|
110
|
-
this.testService = testService;
|
|
111
|
-
this.results = results;
|
|
112
|
-
this.instantiationService = instantiationService;
|
|
113
|
-
this.modelService = modelService;
|
|
114
|
-
this.generation = 0;
|
|
115
|
-
this.changeEmitter = ( new Emitter());
|
|
116
|
-
this.decorationCache = ( new ResourceMap());
|
|
117
|
-
this.invalidatedMessages = ( new WeakSet());
|
|
118
|
-
this.onDidChange = this.changeEmitter.event;
|
|
119
|
-
codeEditorService.registerDecorationType('test-message-decoration', TestMessageDecoration.decorationId, {}, undefined);
|
|
120
|
-
modelService.onModelRemoved(e => this.decorationCache.delete(e.uri));
|
|
121
|
-
const debounceInvalidate = this._register(( new RunOnceScheduler(() => this.invalidate(), 100)));
|
|
122
|
-
this._register(this.testService.onWillProcessDiff(diff => {
|
|
123
|
-
for (const entry of diff) {
|
|
124
|
-
if (entry.op !== 2 ) {
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const rec = this.decorationCache.get(entry.uri);
|
|
128
|
-
if (rec) {
|
|
129
|
-
rec.rangeUpdateVersionId = entry.docv;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (!debounceInvalidate.isScheduled()) {
|
|
133
|
-
debounceInvalidate.schedule();
|
|
134
|
-
}
|
|
135
|
-
}));
|
|
136
|
-
this._register(Event.any(this.results.onResultsChanged, this.results.onTestChanged, this.testService.excluded.onTestExclusionsChanged, this.testService.showInlineOutput.onDidChange, Event.filter(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration("testing.gutterEnabled" )))(() => {
|
|
137
|
-
if (!debounceInvalidate.isScheduled()) {
|
|
138
|
-
debounceInvalidate.schedule();
|
|
139
|
-
}
|
|
140
|
-
}));
|
|
141
|
-
this._register(GutterActionsRegistry.registerGutterActionsGenerator((context, result) => {
|
|
142
|
-
const model = context.editor.getModel();
|
|
143
|
-
const testingDecorations = TestingDecorations.get(context.editor);
|
|
144
|
-
if (!model || !testingDecorations?.currentUri) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const currentDecorations = this.syncDecorations(testingDecorations.currentUri);
|
|
148
|
-
if (!currentDecorations.size) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const modelDecorations = model.getLinesDecorations(context.lineNumber, context.lineNumber);
|
|
152
|
-
for (const { id } of modelDecorations) {
|
|
153
|
-
const decoration = currentDecorations.getById(id);
|
|
154
|
-
if (decoration) {
|
|
155
|
-
const { object: actions } = decoration.getContextMenuActions();
|
|
156
|
-
for (const action of actions) {
|
|
157
|
-
result.push(action, '1_testing');
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
invalidateResultMessage(message) {
|
|
164
|
-
this.invalidatedMessages.add(message);
|
|
165
|
-
this.invalidate();
|
|
166
|
-
}
|
|
167
|
-
syncDecorations(resource) {
|
|
168
|
-
const model = this.modelService.getModel(resource);
|
|
169
|
-
if (!model) {
|
|
170
|
-
return ( new CachedDecorations());
|
|
171
|
-
}
|
|
172
|
-
const cached = this.decorationCache.get(resource);
|
|
173
|
-
if (cached && cached.generation === this.generation && (cached.rangeUpdateVersionId === undefined || cached.rangeUpdateVersionId !== model.getVersionId())) {
|
|
174
|
-
return cached.value;
|
|
175
|
-
}
|
|
176
|
-
return this.applyDecorations(model);
|
|
177
|
-
}
|
|
178
|
-
getDecoratedTestPosition(resource, testId) {
|
|
179
|
-
const model = this.modelService.getModel(resource);
|
|
180
|
-
if (!model) {
|
|
181
|
-
return undefined;
|
|
182
|
-
}
|
|
183
|
-
const decoration = Iterable.find(this.syncDecorations(resource), v => v instanceof RunTestDecoration && v.isForTest(testId));
|
|
184
|
-
if (!decoration) {
|
|
185
|
-
return undefined;
|
|
186
|
-
}
|
|
187
|
-
return model.getDecorationRange(decoration.id)?.getStartPosition();
|
|
188
|
-
}
|
|
189
|
-
invalidate() {
|
|
190
|
-
this.generation++;
|
|
191
|
-
this.changeEmitter.fire();
|
|
192
|
-
}
|
|
193
|
-
applyDecorations(model) {
|
|
194
|
-
const gutterEnabled = getTestingConfiguration(this.configurationService, "testing.gutterEnabled" );
|
|
195
|
-
const uriStr = ( model.uri.toString());
|
|
196
|
-
const cached = this.decorationCache.get(model.uri);
|
|
197
|
-
const testRangesUpdated = cached?.rangeUpdateVersionId === model.getVersionId();
|
|
198
|
-
const lastDecorations = cached?.value ?? ( new CachedDecorations());
|
|
199
|
-
const newDecorations = model.changeDecorations(accessor => {
|
|
200
|
-
const newDecorations = ( new CachedDecorations());
|
|
201
|
-
const runDecorations = ( new TestDecorations());
|
|
202
|
-
for (const test of this.testService.collection.getNodeByUrl(model.uri)) {
|
|
203
|
-
if (!test.item.range) {
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
const stateLookup = this.results.getStateById(test.item.extId);
|
|
207
|
-
const line = test.item.range.startLineNumber;
|
|
208
|
-
runDecorations.push({ line, id: '', test, resultItem: stateLookup?.[1] });
|
|
209
|
-
}
|
|
210
|
-
for (const [line, tests] of runDecorations.lines()) {
|
|
211
|
-
const multi = tests.length > 1;
|
|
212
|
-
let existing = lastDecorations.getForExactTests(( tests.map(t => t.test.item.extId)));
|
|
213
|
-
if (existing && testRangesUpdated && model.getDecorationRange(existing.id)?.startLineNumber !== line) {
|
|
214
|
-
existing = undefined;
|
|
215
|
-
}
|
|
216
|
-
if (existing) {
|
|
217
|
-
if (existing.replaceOptions(tests, gutterEnabled)) {
|
|
218
|
-
accessor.changeDecorationOptions(existing.id, existing.editorDecoration.options);
|
|
219
|
-
}
|
|
220
|
-
newDecorations.addTest(existing);
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
newDecorations.addTest(multi
|
|
224
|
-
? this.instantiationService.createInstance(MultiRunTestDecoration, tests, gutterEnabled, model)
|
|
225
|
-
: this.instantiationService.createInstance(RunSingleTestDecoration, tests[0].test, tests[0].resultItem, model, gutterEnabled));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
const messageLines = ( new Set());
|
|
229
|
-
if (getTestingConfiguration(this.configurationService, "testing.showAllMessages" )) {
|
|
230
|
-
this.results.results.forEach(lastResult => this.applyDecorationsFromResult(lastResult, messageLines, uriStr, lastDecorations, model, newDecorations));
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
this.applyDecorationsFromResult(this.results.results[0], messageLines, uriStr, lastDecorations, model, newDecorations);
|
|
234
|
-
}
|
|
235
|
-
const saveFromRemoval = ( new Set());
|
|
236
|
-
for (const decoration of newDecorations) {
|
|
237
|
-
if (decoration.id === '') {
|
|
238
|
-
decoration.id = accessor.addDecoration(decoration.editorDecoration.range, decoration.editorDecoration.options);
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
saveFromRemoval.add(decoration.id);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
for (const decoration of lastDecorations) {
|
|
245
|
-
if (!( saveFromRemoval.has(decoration.id))) {
|
|
246
|
-
accessor.removeDecoration(decoration.id);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
this.decorationCache.set(model.uri, {
|
|
250
|
-
generation: this.generation,
|
|
251
|
-
rangeUpdateVersionId: cached?.rangeUpdateVersionId,
|
|
252
|
-
value: newDecorations,
|
|
253
|
-
});
|
|
254
|
-
return newDecorations;
|
|
255
|
-
});
|
|
256
|
-
return newDecorations || lastDecorations;
|
|
257
|
-
}
|
|
258
|
-
applyDecorationsFromResult(lastResult, messageLines, uriStr, lastDecorations, model, newDecorations) {
|
|
259
|
-
if (this.testService.showInlineOutput.value && lastResult instanceof LiveTestResult) {
|
|
260
|
-
for (const task of lastResult.tasks) {
|
|
261
|
-
for (const m of task.otherMessages) {
|
|
262
|
-
if (!( this.invalidatedMessages.has(m)) && m.location?.uri.toString() === uriStr) {
|
|
263
|
-
const decoration = lastDecorations.getMessage(m) || this.instantiationService.createInstance(TestMessageDecoration, m, undefined, model);
|
|
264
|
-
newDecorations.addMessage(decoration);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
for (const test of lastResult.tests) {
|
|
269
|
-
for (let taskId = 0; taskId < test.tasks.length; taskId++) {
|
|
270
|
-
const state = test.tasks[taskId];
|
|
271
|
-
for (const kind of [0 , 1 ]) {
|
|
272
|
-
for (let i = 0; i < state.messages.length; i++) {
|
|
273
|
-
const m = state.messages[i];
|
|
274
|
-
if (m.type !== kind || ( this.invalidatedMessages.has(m)) || m.location?.uri.toString() !== uriStr) {
|
|
275
|
-
continue;
|
|
276
|
-
}
|
|
277
|
-
const line = m.location.range.startLineNumber;
|
|
278
|
-
if (!( messageLines.has(line))) {
|
|
279
|
-
const decoration = lastDecorations.getMessage(m) || this.instantiationService.createInstance(TestMessageDecoration, m, buildTestUri({
|
|
280
|
-
type: 3 ,
|
|
281
|
-
messageIndex: i,
|
|
282
|
-
taskIndex: taskId,
|
|
283
|
-
resultId: lastResult.id,
|
|
284
|
-
testExtId: test.item.extId,
|
|
285
|
-
}), model);
|
|
286
|
-
newDecorations.addMessage(decoration);
|
|
287
|
-
messageLines.add(line);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
TestingDecorationService = ( __decorate([
|
|
297
|
-
( __param(0, ICodeEditorService)),
|
|
298
|
-
( __param(1, IConfigurationService)),
|
|
299
|
-
( __param(2, ITestService)),
|
|
300
|
-
( __param(3, ITestResultService)),
|
|
301
|
-
( __param(4, IInstantiationService)),
|
|
302
|
-
( __param(5, IModelService))
|
|
303
|
-
], TestingDecorationService));
|
|
304
|
-
let TestingDecorations = class TestingDecorations extends Disposable {
|
|
305
|
-
static get(editor) {
|
|
306
|
-
return editor.getContribution("editor.contrib.testingDecorations" );
|
|
307
|
-
}
|
|
308
|
-
get currentUri() { return this._currentUri; }
|
|
309
|
-
constructor(editor, codeEditorService, testService, decorations, uriIdentityService) {
|
|
310
|
-
super();
|
|
311
|
-
this.editor = editor;
|
|
312
|
-
this.codeEditorService = codeEditorService;
|
|
313
|
-
this.testService = testService;
|
|
314
|
-
this.decorations = decorations;
|
|
315
|
-
this.uriIdentityService = uriIdentityService;
|
|
316
|
-
this.expectedWidget = ( new MutableDisposable());
|
|
317
|
-
this.actualWidget = ( new MutableDisposable());
|
|
318
|
-
codeEditorService.registerDecorationType('test-message-decoration', TestMessageDecoration.decorationId, {}, undefined, editor);
|
|
319
|
-
this.attachModel(editor.getModel()?.uri);
|
|
320
|
-
this._register(decorations.onDidChange(() => {
|
|
321
|
-
if (this._currentUri) {
|
|
322
|
-
decorations.syncDecorations(this._currentUri);
|
|
323
|
-
}
|
|
324
|
-
}));
|
|
325
|
-
this._register(this.editor.onDidChangeModel(e => this.attachModel(e.newModelUrl || undefined)));
|
|
326
|
-
this._register(this.editor.onMouseDown(e => {
|
|
327
|
-
if (e.target.position && this.currentUri) {
|
|
328
|
-
const modelDecorations = editor.getModel()?.getLineDecorations(e.target.position.lineNumber) ?? [];
|
|
329
|
-
if (!modelDecorations.length) {
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
const cache = decorations.syncDecorations(this.currentUri);
|
|
333
|
-
for (const { id } of modelDecorations) {
|
|
334
|
-
if (cache.getById(id)?.click(e)) {
|
|
335
|
-
e.event.stopPropagation();
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}));
|
|
341
|
-
this._register(Event.accumulate(this.editor.onDidChangeModelContent, 0, this._store)(evts => {
|
|
342
|
-
const model = editor.getModel();
|
|
343
|
-
if (!this._currentUri || !model) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const currentDecorations = decorations.syncDecorations(this._currentUri);
|
|
347
|
-
if (!currentDecorations.size) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
for (const e of evts) {
|
|
351
|
-
for (const change of e.changes) {
|
|
352
|
-
const modelDecorations = model.getLinesDecorations(change.range.startLineNumber, change.range.endLineNumber);
|
|
353
|
-
for (const { id } of modelDecorations) {
|
|
354
|
-
const decoration = currentDecorations.getById(id);
|
|
355
|
-
if (decoration instanceof TestMessageDecoration) {
|
|
356
|
-
decorations.invalidateResultMessage(decoration.testMessage);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}));
|
|
362
|
-
const updateFontFamilyVar = () => {
|
|
363
|
-
this.editor.getContainerDomNode().style.setProperty('--testMessageDecorationFontFamily', editor.getOption(49 ));
|
|
364
|
-
this.editor.getContainerDomNode().style.setProperty('--testMessageDecorationFontSize', `${editor.getOption(52 )}px`);
|
|
365
|
-
};
|
|
366
|
-
this._register(this.editor.onDidChangeConfiguration((e) => {
|
|
367
|
-
if (e.hasChanged(49 )) {
|
|
368
|
-
updateFontFamilyVar();
|
|
369
|
-
}
|
|
370
|
-
}));
|
|
371
|
-
updateFontFamilyVar();
|
|
372
|
-
}
|
|
373
|
-
attachModel(uri) {
|
|
374
|
-
switch (uri && parseTestUri(uri)?.type) {
|
|
375
|
-
case 4 :
|
|
376
|
-
this.expectedWidget.value = ( new ExpectedLensContentWidget(this.editor));
|
|
377
|
-
this.actualWidget.clear();
|
|
378
|
-
break;
|
|
379
|
-
case 3 :
|
|
380
|
-
this.expectedWidget.clear();
|
|
381
|
-
this.actualWidget.value = ( new ActualLensContentWidget(this.editor));
|
|
382
|
-
break;
|
|
383
|
-
default:
|
|
384
|
-
this.expectedWidget.clear();
|
|
385
|
-
this.actualWidget.clear();
|
|
386
|
-
}
|
|
387
|
-
if (isOriginalInDiffEditor(this.codeEditorService, this.editor)) {
|
|
388
|
-
uri = undefined;
|
|
389
|
-
}
|
|
390
|
-
this._currentUri = uri;
|
|
391
|
-
if (!uri) {
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
this.decorations.syncDecorations(uri);
|
|
395
|
-
(async () => {
|
|
396
|
-
for await (const _test of testsInFile(this.testService, this.uriIdentityService, uri, false)) {
|
|
397
|
-
if (this._currentUri !== uri) {
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
})();
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
TestingDecorations = ( __decorate([
|
|
405
|
-
( __param(1, ICodeEditorService)),
|
|
406
|
-
( __param(2, ITestService)),
|
|
407
|
-
( __param(3, ITestingDecorationsService)),
|
|
408
|
-
( __param(4, IUriIdentityService))
|
|
409
|
-
], TestingDecorations));
|
|
410
|
-
const collapseRange = (originalRange) => ({
|
|
411
|
-
startLineNumber: originalRange.startLineNumber,
|
|
412
|
-
endLineNumber: originalRange.startLineNumber,
|
|
413
|
-
startColumn: originalRange.startColumn,
|
|
414
|
-
endColumn: originalRange.startColumn,
|
|
415
|
-
});
|
|
416
|
-
const createRunTestDecoration = (tests, states, visible) => {
|
|
417
|
-
const range = tests[0]?.item.range;
|
|
418
|
-
if (!range) {
|
|
419
|
-
throw new Error('Test decorations can only be created for tests with a range');
|
|
420
|
-
}
|
|
421
|
-
if (!visible) {
|
|
422
|
-
return { range: collapseRange(range), options: { isWholeLine: true, description: 'run-test-decoration' } };
|
|
423
|
-
}
|
|
424
|
-
let computedState = 0 ;
|
|
425
|
-
const hoverMessageParts = [];
|
|
426
|
-
let testIdWithMessages;
|
|
427
|
-
let retired = false;
|
|
428
|
-
for (let i = 0; i < tests.length; i++) {
|
|
429
|
-
const test = tests[i];
|
|
430
|
-
const resultItem = states[i];
|
|
431
|
-
const state = resultItem?.computedState ?? 0 ;
|
|
432
|
-
if (hoverMessageParts.length < 10) {
|
|
433
|
-
hoverMessageParts.push(labelForTestInState(test.item.label, state));
|
|
434
|
-
}
|
|
435
|
-
computedState = maxPriority(computedState, state);
|
|
436
|
-
retired = retired || !!resultItem?.retired;
|
|
437
|
-
if (!testIdWithMessages && resultItem?.tasks.some(t => t.messages.length)) {
|
|
438
|
-
testIdWithMessages = test.item.extId;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
const hasMultipleTests = tests.length > 1 || tests[0].children.size > 0;
|
|
442
|
-
const icon = computedState === 0
|
|
443
|
-
? (hasMultipleTests ? testingRunAllIcon : testingRunIcon)
|
|
444
|
-
: testingStatesToIcons.get(computedState);
|
|
445
|
-
let hoverMessage;
|
|
446
|
-
let glyphMarginClassName = ThemeIcon.asClassName(icon) + ' testing-run-glyph';
|
|
447
|
-
if (retired) {
|
|
448
|
-
glyphMarginClassName += ' retired';
|
|
449
|
-
}
|
|
450
|
-
return {
|
|
451
|
-
range: collapseRange(range),
|
|
452
|
-
options: {
|
|
453
|
-
description: 'run-test-decoration',
|
|
454
|
-
showIfCollapsed: true,
|
|
455
|
-
get hoverMessage() {
|
|
456
|
-
if (!hoverMessage) {
|
|
457
|
-
const building = hoverMessage = ( new MarkdownString('', true)).appendText(hoverMessageParts.join(', ') + '.');
|
|
458
|
-
if (testIdWithMessages) {
|
|
459
|
-
const args = encodeURIComponent(JSON.stringify([testIdWithMessages]));
|
|
460
|
-
building.appendMarkdown(` [${( localizeWithPath(
|
|
461
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
462
|
-
'peekTestOutout',
|
|
463
|
-
'Peek Test Output'
|
|
464
|
-
))}](command:vscode.peekTestError?${args})`);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
return hoverMessage;
|
|
468
|
-
},
|
|
469
|
-
glyphMargin: { position: GLYPH_MARGIN_LANE },
|
|
470
|
-
glyphMarginClassName,
|
|
471
|
-
stickiness: 1 ,
|
|
472
|
-
zIndex: 10000,
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
};
|
|
476
|
-
class TitleLensContentWidget {
|
|
477
|
-
constructor(editor) {
|
|
478
|
-
this.editor = editor;
|
|
479
|
-
this.allowEditorOverflow = false;
|
|
480
|
-
this.suppressMouseDown = true;
|
|
481
|
-
this._domNode = $('span');
|
|
482
|
-
queueMicrotask(() => {
|
|
483
|
-
this.applyStyling();
|
|
484
|
-
this.editor.addContentWidget(this);
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
applyStyling() {
|
|
488
|
-
let fontSize = this.editor.getOption(19 );
|
|
489
|
-
let height;
|
|
490
|
-
if (!fontSize || fontSize < 5) {
|
|
491
|
-
fontSize = (this.editor.getOption(52 ) * .9) | 0;
|
|
492
|
-
height = this.editor.getOption(67 );
|
|
493
|
-
}
|
|
494
|
-
else {
|
|
495
|
-
height = (fontSize * Math.max(1.3, this.editor.getOption(67 ) / this.editor.getOption(52 ))) | 0;
|
|
496
|
-
}
|
|
497
|
-
const editorFontInfo = this.editor.getOption(50 );
|
|
498
|
-
const node = this._domNode;
|
|
499
|
-
node.classList.add('testing-diff-lens-widget');
|
|
500
|
-
node.textContent = this.getText();
|
|
501
|
-
node.style.lineHeight = `${height}px`;
|
|
502
|
-
node.style.fontSize = `${fontSize}px`;
|
|
503
|
-
node.style.fontFamily = `var(--${"testingDiffLensFontFamily" })`;
|
|
504
|
-
node.style.fontFeatureSettings = `var(--${"testingDiffLensFontFeatures" })`;
|
|
505
|
-
const containerStyle = this.editor.getContainerDomNode().style;
|
|
506
|
-
containerStyle.setProperty("testingDiffLensFontFamily" , this.editor.getOption(18 ) ?? 'inherit');
|
|
507
|
-
containerStyle.setProperty("testingDiffLensFontFeatures" , editorFontInfo.fontFeatureSettings);
|
|
508
|
-
this.editor.changeViewZones(accessor => {
|
|
509
|
-
if (this.viewZoneId) {
|
|
510
|
-
accessor.removeZone(this.viewZoneId);
|
|
511
|
-
}
|
|
512
|
-
this.viewZoneId = accessor.addZone({
|
|
513
|
-
afterLineNumber: 0,
|
|
514
|
-
afterColumn: 1073741824 ,
|
|
515
|
-
domNode: document.createElement('div'),
|
|
516
|
-
heightInPx: 20,
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
getDomNode() {
|
|
521
|
-
return this._domNode;
|
|
522
|
-
}
|
|
523
|
-
dispose() {
|
|
524
|
-
this.editor.changeViewZones(accessor => {
|
|
525
|
-
if (this.viewZoneId) {
|
|
526
|
-
accessor.removeZone(this.viewZoneId);
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
this.editor.removeContentWidget(this);
|
|
530
|
-
}
|
|
531
|
-
getPosition() {
|
|
532
|
-
return {
|
|
533
|
-
position: { column: 0, lineNumber: 0 },
|
|
534
|
-
preference: [1 ],
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
class ExpectedLensContentWidget extends TitleLensContentWidget {
|
|
539
|
-
getId() {
|
|
540
|
-
return 'expectedTestingLens';
|
|
541
|
-
}
|
|
542
|
-
getText() {
|
|
543
|
-
return ( localizeWithPath(
|
|
544
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
545
|
-
'expected.title',
|
|
546
|
-
'Expected'
|
|
547
|
-
));
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
class ActualLensContentWidget extends TitleLensContentWidget {
|
|
551
|
-
getId() {
|
|
552
|
-
return 'actualTestingLens';
|
|
553
|
-
}
|
|
554
|
-
getText() {
|
|
555
|
-
return ( localizeWithPath(
|
|
556
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
557
|
-
'actual.title',
|
|
558
|
-
'Actual'
|
|
559
|
-
));
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
let RunTestDecoration = class RunTestDecoration {
|
|
563
|
-
get line() {
|
|
564
|
-
return this.editorDecoration.range.startLineNumber;
|
|
565
|
-
}
|
|
566
|
-
get testIds() {
|
|
567
|
-
return ( this.tests.map(t => t.test.item.extId));
|
|
568
|
-
}
|
|
569
|
-
constructor(tests, visible, model, codeEditorService, testService, contextMenuService, commandService, configurationService, testProfileService, contextKeyService, menuService) {
|
|
570
|
-
this.tests = tests;
|
|
571
|
-
this.visible = visible;
|
|
572
|
-
this.model = model;
|
|
573
|
-
this.codeEditorService = codeEditorService;
|
|
574
|
-
this.testService = testService;
|
|
575
|
-
this.contextMenuService = contextMenuService;
|
|
576
|
-
this.commandService = commandService;
|
|
577
|
-
this.configurationService = configurationService;
|
|
578
|
-
this.testProfileService = testProfileService;
|
|
579
|
-
this.contextKeyService = contextKeyService;
|
|
580
|
-
this.menuService = menuService;
|
|
581
|
-
this.id = '';
|
|
582
|
-
this.displayedStates = ( tests.map(t => t.resultItem?.computedState));
|
|
583
|
-
this.editorDecoration = createRunTestDecoration(( tests.map(t => t.test)), ( tests.map(t => t.resultItem)), visible);
|
|
584
|
-
this.editorDecoration.options.glyphMarginHoverMessage = ( new MarkdownString()).appendText(this.getGutterLabel());
|
|
585
|
-
}
|
|
586
|
-
click(e) {
|
|
587
|
-
if (e.target.type !== 2
|
|
588
|
-
|| e.target.detail.glyphMarginLane !== GLYPH_MARGIN_LANE
|
|
589
|
-
|| e.event.rightButton
|
|
590
|
-
|| isMacintosh && e.event.leftButton && e.event.ctrlKey) {
|
|
591
|
-
return false;
|
|
592
|
-
}
|
|
593
|
-
const alternateAction = e.event.altKey;
|
|
594
|
-
switch (getTestingConfiguration(this.configurationService, "testing.defaultGutterClickAction" )) {
|
|
595
|
-
case "contextMenu" :
|
|
596
|
-
this.showContextMenu(e);
|
|
597
|
-
break;
|
|
598
|
-
case "debug" :
|
|
599
|
-
this.runWith(alternateAction ? 2 : 4 );
|
|
600
|
-
break;
|
|
601
|
-
case "runWithCoverage" :
|
|
602
|
-
this.runWith(alternateAction ? 4 : 8 );
|
|
603
|
-
break;
|
|
604
|
-
case "run" :
|
|
605
|
-
default:
|
|
606
|
-
this.runWith(alternateAction ? 4 : 2 );
|
|
607
|
-
break;
|
|
608
|
-
}
|
|
609
|
-
return true;
|
|
610
|
-
}
|
|
611
|
-
replaceOptions(newTests, visible) {
|
|
612
|
-
const displayedStates = ( newTests.map(t => t.resultItem?.computedState));
|
|
613
|
-
if (visible === this.visible && equals(this.displayedStates, displayedStates)) {
|
|
614
|
-
return false;
|
|
615
|
-
}
|
|
616
|
-
this.tests = newTests;
|
|
617
|
-
this.displayedStates = displayedStates;
|
|
618
|
-
this.visible = visible;
|
|
619
|
-
this.editorDecoration.options = createRunTestDecoration(( newTests.map(t => t.test)), ( newTests.map(t => t.resultItem)), visible).options;
|
|
620
|
-
this.editorDecoration.options.glyphMarginHoverMessage = ( new MarkdownString()).appendText(this.getGutterLabel());
|
|
621
|
-
return true;
|
|
622
|
-
}
|
|
623
|
-
isForTest(testId) {
|
|
624
|
-
return ( this.tests.some(t => t.test.item.extId === testId));
|
|
625
|
-
}
|
|
626
|
-
runWith(profile) {
|
|
627
|
-
return this.testService.runTests({
|
|
628
|
-
tests: ( this.tests.map(({ test }) => test)),
|
|
629
|
-
group: profile,
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
showContextMenu(e) {
|
|
633
|
-
const editor = this.codeEditorService.listCodeEditors().find(e => e.getModel() === this.model);
|
|
634
|
-
editor?.getContribution(EditorLineNumberContextMenu.ID)?.show(e);
|
|
635
|
-
}
|
|
636
|
-
getGutterLabel() {
|
|
637
|
-
switch (getTestingConfiguration(this.configurationService, "testing.defaultGutterClickAction" )) {
|
|
638
|
-
case "contextMenu" :
|
|
639
|
-
return ( localizeWithPath(
|
|
640
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
641
|
-
'testing.gutterMsg.contextMenu',
|
|
642
|
-
'Click for test options'
|
|
643
|
-
));
|
|
644
|
-
case "debug" :
|
|
645
|
-
return ( localizeWithPath(
|
|
646
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
647
|
-
'testing.gutterMsg.debug',
|
|
648
|
-
'Click to debug tests, right click for more options'
|
|
649
|
-
));
|
|
650
|
-
case "runWithCoverage" :
|
|
651
|
-
return ( localizeWithPath(
|
|
652
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
653
|
-
'testing.gutterMsg.coverage',
|
|
654
|
-
'Click to run tests with coverage, right click for more options'
|
|
655
|
-
));
|
|
656
|
-
case "run" :
|
|
657
|
-
default:
|
|
658
|
-
return ( localizeWithPath(
|
|
659
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
660
|
-
'testing.gutterMsg.run',
|
|
661
|
-
'Click to run tests, right click for more options'
|
|
662
|
-
));
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
getTestContextMenuActions(test, resultItem) {
|
|
666
|
-
const testActions = [];
|
|
667
|
-
const capabilities = this.testProfileService.capabilitiesForTest(test);
|
|
668
|
-
[
|
|
669
|
-
{ bitset: 2 , label: ( localizeWithPath(
|
|
670
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
671
|
-
'run test',
|
|
672
|
-
'Run Test'
|
|
673
|
-
)) },
|
|
674
|
-
{ bitset: 4 , label: ( localizeWithPath(
|
|
675
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
676
|
-
'debug test',
|
|
677
|
-
'Debug Test'
|
|
678
|
-
)) },
|
|
679
|
-
{ bitset: 8 , label: ( localizeWithPath(
|
|
680
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
681
|
-
'coverage test',
|
|
682
|
-
'Run with Coverage'
|
|
683
|
-
)) },
|
|
684
|
-
].forEach(({ bitset, label }) => {
|
|
685
|
-
if (capabilities & bitset) {
|
|
686
|
-
testActions.push(( new Action(
|
|
687
|
-
`testing.gutter.${bitset}`,
|
|
688
|
-
label,
|
|
689
|
-
undefined,
|
|
690
|
-
undefined,
|
|
691
|
-
() => this.testService.runTests({ group: bitset, tests: [test] })
|
|
692
|
-
)));
|
|
693
|
-
}
|
|
694
|
-
});
|
|
695
|
-
if (capabilities & 16 ) {
|
|
696
|
-
testActions.push(( new Action('testing.runUsing', ( localizeWithPath(
|
|
697
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
698
|
-
'testing.runUsing',
|
|
699
|
-
'Execute Using Profile...'
|
|
700
|
-
)), undefined, undefined, async () => {
|
|
701
|
-
const profile = await this.commandService.executeCommand('vscode.pickTestProfile', { onlyForTest: test });
|
|
702
|
-
if (!profile) {
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
this.testService.runResolvedTests({
|
|
706
|
-
targets: [{
|
|
707
|
-
profileGroup: profile.group,
|
|
708
|
-
profileId: profile.profileId,
|
|
709
|
-
controllerId: profile.controllerId,
|
|
710
|
-
testIds: [test.item.extId]
|
|
711
|
-
}]
|
|
712
|
-
});
|
|
713
|
-
})));
|
|
714
|
-
}
|
|
715
|
-
if (resultItem && isFailedState(resultItem.computedState)) {
|
|
716
|
-
testActions.push(( new Action('testing.gutter.peekFailure', ( localizeWithPath(
|
|
717
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
718
|
-
'peek failure',
|
|
719
|
-
'Peek Error'
|
|
720
|
-
)), undefined, undefined, () => this.commandService.executeCommand('vscode.peekTestError', test.item.extId))));
|
|
721
|
-
}
|
|
722
|
-
testActions.push(( new Action('testing.gutter.reveal', ( localizeWithPath(
|
|
723
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
724
|
-
'reveal test',
|
|
725
|
-
'Reveal in Test Explorer'
|
|
726
|
-
)), undefined, undefined, () => this.commandService.executeCommand('_revealTestInExplorer', test.item.extId))));
|
|
727
|
-
const contributed = this.getContributedTestActions(test, capabilities);
|
|
728
|
-
return { object: Separator.join(testActions, contributed), dispose() { } };
|
|
729
|
-
}
|
|
730
|
-
getContributedTestActions(test, capabilities) {
|
|
731
|
-
const contextOverlay = this.contextKeyService.createOverlay(getTestItemContextOverlay(test, capabilities));
|
|
732
|
-
const menu = this.menuService.createMenu(MenuId.TestItemGutter, contextOverlay);
|
|
733
|
-
try {
|
|
734
|
-
const target = [];
|
|
735
|
-
const arg = getContextForTestItem(this.testService.collection, test.item.extId);
|
|
736
|
-
createAndFillInContextMenuActions(menu, { shouldForwardArgs: true, arg }, target);
|
|
737
|
-
return target;
|
|
738
|
-
}
|
|
739
|
-
finally {
|
|
740
|
-
menu.dispose();
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
RunTestDecoration = ( __decorate([
|
|
745
|
-
( __param(3, ICodeEditorService)),
|
|
746
|
-
( __param(4, ITestService)),
|
|
747
|
-
( __param(5, IContextMenuService)),
|
|
748
|
-
( __param(6, ICommandService)),
|
|
749
|
-
( __param(7, IConfigurationService)),
|
|
750
|
-
( __param(8, ITestProfileService)),
|
|
751
|
-
( __param(9, IContextKeyService)),
|
|
752
|
-
( __param(10, IMenuService))
|
|
753
|
-
], RunTestDecoration));
|
|
754
|
-
let MultiRunTestDecoration = class MultiRunTestDecoration extends RunTestDecoration {
|
|
755
|
-
constructor(tests, visible, model, codeEditorService, testService, contextMenuService, commandService, configurationService, testProfileService, contextKeyService, menuService, quickInputService) {
|
|
756
|
-
super(tests, visible, model, codeEditorService, testService, contextMenuService, commandService, configurationService, testProfileService, contextKeyService, menuService);
|
|
757
|
-
this.quickInputService = quickInputService;
|
|
758
|
-
}
|
|
759
|
-
getContextMenuActions() {
|
|
760
|
-
const allActions = [];
|
|
761
|
-
[
|
|
762
|
-
{ bitset: 2 , label: ( localizeWithPath(
|
|
763
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
764
|
-
'run all test',
|
|
765
|
-
'Run All Tests'
|
|
766
|
-
)) },
|
|
767
|
-
{ bitset: 8 , label: ( localizeWithPath(
|
|
768
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
769
|
-
'run all test with coverage',
|
|
770
|
-
'Run All Tests with Coverage'
|
|
771
|
-
)) },
|
|
772
|
-
{ bitset: 4 , label: ( localizeWithPath(
|
|
773
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
774
|
-
'debug all test',
|
|
775
|
-
'Debug All Tests'
|
|
776
|
-
)) },
|
|
777
|
-
].forEach(({ bitset, label }, i) => {
|
|
778
|
-
const canRun = ( this.tests.some(({ test }) => this.testProfileService.capabilitiesForTest(test) & bitset));
|
|
779
|
-
if (canRun) {
|
|
780
|
-
allActions.push(( new Action(
|
|
781
|
-
`testing.gutter.run${i}`,
|
|
782
|
-
label,
|
|
783
|
-
undefined,
|
|
784
|
-
undefined,
|
|
785
|
-
() => this.runWith(bitset)
|
|
786
|
-
)));
|
|
787
|
-
}
|
|
788
|
-
});
|
|
789
|
-
const testItems = ( this.tests.map((testItem) => ({
|
|
790
|
-
currentLabel: testItem.test.item.label,
|
|
791
|
-
testItem,
|
|
792
|
-
parent: TestId.fromString(testItem.test.item.extId).parentId,
|
|
793
|
-
})));
|
|
794
|
-
const getLabelConflicts = (tests) => {
|
|
795
|
-
const labelCount = ( new Map());
|
|
796
|
-
for (const test of tests) {
|
|
797
|
-
labelCount.set(test.currentLabel, (labelCount.get(test.currentLabel) || 0) + 1);
|
|
798
|
-
}
|
|
799
|
-
return tests.filter(e => labelCount.get(e.currentLabel) > 1);
|
|
800
|
-
};
|
|
801
|
-
let conflicts, hasParent = true;
|
|
802
|
-
while ((conflicts = getLabelConflicts(testItems)).length && hasParent) {
|
|
803
|
-
for (const conflict of conflicts) {
|
|
804
|
-
if (conflict.parent) {
|
|
805
|
-
const parent = this.testService.collection.getNodeById(( conflict.parent.toString()));
|
|
806
|
-
conflict.currentLabel = parent?.item.label + ' > ' + conflict.currentLabel;
|
|
807
|
-
conflict.parent = conflict.parent.parentId;
|
|
808
|
-
}
|
|
809
|
-
else {
|
|
810
|
-
hasParent = false;
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
testItems.sort((a, b) => {
|
|
815
|
-
const ai = a.testItem.test.item;
|
|
816
|
-
const bi = b.testItem.test.item;
|
|
817
|
-
return (ai.sortText || ai.label).localeCompare(bi.sortText || bi.label);
|
|
818
|
-
});
|
|
819
|
-
const disposable = ( new DisposableStore());
|
|
820
|
-
let testSubmenus = ( testItems.map(({ currentLabel, testItem }) => {
|
|
821
|
-
const actions = this.getTestContextMenuActions(testItem.test, testItem.resultItem);
|
|
822
|
-
disposable.add(actions);
|
|
823
|
-
return ( new SubmenuAction(testItem.test.item.extId, stripIcons(currentLabel), actions.object));
|
|
824
|
-
}));
|
|
825
|
-
const overflow = testSubmenus.length - MAX_TESTS_IN_SUBMENU;
|
|
826
|
-
if (overflow > 0) {
|
|
827
|
-
testSubmenus = testSubmenus.slice(0, MAX_TESTS_IN_SUBMENU);
|
|
828
|
-
testSubmenus.push(( new Action('testing.gutter.overflow', ( localizeWithPath(
|
|
829
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
830
|
-
'testOverflowItems',
|
|
831
|
-
'{0} more tests...',
|
|
832
|
-
overflow
|
|
833
|
-
)), undefined, undefined, () => this.pickAndRun(testItems))));
|
|
834
|
-
}
|
|
835
|
-
return { object: Separator.join(allActions, testSubmenus), dispose: () => disposable.dispose() };
|
|
836
|
-
}
|
|
837
|
-
async pickAndRun(testItems) {
|
|
838
|
-
const doPick = (items, title) => ( new Promise(resolve => {
|
|
839
|
-
const pick = this.quickInputService.createQuickPick();
|
|
840
|
-
pick.placeholder = title;
|
|
841
|
-
pick.items = items;
|
|
842
|
-
pick.onDidHide(() => {
|
|
843
|
-
resolve(undefined);
|
|
844
|
-
pick.dispose();
|
|
845
|
-
});
|
|
846
|
-
pick.onDidAccept(() => {
|
|
847
|
-
resolve(pick.selectedItems[0]);
|
|
848
|
-
pick.dispose();
|
|
849
|
-
});
|
|
850
|
-
pick.show();
|
|
851
|
-
}));
|
|
852
|
-
const item = await doPick(( testItems.map(
|
|
853
|
-
({ currentLabel, testItem }) => ({ label: currentLabel, test: testItem.test, result: testItem.resultItem })
|
|
854
|
-
)), ( localizeWithPath(
|
|
855
|
-
'vs/workbench/contrib/testing/browser/testingDecorations',
|
|
856
|
-
'selectTestToRun',
|
|
857
|
-
'Select a test to run'
|
|
858
|
-
)));
|
|
859
|
-
if (!item) {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
const actions = this.getTestContextMenuActions(item.test, item.result);
|
|
863
|
-
try {
|
|
864
|
-
(await doPick(actions.object, item.label))?.run();
|
|
865
|
-
}
|
|
866
|
-
finally {
|
|
867
|
-
actions.dispose();
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
MultiRunTestDecoration = ( __decorate([
|
|
872
|
-
( __param(3, ICodeEditorService)),
|
|
873
|
-
( __param(4, ITestService)),
|
|
874
|
-
( __param(5, IContextMenuService)),
|
|
875
|
-
( __param(6, ICommandService)),
|
|
876
|
-
( __param(7, IConfigurationService)),
|
|
877
|
-
( __param(8, ITestProfileService)),
|
|
878
|
-
( __param(9, IContextKeyService)),
|
|
879
|
-
( __param(10, IMenuService)),
|
|
880
|
-
( __param(11, IQuickInputService))
|
|
881
|
-
], MultiRunTestDecoration));
|
|
882
|
-
let RunSingleTestDecoration = class RunSingleTestDecoration extends RunTestDecoration {
|
|
883
|
-
constructor(test, resultItem, model, visible, codeEditorService, testService, commandService, contextMenuService, configurationService, testProfiles, contextKeyService, menuService) {
|
|
884
|
-
super([{ test, resultItem }], visible, model, codeEditorService, testService, contextMenuService, commandService, configurationService, testProfiles, contextKeyService, menuService);
|
|
885
|
-
}
|
|
886
|
-
getContextMenuActions() {
|
|
887
|
-
return this.getTestContextMenuActions(this.tests[0].test, this.tests[0].resultItem);
|
|
888
|
-
}
|
|
889
|
-
};
|
|
890
|
-
RunSingleTestDecoration = ( __decorate([
|
|
891
|
-
( __param(4, ICodeEditorService)),
|
|
892
|
-
( __param(5, ITestService)),
|
|
893
|
-
( __param(6, ICommandService)),
|
|
894
|
-
( __param(7, IContextMenuService)),
|
|
895
|
-
( __param(8, IConfigurationService)),
|
|
896
|
-
( __param(9, ITestProfileService)),
|
|
897
|
-
( __param(10, IContextKeyService)),
|
|
898
|
-
( __param(11, IMenuService))
|
|
899
|
-
], RunSingleTestDecoration));
|
|
900
|
-
const lineBreakRe = /\r?\n\s*/g;
|
|
901
|
-
let TestMessageDecoration = class TestMessageDecoration {
|
|
902
|
-
static { TestMessageDecoration_1 = this; }
|
|
903
|
-
static { this.inlineClassName = 'test-message-inline-content'; }
|
|
904
|
-
static { this.decorationId = `testmessage-${generateUuid()}`; }
|
|
905
|
-
constructor(testMessage, messageUri, textModel, peekOpener, editorService) {
|
|
906
|
-
this.testMessage = testMessage;
|
|
907
|
-
this.messageUri = messageUri;
|
|
908
|
-
this.peekOpener = peekOpener;
|
|
909
|
-
this.id = '';
|
|
910
|
-
this.contentIdClass = `test-message-inline-content-id${generateUuid()}`;
|
|
911
|
-
this.location = testMessage.location;
|
|
912
|
-
this.line = this.location.range.startLineNumber;
|
|
913
|
-
const severity = testMessage.type;
|
|
914
|
-
const message = testMessage.message;
|
|
915
|
-
const options = editorService.resolveDecorationOptions(TestMessageDecoration_1.decorationId, true);
|
|
916
|
-
options.hoverMessage = typeof message === 'string' ? ( new MarkdownString()).appendText(message) : message;
|
|
917
|
-
options.zIndex = 10;
|
|
918
|
-
options.className = `testing-inline-message-severity-${severity}`;
|
|
919
|
-
options.isWholeLine = true;
|
|
920
|
-
options.stickiness = 1 ;
|
|
921
|
-
options.collapseOnReplaceEdit = true;
|
|
922
|
-
let inlineText = renderStringAsPlaintext(message).replace(lineBreakRe, ' ');
|
|
923
|
-
if (inlineText.length > MAX_INLINE_MESSAGE_LENGTH) {
|
|
924
|
-
inlineText = inlineText.slice(0, MAX_INLINE_MESSAGE_LENGTH - 1) + '…';
|
|
925
|
-
}
|
|
926
|
-
options.after = {
|
|
927
|
-
content: ' '.repeat(4) + inlineText,
|
|
928
|
-
inlineClassName: `test-message-inline-content test-message-inline-content-s${severity} ${this.contentIdClass} ${messageUri ? 'test-message-inline-content-clickable' : ''}`
|
|
929
|
-
};
|
|
930
|
-
options.showIfCollapsed = true;
|
|
931
|
-
const rulerColor = severity === 0
|
|
932
|
-
? overviewRulerError
|
|
933
|
-
: overviewRulerInfo;
|
|
934
|
-
if (rulerColor) {
|
|
935
|
-
options.overviewRuler = { color: themeColorFromId(rulerColor), position: OverviewRulerLane.Right };
|
|
936
|
-
}
|
|
937
|
-
const lineLength = textModel.getLineLength(this.location.range.startLineNumber);
|
|
938
|
-
const column = lineLength ? (lineLength + 1) : this.location.range.endColumn;
|
|
939
|
-
this.editorDecoration = {
|
|
940
|
-
options,
|
|
941
|
-
range: {
|
|
942
|
-
startLineNumber: this.location.range.startLineNumber,
|
|
943
|
-
startColumn: column,
|
|
944
|
-
endColumn: column,
|
|
945
|
-
endLineNumber: this.location.range.startLineNumber,
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
}
|
|
949
|
-
click(e) {
|
|
950
|
-
if (e.event.rightButton) {
|
|
951
|
-
return false;
|
|
952
|
-
}
|
|
953
|
-
if (!this.messageUri) {
|
|
954
|
-
return false;
|
|
955
|
-
}
|
|
956
|
-
if (e.target.element?.className.includes(this.contentIdClass)) {
|
|
957
|
-
this.peekOpener.peekUri(this.messageUri);
|
|
958
|
-
}
|
|
959
|
-
return false;
|
|
960
|
-
}
|
|
961
|
-
getContextMenuActions() {
|
|
962
|
-
return { object: [], dispose: () => { } };
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
TestMessageDecoration = TestMessageDecoration_1 = ( __decorate([
|
|
966
|
-
( __param(3, ITestingPeekOpener)),
|
|
967
|
-
( __param(4, ICodeEditorService))
|
|
968
|
-
], TestMessageDecoration));
|
|
969
|
-
|
|
970
|
-
export { TestingDecorationService, TestingDecorations };
|