@theia/monaco 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 (96) hide show
  1. package/README.md +100 -100
  2. package/data/monaco-nls.json +1379 -1379
  3. package/data/monaco-themes/vscode/dark_plus.json +201 -201
  4. package/data/monaco-themes/vscode/dark_theia.json +5 -5
  5. package/data/monaco-themes/vscode/dark_vs.json +393 -393
  6. package/data/monaco-themes/vscode/hc_black.json +457 -457
  7. package/data/monaco-themes/vscode/hc_light.json +590 -590
  8. package/data/monaco-themes/vscode/hc_theia.json +5 -5
  9. package/data/monaco-themes/vscode/hc_theia_light.json +5 -5
  10. package/data/monaco-themes/vscode/light_plus.json +202 -202
  11. package/data/monaco-themes/vscode/light_theia.json +10 -10
  12. package/data/monaco-themes/vscode/light_vs.json +421 -421
  13. package/lib/browser/monaco-context-key-service.js +1 -1
  14. package/lib/browser/monaco-context-key-service.js.map +1 -1
  15. package/lib/browser/monaco-editor-model.d.ts +11 -5
  16. package/lib/browser/monaco-editor-model.d.ts.map +1 -1
  17. package/lib/browser/monaco-editor-model.js +2 -1
  18. package/lib/browser/monaco-editor-model.js.map +1 -1
  19. package/lib/browser/monaco-editor-service.js +1 -1
  20. package/lib/browser/monaco-editor-service.js.map +1 -1
  21. package/lib/browser/monaco-editor-zone-widget.js +1 -1
  22. package/lib/browser/monaco-editor.d.ts +5 -4
  23. package/lib/browser/monaco-editor.d.ts.map +1 -1
  24. package/lib/browser/monaco-editor.js +5 -2
  25. package/lib/browser/monaco-editor.js.map +1 -1
  26. package/lib/browser/monaco-frontend-application-contribution.js +25 -25
  27. package/lib/browser/monaco-quick-input-service.d.ts.map +1 -1
  28. package/lib/browser/monaco-quick-input-service.js +15 -15
  29. package/lib/browser/monaco-quick-input-service.js.map +1 -1
  30. package/lib/browser/monaco-text-model-service.d.ts +0 -10
  31. package/lib/browser/monaco-text-model-service.d.ts.map +1 -1
  32. package/lib/browser/monaco-text-model-service.js +0 -36
  33. package/lib/browser/monaco-text-model-service.js.map +1 -1
  34. package/lib/browser/monaco-to-protocol-converter.d.ts +2 -0
  35. package/lib/browser/monaco-to-protocol-converter.d.ts.map +1 -1
  36. package/lib/browser/monaco-to-protocol-converter.js +10 -0
  37. package/lib/browser/monaco-to-protocol-converter.js.map +1 -1
  38. package/package.json +9 -9
  39. package/src/browser/index.ts +17 -17
  40. package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +109 -109
  41. package/src/browser/monaco-bulk-edit-service.ts +64 -64
  42. package/src/browser/monaco-color-registry.ts +73 -73
  43. package/src/browser/monaco-command-registry.ts +85 -85
  44. package/src/browser/monaco-command-service.ts +90 -90
  45. package/src/browser/monaco-command.ts +303 -303
  46. package/src/browser/monaco-context-key-service.ts +144 -144
  47. package/src/browser/monaco-context-menu.ts +112 -112
  48. package/src/browser/monaco-diff-editor.ts +141 -141
  49. package/src/browser/monaco-diff-navigator-factory.ts +39 -39
  50. package/src/browser/monaco-editor-model.ts +693 -685
  51. package/src/browser/monaco-editor-peek-view-widget.ts +233 -233
  52. package/src/browser/monaco-editor-provider.ts +455 -455
  53. package/src/browser/monaco-editor-service.ts +152 -152
  54. package/src/browser/monaco-editor-zone-widget.ts +250 -250
  55. package/src/browser/monaco-editor.ts +733 -729
  56. package/src/browser/monaco-formatting-conflicts.ts +116 -116
  57. package/src/browser/monaco-frontend-application-contribution.ts +182 -182
  58. package/src/browser/monaco-frontend-module.ts +319 -319
  59. package/src/browser/monaco-gotoline-quick-access.ts +47 -47
  60. package/src/browser/monaco-gotosymbol-quick-access.ts +53 -53
  61. package/src/browser/monaco-icon-registry.ts +49 -49
  62. package/src/browser/monaco-indexed-db.ts +130 -130
  63. package/src/browser/monaco-init.ts +134 -134
  64. package/src/browser/monaco-keybinding.ts +111 -111
  65. package/src/browser/monaco-keycode-map.ts +171 -171
  66. package/src/browser/monaco-languages.ts +177 -177
  67. package/src/browser/monaco-marker-collection.ts +83 -83
  68. package/src/browser/monaco-menu.ts +147 -147
  69. package/src/browser/monaco-mime-service.ts +71 -71
  70. package/src/browser/monaco-outline-contribution.ts +404 -404
  71. package/src/browser/monaco-outline-decorator.ts +66 -66
  72. package/src/browser/monaco-quick-access-registry.ts +112 -112
  73. package/src/browser/monaco-quick-input-service.ts +701 -702
  74. package/src/browser/monaco-resolved-keybinding.ts +162 -162
  75. package/src/browser/monaco-snippet-suggest-provider.ts +306 -306
  76. package/src/browser/monaco-standalone-theme-service.ts +51 -51
  77. package/src/browser/monaco-status-bar-contribution.ts +110 -110
  78. package/src/browser/monaco-text-model-service.ts +157 -199
  79. package/src/browser/monaco-theming-service.ts +204 -204
  80. package/src/browser/monaco-to-protocol-converter.ts +82 -71
  81. package/src/browser/monaco-undo-redo-handler.ts +64 -64
  82. package/src/browser/monaco-workspace.ts +416 -416
  83. package/src/browser/protocol-to-monaco-converter.ts +158 -158
  84. package/src/browser/simple-monaco-editor.ts +216 -216
  85. package/src/browser/style/index.css +266 -266
  86. package/src/browser/textmate/index.ts +20 -20
  87. package/src/browser/textmate/monaco-textmate-frontend-bindings.ts +90 -90
  88. package/src/browser/textmate/monaco-textmate-service.ts +187 -187
  89. package/src/browser/textmate/monaco-theme-registry.ts +176 -176
  90. package/src/browser/textmate/monaco-theme-types.ts +37 -37
  91. package/src/browser/textmate/textmate-contribution.ts +29 -29
  92. package/src/browser/textmate/textmate-registry.ts +129 -129
  93. package/src/browser/textmate/textmate-snippet-completion-provider.ts +73 -73
  94. package/src/browser/textmate/textmate-tokenizer.ts +84 -84
  95. package/src/browser/workspace-symbol-command.ts +196 -196
  96. package/src/package.spec.ts +28 -28
@@ -1,319 +1,319 @@
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
- import '../../src/browser/style/index.css';
18
- import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
19
- import { MenuContribution, CommandContribution, quickInputServicePath } from '@theia/core/lib/common';
20
- import {
21
- FrontendApplicationContribution, KeybindingContribution,
22
- PreferenceService, PreferenceSchemaProvider, createPreferenceProxy,
23
- PreferenceScope, PreferenceChange, OVERRIDE_PROPERTY_PATTERN, QuickInputService, StylingParticipant, WebSocketConnectionProvider,
24
- UndoRedoHandler
25
- } from '@theia/core/lib/browser';
26
- import { TextEditorProvider, DiffNavigatorProvider, TextEditor } from '@theia/editor/lib/browser';
27
- import { MonacoEditorProvider, MonacoEditorFactory } from './monaco-editor-provider';
28
- import { MonacoEditorMenuContribution } from './monaco-menu';
29
- import { MonacoEditorCommandHandlers } from './monaco-command';
30
- import { MonacoKeybindingContribution } from './monaco-keybinding';
31
- import { MonacoLanguages } from './monaco-languages';
32
- import { MonacoWorkspace } from './monaco-workspace';
33
- import { MonacoEditorService, MonacoEditorServiceFactory, VSCodeContextKeyService, VSCodeThemeService } from './monaco-editor-service';
34
- import { MonacoTextModelService, MonacoEditorModelFactory } from './monaco-text-model-service';
35
- import { MonacoContextMenuService } from './monaco-context-menu';
36
- import { MonacoOutlineContribution } from './monaco-outline-contribution';
37
- import { MonacoStatusBarContribution } from './monaco-status-bar-contribution';
38
- import { MonacoCommandService } from './monaco-command-service';
39
- import { MonacoCommandRegistry } from './monaco-command-registry';
40
- import { MonacoDiffNavigatorFactory } from './monaco-diff-navigator-factory';
41
- import { MonacoFrontendApplicationContribution } from './monaco-frontend-application-contribution';
42
- import MonacoTextmateModuleBinder from './textmate/monaco-textmate-frontend-bindings';
43
- import { MonacoBulkEditService } from './monaco-bulk-edit-service';
44
- import { MonacoOutlineDecorator } from './monaco-outline-decorator';
45
- import { OutlineTreeDecorator } from '@theia/outline-view/lib/browser/outline-decorator-service';
46
- import { MonacoSnippetSuggestProvider } from './monaco-snippet-suggest-provider';
47
- import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
48
- import { MonacoContextKeyService } from './monaco-context-key-service';
49
- import { MonacoMimeService } from './monaco-mime-service';
50
- import { MimeService } from '@theia/core/lib/browser/mime-service';
51
- import { MonacoEditorServices } from './monaco-editor';
52
- import { MonacoColorRegistry } from './monaco-color-registry';
53
- import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
54
- import { MonacoIconRegistry } from './monaco-icon-registry';
55
- import { IconRegistry } from '@theia/core/lib/browser/icon-registry';
56
- import { MonacoThemingService } from './monaco-theming-service';
57
- import { bindContributionProvider } from '@theia/core';
58
- import { WorkspaceSymbolCommand } from './workspace-symbol-command';
59
- import { LanguageService } from '@theia/core/lib/browser/language-service';
60
- import { MonacoToProtocolConverter } from './monaco-to-protocol-converter';
61
- import { ProtocolToMonacoConverter } from './protocol-to-monaco-converter';
62
- import { MonacoFormattingConflictsContribution } from './monaco-formatting-conflicts';
63
- import { MonacoQuickInputImplementation, MonacoQuickInputService } from './monaco-quick-input-service';
64
- import { GotoLineQuickAccessContribution } from './monaco-gotoline-quick-access';
65
- import { GotoSymbolQuickAccessContribution } from './monaco-gotosymbol-quick-access';
66
- import { QuickAccessContribution, QuickAccessRegistry } from '@theia/core/lib/browser/quick-input/quick-access';
67
- import { MonacoQuickAccessRegistry } from './monaco-quick-access-registry';
68
- import { ConfigurationTarget, IConfigurationChangeEvent, IConfigurationService } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
69
- import { StandaloneConfigurationService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
70
- import { Configuration } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configurationModels';
71
- import { MarkdownRenderer } from '@theia/core/lib/browser/markdown-rendering/markdown-renderer';
72
- import { MonacoMarkdownRenderer } from './markdown-renderer/monaco-markdown-renderer';
73
- import { ThemeService } from '@theia/core/lib/browser/theming';
74
- import { ThemeServiceWithDB } from './monaco-indexed-db';
75
- import { IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
76
- import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
77
- import { ActiveMonacoUndoRedoHandler, FocusedMonacoUndoRedoHandler } from './monaco-undo-redo-handler';
78
-
79
- export default new ContainerModule((bind, unbind, isBound, rebind) => {
80
- bind(MonacoThemingService).toSelf().inSingletonScope();
81
-
82
- bind(MonacoContextKeyService).toSelf().inSingletonScope();
83
- rebind(ContextKeyService).toService(MonacoContextKeyService);
84
-
85
- bind(MonacoSnippetSuggestProvider).toSelf().inSingletonScope();
86
- bind(MonacoFrontendApplicationContribution).toSelf().inSingletonScope();
87
- bind(FrontendApplicationContribution).toService(MonacoFrontendApplicationContribution);
88
- bind(StylingParticipant).toService(MonacoFrontendApplicationContribution);
89
-
90
- bind(MonacoToProtocolConverter).toSelf().inSingletonScope();
91
- bind(ProtocolToMonacoConverter).toSelf().inSingletonScope();
92
-
93
- bind(MonacoLanguages).toSelf().inSingletonScope();
94
- rebind(LanguageService).toService(MonacoLanguages);
95
- bind(WorkspaceSymbolCommand).toSelf().inSingletonScope();
96
- for (const identifier of [CommandContribution, KeybindingContribution, MenuContribution, QuickAccessContribution]) {
97
- bind(identifier).toService(WorkspaceSymbolCommand);
98
- }
99
-
100
- bind(MonacoWorkspace).toSelf().inSingletonScope();
101
-
102
- bind(MonacoConfigurationService).toDynamicValue(({ container }) => createMonacoConfigurationService(container)).inSingletonScope();
103
-
104
- bind(MonacoBulkEditService).toSelf().inSingletonScope();
105
- bind(MonacoEditorServiceFactory).toFactory((context: interfaces.Context) => (contextKeyService: IContextKeyService, themeService: IThemeService) => {
106
- const child = context.container.createChild();
107
- child.bind(VSCodeContextKeyService).toConstantValue(contextKeyService);
108
- child.bind(VSCodeThemeService).toConstantValue(themeService);
109
- child.bind(MonacoEditorService).toSelf().inSingletonScope();
110
- return child.get(MonacoEditorService);
111
- });
112
- bind(MonacoTextModelService).toSelf().inSingletonScope();
113
- bind(MonacoContextMenuService).toSelf().inSingletonScope();
114
- bind(MonacoEditorServices).toSelf().inSingletonScope();
115
- bind(MonacoEditorProvider).toSelf().inSingletonScope();
116
- bindContributionProvider(bind, MonacoEditorFactory);
117
- bindContributionProvider(bind, MonacoEditorModelFactory);
118
- bind(MonacoCommandService).toSelf().inTransientScope();
119
-
120
- bind(TextEditorProvider).toProvider(context =>
121
- uri => context.container.get(MonacoEditorProvider).get(uri)
122
- );
123
-
124
- bind(MonacoDiffNavigatorFactory).toSelf().inSingletonScope();
125
- bind(DiffNavigatorProvider).toFactory(context =>
126
- (editor: TextEditor) => context.container.get(MonacoEditorProvider).getDiffNavigator(editor)
127
- );
128
-
129
- bind(MonacoOutlineContribution).toSelf().inSingletonScope();
130
- bind(FrontendApplicationContribution).toService(MonacoOutlineContribution);
131
-
132
- rebind(MarkdownRenderer).to(MonacoMarkdownRenderer).inSingletonScope();
133
-
134
- bind(MonacoFormattingConflictsContribution).toSelf().inSingletonScope();
135
- bind(FrontendApplicationContribution).toService(MonacoFormattingConflictsContribution);
136
-
137
- bind(MonacoStatusBarContribution).toSelf().inSingletonScope();
138
- bind(FrontendApplicationContribution).toService(MonacoStatusBarContribution);
139
-
140
- bind(MonacoCommandRegistry).toSelf().inSingletonScope();
141
- bind(MonacoEditorCommandHandlers).toSelf().inSingletonScope();
142
- bind(CommandContribution).toService(MonacoEditorCommandHandlers);
143
- bind(MonacoEditorMenuContribution).toSelf().inSingletonScope();
144
- bind(MenuContribution).toService(MonacoEditorMenuContribution);
145
- bind(MonacoKeybindingContribution).toSelf().inSingletonScope();
146
- bind(KeybindingContribution).toService(MonacoKeybindingContribution);
147
-
148
- bind(MonacoQuickInputImplementation).toSelf().inSingletonScope();
149
- bind(MonacoQuickInputService).toSelf().inSingletonScope().onActivation(({ container }, quickInputService: MonacoQuickInputService) => {
150
- WebSocketConnectionProvider.createHandler(container, quickInputServicePath, quickInputService);
151
- return quickInputService;
152
- });
153
- bind(QuickInputService).toService(MonacoQuickInputService);
154
-
155
- bind(MonacoQuickAccessRegistry).toSelf().inSingletonScope();
156
- bind(QuickAccessRegistry).toService(MonacoQuickAccessRegistry);
157
-
158
- bind(GotoLineQuickAccessContribution).toSelf().inSingletonScope();
159
- bind(QuickAccessContribution).toService(GotoLineQuickAccessContribution);
160
-
161
- bind(GotoSymbolQuickAccessContribution).toSelf().inSingletonScope();
162
- bind(QuickAccessContribution).toService(GotoSymbolQuickAccessContribution);
163
-
164
- MonacoTextmateModuleBinder(bind, unbind, isBound, rebind);
165
-
166
- bind(MonacoOutlineDecorator).toSelf().inSingletonScope();
167
- bind(OutlineTreeDecorator).toService(MonacoOutlineDecorator);
168
-
169
- bind(MonacoMimeService).toSelf().inSingletonScope();
170
- rebind(MimeService).toService(MonacoMimeService);
171
-
172
- bind(MonacoColorRegistry).toSelf().inSingletonScope();
173
- rebind(ColorRegistry).toService(MonacoColorRegistry);
174
-
175
- bind(ThemeServiceWithDB).toSelf().inSingletonScope();
176
- rebind(ThemeService).toService(ThemeServiceWithDB);
177
-
178
- bind(MonacoIconRegistry).toSelf().inSingletonScope();
179
- bind(IconRegistry).toService(MonacoIconRegistry);
180
-
181
- bind(FocusedMonacoUndoRedoHandler).toSelf().inSingletonScope();
182
- bind(ActiveMonacoUndoRedoHandler).toSelf().inSingletonScope();
183
- bind(UndoRedoHandler).toService(FocusedMonacoUndoRedoHandler);
184
- bind(UndoRedoHandler).toService(ActiveMonacoUndoRedoHandler);
185
- });
186
-
187
- export const MonacoConfigurationService = Symbol('MonacoConfigurationService');
188
- export function createMonacoConfigurationService(container: interfaces.Container): IConfigurationService {
189
- const preferences = container.get<PreferenceService>(PreferenceService);
190
- const preferenceSchemaProvider = container.get<PreferenceSchemaProvider>(PreferenceSchemaProvider);
191
- const service = new StandaloneConfigurationService();
192
- const _configuration: Configuration = service['_configuration'];
193
-
194
- _configuration.getValue = (section, overrides) => {
195
- const overrideIdentifier: string | undefined = (overrides && 'overrideIdentifier' in overrides && typeof overrides.overrideIdentifier === 'string')
196
- ? overrides['overrideIdentifier']
197
- : undefined;
198
- const resourceUri: string | undefined = (overrides && 'resource' in overrides && !!overrides['resource']) ? overrides['resource'].toString() : undefined;
199
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
200
- const proxy = createPreferenceProxy<{ [key: string]: any }>(preferences, preferenceSchemaProvider.getCombinedSchema(), {
201
- resourceUri, overrideIdentifier, style: 'both'
202
- });
203
- if (section) {
204
- return proxy[section];
205
- }
206
- return proxy;
207
- };
208
-
209
- /*
210
- * Since we never read values from the underlying service, writing to it doesn't make sense. The standalone editor writes to the configuration when being created,
211
- * which makes sense in the standalone case where there is no preference infrastructure in place. Those writes degrade the performance, however, so we patch the
212
- * service to an empty implementation.
213
- */
214
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
215
- service.updateValues = (values: [string, any][]) => Promise.resolve();
216
-
217
- const toTarget = (scope: PreferenceScope): ConfigurationTarget => {
218
- switch (scope) {
219
- case PreferenceScope.Default: return ConfigurationTarget.DEFAULT;
220
- case PreferenceScope.User: return ConfigurationTarget.USER;
221
- case PreferenceScope.Workspace: return ConfigurationTarget.WORKSPACE;
222
- case PreferenceScope.Folder: return ConfigurationTarget.WORKSPACE_FOLDER;
223
- }
224
- };
225
-
226
- interface FireDidChangeConfigurationContext {
227
- changes: PreferenceChange[];
228
- affectedKeys: Set<string>;
229
- keys: Set<string>;
230
- overrides: Map<string, Set<string>>
231
- }
232
- const newFireDidChangeConfigurationContext = (): FireDidChangeConfigurationContext => ({
233
- changes: [],
234
- affectedKeys: new Set<string>(),
235
- keys: new Set<string>(),
236
- overrides: new Map<string, Set<string>>()
237
- });
238
- const fireDidChangeConfiguration = (source: ConfigurationTarget, context: FireDidChangeConfigurationContext): void => {
239
- if (!context.affectedKeys.size) {
240
- return;
241
- }
242
- const overrides: [string, string[]][] = [];
243
- for (const [override, values] of context.overrides) {
244
- overrides.push([override, [...values]]);
245
- }
246
- service['_onDidChangeConfiguration'].fire(<IConfigurationChangeEvent>{
247
- sourceConfig: {},
248
- change: {
249
- keys: [...context.keys],
250
- overrides
251
- },
252
- affectedKeys: context.affectedKeys,
253
- source,
254
- affectsConfiguration: (prefix, options) => {
255
- if (!context.affectedKeys.has(prefix)) {
256
- return false;
257
- }
258
- for (const change of context.changes) {
259
- const overridden = preferences.overriddenPreferenceName(change.preferenceName);
260
- const preferenceName = overridden ? overridden.preferenceName : change.preferenceName;
261
- if (preferenceName.startsWith(prefix)) {
262
- if (options?.overrideIdentifier !== undefined) {
263
- if (overridden && overridden.overrideIdentifier !== options?.overrideIdentifier) {
264
- continue;
265
- }
266
- }
267
- if (change.affects(options?.resource?.toString())) {
268
- return true;
269
- }
270
- }
271
- }
272
- return false;
273
- }
274
- });
275
- };
276
-
277
- preferences.onPreferencesChanged(event => {
278
- let source: ConfigurationTarget | undefined;
279
- let context = newFireDidChangeConfigurationContext();
280
- for (let key of Object.keys(event)) {
281
- const change = event[key];
282
- const target = toTarget(change.scope);
283
- if (source !== undefined && target !== source) {
284
- fireDidChangeConfiguration(source, context);
285
- context = newFireDidChangeConfigurationContext();
286
- }
287
- context.changes.push(change);
288
- source = target;
289
-
290
- let overrideKeys: Set<string> | undefined;
291
- if (key.startsWith('[')) {
292
- const index = key.indexOf('.');
293
- const override = key.substring(0, index);
294
- const overrideIdentifier = override.match(OVERRIDE_PROPERTY_PATTERN)?.[1];
295
- if (overrideIdentifier) {
296
- context.keys.add(override);
297
- context.affectedKeys.add(override);
298
- overrideKeys = context.overrides.get(overrideIdentifier) || new Set<string>();
299
- context.overrides.set(overrideIdentifier, overrideKeys);
300
- key = key.substring(index + 1);
301
- }
302
- }
303
- while (key) {
304
- if (overrideKeys) {
305
- overrideKeys.add(key);
306
- }
307
- context.keys.add(key);
308
- context.affectedKeys.add(key);
309
- const index = key.lastIndexOf('.');
310
- key = key.substring(0, index);
311
- }
312
- }
313
- if (source) {
314
- fireDidChangeConfiguration(source, context);
315
- }
316
- });
317
-
318
- return service;
319
- }
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
+ import '../../src/browser/style/index.css';
18
+ import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
19
+ import { MenuContribution, CommandContribution, quickInputServicePath } from '@theia/core/lib/common';
20
+ import {
21
+ FrontendApplicationContribution, KeybindingContribution,
22
+ PreferenceService, PreferenceSchemaProvider, createPreferenceProxy,
23
+ PreferenceScope, PreferenceChange, OVERRIDE_PROPERTY_PATTERN, QuickInputService, StylingParticipant, WebSocketConnectionProvider,
24
+ UndoRedoHandler
25
+ } from '@theia/core/lib/browser';
26
+ import { TextEditorProvider, DiffNavigatorProvider, TextEditor } from '@theia/editor/lib/browser';
27
+ import { MonacoEditorProvider, MonacoEditorFactory } from './monaco-editor-provider';
28
+ import { MonacoEditorMenuContribution } from './monaco-menu';
29
+ import { MonacoEditorCommandHandlers } from './monaco-command';
30
+ import { MonacoKeybindingContribution } from './monaco-keybinding';
31
+ import { MonacoLanguages } from './monaco-languages';
32
+ import { MonacoWorkspace } from './monaco-workspace';
33
+ import { MonacoEditorService, MonacoEditorServiceFactory, VSCodeContextKeyService, VSCodeThemeService } from './monaco-editor-service';
34
+ import { MonacoTextModelService, MonacoEditorModelFactory } from './monaco-text-model-service';
35
+ import { MonacoContextMenuService } from './monaco-context-menu';
36
+ import { MonacoOutlineContribution } from './monaco-outline-contribution';
37
+ import { MonacoStatusBarContribution } from './monaco-status-bar-contribution';
38
+ import { MonacoCommandService } from './monaco-command-service';
39
+ import { MonacoCommandRegistry } from './monaco-command-registry';
40
+ import { MonacoDiffNavigatorFactory } from './monaco-diff-navigator-factory';
41
+ import { MonacoFrontendApplicationContribution } from './monaco-frontend-application-contribution';
42
+ import MonacoTextmateModuleBinder from './textmate/monaco-textmate-frontend-bindings';
43
+ import { MonacoBulkEditService } from './monaco-bulk-edit-service';
44
+ import { MonacoOutlineDecorator } from './monaco-outline-decorator';
45
+ import { OutlineTreeDecorator } from '@theia/outline-view/lib/browser/outline-decorator-service';
46
+ import { MonacoSnippetSuggestProvider } from './monaco-snippet-suggest-provider';
47
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
48
+ import { MonacoContextKeyService } from './monaco-context-key-service';
49
+ import { MonacoMimeService } from './monaco-mime-service';
50
+ import { MimeService } from '@theia/core/lib/browser/mime-service';
51
+ import { MonacoEditorServices } from './monaco-editor';
52
+ import { MonacoColorRegistry } from './monaco-color-registry';
53
+ import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
54
+ import { MonacoIconRegistry } from './monaco-icon-registry';
55
+ import { IconRegistry } from '@theia/core/lib/browser/icon-registry';
56
+ import { MonacoThemingService } from './monaco-theming-service';
57
+ import { bindContributionProvider } from '@theia/core';
58
+ import { WorkspaceSymbolCommand } from './workspace-symbol-command';
59
+ import { LanguageService } from '@theia/core/lib/browser/language-service';
60
+ import { MonacoToProtocolConverter } from './monaco-to-protocol-converter';
61
+ import { ProtocolToMonacoConverter } from './protocol-to-monaco-converter';
62
+ import { MonacoFormattingConflictsContribution } from './monaco-formatting-conflicts';
63
+ import { MonacoQuickInputImplementation, MonacoQuickInputService } from './monaco-quick-input-service';
64
+ import { GotoLineQuickAccessContribution } from './monaco-gotoline-quick-access';
65
+ import { GotoSymbolQuickAccessContribution } from './monaco-gotosymbol-quick-access';
66
+ import { QuickAccessContribution, QuickAccessRegistry } from '@theia/core/lib/browser/quick-input/quick-access';
67
+ import { MonacoQuickAccessRegistry } from './monaco-quick-access-registry';
68
+ import { ConfigurationTarget, IConfigurationChangeEvent, IConfigurationService } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
69
+ import { StandaloneConfigurationService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
70
+ import { Configuration } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configurationModels';
71
+ import { MarkdownRenderer } from '@theia/core/lib/browser/markdown-rendering/markdown-renderer';
72
+ import { MonacoMarkdownRenderer } from './markdown-renderer/monaco-markdown-renderer';
73
+ import { ThemeService } from '@theia/core/lib/browser/theming';
74
+ import { ThemeServiceWithDB } from './monaco-indexed-db';
75
+ import { IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
76
+ import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
77
+ import { ActiveMonacoUndoRedoHandler, FocusedMonacoUndoRedoHandler } from './monaco-undo-redo-handler';
78
+
79
+ export default new ContainerModule((bind, unbind, isBound, rebind) => {
80
+ bind(MonacoThemingService).toSelf().inSingletonScope();
81
+
82
+ bind(MonacoContextKeyService).toSelf().inSingletonScope();
83
+ rebind(ContextKeyService).toService(MonacoContextKeyService);
84
+
85
+ bind(MonacoSnippetSuggestProvider).toSelf().inSingletonScope();
86
+ bind(MonacoFrontendApplicationContribution).toSelf().inSingletonScope();
87
+ bind(FrontendApplicationContribution).toService(MonacoFrontendApplicationContribution);
88
+ bind(StylingParticipant).toService(MonacoFrontendApplicationContribution);
89
+
90
+ bind(MonacoToProtocolConverter).toSelf().inSingletonScope();
91
+ bind(ProtocolToMonacoConverter).toSelf().inSingletonScope();
92
+
93
+ bind(MonacoLanguages).toSelf().inSingletonScope();
94
+ rebind(LanguageService).toService(MonacoLanguages);
95
+ bind(WorkspaceSymbolCommand).toSelf().inSingletonScope();
96
+ for (const identifier of [CommandContribution, KeybindingContribution, MenuContribution, QuickAccessContribution]) {
97
+ bind(identifier).toService(WorkspaceSymbolCommand);
98
+ }
99
+
100
+ bind(MonacoWorkspace).toSelf().inSingletonScope();
101
+
102
+ bind(MonacoConfigurationService).toDynamicValue(({ container }) => createMonacoConfigurationService(container)).inSingletonScope();
103
+
104
+ bind(MonacoBulkEditService).toSelf().inSingletonScope();
105
+ bind(MonacoEditorServiceFactory).toFactory((context: interfaces.Context) => (contextKeyService: IContextKeyService, themeService: IThemeService) => {
106
+ const child = context.container.createChild();
107
+ child.bind(VSCodeContextKeyService).toConstantValue(contextKeyService);
108
+ child.bind(VSCodeThemeService).toConstantValue(themeService);
109
+ child.bind(MonacoEditorService).toSelf().inSingletonScope();
110
+ return child.get(MonacoEditorService);
111
+ });
112
+ bind(MonacoTextModelService).toSelf().inSingletonScope();
113
+ bind(MonacoContextMenuService).toSelf().inSingletonScope();
114
+ bind(MonacoEditorServices).toSelf().inSingletonScope();
115
+ bind(MonacoEditorProvider).toSelf().inSingletonScope();
116
+ bindContributionProvider(bind, MonacoEditorFactory);
117
+ bindContributionProvider(bind, MonacoEditorModelFactory);
118
+ bind(MonacoCommandService).toSelf().inTransientScope();
119
+
120
+ bind(TextEditorProvider).toProvider(context =>
121
+ uri => context.container.get(MonacoEditorProvider).get(uri)
122
+ );
123
+
124
+ bind(MonacoDiffNavigatorFactory).toSelf().inSingletonScope();
125
+ bind(DiffNavigatorProvider).toFactory(context =>
126
+ (editor: TextEditor) => context.container.get(MonacoEditorProvider).getDiffNavigator(editor)
127
+ );
128
+
129
+ bind(MonacoOutlineContribution).toSelf().inSingletonScope();
130
+ bind(FrontendApplicationContribution).toService(MonacoOutlineContribution);
131
+
132
+ rebind(MarkdownRenderer).to(MonacoMarkdownRenderer).inSingletonScope();
133
+
134
+ bind(MonacoFormattingConflictsContribution).toSelf().inSingletonScope();
135
+ bind(FrontendApplicationContribution).toService(MonacoFormattingConflictsContribution);
136
+
137
+ bind(MonacoStatusBarContribution).toSelf().inSingletonScope();
138
+ bind(FrontendApplicationContribution).toService(MonacoStatusBarContribution);
139
+
140
+ bind(MonacoCommandRegistry).toSelf().inSingletonScope();
141
+ bind(MonacoEditorCommandHandlers).toSelf().inSingletonScope();
142
+ bind(CommandContribution).toService(MonacoEditorCommandHandlers);
143
+ bind(MonacoEditorMenuContribution).toSelf().inSingletonScope();
144
+ bind(MenuContribution).toService(MonacoEditorMenuContribution);
145
+ bind(MonacoKeybindingContribution).toSelf().inSingletonScope();
146
+ bind(KeybindingContribution).toService(MonacoKeybindingContribution);
147
+
148
+ bind(MonacoQuickInputImplementation).toSelf().inSingletonScope();
149
+ bind(MonacoQuickInputService).toSelf().inSingletonScope().onActivation(({ container }, quickInputService: MonacoQuickInputService) => {
150
+ WebSocketConnectionProvider.createHandler(container, quickInputServicePath, quickInputService);
151
+ return quickInputService;
152
+ });
153
+ bind(QuickInputService).toService(MonacoQuickInputService);
154
+
155
+ bind(MonacoQuickAccessRegistry).toSelf().inSingletonScope();
156
+ bind(QuickAccessRegistry).toService(MonacoQuickAccessRegistry);
157
+
158
+ bind(GotoLineQuickAccessContribution).toSelf().inSingletonScope();
159
+ bind(QuickAccessContribution).toService(GotoLineQuickAccessContribution);
160
+
161
+ bind(GotoSymbolQuickAccessContribution).toSelf().inSingletonScope();
162
+ bind(QuickAccessContribution).toService(GotoSymbolQuickAccessContribution);
163
+
164
+ MonacoTextmateModuleBinder(bind, unbind, isBound, rebind);
165
+
166
+ bind(MonacoOutlineDecorator).toSelf().inSingletonScope();
167
+ bind(OutlineTreeDecorator).toService(MonacoOutlineDecorator);
168
+
169
+ bind(MonacoMimeService).toSelf().inSingletonScope();
170
+ rebind(MimeService).toService(MonacoMimeService);
171
+
172
+ bind(MonacoColorRegistry).toSelf().inSingletonScope();
173
+ rebind(ColorRegistry).toService(MonacoColorRegistry);
174
+
175
+ bind(ThemeServiceWithDB).toSelf().inSingletonScope();
176
+ rebind(ThemeService).toService(ThemeServiceWithDB);
177
+
178
+ bind(MonacoIconRegistry).toSelf().inSingletonScope();
179
+ bind(IconRegistry).toService(MonacoIconRegistry);
180
+
181
+ bind(FocusedMonacoUndoRedoHandler).toSelf().inSingletonScope();
182
+ bind(ActiveMonacoUndoRedoHandler).toSelf().inSingletonScope();
183
+ bind(UndoRedoHandler).toService(FocusedMonacoUndoRedoHandler);
184
+ bind(UndoRedoHandler).toService(ActiveMonacoUndoRedoHandler);
185
+ });
186
+
187
+ export const MonacoConfigurationService = Symbol('MonacoConfigurationService');
188
+ export function createMonacoConfigurationService(container: interfaces.Container): IConfigurationService {
189
+ const preferences = container.get<PreferenceService>(PreferenceService);
190
+ const preferenceSchemaProvider = container.get<PreferenceSchemaProvider>(PreferenceSchemaProvider);
191
+ const service = new StandaloneConfigurationService();
192
+ const _configuration: Configuration = service['_configuration'];
193
+
194
+ _configuration.getValue = (section, overrides) => {
195
+ const overrideIdentifier: string | undefined = (overrides && 'overrideIdentifier' in overrides && typeof overrides.overrideIdentifier === 'string')
196
+ ? overrides['overrideIdentifier']
197
+ : undefined;
198
+ const resourceUri: string | undefined = (overrides && 'resource' in overrides && !!overrides['resource']) ? overrides['resource'].toString() : undefined;
199
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
200
+ const proxy = createPreferenceProxy<{ [key: string]: any }>(preferences, preferenceSchemaProvider.getCombinedSchema(), {
201
+ resourceUri, overrideIdentifier, style: 'both'
202
+ });
203
+ if (section) {
204
+ return proxy[section];
205
+ }
206
+ return proxy;
207
+ };
208
+
209
+ /*
210
+ * Since we never read values from the underlying service, writing to it doesn't make sense. The standalone editor writes to the configuration when being created,
211
+ * which makes sense in the standalone case where there is no preference infrastructure in place. Those writes degrade the performance, however, so we patch the
212
+ * service to an empty implementation.
213
+ */
214
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
215
+ service.updateValues = (values: [string, any][]) => Promise.resolve();
216
+
217
+ const toTarget = (scope: PreferenceScope): ConfigurationTarget => {
218
+ switch (scope) {
219
+ case PreferenceScope.Default: return ConfigurationTarget.DEFAULT;
220
+ case PreferenceScope.User: return ConfigurationTarget.USER;
221
+ case PreferenceScope.Workspace: return ConfigurationTarget.WORKSPACE;
222
+ case PreferenceScope.Folder: return ConfigurationTarget.WORKSPACE_FOLDER;
223
+ }
224
+ };
225
+
226
+ interface FireDidChangeConfigurationContext {
227
+ changes: PreferenceChange[];
228
+ affectedKeys: Set<string>;
229
+ keys: Set<string>;
230
+ overrides: Map<string, Set<string>>
231
+ }
232
+ const newFireDidChangeConfigurationContext = (): FireDidChangeConfigurationContext => ({
233
+ changes: [],
234
+ affectedKeys: new Set<string>(),
235
+ keys: new Set<string>(),
236
+ overrides: new Map<string, Set<string>>()
237
+ });
238
+ const fireDidChangeConfiguration = (source: ConfigurationTarget, context: FireDidChangeConfigurationContext): void => {
239
+ if (!context.affectedKeys.size) {
240
+ return;
241
+ }
242
+ const overrides: [string, string[]][] = [];
243
+ for (const [override, values] of context.overrides) {
244
+ overrides.push([override, [...values]]);
245
+ }
246
+ service['_onDidChangeConfiguration'].fire(<IConfigurationChangeEvent>{
247
+ sourceConfig: {},
248
+ change: {
249
+ keys: [...context.keys],
250
+ overrides
251
+ },
252
+ affectedKeys: context.affectedKeys,
253
+ source,
254
+ affectsConfiguration: (prefix, options) => {
255
+ if (!context.affectedKeys.has(prefix)) {
256
+ return false;
257
+ }
258
+ for (const change of context.changes) {
259
+ const overridden = preferences.overriddenPreferenceName(change.preferenceName);
260
+ const preferenceName = overridden ? overridden.preferenceName : change.preferenceName;
261
+ if (preferenceName.startsWith(prefix)) {
262
+ if (options?.overrideIdentifier !== undefined) {
263
+ if (overridden && overridden.overrideIdentifier !== options?.overrideIdentifier) {
264
+ continue;
265
+ }
266
+ }
267
+ if (change.affects(options?.resource?.toString())) {
268
+ return true;
269
+ }
270
+ }
271
+ }
272
+ return false;
273
+ }
274
+ });
275
+ };
276
+
277
+ preferences.onPreferencesChanged(event => {
278
+ let source: ConfigurationTarget | undefined;
279
+ let context = newFireDidChangeConfigurationContext();
280
+ for (let key of Object.keys(event)) {
281
+ const change = event[key];
282
+ const target = toTarget(change.scope);
283
+ if (source !== undefined && target !== source) {
284
+ fireDidChangeConfiguration(source, context);
285
+ context = newFireDidChangeConfigurationContext();
286
+ }
287
+ context.changes.push(change);
288
+ source = target;
289
+
290
+ let overrideKeys: Set<string> | undefined;
291
+ if (key.startsWith('[')) {
292
+ const index = key.indexOf('.');
293
+ const override = key.substring(0, index);
294
+ const overrideIdentifier = override.match(OVERRIDE_PROPERTY_PATTERN)?.[1];
295
+ if (overrideIdentifier) {
296
+ context.keys.add(override);
297
+ context.affectedKeys.add(override);
298
+ overrideKeys = context.overrides.get(overrideIdentifier) || new Set<string>();
299
+ context.overrides.set(overrideIdentifier, overrideKeys);
300
+ key = key.substring(index + 1);
301
+ }
302
+ }
303
+ while (key) {
304
+ if (overrideKeys) {
305
+ overrideKeys.add(key);
306
+ }
307
+ context.keys.add(key);
308
+ context.affectedKeys.add(key);
309
+ const index = key.lastIndexOf('.');
310
+ key = key.substring(0, index);
311
+ }
312
+ }
313
+ if (source) {
314
+ fireDidChangeConfiguration(source, context);
315
+ }
316
+ });
317
+
318
+ return service;
319
+ }