@theia/editor 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.
Files changed (48) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/editor-manager.d.ts.map +1 -1
  3. package/lib/browser/editor-manager.js +11 -4
  4. package/lib/browser/editor-manager.js.map +1 -1
  5. package/lib/browser/editor-variable-contribution.d.ts.map +1 -1
  6. package/lib/browser/editor-variable-contribution.js +9 -1
  7. package/lib/browser/editor-variable-contribution.js.map +1 -1
  8. package/lib/browser/editor.d.ts +5 -2
  9. package/lib/browser/editor.d.ts.map +1 -1
  10. package/lib/browser/editor.js.map +1 -1
  11. package/lib/browser/navigation/navigation-location-service.js +3 -3
  12. package/package.json +5 -5
  13. package/src/browser/decorations/editor-decoration-style.ts +41 -41
  14. package/src/browser/decorations/editor-decoration.ts +127 -127
  15. package/src/browser/decorations/editor-decorator.ts +36 -36
  16. package/src/browser/decorations/index.ts +19 -19
  17. package/src/browser/diff-navigator.ts +27 -27
  18. package/src/browser/editor-command.ts +393 -393
  19. package/src/browser/editor-contribution.ts +185 -185
  20. package/src/browser/editor-frontend-module.ts +90 -90
  21. package/src/browser/editor-generated-preference-schema.ts +2956 -2956
  22. package/src/browser/editor-keybinding.ts +55 -55
  23. package/src/browser/editor-language-quick-pick-service.ts +68 -68
  24. package/src/browser/editor-linenumber-contribution.ts +88 -88
  25. package/src/browser/editor-manager.ts +462 -452
  26. package/src/browser/editor-menu.ts +224 -224
  27. package/src/browser/editor-navigation-contribution.ts +343 -343
  28. package/src/browser/editor-preferences.ts +226 -226
  29. package/src/browser/editor-variable-contribution.ts +62 -54
  30. package/src/browser/editor-widget-factory.ts +82 -82
  31. package/src/browser/editor-widget.ts +139 -139
  32. package/src/browser/editor.ts +366 -362
  33. package/src/browser/index.ts +26 -26
  34. package/src/browser/language-status/editor-language-status-service.ts +271 -271
  35. package/src/browser/language-status/editor-language-status.css +101 -101
  36. package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
  37. package/src/browser/navigation/navigation-location-service.ts +284 -284
  38. package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
  39. package/src/browser/navigation/navigation-location-similarity.ts +58 -58
  40. package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
  41. package/src/browser/navigation/navigation-location-updater.ts +220 -220
  42. package/src/browser/navigation/navigation-location.ts +418 -418
  43. package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
  44. package/src/browser/quick-editor-service.ts +94 -94
  45. package/src/browser/style/index.css +19 -19
  46. package/src/browser/undo-redo-service.ts +120 -120
  47. package/src/common/language-selector.ts +104 -104
  48. package/src/package.spec.ts +28 -28
@@ -1,26 +1,26 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- export * from './diff-navigator';
18
- export * from './editor';
19
- export * from './editor-widget';
20
- export * from './editor-manager';
21
- export * from './editor-command';
22
- export * from './editor-menu';
23
- export * from './editor-frontend-module';
24
- export * from './editor-preferences';
25
- export * from './decorations';
26
- export * from './editor-linenumber-contribution';
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ export * from './diff-navigator';
18
+ export * from './editor';
19
+ export * from './editor-widget';
20
+ export * from './editor-manager';
21
+ export * from './editor-command';
22
+ export * from './editor-menu';
23
+ export * from './editor-frontend-module';
24
+ export * from './editor-preferences';
25
+ export * from './decorations';
26
+ export * from './editor-linenumber-contribution';
@@ -1,271 +1,271 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2022 Ericsson 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 { codicon, StatusBar, StatusBarAlignment, StatusBarEntry } from '@theia/core/lib/browser';
19
- import { LanguageService } from '@theia/core/lib/browser/language-service';
20
- import { CommandRegistry, nls } from '@theia/core';
21
- import { TextEditor } from '../editor';
22
- import { EditorCommands } from '../editor-command';
23
- import { LanguageSelector, score } from '../../common/language-selector';
24
- import { AccessibilityInformation } from '@theia/core/lib/common/accessibility';
25
- import URI from '@theia/core/lib/common/uri';
26
- import { CurrentEditorAccess } from '../editor-manager';
27
- import { Severity } from '@theia/core/lib/common/severity';
28
- import { LabelParser } from '@theia/core/lib/browser/label-parser';
29
-
30
- /**
31
- * Represents the severity of a language status item.
32
- */
33
- export enum LanguageStatusSeverity {
34
- Information = 0,
35
- Warning = 1,
36
- Error = 2
37
- }
38
-
39
- /**
40
- * Command represents a particular invocation of a registered command.
41
- */
42
- export interface Command {
43
- /**
44
- * The identifier of the actual command handler.
45
- */
46
- id: string;
47
- /**
48
- * Title of the command invocation, like "Add local variable 'foo'".
49
- */
50
- title?: string;
51
- /**
52
- * A tooltip for for command, when represented in the UI.
53
- */
54
- tooltip?: string;
55
- /**
56
- * Arguments that the command handler should be
57
- * invoked with.
58
- */
59
- arguments?: unknown[];
60
- }
61
-
62
- /**
63
- * A language status item is the preferred way to present language status reports for the active text editors,
64
- * such as selected linter or notifying about a configuration problem.
65
- */
66
- export interface LanguageStatus {
67
- readonly id: string;
68
- readonly name: string;
69
- readonly selector: LanguageSelector;
70
- readonly severity: Severity;
71
- readonly label: string;
72
- readonly detail: string;
73
- readonly busy: boolean;
74
- readonly source: string;
75
- readonly command: Command | undefined;
76
- readonly accessibilityInfo: AccessibilityInformation | undefined;
77
- }
78
-
79
- @injectable()
80
- export class EditorLanguageStatusService {
81
- @inject(StatusBar) protected readonly statusBar: StatusBar;
82
- @inject(LanguageService) protected readonly languages: LanguageService;
83
- @inject(CurrentEditorAccess) protected readonly editorAccess: CurrentEditorAccess;
84
- @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
85
- @inject(LabelParser) protected readonly labelParser: LabelParser;
86
- protected static LANGUAGE_MODE_ID = 'editor-status-language';
87
- protected static LANGUAGE_STATUS_ID = 'editor-language-status-items';
88
-
89
- protected readonly status = new Map<number, LanguageStatus>();
90
- protected pinnedCommands = new Set<string>();
91
-
92
- setLanguageStatusItem(handle: number, item: LanguageStatus): void {
93
- this.status.set(handle, item);
94
- this.updateLanguageStatusItems();
95
- }
96
-
97
- removeLanguageStatusItem(handle: number): void {
98
- this.status.delete(handle);
99
- this.updateLanguageStatusItems();
100
- }
101
-
102
- updateLanguageStatus(editor: TextEditor | undefined): void {
103
- if (!editor) {
104
- this.statusBar.removeElement(EditorLanguageStatusService.LANGUAGE_MODE_ID);
105
- return;
106
- }
107
- const language = this.languages.getLanguage(editor.document.languageId);
108
- const languageName = language ? language.name : '';
109
- this.statusBar.setElement(EditorLanguageStatusService.LANGUAGE_MODE_ID, {
110
- text: languageName,
111
- alignment: StatusBarAlignment.RIGHT,
112
- priority: 1,
113
- command: EditorCommands.CHANGE_LANGUAGE.id,
114
- tooltip: nls.localizeByDefault('Select Language Mode')
115
- });
116
- this.updateLanguageStatusItems(editor);
117
- }
118
-
119
- protected updateLanguageStatusItems(editor = this.editorAccess.editor): void {
120
- if (!editor) {
121
- this.statusBar.removeElement(EditorLanguageStatusService.LANGUAGE_STATUS_ID);
122
- this.updatePinnedItems();
123
- return;
124
- }
125
- const uri = new URI(editor.document.uri);
126
- const items = Array.from(this.status.values())
127
- .filter(item => score(item.selector, uri.scheme, uri.path.toString(), editor.document.languageId, true))
128
- .sort((left, right) => right.severity - left.severity);
129
- if (!items.length) {
130
- this.statusBar.removeElement(EditorLanguageStatusService.LANGUAGE_STATUS_ID);
131
- return;
132
- }
133
- const severityText = items[0].severity === Severity.Info
134
- ? '$(bracket)'
135
- : items[0].severity === Severity.Warning
136
- ? '$(bracket-dot)'
137
- : '$(bracket-error)';
138
- this.statusBar.setElement(EditorLanguageStatusService.LANGUAGE_STATUS_ID, {
139
- text: severityText,
140
- alignment: StatusBarAlignment.RIGHT,
141
- priority: 2,
142
- tooltip: this.createTooltip(items),
143
- affinity: { id: EditorLanguageStatusService.LANGUAGE_MODE_ID, alignment: StatusBarAlignment.LEFT, compact: true },
144
- });
145
- this.updatePinnedItems(items);
146
- }
147
-
148
- protected updatePinnedItems(items?: LanguageStatus[]): void {
149
- const toRemoveFromStatusBar = new Set(this.pinnedCommands);
150
- items?.forEach(item => {
151
- if (toRemoveFromStatusBar.has(item.id)) {
152
- toRemoveFromStatusBar.delete(item.id);
153
- this.statusBar.setElement(item.id, this.toPinnedItem(item));
154
- }
155
- });
156
- toRemoveFromStatusBar.forEach(id => this.statusBar.removeElement(id));
157
- }
158
-
159
- protected toPinnedItem(item: LanguageStatus): StatusBarEntry {
160
- return {
161
- text: item.label,
162
- affinity: { id: EditorLanguageStatusService.LANGUAGE_MODE_ID, alignment: StatusBarAlignment.RIGHT, compact: false },
163
- alignment: StatusBarAlignment.RIGHT,
164
- onclick: item.command && (e => { e.preventDefault(); this.commandRegistry.executeCommand(item.command!.id, ...(item.command?.arguments ?? [])); }),
165
- };
166
- }
167
-
168
- protected createTooltip(items: LanguageStatus[]): HTMLElement {
169
- const hoverContainer = document.createElement('div');
170
- hoverContainer.classList.add('hover-row');
171
- for (const item of items) {
172
- const itemContainer = document.createElement('div');
173
- itemContainer.classList.add('hover-language-status');
174
- {
175
- const severityContainer = document.createElement('div');
176
- severityContainer.classList.add('severity', `sev${item.severity}`);
177
- severityContainer.classList.toggle('show', item.severity === Severity.Error || item.severity === Severity.Warning);
178
- {
179
- const severityIcon = document.createElement('span');
180
- severityIcon.className = this.getSeverityIconClasses(item.severity);
181
- severityContainer.appendChild(severityIcon);
182
- }
183
- itemContainer.appendChild(severityContainer);
184
- }
185
- const textContainer = document.createElement('div');
186
- textContainer.className = 'element';
187
- const labelContainer = document.createElement('div');
188
- labelContainer.className = 'left';
189
- const label = document.createElement('span');
190
- label.classList.add('label');
191
- this.renderWithIcons(label, item.busy ? `$(sync~spin)\u00A0\u00A0${item.label}` : item.label);
192
- labelContainer.appendChild(label);
193
- const detail = document.createElement('span');
194
- detail.classList.add('detail');
195
- this.renderWithIcons(detail, item.detail);
196
- labelContainer.appendChild(detail);
197
- textContainer.appendChild(labelContainer);
198
- const commandContainer = document.createElement('div');
199
- commandContainer.classList.add('right');
200
- if (item.command) {
201
- const link = document.createElement('a');
202
- link.classList.add('language-status-link');
203
- link.href = new URI()
204
- .withScheme('command')
205
- .withPath(item.command.id)
206
- .withQuery(item.command.arguments ? encodeURIComponent(JSON.stringify(item.command.arguments)) : '')
207
- .toString(false);
208
- link.onclick = e => { e.preventDefault(); this.commandRegistry.executeCommand(item.command!.id, ...(item.command?.arguments ?? [])); };
209
- link.textContent = item.command.title ?? item.command.id;
210
- link.title = item.command.tooltip ?? '';
211
- link.ariaRoleDescription = 'button';
212
- link.ariaDisabled = 'false';
213
- commandContainer.appendChild(link);
214
- const pinContainer = document.createElement('div');
215
- pinContainer.classList.add('language-status-action-bar');
216
- const pin = document.createElement('a');
217
- this.setPinProperties(pin, item.id);
218
- pin.onclick = e => { e.preventDefault(); this.togglePinned(item); this.setPinProperties(pin, item.id); };
219
- pinContainer.appendChild(pin);
220
- commandContainer.appendChild(pinContainer);
221
- }
222
- textContainer.appendChild(commandContainer);
223
- itemContainer.append(textContainer);
224
- hoverContainer.appendChild(itemContainer);
225
- }
226
- return hoverContainer;
227
- }
228
-
229
- protected setPinProperties(pin: HTMLElement, id: string): void {
230
- pin.className = this.pinnedCommands.has(id) ? codicon('pinned', true) : codicon('pin', true);
231
- pin.ariaRoleDescription = 'button';
232
- const pinText = this.pinnedCommands.has(id)
233
- ? nls.localizeByDefault('Remove from Status Bar')
234
- : nls.localizeByDefault('Add to Status Bar');
235
- pin.ariaLabel = pinText;
236
- pin.title = pinText;
237
- }
238
-
239
- protected togglePinned(item: LanguageStatus): void {
240
- if (this.pinnedCommands.has(item.id)) {
241
- this.pinnedCommands.delete(item.id);
242
- this.statusBar.removeElement(item.id);
243
- } else {
244
- this.pinnedCommands.add(item.id);
245
- this.statusBar.setElement(item.id, this.toPinnedItem(item));
246
- }
247
- }
248
-
249
- protected getSeverityIconClasses(severity: Severity): string {
250
- switch (severity) {
251
- case Severity.Error: return codicon('error');
252
- case Severity.Warning: return codicon('info');
253
- default: return codicon('check');
254
- }
255
- }
256
-
257
- protected renderWithIcons(host: HTMLElement, text?: string): void {
258
- if (text) {
259
- for (const chunk of this.labelParser.parse(text)) {
260
- if (typeof chunk === 'string') {
261
- host.append(chunk);
262
- } else {
263
- const iconSpan = document.createElement('span');
264
- const className = codicon(chunk.name) + (chunk.animation ? ` fa-${chunk.animation}` : '');
265
- iconSpan.className = className;
266
- host.append(iconSpan);
267
- }
268
- }
269
- }
270
- }
271
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 Ericsson 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 { codicon, StatusBar, StatusBarAlignment, StatusBarEntry } from '@theia/core/lib/browser';
19
+ import { LanguageService } from '@theia/core/lib/browser/language-service';
20
+ import { CommandRegistry, nls } from '@theia/core';
21
+ import { TextEditor } from '../editor';
22
+ import { EditorCommands } from '../editor-command';
23
+ import { LanguageSelector, score } from '../../common/language-selector';
24
+ import { AccessibilityInformation } from '@theia/core/lib/common/accessibility';
25
+ import URI from '@theia/core/lib/common/uri';
26
+ import { CurrentEditorAccess } from '../editor-manager';
27
+ import { Severity } from '@theia/core/lib/common/severity';
28
+ import { LabelParser } from '@theia/core/lib/browser/label-parser';
29
+
30
+ /**
31
+ * Represents the severity of a language status item.
32
+ */
33
+ export enum LanguageStatusSeverity {
34
+ Information = 0,
35
+ Warning = 1,
36
+ Error = 2
37
+ }
38
+
39
+ /**
40
+ * Command represents a particular invocation of a registered command.
41
+ */
42
+ export interface Command {
43
+ /**
44
+ * The identifier of the actual command handler.
45
+ */
46
+ id: string;
47
+ /**
48
+ * Title of the command invocation, like "Add local variable 'foo'".
49
+ */
50
+ title?: string;
51
+ /**
52
+ * A tooltip for for command, when represented in the UI.
53
+ */
54
+ tooltip?: string;
55
+ /**
56
+ * Arguments that the command handler should be
57
+ * invoked with.
58
+ */
59
+ arguments?: unknown[];
60
+ }
61
+
62
+ /**
63
+ * A language status item is the preferred way to present language status reports for the active text editors,
64
+ * such as selected linter or notifying about a configuration problem.
65
+ */
66
+ export interface LanguageStatus {
67
+ readonly id: string;
68
+ readonly name: string;
69
+ readonly selector: LanguageSelector;
70
+ readonly severity: Severity;
71
+ readonly label: string;
72
+ readonly detail: string;
73
+ readonly busy: boolean;
74
+ readonly source: string;
75
+ readonly command: Command | undefined;
76
+ readonly accessibilityInfo: AccessibilityInformation | undefined;
77
+ }
78
+
79
+ @injectable()
80
+ export class EditorLanguageStatusService {
81
+ @inject(StatusBar) protected readonly statusBar: StatusBar;
82
+ @inject(LanguageService) protected readonly languages: LanguageService;
83
+ @inject(CurrentEditorAccess) protected readonly editorAccess: CurrentEditorAccess;
84
+ @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
85
+ @inject(LabelParser) protected readonly labelParser: LabelParser;
86
+ protected static LANGUAGE_MODE_ID = 'editor-status-language';
87
+ protected static LANGUAGE_STATUS_ID = 'editor-language-status-items';
88
+
89
+ protected readonly status = new Map<number, LanguageStatus>();
90
+ protected pinnedCommands = new Set<string>();
91
+
92
+ setLanguageStatusItem(handle: number, item: LanguageStatus): void {
93
+ this.status.set(handle, item);
94
+ this.updateLanguageStatusItems();
95
+ }
96
+
97
+ removeLanguageStatusItem(handle: number): void {
98
+ this.status.delete(handle);
99
+ this.updateLanguageStatusItems();
100
+ }
101
+
102
+ updateLanguageStatus(editor: TextEditor | undefined): void {
103
+ if (!editor) {
104
+ this.statusBar.removeElement(EditorLanguageStatusService.LANGUAGE_MODE_ID);
105
+ return;
106
+ }
107
+ const language = this.languages.getLanguage(editor.document.languageId);
108
+ const languageName = language ? language.name : '';
109
+ this.statusBar.setElement(EditorLanguageStatusService.LANGUAGE_MODE_ID, {
110
+ text: languageName,
111
+ alignment: StatusBarAlignment.RIGHT,
112
+ priority: 1,
113
+ command: EditorCommands.CHANGE_LANGUAGE.id,
114
+ tooltip: nls.localizeByDefault('Select Language Mode')
115
+ });
116
+ this.updateLanguageStatusItems(editor);
117
+ }
118
+
119
+ protected updateLanguageStatusItems(editor = this.editorAccess.editor): void {
120
+ if (!editor) {
121
+ this.statusBar.removeElement(EditorLanguageStatusService.LANGUAGE_STATUS_ID);
122
+ this.updatePinnedItems();
123
+ return;
124
+ }
125
+ const uri = new URI(editor.document.uri);
126
+ const items = Array.from(this.status.values())
127
+ .filter(item => score(item.selector, uri.scheme, uri.path.toString(), editor.document.languageId, true))
128
+ .sort((left, right) => right.severity - left.severity);
129
+ if (!items.length) {
130
+ this.statusBar.removeElement(EditorLanguageStatusService.LANGUAGE_STATUS_ID);
131
+ return;
132
+ }
133
+ const severityText = items[0].severity === Severity.Info
134
+ ? '$(bracket)'
135
+ : items[0].severity === Severity.Warning
136
+ ? '$(bracket-dot)'
137
+ : '$(bracket-error)';
138
+ this.statusBar.setElement(EditorLanguageStatusService.LANGUAGE_STATUS_ID, {
139
+ text: severityText,
140
+ alignment: StatusBarAlignment.RIGHT,
141
+ priority: 2,
142
+ tooltip: this.createTooltip(items),
143
+ affinity: { id: EditorLanguageStatusService.LANGUAGE_MODE_ID, alignment: StatusBarAlignment.LEFT, compact: true },
144
+ });
145
+ this.updatePinnedItems(items);
146
+ }
147
+
148
+ protected updatePinnedItems(items?: LanguageStatus[]): void {
149
+ const toRemoveFromStatusBar = new Set(this.pinnedCommands);
150
+ items?.forEach(item => {
151
+ if (toRemoveFromStatusBar.has(item.id)) {
152
+ toRemoveFromStatusBar.delete(item.id);
153
+ this.statusBar.setElement(item.id, this.toPinnedItem(item));
154
+ }
155
+ });
156
+ toRemoveFromStatusBar.forEach(id => this.statusBar.removeElement(id));
157
+ }
158
+
159
+ protected toPinnedItem(item: LanguageStatus): StatusBarEntry {
160
+ return {
161
+ text: item.label,
162
+ affinity: { id: EditorLanguageStatusService.LANGUAGE_MODE_ID, alignment: StatusBarAlignment.RIGHT, compact: false },
163
+ alignment: StatusBarAlignment.RIGHT,
164
+ onclick: item.command && (e => { e.preventDefault(); this.commandRegistry.executeCommand(item.command!.id, ...(item.command?.arguments ?? [])); }),
165
+ };
166
+ }
167
+
168
+ protected createTooltip(items: LanguageStatus[]): HTMLElement {
169
+ const hoverContainer = document.createElement('div');
170
+ hoverContainer.classList.add('hover-row');
171
+ for (const item of items) {
172
+ const itemContainer = document.createElement('div');
173
+ itemContainer.classList.add('hover-language-status');
174
+ {
175
+ const severityContainer = document.createElement('div');
176
+ severityContainer.classList.add('severity', `sev${item.severity}`);
177
+ severityContainer.classList.toggle('show', item.severity === Severity.Error || item.severity === Severity.Warning);
178
+ {
179
+ const severityIcon = document.createElement('span');
180
+ severityIcon.className = this.getSeverityIconClasses(item.severity);
181
+ severityContainer.appendChild(severityIcon);
182
+ }
183
+ itemContainer.appendChild(severityContainer);
184
+ }
185
+ const textContainer = document.createElement('div');
186
+ textContainer.className = 'element';
187
+ const labelContainer = document.createElement('div');
188
+ labelContainer.className = 'left';
189
+ const label = document.createElement('span');
190
+ label.classList.add('label');
191
+ this.renderWithIcons(label, item.busy ? `$(sync~spin)\u00A0\u00A0${item.label}` : item.label);
192
+ labelContainer.appendChild(label);
193
+ const detail = document.createElement('span');
194
+ detail.classList.add('detail');
195
+ this.renderWithIcons(detail, item.detail);
196
+ labelContainer.appendChild(detail);
197
+ textContainer.appendChild(labelContainer);
198
+ const commandContainer = document.createElement('div');
199
+ commandContainer.classList.add('right');
200
+ if (item.command) {
201
+ const link = document.createElement('a');
202
+ link.classList.add('language-status-link');
203
+ link.href = new URI()
204
+ .withScheme('command')
205
+ .withPath(item.command.id)
206
+ .withQuery(item.command.arguments ? encodeURIComponent(JSON.stringify(item.command.arguments)) : '')
207
+ .toString(false);
208
+ link.onclick = e => { e.preventDefault(); this.commandRegistry.executeCommand(item.command!.id, ...(item.command?.arguments ?? [])); };
209
+ link.textContent = item.command.title ?? item.command.id;
210
+ link.title = item.command.tooltip ?? '';
211
+ link.ariaRoleDescription = 'button';
212
+ link.ariaDisabled = 'false';
213
+ commandContainer.appendChild(link);
214
+ const pinContainer = document.createElement('div');
215
+ pinContainer.classList.add('language-status-action-bar');
216
+ const pin = document.createElement('a');
217
+ this.setPinProperties(pin, item.id);
218
+ pin.onclick = e => { e.preventDefault(); this.togglePinned(item); this.setPinProperties(pin, item.id); };
219
+ pinContainer.appendChild(pin);
220
+ commandContainer.appendChild(pinContainer);
221
+ }
222
+ textContainer.appendChild(commandContainer);
223
+ itemContainer.append(textContainer);
224
+ hoverContainer.appendChild(itemContainer);
225
+ }
226
+ return hoverContainer;
227
+ }
228
+
229
+ protected setPinProperties(pin: HTMLElement, id: string): void {
230
+ pin.className = this.pinnedCommands.has(id) ? codicon('pinned', true) : codicon('pin', true);
231
+ pin.ariaRoleDescription = 'button';
232
+ const pinText = this.pinnedCommands.has(id)
233
+ ? nls.localizeByDefault('Remove from Status Bar')
234
+ : nls.localizeByDefault('Add to Status Bar');
235
+ pin.ariaLabel = pinText;
236
+ pin.title = pinText;
237
+ }
238
+
239
+ protected togglePinned(item: LanguageStatus): void {
240
+ if (this.pinnedCommands.has(item.id)) {
241
+ this.pinnedCommands.delete(item.id);
242
+ this.statusBar.removeElement(item.id);
243
+ } else {
244
+ this.pinnedCommands.add(item.id);
245
+ this.statusBar.setElement(item.id, this.toPinnedItem(item));
246
+ }
247
+ }
248
+
249
+ protected getSeverityIconClasses(severity: Severity): string {
250
+ switch (severity) {
251
+ case Severity.Error: return codicon('error');
252
+ case Severity.Warning: return codicon('info');
253
+ default: return codicon('check');
254
+ }
255
+ }
256
+
257
+ protected renderWithIcons(host: HTMLElement, text?: string): void {
258
+ if (text) {
259
+ for (const chunk of this.labelParser.parse(text)) {
260
+ if (typeof chunk === 'string') {
261
+ host.append(chunk);
262
+ } else {
263
+ const iconSpan = document.createElement('span');
264
+ const className = codicon(chunk.name) + (chunk.animation ? ` fa-${chunk.animation}` : '');
265
+ iconSpan.className = className;
266
+ host.append(iconSpan);
267
+ }
268
+ }
269
+ }
270
+ }
271
+ }