@theia/bulk-edit 1.53.0-next.5 → 1.53.0-next.55

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.
@@ -1,73 +1,73 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
18
- import * as chai from 'chai';
19
- import { ResourceTextEdit } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/bulkEditService';
20
- import { URI as Uri } from '@theia/core/shared/vscode-uri';
21
-
22
- let disableJSDOM = enableJSDOM();
23
-
24
- import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
25
- FrontendApplicationConfigProvider.set({});
26
-
27
- import { Container } from '@theia/core/shared/inversify';
28
- import { BulkEditInfoNode, BulkEditTree } from './bulk-edit-tree';
29
-
30
- const expect = chai.expect;
31
- let bulkEditTree: BulkEditTree;
32
- let testContainer: Container;
33
- const fileContextsMap = new Map<string, string>();
34
- let resourceTextEdits: ResourceTextEdit[];
35
-
36
- disableJSDOM();
37
-
38
- before(() => {
39
- disableJSDOM = enableJSDOM();
40
-
41
- testContainer = new Container();
42
- testContainer.bind(BulkEditTree).toSelf();
43
- bulkEditTree = testContainer.get(BulkEditTree);
44
-
45
- fileContextsMap.set('/c:/test1.ts', 'aaaaaaaaaaaaaaaaaaa');
46
- fileContextsMap.set('/c:/test2.ts', 'bbbbbbbbbbbbbbbbbbb');
47
-
48
- resourceTextEdits = <ResourceTextEdit[]><unknown>[
49
- {
50
- 'resource': Uri.file('c:/test1.ts'),
51
- 'textEdit': {
52
- 'text': 'AAAAA', 'range': { 'startLineNumber': 1, 'startColumn': 5, 'endLineNumber': 1, 'endColumn': 10 }
53
- }
54
- },
55
- {
56
- 'resource': Uri.file('c:/test2.ts'),
57
- 'textEdit': {
58
- 'text': 'BBBBBB', 'range': { 'startLineNumber': 1, 'startColumn': 3, 'endLineNumber': 1, 'endColumn': 8 }
59
- }
60
- }
61
- ];
62
- });
63
-
64
- after(() => {
65
- disableJSDOM();
66
- });
67
-
68
- describe('bulk-edit-tree', () => {
69
- it('initialize tree', () => {
70
- bulkEditTree.initTree(resourceTextEdits, fileContextsMap);
71
- expect((bulkEditTree.root as BulkEditInfoNode).children.length).is.equal(2);
72
- });
73
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
18
+ import * as chai from 'chai';
19
+ import { ResourceTextEdit } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/bulkEditService';
20
+ import { URI as Uri } from '@theia/core/shared/vscode-uri';
21
+
22
+ let disableJSDOM = enableJSDOM();
23
+
24
+ import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
25
+ FrontendApplicationConfigProvider.set({});
26
+
27
+ import { Container } from '@theia/core/shared/inversify';
28
+ import { BulkEditInfoNode, BulkEditTree } from './bulk-edit-tree';
29
+
30
+ const expect = chai.expect;
31
+ let bulkEditTree: BulkEditTree;
32
+ let testContainer: Container;
33
+ const fileContextsMap = new Map<string, string>();
34
+ let resourceTextEdits: ResourceTextEdit[];
35
+
36
+ disableJSDOM();
37
+
38
+ before(() => {
39
+ disableJSDOM = enableJSDOM();
40
+
41
+ testContainer = new Container();
42
+ testContainer.bind(BulkEditTree).toSelf();
43
+ bulkEditTree = testContainer.get(BulkEditTree);
44
+
45
+ fileContextsMap.set('/c:/test1.ts', 'aaaaaaaaaaaaaaaaaaa');
46
+ fileContextsMap.set('/c:/test2.ts', 'bbbbbbbbbbbbbbbbbbb');
47
+
48
+ resourceTextEdits = <ResourceTextEdit[]><unknown>[
49
+ {
50
+ 'resource': Uri.file('c:/test1.ts'),
51
+ 'textEdit': {
52
+ 'text': 'AAAAA', 'range': { 'startLineNumber': 1, 'startColumn': 5, 'endLineNumber': 1, 'endColumn': 10 }
53
+ }
54
+ },
55
+ {
56
+ 'resource': Uri.file('c:/test2.ts'),
57
+ 'textEdit': {
58
+ 'text': 'BBBBBB', 'range': { 'startLineNumber': 1, 'startColumn': 3, 'endLineNumber': 1, 'endColumn': 8 }
59
+ }
60
+ }
61
+ ];
62
+ });
63
+
64
+ after(() => {
65
+ disableJSDOM();
66
+ });
67
+
68
+ describe('bulk-edit-tree', () => {
69
+ it('initialize tree', () => {
70
+ bulkEditTree.initTree(resourceTextEdits, fileContextsMap);
71
+ expect((bulkEditTree.root as BulkEditInfoNode).children.length).is.equal(2);
72
+ });
73
+ });
@@ -1,114 +1,114 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable } from '@theia/core/shared/inversify';
18
- import { TreeNode, CompositeTreeNode, SelectableTreeNode, ExpandableTreeNode, TreeImpl } from '@theia/core/lib/browser';
19
- import { UriSelection } from '@theia/core/lib/common/selection';
20
- import { BulkEditNodeSelection } from './bulk-edit-node-selection';
21
- import URI from '@theia/core/lib/common/uri';
22
- import { ResourceFileEdit, ResourceTextEdit } from '@theia/monaco/lib/browser/monaco-workspace';
23
- import {
24
- ResourceEdit, ResourceFileEdit as MonacoResourceFileEdit, ResourceTextEdit as MonacoResourceTextEdit
25
- } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/bulkEditService';
26
-
27
- @injectable()
28
- export class BulkEditTree extends TreeImpl {
29
- public async initTree(edits: ResourceEdit[], fileContents: Map<string, string>): Promise<void> {
30
- this.root = <CompositeTreeNode>{
31
- visible: false,
32
- id: 'theia-bulk-edit-tree-widget',
33
- name: 'BulkEditTree',
34
- children: this.getChildren(edits, fileContents),
35
- parent: undefined
36
- };
37
- }
38
-
39
- private getChildren(edits: ResourceEdit[], fileContentsMap: Map<string, string>): BulkEditInfoNode[] {
40
- let bulkEditInfos: BulkEditInfoNode[] = [];
41
- if (edits) {
42
- bulkEditInfos = edits
43
- .map(edit => this.getResourcePath(edit))
44
- .filter((path, index, arr) => path && arr.indexOf(path) === index)
45
- .map((path: string) => this.createBulkEditInfo(path, new URI(path), fileContentsMap.get(path)))
46
- .filter(Boolean);
47
-
48
- if (bulkEditInfos.length > 0) {
49
- bulkEditInfos.forEach(editInfo => {
50
- editInfo.children = edits.filter(edit =>
51
- ((('resource' in edit) && (edit as MonacoResourceTextEdit)?.resource?.path === editInfo.id)) ||
52
- (('newResource' in edit) && (edit as MonacoResourceFileEdit)?.newResource?.path === editInfo.id))
53
- .map((edit, index) => this.createBulkEditNode(('resource' in edit ? edit as MonacoResourceTextEdit :
54
- edit as MonacoResourceFileEdit), index, editInfo));
55
- });
56
- }
57
- }
58
- return bulkEditInfos;
59
- }
60
-
61
- private createBulkEditNode(bulkEdit: MonacoResourceFileEdit | MonacoResourceTextEdit, index: number, parent: BulkEditInfoNode): BulkEditNode {
62
- const id = parent.id + '_' + index;
63
- const existing = this.getNode(id);
64
- if (BulkEditNode.is(existing)) {
65
- existing.bulkEdit = bulkEdit;
66
- return existing;
67
- }
68
- return {
69
- id,
70
- name: 'bulkEdit',
71
- parent,
72
- selected: false,
73
- uri: parent.uri,
74
- bulkEdit
75
- };
76
- }
77
-
78
- private createBulkEditInfo(id: string, uri: URI, fileContents: string | undefined): BulkEditInfoNode {
79
- return {
80
- id,
81
- uri,
82
- expanded: true,
83
- selected: false,
84
- parent: this.root as BulkEditInfoNode,
85
- fileContents,
86
- children: []
87
- };
88
- }
89
-
90
- private getResourcePath(edit: ResourceEdit): string | undefined {
91
- return ResourceTextEdit.is(edit) ? edit.resource.path :
92
- ResourceFileEdit.is(edit) && edit.newResource ? edit.newResource.path : undefined;
93
- }
94
- }
95
-
96
- export interface BulkEditNode extends UriSelection, SelectableTreeNode {
97
- parent: CompositeTreeNode;
98
- bulkEdit: MonacoResourceFileEdit | MonacoResourceTextEdit;
99
- }
100
- export namespace BulkEditNode {
101
- export function is(node: TreeNode | undefined): node is BulkEditNode {
102
- return UriSelection.is(node) && SelectableTreeNode.is(node) && BulkEditNodeSelection.is(node);
103
- }
104
- }
105
-
106
- export interface BulkEditInfoNode extends UriSelection, SelectableTreeNode, ExpandableTreeNode {
107
- parent: CompositeTreeNode;
108
- fileContents?: string;
109
- }
110
- export namespace BulkEditInfoNode {
111
- export function is(node: unknown): node is BulkEditInfoNode {
112
- return ExpandableTreeNode.is(node) && UriSelection.is(node) && 'fileContents' in node;
113
- }
114
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+ import { TreeNode, CompositeTreeNode, SelectableTreeNode, ExpandableTreeNode, TreeImpl } from '@theia/core/lib/browser';
19
+ import { UriSelection } from '@theia/core/lib/common/selection';
20
+ import { BulkEditNodeSelection } from './bulk-edit-node-selection';
21
+ import URI from '@theia/core/lib/common/uri';
22
+ import { ResourceFileEdit, ResourceTextEdit } from '@theia/monaco/lib/browser/monaco-workspace';
23
+ import {
24
+ ResourceEdit, ResourceFileEdit as MonacoResourceFileEdit, ResourceTextEdit as MonacoResourceTextEdit
25
+ } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/bulkEditService';
26
+
27
+ @injectable()
28
+ export class BulkEditTree extends TreeImpl {
29
+ public async initTree(edits: ResourceEdit[], fileContents: Map<string, string>): Promise<void> {
30
+ this.root = <CompositeTreeNode>{
31
+ visible: false,
32
+ id: 'theia-bulk-edit-tree-widget',
33
+ name: 'BulkEditTree',
34
+ children: this.getChildren(edits, fileContents),
35
+ parent: undefined
36
+ };
37
+ }
38
+
39
+ private getChildren(edits: ResourceEdit[], fileContentsMap: Map<string, string>): BulkEditInfoNode[] {
40
+ let bulkEditInfos: BulkEditInfoNode[] = [];
41
+ if (edits) {
42
+ bulkEditInfos = edits
43
+ .map(edit => this.getResourcePath(edit))
44
+ .filter((path, index, arr) => path && arr.indexOf(path) === index)
45
+ .map((path: string) => this.createBulkEditInfo(path, new URI(path), fileContentsMap.get(path)))
46
+ .filter(Boolean);
47
+
48
+ if (bulkEditInfos.length > 0) {
49
+ bulkEditInfos.forEach(editInfo => {
50
+ editInfo.children = edits.filter(edit =>
51
+ ((('resource' in edit) && (edit as MonacoResourceTextEdit)?.resource?.path === editInfo.id)) ||
52
+ (('newResource' in edit) && (edit as MonacoResourceFileEdit)?.newResource?.path === editInfo.id))
53
+ .map((edit, index) => this.createBulkEditNode(('resource' in edit ? edit as MonacoResourceTextEdit :
54
+ edit as MonacoResourceFileEdit), index, editInfo));
55
+ });
56
+ }
57
+ }
58
+ return bulkEditInfos;
59
+ }
60
+
61
+ private createBulkEditNode(bulkEdit: MonacoResourceFileEdit | MonacoResourceTextEdit, index: number, parent: BulkEditInfoNode): BulkEditNode {
62
+ const id = parent.id + '_' + index;
63
+ const existing = this.getNode(id);
64
+ if (BulkEditNode.is(existing)) {
65
+ existing.bulkEdit = bulkEdit;
66
+ return existing;
67
+ }
68
+ return {
69
+ id,
70
+ name: 'bulkEdit',
71
+ parent,
72
+ selected: false,
73
+ uri: parent.uri,
74
+ bulkEdit
75
+ };
76
+ }
77
+
78
+ private createBulkEditInfo(id: string, uri: URI, fileContents: string | undefined): BulkEditInfoNode {
79
+ return {
80
+ id,
81
+ uri,
82
+ expanded: true,
83
+ selected: false,
84
+ parent: this.root as BulkEditInfoNode,
85
+ fileContents,
86
+ children: []
87
+ };
88
+ }
89
+
90
+ private getResourcePath(edit: ResourceEdit): string | undefined {
91
+ return ResourceTextEdit.is(edit) ? edit.resource.path :
92
+ ResourceFileEdit.is(edit) && edit.newResource ? edit.newResource.path : undefined;
93
+ }
94
+ }
95
+
96
+ export interface BulkEditNode extends UriSelection, SelectableTreeNode {
97
+ parent: CompositeTreeNode;
98
+ bulkEdit: MonacoResourceFileEdit | MonacoResourceTextEdit;
99
+ }
100
+ export namespace BulkEditNode {
101
+ export function is(node: TreeNode | undefined): node is BulkEditNode {
102
+ return UriSelection.is(node) && SelectableTreeNode.is(node) && BulkEditNodeSelection.is(node);
103
+ }
104
+ }
105
+
106
+ export interface BulkEditInfoNode extends UriSelection, SelectableTreeNode, ExpandableTreeNode {
107
+ parent: CompositeTreeNode;
108
+ fileContents?: string;
109
+ }
110
+ export namespace BulkEditInfoNode {
111
+ export function is(node: unknown): node is BulkEditInfoNode {
112
+ return ExpandableTreeNode.is(node) && UriSelection.is(node) && 'fileContents' in node;
113
+ }
114
+ }
@@ -1,21 +1,21 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- export * from './bulk-edit-tree';
18
- export * from './bulk-edit-tree-model';
19
- export * from './bulk-edit-node-selection';
20
- export * from './bulk-edit-tree-widget';
21
- export * from './bulk-edit-tree-container';
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ export * from './bulk-edit-tree';
18
+ export * from './bulk-edit-tree-model';
19
+ export * from './bulk-edit-node-selection';
20
+ export * from './bulk-edit-tree-widget';
21
+ export * from './bulk-edit-tree-container';
@@ -1,71 +1,71 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable, inject } from '@theia/core/shared/inversify';
18
- import { LabelProvider, LabelProviderContribution, DidChangeLabelEvent } from '@theia/core/lib/browser/label-provider';
19
- import { BulkEditInfoNode } from './bulk-edit-tree';
20
- import { TreeLabelProvider } from '@theia/core/lib/browser/tree/tree-label-provider';
21
- import { WorkspaceService } from '@theia/workspace/lib/browser';
22
-
23
- @injectable()
24
- export class BulkEditTreeLabelProvider implements LabelProviderContribution {
25
-
26
- @inject(LabelProvider)
27
- protected readonly labelProvider: LabelProvider;
28
-
29
- @inject(TreeLabelProvider)
30
- protected readonly treeLabelProvider: TreeLabelProvider;
31
-
32
- @inject(WorkspaceService)
33
- protected readonly workspaceService: WorkspaceService;
34
-
35
- canHandle(element: object): number {
36
- return BulkEditInfoNode.is(element) ?
37
- this.treeLabelProvider.canHandle(element) + 1 :
38
- 0;
39
- }
40
-
41
- getIcon(node: BulkEditInfoNode): string {
42
- return this.labelProvider.getIcon(node.uri);
43
- }
44
-
45
- getName(node: BulkEditInfoNode): string {
46
- return this.labelProvider.getName(node.uri);
47
- }
48
-
49
- getLongName(node: BulkEditInfoNode): string {
50
- const description: string[] = [];
51
- const rootUri = this.workspaceService.getWorkspaceRootUri(node.uri);
52
- // In a multiple-root workspace include the root name to the label before the parent directory.
53
- if (this.workspaceService.isMultiRootWorkspaceOpened && rootUri) {
54
- description.push(this.labelProvider.getName(rootUri));
55
- }
56
- // If the given resource is not at the workspace root, include the parent directory to the label.
57
- if (rootUri?.toString() !== node.uri.parent.toString()) {
58
- description.push(this.labelProvider.getLongName(node.uri.parent));
59
- }
60
- return description.join(' ● ');
61
- }
62
-
63
- getDescription(node: BulkEditInfoNode): string {
64
- return this.labelProvider.getLongName(node.uri.parent);
65
- }
66
-
67
- affects(node: BulkEditInfoNode, event: DidChangeLabelEvent): boolean {
68
- return event.affects(node.uri) || event.affects(node.uri.parent);
69
- }
70
-
71
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject } from '@theia/core/shared/inversify';
18
+ import { LabelProvider, LabelProviderContribution, DidChangeLabelEvent } from '@theia/core/lib/browser/label-provider';
19
+ import { BulkEditInfoNode } from './bulk-edit-tree';
20
+ import { TreeLabelProvider } from '@theia/core/lib/browser/tree/tree-label-provider';
21
+ import { WorkspaceService } from '@theia/workspace/lib/browser';
22
+
23
+ @injectable()
24
+ export class BulkEditTreeLabelProvider implements LabelProviderContribution {
25
+
26
+ @inject(LabelProvider)
27
+ protected readonly labelProvider: LabelProvider;
28
+
29
+ @inject(TreeLabelProvider)
30
+ protected readonly treeLabelProvider: TreeLabelProvider;
31
+
32
+ @inject(WorkspaceService)
33
+ protected readonly workspaceService: WorkspaceService;
34
+
35
+ canHandle(element: object): number {
36
+ return BulkEditInfoNode.is(element) ?
37
+ this.treeLabelProvider.canHandle(element) + 1 :
38
+ 0;
39
+ }
40
+
41
+ getIcon(node: BulkEditInfoNode): string {
42
+ return this.labelProvider.getIcon(node.uri);
43
+ }
44
+
45
+ getName(node: BulkEditInfoNode): string {
46
+ return this.labelProvider.getName(node.uri);
47
+ }
48
+
49
+ getLongName(node: BulkEditInfoNode): string {
50
+ const description: string[] = [];
51
+ const rootUri = this.workspaceService.getWorkspaceRootUri(node.uri);
52
+ // In a multiple-root workspace include the root name to the label before the parent directory.
53
+ if (this.workspaceService.isMultiRootWorkspaceOpened && rootUri) {
54
+ description.push(this.labelProvider.getName(rootUri));
55
+ }
56
+ // If the given resource is not at the workspace root, include the parent directory to the label.
57
+ if (rootUri?.toString() !== node.uri.parent.toString()) {
58
+ description.push(this.labelProvider.getLongName(node.uri.parent));
59
+ }
60
+ return description.join(' ● ');
61
+ }
62
+
63
+ getDescription(node: BulkEditInfoNode): string {
64
+ return this.labelProvider.getLongName(node.uri.parent);
65
+ }
66
+
67
+ affects(node: BulkEditInfoNode, event: DidChangeLabelEvent): boolean {
68
+ return event.affects(node.uri) || event.affects(node.uri.parent);
69
+ }
70
+
71
+ }