@codingame/monaco-vscode-bulk-edit-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.
- package/bulkEdit.js +2 -2
- package/package.json +2 -2
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/external/tslib/tslib.es6.js +0 -11
- package/override/vs/platform/dialogs/common/dialogs.js +0 -10
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.js +0 -360
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.js +0 -364
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.js +0 -267
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/conflicts.js +0 -80
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution.js +0 -365
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.js +0 -342
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPreview.js +0 -363
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditTree.js +0 -657
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import './bulkEdit.css.js';
|
|
3
|
-
import { WorkbenchAsyncDataTree } from 'vscode/vscode/vs/platform/list/browser/listService';
|
|
4
|
-
import { compareBulkFileOperations, BulkEditDataSource, BulkEditDelegate, TextEditElementRenderer, FileElementRenderer, CategoryElementRenderer, BulkEditAccessibilityProvider, BulkEditIdentityProvider, BulkEditNaviLabelProvider, BulkEditSorter, FileElement, CategoryElement, TextEditElement } from './bulkEditTree.js';
|
|
5
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
-
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
7
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
8
|
-
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
9
|
-
import { SIDE_GROUP, ACTIVE_GROUP, IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
10
|
-
import { BulkEditPreviewProvider, BulkFileOperations } from './bulkEditPreview.js';
|
|
11
|
-
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
|
|
12
|
-
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
13
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
14
|
-
import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
|
|
15
|
-
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
16
|
-
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
17
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
18
|
-
import { RawContextKey, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
19
|
-
import { ResourceLabels } from 'vscode/vscode/vs/workbench/browser/labels';
|
|
20
|
-
import '../../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
21
|
-
import { MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
22
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
23
|
-
import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
|
|
24
|
-
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
25
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
26
|
-
import { ButtonBar } from 'vscode/vscode/vs/base/browser/ui/button/button';
|
|
27
|
-
import { defaultButtonStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
|
|
28
|
-
import { LRUCachedFunction, CachedFunction } from 'vscode/vscode/vs/base/common/cache';
|
|
29
|
-
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
30
|
-
|
|
31
|
-
var BulkEditPane_1;
|
|
32
|
-
let BulkEditPane = class BulkEditPane extends ViewPane {
|
|
33
|
-
static { BulkEditPane_1 = this; }
|
|
34
|
-
static { this.ID = 'refactorPreview'; }
|
|
35
|
-
static { this.Schema = 'vscode-bulkeditpreview-multieditor'; }
|
|
36
|
-
static { this.ctxHasCategories = ( new RawContextKey('refactorPreview.hasCategories', false)); }
|
|
37
|
-
static { this.ctxGroupByFile = ( new RawContextKey('refactorPreview.groupByFile', true)); }
|
|
38
|
-
static { this.ctxHasCheckedChanges = ( new RawContextKey('refactorPreview.hasCheckedChanges', true)); }
|
|
39
|
-
static { this._memGroupByFile = `${BulkEditPane_1.ID}.groupByFile`; }
|
|
40
|
-
constructor(options, _instaService, _editorService, _labelService, _textModelService, _dialogService, _contextMenuService, _storageService, contextKeyService, viewDescriptorService, keybindingService, contextMenuService, configurationService, openerService, themeService, telemetryService) {
|
|
41
|
-
super({ ...options, titleMenuId: MenuId.BulkEditTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, _instaService, openerService, themeService, telemetryService);
|
|
42
|
-
this._instaService = _instaService;
|
|
43
|
-
this._editorService = _editorService;
|
|
44
|
-
this._labelService = _labelService;
|
|
45
|
-
this._textModelService = _textModelService;
|
|
46
|
-
this._dialogService = _dialogService;
|
|
47
|
-
this._contextMenuService = _contextMenuService;
|
|
48
|
-
this._storageService = _storageService;
|
|
49
|
-
this._treeViewStates = ( new Map());
|
|
50
|
-
this._disposables = ( new DisposableStore());
|
|
51
|
-
this._sessionDisposables = ( new DisposableStore());
|
|
52
|
-
this._computeResourceDiffEditorInputs = ( new LRUCachedFunction(async (fileOperations) => {
|
|
53
|
-
const computeDiffEditorInput = ( new CachedFunction(async (fileOperation) => {
|
|
54
|
-
const fileOperationUri = fileOperation.uri;
|
|
55
|
-
const previewUri = this._currentProvider.asPreviewUri(fileOperationUri);
|
|
56
|
-
if (fileOperation.type & 4 ) {
|
|
57
|
-
return {
|
|
58
|
-
original: { resource: URI.revive(previewUri) },
|
|
59
|
-
modified: { resource: undefined }
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
let leftResource;
|
|
64
|
-
try {
|
|
65
|
-
(await this._textModelService.createModelReference(fileOperationUri)).dispose();
|
|
66
|
-
leftResource = fileOperationUri;
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
leftResource = BulkEditPreviewProvider.emptyPreview;
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
original: { resource: URI.revive(leftResource) },
|
|
73
|
-
modified: { resource: URI.revive(previewUri) }
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}));
|
|
77
|
-
const sortedFileOperations = fileOperations.slice().sort(compareBulkFileOperations);
|
|
78
|
-
const resources = [];
|
|
79
|
-
for (const operation of sortedFileOperations) {
|
|
80
|
-
resources.push(await computeDiffEditorInput.get(operation));
|
|
81
|
-
}
|
|
82
|
-
const getResourceDiffEditorInputIdOfOperation = async (operation) => {
|
|
83
|
-
const resource = await computeDiffEditorInput.get(operation);
|
|
84
|
-
return { original: resource.original.resource, modified: resource.modified.resource };
|
|
85
|
-
};
|
|
86
|
-
return {
|
|
87
|
-
resources,
|
|
88
|
-
getResourceDiffEditorInputIdOfOperation
|
|
89
|
-
};
|
|
90
|
-
}, key => key));
|
|
91
|
-
this.element.classList.add('bulk-edit-panel', 'show-file-icons');
|
|
92
|
-
this._ctxHasCategories = BulkEditPane_1.ctxHasCategories.bindTo(contextKeyService);
|
|
93
|
-
this._ctxGroupByFile = BulkEditPane_1.ctxGroupByFile.bindTo(contextKeyService);
|
|
94
|
-
this._ctxHasCheckedChanges = BulkEditPane_1.ctxHasCheckedChanges.bindTo(contextKeyService);
|
|
95
|
-
this.telemetryService.publicLog2('views.bulkEditPane');
|
|
96
|
-
}
|
|
97
|
-
dispose() {
|
|
98
|
-
this._tree.dispose();
|
|
99
|
-
this._disposables.dispose();
|
|
100
|
-
super.dispose();
|
|
101
|
-
}
|
|
102
|
-
renderBody(parent) {
|
|
103
|
-
super.renderBody(parent);
|
|
104
|
-
const resourceLabels = this._instaService.createInstance(ResourceLabels, { onDidChangeVisibility: this.onDidChangeBodyVisibility });
|
|
105
|
-
this._disposables.add(resourceLabels);
|
|
106
|
-
const contentContainer = document.createElement('div');
|
|
107
|
-
contentContainer.className = 'content';
|
|
108
|
-
parent.appendChild(contentContainer);
|
|
109
|
-
const treeContainer = document.createElement('div');
|
|
110
|
-
contentContainer.appendChild(treeContainer);
|
|
111
|
-
this._treeDataSource = this._instaService.createInstance(BulkEditDataSource);
|
|
112
|
-
this._treeDataSource.groupByFile = this._storageService.getBoolean(BulkEditPane_1._memGroupByFile, 0 , true);
|
|
113
|
-
this._ctxGroupByFile.set(this._treeDataSource.groupByFile);
|
|
114
|
-
this._tree = this._instaService.createInstance(WorkbenchAsyncDataTree, this.id, treeContainer, ( new BulkEditDelegate()), [this._instaService.createInstance(TextEditElementRenderer), this._instaService.createInstance(FileElementRenderer, resourceLabels), this._instaService.createInstance(CategoryElementRenderer)], this._treeDataSource, {
|
|
115
|
-
accessibilityProvider: this._instaService.createInstance(BulkEditAccessibilityProvider),
|
|
116
|
-
identityProvider: ( new BulkEditIdentityProvider()),
|
|
117
|
-
expandOnlyOnTwistieClick: true,
|
|
118
|
-
multipleSelectionSupport: false,
|
|
119
|
-
keyboardNavigationLabelProvider: ( new BulkEditNaviLabelProvider()),
|
|
120
|
-
sorter: ( new BulkEditSorter()),
|
|
121
|
-
selectionNavigation: true
|
|
122
|
-
});
|
|
123
|
-
this._disposables.add(this._tree.onContextMenu(this._onContextMenu, this));
|
|
124
|
-
this._disposables.add(this._tree.onDidOpen(e => this._openElementInMultiDiffEditor(e)));
|
|
125
|
-
const buttonsContainer = document.createElement('div');
|
|
126
|
-
buttonsContainer.className = 'buttons';
|
|
127
|
-
contentContainer.appendChild(buttonsContainer);
|
|
128
|
-
const buttonBar = ( new ButtonBar(buttonsContainer));
|
|
129
|
-
this._disposables.add(buttonBar);
|
|
130
|
-
const btnConfirm = buttonBar.addButton({ supportIcons: true, ...defaultButtonStyles });
|
|
131
|
-
btnConfirm.label = ( localizeWithPath(
|
|
132
|
-
'vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane',
|
|
133
|
-
'ok',
|
|
134
|
-
'Apply'
|
|
135
|
-
));
|
|
136
|
-
btnConfirm.onDidClick(() => this.accept(), this, this._disposables);
|
|
137
|
-
const btnCancel = buttonBar.addButton({ ...defaultButtonStyles, secondary: true });
|
|
138
|
-
btnCancel.label = ( localizeWithPath(
|
|
139
|
-
'vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane',
|
|
140
|
-
'cancel',
|
|
141
|
-
'Discard'
|
|
142
|
-
));
|
|
143
|
-
btnCancel.onDidClick(() => this.discard(), this, this._disposables);
|
|
144
|
-
this._message = document.createElement('span');
|
|
145
|
-
this._message.className = 'message';
|
|
146
|
-
this._message.innerText = ( localizeWithPath(
|
|
147
|
-
'vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane',
|
|
148
|
-
'empty.msg',
|
|
149
|
-
"Invoke a code action, like rename, to see a preview of its changes here."
|
|
150
|
-
));
|
|
151
|
-
parent.appendChild(this._message);
|
|
152
|
-
this._setState("message" );
|
|
153
|
-
}
|
|
154
|
-
layoutBody(height, width) {
|
|
155
|
-
super.layoutBody(height, width);
|
|
156
|
-
const treeHeight = height - 50;
|
|
157
|
-
this._tree.getHTMLElement().parentElement.style.height = `${treeHeight}px`;
|
|
158
|
-
this._tree.layout(treeHeight, width);
|
|
159
|
-
}
|
|
160
|
-
_setState(state) {
|
|
161
|
-
this.element.dataset['state'] = state;
|
|
162
|
-
}
|
|
163
|
-
async setInput(edit, token) {
|
|
164
|
-
this._setState("data" );
|
|
165
|
-
this._sessionDisposables.clear();
|
|
166
|
-
this._treeViewStates.clear();
|
|
167
|
-
if (this._currentResolve) {
|
|
168
|
-
this._currentResolve(undefined);
|
|
169
|
-
this._currentResolve = undefined;
|
|
170
|
-
}
|
|
171
|
-
const input = await this._instaService.invokeFunction(BulkFileOperations.create, edit);
|
|
172
|
-
this._currentProvider = this._instaService.createInstance(BulkEditPreviewProvider, input);
|
|
173
|
-
this._sessionDisposables.add(this._currentProvider);
|
|
174
|
-
this._sessionDisposables.add(input);
|
|
175
|
-
const hasCategories = input.categories.length > 1;
|
|
176
|
-
this._ctxHasCategories.set(hasCategories);
|
|
177
|
-
this._treeDataSource.groupByFile = !hasCategories || this._treeDataSource.groupByFile;
|
|
178
|
-
this._ctxHasCheckedChanges.set(input.checked.checkedCount > 0);
|
|
179
|
-
this._currentInput = input;
|
|
180
|
-
return ( new Promise(resolve => {
|
|
181
|
-
token.onCancellationRequested(() => resolve(undefined));
|
|
182
|
-
this._currentResolve = resolve;
|
|
183
|
-
this._setTreeInput(input);
|
|
184
|
-
this._sessionDisposables.add(input.checked.onDidChange(() => {
|
|
185
|
-
this._tree.updateChildren();
|
|
186
|
-
this._ctxHasCheckedChanges.set(input.checked.checkedCount > 0);
|
|
187
|
-
}));
|
|
188
|
-
}));
|
|
189
|
-
}
|
|
190
|
-
hasInput() {
|
|
191
|
-
return Boolean(this._currentInput);
|
|
192
|
-
}
|
|
193
|
-
async _setTreeInput(input) {
|
|
194
|
-
const viewState = this._treeViewStates.get(this._treeDataSource.groupByFile);
|
|
195
|
-
await this._tree.setInput(input, viewState);
|
|
196
|
-
this._tree.domFocus();
|
|
197
|
-
if (viewState) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
const expand = [...this._tree.getNode(input).children].slice(0, 10);
|
|
201
|
-
while (expand.length > 0) {
|
|
202
|
-
const { element } = expand.shift();
|
|
203
|
-
if (element instanceof FileElement) {
|
|
204
|
-
await this._tree.expand(element, true);
|
|
205
|
-
}
|
|
206
|
-
if (element instanceof CategoryElement) {
|
|
207
|
-
await this._tree.expand(element, true);
|
|
208
|
-
expand.push(...this._tree.getNode(element).children);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
accept() {
|
|
213
|
-
const conflicts = this._currentInput?.conflicts.list();
|
|
214
|
-
if (!conflicts || conflicts.length === 0) {
|
|
215
|
-
this._done(true);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
let message;
|
|
219
|
-
if (conflicts.length === 1) {
|
|
220
|
-
message = ( localizeWithPath(
|
|
221
|
-
'vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane',
|
|
222
|
-
'conflict.1',
|
|
223
|
-
"Cannot apply refactoring because '{0}' has changed in the meantime.",
|
|
224
|
-
this._labelService.getUriLabel(conflicts[0], { relative: true })
|
|
225
|
-
));
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
message = ( localizeWithPath(
|
|
229
|
-
'vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane',
|
|
230
|
-
'conflict.N',
|
|
231
|
-
"Cannot apply refactoring because {0} other files have changed in the meantime.",
|
|
232
|
-
conflicts.length
|
|
233
|
-
));
|
|
234
|
-
}
|
|
235
|
-
this._dialogService.warn(message).finally(() => this._done(false));
|
|
236
|
-
}
|
|
237
|
-
discard() {
|
|
238
|
-
this._done(false);
|
|
239
|
-
}
|
|
240
|
-
_done(accept) {
|
|
241
|
-
this._currentResolve?.(accept ? this._currentInput?.getWorkspaceEdit() : undefined);
|
|
242
|
-
this._currentInput = undefined;
|
|
243
|
-
this._setState("message" );
|
|
244
|
-
this._sessionDisposables.clear();
|
|
245
|
-
}
|
|
246
|
-
toggleChecked() {
|
|
247
|
-
const [first] = this._tree.getFocus();
|
|
248
|
-
if ((first instanceof FileElement || first instanceof TextEditElement) && !first.isDisabled()) {
|
|
249
|
-
first.setChecked(!first.isChecked());
|
|
250
|
-
}
|
|
251
|
-
else if (first instanceof CategoryElement) {
|
|
252
|
-
first.setChecked(!first.isChecked());
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
groupByFile() {
|
|
256
|
-
if (!this._treeDataSource.groupByFile) {
|
|
257
|
-
this.toggleGrouping();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
groupByType() {
|
|
261
|
-
if (this._treeDataSource.groupByFile) {
|
|
262
|
-
this.toggleGrouping();
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
toggleGrouping() {
|
|
266
|
-
const input = this._tree.getInput();
|
|
267
|
-
if (input) {
|
|
268
|
-
const oldViewState = this._tree.getViewState();
|
|
269
|
-
this._treeViewStates.set(this._treeDataSource.groupByFile, oldViewState);
|
|
270
|
-
this._treeDataSource.groupByFile = !this._treeDataSource.groupByFile;
|
|
271
|
-
this._setTreeInput(input);
|
|
272
|
-
this._storageService.store(BulkEditPane_1._memGroupByFile, this._treeDataSource.groupByFile, 0 , 0 );
|
|
273
|
-
this._ctxGroupByFile.set(this._treeDataSource.groupByFile);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
async _openElementInMultiDiffEditor(e) {
|
|
277
|
-
const fileOperations = this._currentInput?.fileOperations;
|
|
278
|
-
if (!fileOperations) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
let selection = undefined;
|
|
282
|
-
let fileElement;
|
|
283
|
-
if (e.element instanceof TextEditElement) {
|
|
284
|
-
fileElement = e.element.parent;
|
|
285
|
-
selection = e.element.edit.textEdit.textEdit.range;
|
|
286
|
-
}
|
|
287
|
-
else if (e.element instanceof FileElement) {
|
|
288
|
-
fileElement = e.element;
|
|
289
|
-
selection = e.element.edit.textEdits[0]?.textEdit.textEdit.range;
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
const result = await this._computeResourceDiffEditorInputs.get(fileOperations);
|
|
295
|
-
const resourceId = await result.getResourceDiffEditorInputIdOfOperation(fileElement.edit);
|
|
296
|
-
const options = {
|
|
297
|
-
...e.editorOptions,
|
|
298
|
-
viewState: {
|
|
299
|
-
revealData: {
|
|
300
|
-
resource: resourceId,
|
|
301
|
-
range: selection,
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
const multiDiffSource = ( URI.from({ scheme: BulkEditPane_1.Schema }));
|
|
306
|
-
const label = 'Refactor Preview';
|
|
307
|
-
this._editorService.openEditor({
|
|
308
|
-
multiDiffSource,
|
|
309
|
-
label,
|
|
310
|
-
options,
|
|
311
|
-
isTransient: true,
|
|
312
|
-
description: label,
|
|
313
|
-
resources: result.resources
|
|
314
|
-
}, e.sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
|
|
315
|
-
}
|
|
316
|
-
_onContextMenu(e) {
|
|
317
|
-
this._contextMenuService.showContextMenu({
|
|
318
|
-
menuId: MenuId.BulkEditContext,
|
|
319
|
-
contextKeyService: this.contextKeyService,
|
|
320
|
-
getAnchor: () => e.anchor
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
BulkEditPane = BulkEditPane_1 = ( __decorate([
|
|
325
|
-
( __param(1, IInstantiationService)),
|
|
326
|
-
( __param(2, IEditorService)),
|
|
327
|
-
( __param(3, ILabelService)),
|
|
328
|
-
( __param(4, ITextModelService)),
|
|
329
|
-
( __param(5, IDialogService)),
|
|
330
|
-
( __param(6, IContextMenuService)),
|
|
331
|
-
( __param(7, IStorageService)),
|
|
332
|
-
( __param(8, IContextKeyService)),
|
|
333
|
-
( __param(9, IViewDescriptorService)),
|
|
334
|
-
( __param(10, IKeybindingService)),
|
|
335
|
-
( __param(11, IContextMenuService)),
|
|
336
|
-
( __param(12, IConfigurationService)),
|
|
337
|
-
( __param(13, IOpenerService)),
|
|
338
|
-
( __param(14, IThemeService)),
|
|
339
|
-
( __param(15, ITelemetryService))
|
|
340
|
-
], BulkEditPane));
|
|
341
|
-
|
|
342
|
-
export { BulkEditPane };
|