@theia/monaco 1.34.2 → 1.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +641 -641
- package/README.md +100 -100
- package/data/monaco-nls.json +1379 -1379
- package/data/monaco-themes/vscode/dark_plus.json +201 -201
- package/data/monaco-themes/vscode/dark_theia.json +5 -5
- package/data/monaco-themes/vscode/dark_vs.json +392 -392
- package/data/monaco-themes/vscode/hc_black.json +457 -457
- package/data/monaco-themes/vscode/hc_light.json +590 -590
- package/data/monaco-themes/vscode/hc_theia.json +5 -5
- package/data/monaco-themes/vscode/hc_theia_light.json +5 -5
- package/data/monaco-themes/vscode/light_plus.json +202 -202
- package/data/monaco-themes/vscode/light_theia.json +10 -10
- package/data/monaco-themes/vscode/light_vs.json +421 -421
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +28 -28
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts +24 -24
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js +137 -137
- package/lib/browser/monaco-bulk-edit-service.d.ts +14 -14
- package/lib/browser/monaco-bulk-edit-service.js +66 -66
- package/lib/browser/monaco-color-registry.d.ts +16 -16
- package/lib/browser/monaco-color-registry.js +82 -82
- package/lib/browser/monaco-command-registry.d.ts +19 -19
- package/lib/browser/monaco-command-registry.js +82 -82
- package/lib/browser/monaco-command-service.d.ts +26 -26
- package/lib/browser/monaco-command-service.js +92 -92
- package/lib/browser/monaco-command.d.ts +94 -94
- package/lib/browser/monaco-command.js +306 -306
- package/lib/browser/monaco-context-key-service.d.ts +22 -22
- package/lib/browser/monaco-context-key-service.js +147 -147
- package/lib/browser/monaco-context-menu.d.ts +16 -16
- package/lib/browser/monaco-context-menu.js +102 -102
- package/lib/browser/monaco-diagnostic-collection.d.ts +28 -28
- package/lib/browser/monaco-diagnostic-collection.js +86 -86
- package/lib/browser/monaco-diff-editor.d.ts +29 -29
- package/lib/browser/monaco-diff-editor.js +74 -74
- package/lib/browser/monaco-diff-navigator-factory.d.ts +7 -7
- package/lib/browser/monaco-diff-navigator-factory.js +66 -66
- package/lib/browser/monaco-editor-model.d.ts +156 -156
- package/lib/browser/monaco-editor-model.js +555 -555
- package/lib/browser/monaco-editor-provider.d.ts +89 -89
- package/lib/browser/monaco-editor-provider.js +440 -440
- package/lib/browser/monaco-editor-service.d.ts +27 -27
- package/lib/browser/monaco-editor-service.js +151 -151
- package/lib/browser/monaco-editor-zone-widget.d.ts +43 -43
- package/lib/browser/monaco-editor-zone-widget.js +194 -194
- package/lib/browser/monaco-editor.d.ts +151 -151
- package/lib/browser/monaco-editor.js +497 -497
- package/lib/browser/monaco-formatting-conflicts.d.ts +13 -13
- package/lib/browser/monaco-formatting-conflicts.js +110 -110
- package/lib/browser/monaco-frontend-application-contribution.d.ts +26 -26
- package/lib/browser/monaco-frontend-application-contribution.js +201 -201
- package/lib/browser/monaco-frontend-module.d.ts +7 -7
- package/lib/browser/monaco-frontend-module.js +266 -266
- package/lib/browser/monaco-gotoline-quick-access.d.ts +11 -11
- package/lib/browser/monaco-gotoline-quick-access.js +64 -64
- package/lib/browser/monaco-gotosymbol-quick-access.d.ts +16 -16
- package/lib/browser/monaco-gotosymbol-quick-access.js +70 -70
- package/lib/browser/monaco-indexed-db.d.ts +28 -28
- package/lib/browser/monaco-indexed-db.js +131 -131
- package/lib/browser/monaco-keybinding-contexts.d.ts +15 -15
- package/lib/browser/monaco-keybinding-contexts.js +50 -50
- package/lib/browser/monaco-keybinding.d.ts +16 -16
- package/lib/browser/monaco-keybinding.js +134 -134
- package/lib/browser/monaco-keycode-map.d.ts +2 -2
- package/lib/browser/monaco-keycode-map.js +163 -163
- package/lib/browser/monaco-languages.d.ts +27 -27
- package/lib/browser/monaco-languages.js +136 -136
- package/lib/browser/monaco-menu.d.ts +20 -20
- package/lib/browser/monaco-menu.js +145 -145
- package/lib/browser/monaco-mime-service.d.ts +10 -10
- package/lib/browser/monaco-mime-service.js +78 -78
- package/lib/browser/monaco-outline-contribution.d.ts +78 -78
- package/lib/browser/monaco-outline-contribution.js +384 -384
- package/lib/browser/monaco-outline-decorator.d.ts +12 -12
- package/lib/browser/monaco-outline-decorator.js +67 -67
- package/lib/browser/monaco-quick-access-registry.d.ts +11 -11
- package/lib/browser/monaco-quick-access-registry.js +99 -99
- package/lib/browser/monaco-quick-input-service.d.ts +99 -99
- package/lib/browser/monaco-quick-input-service.js +555 -555
- package/lib/browser/monaco-resolved-keybinding.d.ts +23 -23
- package/lib/browser/monaco-resolved-keybinding.js +131 -131
- package/lib/browser/monaco-snippet-suggest-provider.d.ts +64 -64
- package/lib/browser/monaco-snippet-suggest-provider.js +269 -269
- package/lib/browser/monaco-status-bar-contribution.d.ts +17 -17
- package/lib/browser/monaco-status-bar-contribution.js +120 -120
- package/lib/browser/monaco-text-model-service.d.ts +51 -51
- package/lib/browser/monaco-text-model-service.js +184 -184
- package/lib/browser/monaco-theming-service.d.ts +67 -67
- package/lib/browser/monaco-theming-service.js +171 -171
- package/lib/browser/monaco-to-protocol-converter.d.ts +26 -26
- package/lib/browser/monaco-to-protocol-converter.js +61 -61
- package/lib/browser/monaco-workspace.d.ts +83 -83
- package/lib/browser/monaco-workspace.js +369 -369
- package/lib/browser/protocol-to-monaco-converter.d.ts +31 -31
- package/lib/browser/protocol-to-monaco-converter.js +133 -133
- package/lib/browser/textmate/index.d.ts +4 -4
- package/lib/browser/textmate/index.js +31 -31
- package/lib/browser/textmate/monaco-textmate-frontend-bindings.d.ts +12 -12
- package/lib/browser/textmate/monaco-textmate-frontend-bindings.js +94 -94
- package/lib/browser/textmate/monaco-textmate-service.d.ts +30 -30
- package/lib/browser/textmate/monaco-textmate-service.js +185 -185
- package/lib/browser/textmate/monaco-theme-registry.d.ts +27 -27
- package/lib/browser/textmate/monaco-theme-registry.js +171 -171
- package/lib/browser/textmate/monaco-theme-types.d.ts +20 -20
- package/lib/browser/textmate/monaco-theme-types.js +21 -21
- package/lib/browser/textmate/textmate-contribution.d.ts +9 -9
- package/lib/browser/textmate/textmate-contribution.js +27 -27
- package/lib/browser/textmate/textmate-registry.d.ts +31 -31
- package/lib/browser/textmate/textmate-registry.js +109 -109
- package/lib/browser/textmate/textmate-snippet-completion-provider.d.ts +26 -26
- package/lib/browser/textmate/textmate-snippet-completion-provider.js +53 -53
- package/lib/browser/textmate/textmate-tokenizer.d.ts +22 -22
- package/lib/browser/textmate/textmate-tokenizer.js +65 -65
- package/lib/browser/workspace-symbol-command.d.ts +55 -55
- package/lib/browser/workspace-symbol-command.js +215 -215
- package/lib/package.spec.js +25 -25
- package/package.json +8 -8
- package/src/browser/index.ts +17 -17
- package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +117 -117
- package/src/browser/monaco-bulk-edit-service.ts +64 -64
- package/src/browser/monaco-color-registry.ts +73 -73
- package/src/browser/monaco-command-registry.ts +82 -82
- package/src/browser/monaco-command-service.ts +99 -99
- package/src/browser/monaco-command.ts +311 -311
- package/src/browser/monaco-context-key-service.ts +143 -143
- package/src/browser/monaco-context-menu.ts +90 -90
- package/src/browser/monaco-diagnostic-collection.ts +101 -101
- package/src/browser/monaco-diff-editor.ts +101 -101
- package/src/browser/monaco-diff-navigator-factory.ts +61 -61
- package/src/browser/monaco-editor-model.ts +681 -681
- package/src/browser/monaco-editor-provider.ts +452 -452
- package/src/browser/monaco-editor-service.ts +144 -144
- package/src/browser/monaco-editor-zone-widget.ts +250 -250
- package/src/browser/monaco-editor.ts +644 -644
- package/src/browser/monaco-formatting-conflicts.ts +115 -115
- package/src/browser/monaco-frontend-application-contribution.ts +188 -188
- package/src/browser/monaco-frontend-module.ts +314 -314
- package/src/browser/monaco-gotoline-quick-access.ts +47 -47
- package/src/browser/monaco-gotosymbol-quick-access.ts +53 -53
- package/src/browser/monaco-indexed-db.ts +130 -130
- package/src/browser/monaco-keybinding-contexts.ts +43 -43
- package/src/browser/monaco-keybinding.ts +111 -111
- package/src/browser/monaco-keycode-map.ts +171 -171
- package/src/browser/monaco-languages.ts +129 -129
- package/src/browser/monaco-menu.ts +142 -142
- package/src/browser/monaco-mime-service.ts +71 -71
- package/src/browser/monaco-outline-contribution.ts +404 -404
- package/src/browser/monaco-outline-decorator.ts +66 -66
- package/src/browser/monaco-quick-access-registry.ts +112 -112
- package/src/browser/monaco-quick-input-service.ts +651 -651
- package/src/browser/monaco-resolved-keybinding.ts +162 -162
- package/src/browser/monaco-snippet-suggest-provider.ts +300 -300
- package/src/browser/monaco-status-bar-contribution.ts +109 -109
- package/src/browser/monaco-text-model-service.ts +194 -194
- package/src/browser/monaco-theming-service.ts +204 -204
- package/src/browser/monaco-to-protocol-converter.ts +71 -71
- package/src/browser/monaco-workspace.ts +393 -393
- package/src/browser/protocol-to-monaco-converter.ts +158 -158
- package/src/browser/style/index.css +267 -267
- package/src/browser/textmate/index.ts +20 -20
- package/src/browser/textmate/monaco-textmate-frontend-bindings.ts +94 -94
- package/src/browser/textmate/monaco-textmate-service.ts +187 -187
- package/src/browser/textmate/monaco-theme-registry.ts +176 -176
- package/src/browser/textmate/monaco-theme-types.ts +37 -37
- package/src/browser/textmate/textmate-contribution.ts +29 -29
- package/src/browser/textmate/textmate-registry.ts +129 -129
- package/src/browser/textmate/textmate-snippet-completion-provider.ts +73 -73
- package/src/browser/textmate/textmate-tokenizer.ts +84 -84
- package/src/browser/workspace-symbol-command.ts +196 -196
- package/src/package.spec.ts +28 -28
|
@@ -1,185 +1,185 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.MonacoTextModelService = exports.MonacoEditorModelFactory = void 0;
|
|
28
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
-
const uri_1 = require("@theia/core/lib/common/uri");
|
|
30
|
-
const core_1 = require("@theia/core");
|
|
31
|
-
const browser_1 = require("@theia/editor/lib/browser");
|
|
32
|
-
const monaco_editor_model_1 = require("./monaco-editor-model");
|
|
33
|
-
const monaco_to_protocol_converter_1 = require("./monaco-to-protocol-converter");
|
|
34
|
-
const protocol_to_monaco_converter_1 = require("./protocol-to-monaco-converter");
|
|
35
|
-
const logger_1 = require("@theia/core/lib/common/logger");
|
|
36
|
-
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
37
|
-
const standaloneServices_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices");
|
|
38
|
-
const textResourceConfiguration_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/services/textResourceConfiguration");
|
|
39
|
-
exports.MonacoEditorModelFactory = Symbol('MonacoEditorModelFactory');
|
|
40
|
-
let MonacoTextModelService = class MonacoTextModelService {
|
|
41
|
-
constructor() {
|
|
42
|
-
/**
|
|
43
|
-
* This component does some asynchronous work before being fully initialized.
|
|
44
|
-
*
|
|
45
|
-
* @deprecated since 1.25.0. Is instantly resolved.
|
|
46
|
-
*/
|
|
47
|
-
this.ready = Promise.resolve();
|
|
48
|
-
this._models = new core_1.ReferenceCollection(uri => this.loadModel(new uri_1.default(uri)));
|
|
49
|
-
this.modelOptions = {
|
|
50
|
-
'editor.tabSize': 'tabSize',
|
|
51
|
-
'editor.insertSpaces': 'insertSpaces'
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
init() {
|
|
55
|
-
const resourcePropertiesService = standaloneServices_1.StandaloneServices.get(textResourceConfiguration_1.ITextResourcePropertiesService);
|
|
56
|
-
if (resourcePropertiesService) {
|
|
57
|
-
resourcePropertiesService.getEOL = () => {
|
|
58
|
-
const eol = this.editorPreferences['files.eol'];
|
|
59
|
-
if (eol && eol !== 'auto') {
|
|
60
|
-
return eol;
|
|
61
|
-
}
|
|
62
|
-
return core_1.OS.backend.isWindows ? '\r\n' : '\n';
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
get models() {
|
|
67
|
-
return this._models.values();
|
|
68
|
-
}
|
|
69
|
-
get(uri) {
|
|
70
|
-
return this._models.get(uri);
|
|
71
|
-
}
|
|
72
|
-
get onDidCreate() {
|
|
73
|
-
return this._models.onDidCreate;
|
|
74
|
-
}
|
|
75
|
-
createModelReference(raw) {
|
|
76
|
-
return this._models.acquire(raw.toString());
|
|
77
|
-
}
|
|
78
|
-
async loadModel(uri) {
|
|
79
|
-
await this.editorPreferences.ready;
|
|
80
|
-
const resource = await this.resourceProvider(uri);
|
|
81
|
-
const model = await (await this.createModel(resource)).load();
|
|
82
|
-
this.updateModel(model);
|
|
83
|
-
model.textEditorModel.onDidChangeLanguage(() => this.updateModel(model));
|
|
84
|
-
const disposable = this.editorPreferences.onPreferenceChanged(change => this.updateModel(model, change));
|
|
85
|
-
model.onDispose(() => disposable.dispose());
|
|
86
|
-
return model;
|
|
87
|
-
}
|
|
88
|
-
createModel(resource) {
|
|
89
|
-
const factory = this.factories.getContributions().find(({ scheme }) => resource.uri.scheme === scheme);
|
|
90
|
-
return factory ? factory.createModel(resource) : new monaco_editor_model_1.MonacoEditorModel(resource, this.m2p, this.p2m, this.logger, this.editorPreferences);
|
|
91
|
-
}
|
|
92
|
-
toModelOption(editorPreference) {
|
|
93
|
-
switch (editorPreference) {
|
|
94
|
-
case 'editor.tabSize': return 'tabSize';
|
|
95
|
-
case 'editor.insertSpaces': return 'insertSpaces';
|
|
96
|
-
case 'editor.bracketPairColorization.enabled':
|
|
97
|
-
case 'editor.bracketPairColorization.independentColorPoolPerBracketType':
|
|
98
|
-
return 'bracketColorizationOptions';
|
|
99
|
-
case 'editor.trimAutoWhitespace': return 'trimAutoWhitespace';
|
|
100
|
-
}
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
updateModel(model, change) {
|
|
104
|
-
if (!change) {
|
|
105
|
-
model.autoSave = this.editorPreferences.get('files.autoSave', undefined, model.uri);
|
|
106
|
-
model.autoSaveDelay = this.editorPreferences.get('files.autoSaveDelay', undefined, model.uri);
|
|
107
|
-
model.textEditorModel.updateOptions(this.getModelOptions(model));
|
|
108
|
-
}
|
|
109
|
-
else if (change.affects(model.uri, model.languageId)) {
|
|
110
|
-
if (change.preferenceName === 'files.autoSave') {
|
|
111
|
-
model.autoSave = this.editorPreferences.get('files.autoSave', undefined, model.uri);
|
|
112
|
-
}
|
|
113
|
-
if (change.preferenceName === 'files.autoSaveDelay') {
|
|
114
|
-
model.autoSaveDelay = this.editorPreferences.get('files.autoSaveDelay', undefined, model.uri);
|
|
115
|
-
}
|
|
116
|
-
const modelOption = this.toModelOption(change.preferenceName);
|
|
117
|
-
if (modelOption) {
|
|
118
|
-
model.textEditorModel.updateOptions(this.getModelOptions(model));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
getModelOptions(arg) {
|
|
123
|
-
const uri = typeof arg === 'string' ? arg : arg.uri;
|
|
124
|
-
const overrideIdentifier = typeof arg === 'string' ? undefined : arg.languageId;
|
|
125
|
-
return {
|
|
126
|
-
tabSize: this.editorPreferences.get({ preferenceName: 'editor.tabSize', overrideIdentifier }, undefined, uri),
|
|
127
|
-
insertSpaces: this.editorPreferences.get({ preferenceName: 'editor.insertSpaces', overrideIdentifier }, undefined, uri),
|
|
128
|
-
bracketColorizationOptions: {
|
|
129
|
-
enabled: this.editorPreferences.get({ preferenceName: 'editor.bracketPairColorization.enabled', overrideIdentifier }, undefined, uri),
|
|
130
|
-
independentColorPoolPerBracketType: this.editorPreferences.get({ preferenceName: 'editor.bracketPairColorization.independentColorPoolPerBracketType', overrideIdentifier }, undefined, uri),
|
|
131
|
-
},
|
|
132
|
-
trimAutoWhitespace: this.editorPreferences.get({ preferenceName: 'editor.trimAutoWhitespace', overrideIdentifier }, undefined, uri),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
registerTextModelContentProvider(scheme, provider) {
|
|
136
|
-
return {
|
|
137
|
-
dispose() {
|
|
138
|
-
// no-op
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
canHandleResource(resource) {
|
|
143
|
-
return this.fileService.canHandleResource(new uri_1.default(resource));
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
__decorate([
|
|
147
|
-
(0, inversify_1.inject)(core_1.ResourceProvider),
|
|
148
|
-
__metadata("design:type", Function)
|
|
149
|
-
], MonacoTextModelService.prototype, "resourceProvider", void 0);
|
|
150
|
-
__decorate([
|
|
151
|
-
(0, inversify_1.inject)(browser_1.EditorPreferences),
|
|
152
|
-
__metadata("design:type", Object)
|
|
153
|
-
], MonacoTextModelService.prototype, "editorPreferences", void 0);
|
|
154
|
-
__decorate([
|
|
155
|
-
(0, inversify_1.inject)(monaco_to_protocol_converter_1.MonacoToProtocolConverter),
|
|
156
|
-
__metadata("design:type", monaco_to_protocol_converter_1.MonacoToProtocolConverter)
|
|
157
|
-
], MonacoTextModelService.prototype, "m2p", void 0);
|
|
158
|
-
__decorate([
|
|
159
|
-
(0, inversify_1.inject)(protocol_to_monaco_converter_1.ProtocolToMonacoConverter),
|
|
160
|
-
__metadata("design:type", protocol_to_monaco_converter_1.ProtocolToMonacoConverter)
|
|
161
|
-
], MonacoTextModelService.prototype, "p2m", void 0);
|
|
162
|
-
__decorate([
|
|
163
|
-
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
164
|
-
(0, inversify_1.named)(exports.MonacoEditorModelFactory),
|
|
165
|
-
__metadata("design:type", Object)
|
|
166
|
-
], MonacoTextModelService.prototype, "factories", void 0);
|
|
167
|
-
__decorate([
|
|
168
|
-
(0, inversify_1.inject)(logger_1.ILogger),
|
|
169
|
-
__metadata("design:type", Object)
|
|
170
|
-
], MonacoTextModelService.prototype, "logger", void 0);
|
|
171
|
-
__decorate([
|
|
172
|
-
(0, inversify_1.inject)(file_service_1.FileService),
|
|
173
|
-
__metadata("design:type", file_service_1.FileService)
|
|
174
|
-
], MonacoTextModelService.prototype, "fileService", void 0);
|
|
175
|
-
__decorate([
|
|
176
|
-
(0, inversify_1.postConstruct)(),
|
|
177
|
-
__metadata("design:type", Function),
|
|
178
|
-
__metadata("design:paramtypes", []),
|
|
179
|
-
__metadata("design:returntype", void 0)
|
|
180
|
-
], MonacoTextModelService.prototype, "init", null);
|
|
181
|
-
MonacoTextModelService = __decorate([
|
|
182
|
-
(0, inversify_1.injectable)()
|
|
183
|
-
], MonacoTextModelService);
|
|
184
|
-
exports.MonacoTextModelService = MonacoTextModelService;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.MonacoTextModelService = exports.MonacoEditorModelFactory = void 0;
|
|
28
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
30
|
+
const core_1 = require("@theia/core");
|
|
31
|
+
const browser_1 = require("@theia/editor/lib/browser");
|
|
32
|
+
const monaco_editor_model_1 = require("./monaco-editor-model");
|
|
33
|
+
const monaco_to_protocol_converter_1 = require("./monaco-to-protocol-converter");
|
|
34
|
+
const protocol_to_monaco_converter_1 = require("./protocol-to-monaco-converter");
|
|
35
|
+
const logger_1 = require("@theia/core/lib/common/logger");
|
|
36
|
+
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
37
|
+
const standaloneServices_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices");
|
|
38
|
+
const textResourceConfiguration_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/services/textResourceConfiguration");
|
|
39
|
+
exports.MonacoEditorModelFactory = Symbol('MonacoEditorModelFactory');
|
|
40
|
+
let MonacoTextModelService = class MonacoTextModelService {
|
|
41
|
+
constructor() {
|
|
42
|
+
/**
|
|
43
|
+
* This component does some asynchronous work before being fully initialized.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated since 1.25.0. Is instantly resolved.
|
|
46
|
+
*/
|
|
47
|
+
this.ready = Promise.resolve();
|
|
48
|
+
this._models = new core_1.ReferenceCollection(uri => this.loadModel(new uri_1.default(uri)));
|
|
49
|
+
this.modelOptions = {
|
|
50
|
+
'editor.tabSize': 'tabSize',
|
|
51
|
+
'editor.insertSpaces': 'insertSpaces'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
init() {
|
|
55
|
+
const resourcePropertiesService = standaloneServices_1.StandaloneServices.get(textResourceConfiguration_1.ITextResourcePropertiesService);
|
|
56
|
+
if (resourcePropertiesService) {
|
|
57
|
+
resourcePropertiesService.getEOL = () => {
|
|
58
|
+
const eol = this.editorPreferences['files.eol'];
|
|
59
|
+
if (eol && eol !== 'auto') {
|
|
60
|
+
return eol;
|
|
61
|
+
}
|
|
62
|
+
return core_1.OS.backend.isWindows ? '\r\n' : '\n';
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
get models() {
|
|
67
|
+
return this._models.values();
|
|
68
|
+
}
|
|
69
|
+
get(uri) {
|
|
70
|
+
return this._models.get(uri);
|
|
71
|
+
}
|
|
72
|
+
get onDidCreate() {
|
|
73
|
+
return this._models.onDidCreate;
|
|
74
|
+
}
|
|
75
|
+
createModelReference(raw) {
|
|
76
|
+
return this._models.acquire(raw.toString());
|
|
77
|
+
}
|
|
78
|
+
async loadModel(uri) {
|
|
79
|
+
await this.editorPreferences.ready;
|
|
80
|
+
const resource = await this.resourceProvider(uri);
|
|
81
|
+
const model = await (await this.createModel(resource)).load();
|
|
82
|
+
this.updateModel(model);
|
|
83
|
+
model.textEditorModel.onDidChangeLanguage(() => this.updateModel(model));
|
|
84
|
+
const disposable = this.editorPreferences.onPreferenceChanged(change => this.updateModel(model, change));
|
|
85
|
+
model.onDispose(() => disposable.dispose());
|
|
86
|
+
return model;
|
|
87
|
+
}
|
|
88
|
+
createModel(resource) {
|
|
89
|
+
const factory = this.factories.getContributions().find(({ scheme }) => resource.uri.scheme === scheme);
|
|
90
|
+
return factory ? factory.createModel(resource) : new monaco_editor_model_1.MonacoEditorModel(resource, this.m2p, this.p2m, this.logger, this.editorPreferences);
|
|
91
|
+
}
|
|
92
|
+
toModelOption(editorPreference) {
|
|
93
|
+
switch (editorPreference) {
|
|
94
|
+
case 'editor.tabSize': return 'tabSize';
|
|
95
|
+
case 'editor.insertSpaces': return 'insertSpaces';
|
|
96
|
+
case 'editor.bracketPairColorization.enabled':
|
|
97
|
+
case 'editor.bracketPairColorization.independentColorPoolPerBracketType':
|
|
98
|
+
return 'bracketColorizationOptions';
|
|
99
|
+
case 'editor.trimAutoWhitespace': return 'trimAutoWhitespace';
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
updateModel(model, change) {
|
|
104
|
+
if (!change) {
|
|
105
|
+
model.autoSave = this.editorPreferences.get('files.autoSave', undefined, model.uri);
|
|
106
|
+
model.autoSaveDelay = this.editorPreferences.get('files.autoSaveDelay', undefined, model.uri);
|
|
107
|
+
model.textEditorModel.updateOptions(this.getModelOptions(model));
|
|
108
|
+
}
|
|
109
|
+
else if (change.affects(model.uri, model.languageId)) {
|
|
110
|
+
if (change.preferenceName === 'files.autoSave') {
|
|
111
|
+
model.autoSave = this.editorPreferences.get('files.autoSave', undefined, model.uri);
|
|
112
|
+
}
|
|
113
|
+
if (change.preferenceName === 'files.autoSaveDelay') {
|
|
114
|
+
model.autoSaveDelay = this.editorPreferences.get('files.autoSaveDelay', undefined, model.uri);
|
|
115
|
+
}
|
|
116
|
+
const modelOption = this.toModelOption(change.preferenceName);
|
|
117
|
+
if (modelOption) {
|
|
118
|
+
model.textEditorModel.updateOptions(this.getModelOptions(model));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
getModelOptions(arg) {
|
|
123
|
+
const uri = typeof arg === 'string' ? arg : arg.uri;
|
|
124
|
+
const overrideIdentifier = typeof arg === 'string' ? undefined : arg.languageId;
|
|
125
|
+
return {
|
|
126
|
+
tabSize: this.editorPreferences.get({ preferenceName: 'editor.tabSize', overrideIdentifier }, undefined, uri),
|
|
127
|
+
insertSpaces: this.editorPreferences.get({ preferenceName: 'editor.insertSpaces', overrideIdentifier }, undefined, uri),
|
|
128
|
+
bracketColorizationOptions: {
|
|
129
|
+
enabled: this.editorPreferences.get({ preferenceName: 'editor.bracketPairColorization.enabled', overrideIdentifier }, undefined, uri),
|
|
130
|
+
independentColorPoolPerBracketType: this.editorPreferences.get({ preferenceName: 'editor.bracketPairColorization.independentColorPoolPerBracketType', overrideIdentifier }, undefined, uri),
|
|
131
|
+
},
|
|
132
|
+
trimAutoWhitespace: this.editorPreferences.get({ preferenceName: 'editor.trimAutoWhitespace', overrideIdentifier }, undefined, uri),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
registerTextModelContentProvider(scheme, provider) {
|
|
136
|
+
return {
|
|
137
|
+
dispose() {
|
|
138
|
+
// no-op
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
canHandleResource(resource) {
|
|
143
|
+
return this.fileService.canHandleResource(new uri_1.default(resource));
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, inversify_1.inject)(core_1.ResourceProvider),
|
|
148
|
+
__metadata("design:type", Function)
|
|
149
|
+
], MonacoTextModelService.prototype, "resourceProvider", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, inversify_1.inject)(browser_1.EditorPreferences),
|
|
152
|
+
__metadata("design:type", Object)
|
|
153
|
+
], MonacoTextModelService.prototype, "editorPreferences", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
(0, inversify_1.inject)(monaco_to_protocol_converter_1.MonacoToProtocolConverter),
|
|
156
|
+
__metadata("design:type", monaco_to_protocol_converter_1.MonacoToProtocolConverter)
|
|
157
|
+
], MonacoTextModelService.prototype, "m2p", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, inversify_1.inject)(protocol_to_monaco_converter_1.ProtocolToMonacoConverter),
|
|
160
|
+
__metadata("design:type", protocol_to_monaco_converter_1.ProtocolToMonacoConverter)
|
|
161
|
+
], MonacoTextModelService.prototype, "p2m", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
164
|
+
(0, inversify_1.named)(exports.MonacoEditorModelFactory),
|
|
165
|
+
__metadata("design:type", Object)
|
|
166
|
+
], MonacoTextModelService.prototype, "factories", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, inversify_1.inject)(logger_1.ILogger),
|
|
169
|
+
__metadata("design:type", Object)
|
|
170
|
+
], MonacoTextModelService.prototype, "logger", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
(0, inversify_1.inject)(file_service_1.FileService),
|
|
173
|
+
__metadata("design:type", file_service_1.FileService)
|
|
174
|
+
], MonacoTextModelService.prototype, "fileService", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
(0, inversify_1.postConstruct)(),
|
|
177
|
+
__metadata("design:type", Function),
|
|
178
|
+
__metadata("design:paramtypes", []),
|
|
179
|
+
__metadata("design:returntype", void 0)
|
|
180
|
+
], MonacoTextModelService.prototype, "init", null);
|
|
181
|
+
MonacoTextModelService = __decorate([
|
|
182
|
+
(0, inversify_1.injectable)()
|
|
183
|
+
], MonacoTextModelService);
|
|
184
|
+
exports.MonacoTextModelService = MonacoTextModelService;
|
|
185
185
|
//# sourceMappingURL=monaco-text-model-service.js.map
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import URI from '@theia/core/lib/common/uri';
|
|
2
|
-
import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
3
|
-
import { MonacoThemeRegistry } from './textmate/monaco-theme-registry';
|
|
4
|
-
import { MonacoThemeState, ThemeServiceWithDB } from './monaco-indexed-db';
|
|
5
|
-
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
6
|
-
import * as monaco from '@theia/monaco-editor-core';
|
|
7
|
-
export interface MonacoTheme {
|
|
8
|
-
id?: string;
|
|
9
|
-
label?: string;
|
|
10
|
-
uiTheme?: monaco.editor.BuiltinTheme;
|
|
11
|
-
description?: string;
|
|
12
|
-
uri: string;
|
|
13
|
-
}
|
|
14
|
-
export interface MonacoThemeJson {
|
|
15
|
-
/**
|
|
16
|
-
* theme id (optional), label is used if not provided
|
|
17
|
-
*/
|
|
18
|
-
id?: string;
|
|
19
|
-
label: string;
|
|
20
|
-
/**
|
|
21
|
-
* theme type, `vs-dark` if not provided
|
|
22
|
-
*/
|
|
23
|
-
uiTheme?: monaco.editor.BuiltinTheme;
|
|
24
|
-
description?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Follow https://code.visualstudio.com/api/extension-guides/color-theme#create-a-new-color-theme to create a custom theme.
|
|
27
|
-
*/
|
|
28
|
-
json: any;
|
|
29
|
-
/**
|
|
30
|
-
* Themes can include each other. It specifies how inclusions should be resolved.
|
|
31
|
-
*/
|
|
32
|
-
includes?: {
|
|
33
|
-
[includePath: string]: any;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export declare class MonacoThemingService {
|
|
37
|
-
protected readonly fileService: FileService;
|
|
38
|
-
protected readonly monacoThemeRegistry: MonacoThemeRegistry;
|
|
39
|
-
protected readonly themeService: ThemeServiceWithDB;
|
|
40
|
-
/** Register themes whose configuration needs to be loaded */
|
|
41
|
-
register(theme: MonacoTheme, pending?: {
|
|
42
|
-
[uri: string]: Promise<any>;
|
|
43
|
-
}): Disposable;
|
|
44
|
-
protected doRegister(theme: MonacoTheme, pending: {
|
|
45
|
-
[uri: string]: Promise<any>;
|
|
46
|
-
}, toDispose: DisposableCollection): Promise<void>;
|
|
47
|
-
protected loadTheme(uri: string, includes: {
|
|
48
|
-
[include: string]: any;
|
|
49
|
-
}, pending: {
|
|
50
|
-
[uri: string]: Promise<any>;
|
|
51
|
-
}, toDispose: DisposableCollection): Promise<any>;
|
|
52
|
-
protected doLoadTheme(themeUri: URI, referencedPath: string, includes: {
|
|
53
|
-
[include: string]: any;
|
|
54
|
-
}, pending: {
|
|
55
|
-
[uri: string]: Promise<any>;
|
|
56
|
-
}, toDispose: DisposableCollection): Promise<any>;
|
|
57
|
-
initialize(): void;
|
|
58
|
-
/** register a theme whose configuration has already been loaded */
|
|
59
|
-
registerParsedTheme(theme: MonacoThemeJson): Disposable;
|
|
60
|
-
protected toUpdateUiTheme: DisposableCollection;
|
|
61
|
-
protected updateBodyUiTheme(): void;
|
|
62
|
-
protected doRegisterParsedTheme(state: MonacoThemeState): Disposable;
|
|
63
|
-
protected restore(): Promise<void>;
|
|
64
|
-
protected static toCssSelector(str: string): string;
|
|
65
|
-
/** removes all invalid theming values */
|
|
66
|
-
private clean;
|
|
67
|
-
}
|
|
1
|
+
import URI from '@theia/core/lib/common/uri';
|
|
2
|
+
import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
3
|
+
import { MonacoThemeRegistry } from './textmate/monaco-theme-registry';
|
|
4
|
+
import { MonacoThemeState, ThemeServiceWithDB } from './monaco-indexed-db';
|
|
5
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
6
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
7
|
+
export interface MonacoTheme {
|
|
8
|
+
id?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
uiTheme?: monaco.editor.BuiltinTheme;
|
|
11
|
+
description?: string;
|
|
12
|
+
uri: string;
|
|
13
|
+
}
|
|
14
|
+
export interface MonacoThemeJson {
|
|
15
|
+
/**
|
|
16
|
+
* theme id (optional), label is used if not provided
|
|
17
|
+
*/
|
|
18
|
+
id?: string;
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* theme type, `vs-dark` if not provided
|
|
22
|
+
*/
|
|
23
|
+
uiTheme?: monaco.editor.BuiltinTheme;
|
|
24
|
+
description?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Follow https://code.visualstudio.com/api/extension-guides/color-theme#create-a-new-color-theme to create a custom theme.
|
|
27
|
+
*/
|
|
28
|
+
json: any;
|
|
29
|
+
/**
|
|
30
|
+
* Themes can include each other. It specifies how inclusions should be resolved.
|
|
31
|
+
*/
|
|
32
|
+
includes?: {
|
|
33
|
+
[includePath: string]: any;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export declare class MonacoThemingService {
|
|
37
|
+
protected readonly fileService: FileService;
|
|
38
|
+
protected readonly monacoThemeRegistry: MonacoThemeRegistry;
|
|
39
|
+
protected readonly themeService: ThemeServiceWithDB;
|
|
40
|
+
/** Register themes whose configuration needs to be loaded */
|
|
41
|
+
register(theme: MonacoTheme, pending?: {
|
|
42
|
+
[uri: string]: Promise<any>;
|
|
43
|
+
}): Disposable;
|
|
44
|
+
protected doRegister(theme: MonacoTheme, pending: {
|
|
45
|
+
[uri: string]: Promise<any>;
|
|
46
|
+
}, toDispose: DisposableCollection): Promise<void>;
|
|
47
|
+
protected loadTheme(uri: string, includes: {
|
|
48
|
+
[include: string]: any;
|
|
49
|
+
}, pending: {
|
|
50
|
+
[uri: string]: Promise<any>;
|
|
51
|
+
}, toDispose: DisposableCollection): Promise<any>;
|
|
52
|
+
protected doLoadTheme(themeUri: URI, referencedPath: string, includes: {
|
|
53
|
+
[include: string]: any;
|
|
54
|
+
}, pending: {
|
|
55
|
+
[uri: string]: Promise<any>;
|
|
56
|
+
}, toDispose: DisposableCollection): Promise<any>;
|
|
57
|
+
initialize(): void;
|
|
58
|
+
/** register a theme whose configuration has already been loaded */
|
|
59
|
+
registerParsedTheme(theme: MonacoThemeJson): Disposable;
|
|
60
|
+
protected toUpdateUiTheme: DisposableCollection;
|
|
61
|
+
protected updateBodyUiTheme(): void;
|
|
62
|
+
protected doRegisterParsedTheme(state: MonacoThemeState): Disposable;
|
|
63
|
+
protected restore(): Promise<void>;
|
|
64
|
+
protected static toCssSelector(str: string): string;
|
|
65
|
+
/** removes all invalid theming values */
|
|
66
|
+
private clean;
|
|
67
|
+
}
|
|
68
68
|
//# sourceMappingURL=monaco-theming-service.d.ts.map
|