@volar/monaco 1.4.0-alpha.1 → 1.4.0-alpha.10
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/out/editor.js +8 -12
- package/out/index.js +1 -0
- package/out/languages.js +3 -0
- package/out/utils/markers.js +1 -0
- package/out/utils/monaco2protocol.js +1 -0
- package/out/utils/protocol2monaco.js +1 -0
- package/out/utils/provider.js +86 -58
- package/out/worker.js +4 -2
- package/package.json +3 -3
package/out/editor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.editor = void 0;
|
|
3
|
-
const language_service_1 = require("@volar/language-service");
|
|
4
4
|
const monaco_editor_core_1 = require("monaco-editor-core");
|
|
5
5
|
const markers_1 = require("./utils/markers");
|
|
6
6
|
const protocol2monaco = require("./utils/protocol2monaco");
|
|
@@ -67,12 +67,10 @@ var editor;
|
|
|
67
67
|
}
|
|
68
68
|
const version = model.getVersionId();
|
|
69
69
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
70
|
-
const diagnostics = await languageService.doValidation(model.uri.toString(),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onCancellationRequested: language_service_1.Event.None,
|
|
75
|
-
}, 'all');
|
|
70
|
+
const diagnostics = await languageService.doValidation(model.uri.toString(), 'all');
|
|
71
|
+
if (model.getVersionId() !== version) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
76
74
|
const result = diagnostics.map(error => {
|
|
77
75
|
const marker = protocol2monaco.asMarkerData(error);
|
|
78
76
|
markers_1.markers.set(marker, error);
|
|
@@ -145,12 +143,10 @@ var editor;
|
|
|
145
143
|
text: lastChange.text,
|
|
146
144
|
rangeOffset: lastChange.rangeOffset,
|
|
147
145
|
},
|
|
148
|
-
}, {
|
|
149
|
-
get isCancellationRequested() {
|
|
150
|
-
return model.getVersionId() !== version;
|
|
151
|
-
},
|
|
152
|
-
onCancellationRequested: language_service_1.Event.None,
|
|
153
146
|
});
|
|
147
|
+
if (model.getVersionId() !== version) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
154
150
|
const codeEditor = editor.getEditors().find((e) => e.getModel() === model);
|
|
155
151
|
if (codeEditor && edit && model.getVersionId() === version) {
|
|
156
152
|
if (typeof edit === 'string') {
|
package/out/index.js
CHANGED
package/out/languages.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.languages = void 0;
|
|
3
4
|
const provider_1 = require("./utils/provider");
|
|
@@ -28,6 +29,8 @@ var languages;
|
|
|
28
29
|
languages.registerDeclarationProvider(language, provider),
|
|
29
30
|
languages.registerSelectionRangeProvider(language, provider),
|
|
30
31
|
languages.registerInlayHintsProvider(language, provider),
|
|
32
|
+
languages.registerDocumentSemanticTokensProvider(language, provider),
|
|
33
|
+
languages.registerDocumentRangeSemanticTokensProvider(language, provider),
|
|
31
34
|
];
|
|
32
35
|
return { dispose: () => disposables.forEach((d) => d.dispose()) };
|
|
33
36
|
}
|
package/out/utils/markers.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.asFormattingOptions = exports.asTriggerKind = exports.asMarkdownString = exports.asParameterInformation = exports.asSignatureInformation = exports.asSignatureHelp = exports.asSignatureHelpTriggerKind = exports.asSignatureHelpContext = exports.asCompletionContext = exports.asRange = exports.asPosition = void 0;
|
|
3
4
|
const monaco_editor_core_1 = require("monaco-editor-core");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.asPosition = exports.asInlayHintLabelPart = exports.asInlayHintLabel = exports.asInlayHintKind = exports.asInlayHint = exports.asSelectionRange = exports.asFoldingRange = exports.asColorPresentation = exports.asColorInformation = exports.asLink = exports.asCodeAction = exports.asCodeLens = exports.asDocumentHighlightKind = exports.asDocumentHighlight = exports.asSymbolKind = exports.asSymbolTag = exports.asDocumentSymbol = exports.asWorkspaceEdit = exports.asMarkerSeverity = exports.asRelatedInformation = exports.asMarkerTag = exports.asMarkerData = exports.asParameterInformation = exports.asSignatureInformation = exports.asSignatureHelp = exports.asUri = exports.asLocation = exports.asMarkdownString = exports.asHover = exports.asRange = exports.asCompletionItemRange = exports.asTextEdit = exports.asCommand = exports.asCompletionItem = exports.asCompletionItemKind = exports.asCompletionList = void 0;
|
|
3
4
|
const monaco_editor_core_1 = require("monaco-editor-core");
|
package/out/utils/provider.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.createLanguageFeaturesProvider = void 0;
|
|
3
4
|
const language_service_1 = require("@volar/language-service");
|
|
@@ -9,6 +10,8 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
9
10
|
const codeLens = new WeakMap();
|
|
10
11
|
const codeActions = new WeakMap();
|
|
11
12
|
const colorInfos = new WeakMap();
|
|
13
|
+
const documentLinks = new WeakMap();
|
|
14
|
+
const inlayHints = new WeakMap();
|
|
12
15
|
const languageService = await worker.getProxy();
|
|
13
16
|
return {
|
|
14
17
|
triggerCharacters: await languageService.triggerCharacters(),
|
|
@@ -18,9 +21,9 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
18
21
|
getLegend() {
|
|
19
22
|
return language_service_1.standardSemanticTokensLegend;
|
|
20
23
|
},
|
|
21
|
-
async provideDocumentSemanticTokens(model, _lastResultId
|
|
24
|
+
async provideDocumentSemanticTokens(model, _lastResultId) {
|
|
22
25
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
23
|
-
const codeResult = await languageService.getSemanticTokens(model.uri.toString(), undefined, language_service_1.standardSemanticTokensLegend
|
|
26
|
+
const codeResult = await languageService.getSemanticTokens(model.uri.toString(), undefined, language_service_1.standardSemanticTokensLegend);
|
|
24
27
|
if (codeResult) {
|
|
25
28
|
return {
|
|
26
29
|
resultId: codeResult.resultId,
|
|
@@ -28,9 +31,9 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
},
|
|
31
|
-
async provideDocumentRangeSemanticTokens(model, range
|
|
34
|
+
async provideDocumentRangeSemanticTokens(model, range) {
|
|
32
35
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
33
|
-
const codeResult = await languageService.getSemanticTokens(model.uri.toString(), monaco2protocol.asRange(range), language_service_1.standardSemanticTokensLegend
|
|
36
|
+
const codeResult = await languageService.getSemanticTokens(model.uri.toString(), monaco2protocol.asRange(range), language_service_1.standardSemanticTokensLegend);
|
|
34
37
|
if (codeResult) {
|
|
35
38
|
return {
|
|
36
39
|
resultId: codeResult.resultId,
|
|
@@ -39,23 +42,23 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
39
42
|
}
|
|
40
43
|
},
|
|
41
44
|
releaseDocumentSemanticTokens() { },
|
|
42
|
-
async provideDocumentSymbols(model
|
|
45
|
+
async provideDocumentSymbols(model) {
|
|
43
46
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
44
|
-
const codeResult = await languageService.findDocumentSymbols(model.uri.toString()
|
|
47
|
+
const codeResult = await languageService.findDocumentSymbols(model.uri.toString());
|
|
45
48
|
if (codeResult) {
|
|
46
49
|
return codeResult.map(protocol2monaco.asDocumentSymbol);
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
|
-
async provideDocumentHighlights(model, position
|
|
52
|
+
async provideDocumentHighlights(model, position) {
|
|
50
53
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
51
|
-
const codeResult = await languageService.findDocumentHighlights(model.uri.toString(), monaco2protocol.asPosition(position)
|
|
54
|
+
const codeResult = await languageService.findDocumentHighlights(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
52
55
|
if (codeResult) {
|
|
53
56
|
return codeResult.map(protocol2monaco.asDocumentHighlight);
|
|
54
57
|
}
|
|
55
58
|
},
|
|
56
|
-
async provideLinkedEditingRanges(model, position
|
|
59
|
+
async provideLinkedEditingRanges(model, position) {
|
|
57
60
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
58
|
-
const codeResult = await languageService.findLinkedEditingRanges(model.uri.toString(), monaco2protocol.asPosition(position)
|
|
61
|
+
const codeResult = await languageService.findLinkedEditingRanges(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
59
62
|
if (codeResult) {
|
|
60
63
|
return {
|
|
61
64
|
ranges: codeResult.ranges.map(protocol2monaco.asRange),
|
|
@@ -65,30 +68,30 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
},
|
|
68
|
-
async provideDefinition(model, position
|
|
71
|
+
async provideDefinition(model, position) {
|
|
69
72
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
70
|
-
const codeResult = await languageService.findDefinition(model.uri.toString(), monaco2protocol.asPosition(position)
|
|
73
|
+
const codeResult = await languageService.findDefinition(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
71
74
|
if (codeResult) {
|
|
72
75
|
return codeResult.map(protocol2monaco.asLocation);
|
|
73
76
|
}
|
|
74
77
|
},
|
|
75
|
-
async provideImplementation(model, position
|
|
78
|
+
async provideImplementation(model, position) {
|
|
76
79
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
77
|
-
const codeResult = await languageService.findImplementations(model.uri.toString(), monaco2protocol.asPosition(position)
|
|
80
|
+
const codeResult = await languageService.findImplementations(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
78
81
|
if (codeResult) {
|
|
79
82
|
return codeResult.map(protocol2monaco.asLocation);
|
|
80
83
|
}
|
|
81
84
|
},
|
|
82
|
-
async provideTypeDefinition(model, position
|
|
85
|
+
async provideTypeDefinition(model, position) {
|
|
83
86
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
84
|
-
const codeResult = await languageService.findTypeDefinition(model.uri.toString(), monaco2protocol.asPosition(position)
|
|
87
|
+
const codeResult = await languageService.findTypeDefinition(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
85
88
|
if (codeResult) {
|
|
86
89
|
return codeResult.map(protocol2monaco.asLocation);
|
|
87
90
|
}
|
|
88
91
|
},
|
|
89
|
-
async provideCodeLenses(model
|
|
92
|
+
async provideCodeLenses(model) {
|
|
90
93
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
91
|
-
const codeResult = await languageService.doCodeLens(model.uri.toString()
|
|
94
|
+
const codeResult = await languageService.doCodeLens(model.uri.toString());
|
|
92
95
|
if (codeResult) {
|
|
93
96
|
const monacoResult = codeResult.map(protocol2monaco.asCodeLens);
|
|
94
97
|
for (let i = 0; i < monacoResult.length; i++) {
|
|
@@ -100,11 +103,11 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
100
103
|
};
|
|
101
104
|
}
|
|
102
105
|
},
|
|
103
|
-
async resolveCodeLens(_, monacoResult
|
|
106
|
+
async resolveCodeLens(_, monacoResult) {
|
|
104
107
|
let codeResult = codeLens.get(monacoResult);
|
|
105
108
|
if (codeResult) {
|
|
106
109
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
107
|
-
codeResult = await languageService.doCodeLensResolve(codeResult
|
|
110
|
+
codeResult = await languageService.doCodeLensResolve(codeResult);
|
|
108
111
|
if (codeResult) {
|
|
109
112
|
monacoResult = protocol2monaco.asCodeLens(codeResult);
|
|
110
113
|
codeLens.set(monacoResult, codeResult);
|
|
@@ -112,7 +115,7 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
112
115
|
}
|
|
113
116
|
return monacoResult;
|
|
114
117
|
},
|
|
115
|
-
async provideCodeActions(model, range, context
|
|
118
|
+
async provideCodeActions(model, range, context) {
|
|
116
119
|
const diagnostics = [];
|
|
117
120
|
for (const marker of context.markers) {
|
|
118
121
|
const diagnostic = markers_1.markers.get(marker);
|
|
@@ -124,7 +127,7 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
124
127
|
const codeResult = await languageService.doCodeActions(model.uri.toString(), monaco2protocol.asRange(range), {
|
|
125
128
|
diagnostics: diagnostics,
|
|
126
129
|
only: context.only ? [context.only] : undefined,
|
|
127
|
-
}
|
|
130
|
+
});
|
|
128
131
|
if (codeResult) {
|
|
129
132
|
const monacoResult = codeResult.map(protocol2monaco.asCodeAction);
|
|
130
133
|
for (let i = 0; i < monacoResult.length; i++) {
|
|
@@ -136,11 +139,11 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
136
139
|
};
|
|
137
140
|
}
|
|
138
141
|
},
|
|
139
|
-
async resolveCodeAction(monacoResult
|
|
142
|
+
async resolveCodeAction(monacoResult) {
|
|
140
143
|
let codeResult = codeActions.get(monacoResult);
|
|
141
144
|
if (codeResult) {
|
|
142
145
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
143
|
-
codeResult = await languageService.doCodeActionResolve(codeResult
|
|
146
|
+
codeResult = await languageService.doCodeActionResolve(codeResult);
|
|
144
147
|
if (codeResult) {
|
|
145
148
|
monacoResult = protocol2monaco.asCodeAction(codeResult);
|
|
146
149
|
codeActions.set(monacoResult, codeResult);
|
|
@@ -148,42 +151,54 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
148
151
|
}
|
|
149
152
|
return monacoResult;
|
|
150
153
|
},
|
|
151
|
-
async provideDocumentFormattingEdits(model, options
|
|
154
|
+
async provideDocumentFormattingEdits(model, options) {
|
|
152
155
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
153
|
-
const codeResult = await languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), undefined, undefined
|
|
156
|
+
const codeResult = await languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), undefined, undefined);
|
|
154
157
|
if (codeResult) {
|
|
155
158
|
return codeResult.map(protocol2monaco.asTextEdit);
|
|
156
159
|
}
|
|
157
160
|
},
|
|
158
|
-
async provideDocumentRangeFormattingEdits(model, range, options
|
|
161
|
+
async provideDocumentRangeFormattingEdits(model, range, options) {
|
|
159
162
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
160
|
-
const codeResult = await languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), monaco2protocol.asRange(range), undefined
|
|
163
|
+
const codeResult = await languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), monaco2protocol.asRange(range), undefined);
|
|
161
164
|
if (codeResult) {
|
|
162
165
|
return codeResult.map(protocol2monaco.asTextEdit);
|
|
163
166
|
}
|
|
164
167
|
},
|
|
165
|
-
async provideOnTypeFormattingEdits(model, position, ch, options
|
|
168
|
+
async provideOnTypeFormattingEdits(model, position, ch, options) {
|
|
166
169
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
167
170
|
const codeResult = await languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), undefined, {
|
|
168
171
|
ch: ch,
|
|
169
172
|
position: monaco2protocol.asPosition(position),
|
|
170
|
-
}
|
|
173
|
+
});
|
|
171
174
|
if (codeResult) {
|
|
172
175
|
return codeResult.map(protocol2monaco.asTextEdit);
|
|
173
176
|
}
|
|
174
177
|
},
|
|
175
|
-
async provideLinks(model
|
|
178
|
+
async provideLinks(model) {
|
|
176
179
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
177
|
-
const codeResult = await languageService.findDocumentLinks(model.uri.toString()
|
|
180
|
+
const codeResult = await languageService.findDocumentLinks(model.uri.toString());
|
|
178
181
|
if (codeResult) {
|
|
179
182
|
return {
|
|
180
|
-
links: codeResult.map(
|
|
183
|
+
links: codeResult.map(link => {
|
|
184
|
+
const monacoLink = protocol2monaco.asLink(link);
|
|
185
|
+
documentLinks.set(monacoLink, link);
|
|
186
|
+
return monacoLink;
|
|
187
|
+
}),
|
|
181
188
|
};
|
|
182
189
|
}
|
|
183
190
|
},
|
|
184
|
-
async
|
|
191
|
+
async resolveLink(link) {
|
|
192
|
+
let codeResult = documentLinks.get(link);
|
|
193
|
+
if (codeResult) {
|
|
194
|
+
codeResult = await languageService.doDocumentLinkResolve(codeResult);
|
|
195
|
+
return protocol2monaco.asLink(codeResult);
|
|
196
|
+
}
|
|
197
|
+
return link;
|
|
198
|
+
},
|
|
199
|
+
async provideCompletionItems(model, position, context) {
|
|
185
200
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
186
|
-
const codeResult = await languageService.doComplete(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asCompletionContext(context)
|
|
201
|
+
const codeResult = await languageService.doComplete(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asCompletionContext(context));
|
|
187
202
|
const fallbackRange = {
|
|
188
203
|
start: monaco2protocol.asPosition(position),
|
|
189
204
|
end: monaco2protocol.asPosition(position),
|
|
@@ -194,11 +209,11 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
194
209
|
}
|
|
195
210
|
return monacoResult;
|
|
196
211
|
},
|
|
197
|
-
async resolveCompletionItem(monacoItem
|
|
212
|
+
async resolveCompletionItem(monacoItem) {
|
|
198
213
|
let codeItem = completionItems.get(monacoItem);
|
|
199
214
|
if (codeItem) {
|
|
200
215
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
201
|
-
codeItem = await languageService.doCompletionResolve(codeItem
|
|
216
|
+
codeItem = await languageService.doCompletionResolve(codeItem);
|
|
202
217
|
const fallbackRange = 'replace' in monacoItem.range
|
|
203
218
|
? monaco2protocol.asRange(monacoItem.range.replace)
|
|
204
219
|
: monaco2protocol.asRange(monacoItem.range);
|
|
@@ -207,48 +222,48 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
207
222
|
}
|
|
208
223
|
return monacoItem;
|
|
209
224
|
},
|
|
210
|
-
async provideDocumentColors(model
|
|
225
|
+
async provideDocumentColors(model) {
|
|
211
226
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
212
|
-
const codeResult = await languageService.findDocumentColors(model.uri.toString()
|
|
227
|
+
const codeResult = await languageService.findDocumentColors(model.uri.toString());
|
|
213
228
|
if (codeResult) {
|
|
214
229
|
return codeResult.map(protocol2monaco.asColorInformation);
|
|
215
230
|
}
|
|
216
231
|
},
|
|
217
|
-
async provideColorPresentations(model, monacoResult
|
|
232
|
+
async provideColorPresentations(model, monacoResult) {
|
|
218
233
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
219
234
|
const codeResult = colorInfos.get(monacoResult);
|
|
220
235
|
if (codeResult) {
|
|
221
236
|
const codeColors = await languageService.getColorPresentations(model.uri.toString(), codeResult.color, {
|
|
222
237
|
start: monaco2protocol.asPosition(model.getPositionAt(0)),
|
|
223
238
|
end: monaco2protocol.asPosition(model.getPositionAt(model.getValueLength())),
|
|
224
|
-
}
|
|
239
|
+
});
|
|
225
240
|
if (codeColors) {
|
|
226
241
|
return codeColors.map(protocol2monaco.asColorPresentation);
|
|
227
242
|
}
|
|
228
243
|
}
|
|
229
244
|
},
|
|
230
|
-
async provideFoldingRanges(model, _context
|
|
245
|
+
async provideFoldingRanges(model, _context) {
|
|
231
246
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
232
|
-
const codeResult = await languageService.getFoldingRanges(model.uri.toString()
|
|
247
|
+
const codeResult = await languageService.getFoldingRanges(model.uri.toString());
|
|
233
248
|
if (codeResult) {
|
|
234
249
|
return codeResult.map(protocol2monaco.asFoldingRange);
|
|
235
250
|
}
|
|
236
251
|
},
|
|
237
|
-
async provideDeclaration(model, position
|
|
252
|
+
async provideDeclaration(model, position) {
|
|
238
253
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
239
|
-
const codeResult = await languageService.findDefinition(model.uri.toString(), monaco2protocol.asPosition(position)
|
|
254
|
+
const codeResult = await languageService.findDefinition(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
240
255
|
if (codeResult) {
|
|
241
256
|
return codeResult.map(protocol2monaco.asLocation);
|
|
242
257
|
}
|
|
243
258
|
},
|
|
244
|
-
async provideSelectionRanges(model, positions
|
|
259
|
+
async provideSelectionRanges(model, positions) {
|
|
245
260
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
246
|
-
const codeResults = await Promise.all(positions.map((position) => languageService.getSelectionRanges(model.uri.toString(), [monaco2protocol.asPosition(position)]
|
|
261
|
+
const codeResults = await Promise.all(positions.map((position) => languageService.getSelectionRanges(model.uri.toString(), [monaco2protocol.asPosition(position)])));
|
|
247
262
|
return codeResults.map((codeResult) => codeResult?.map(protocol2monaco.asSelectionRange) ?? []);
|
|
248
263
|
},
|
|
249
|
-
async provideSignatureHelp(model, position,
|
|
264
|
+
async provideSignatureHelp(model, position, _token, context) {
|
|
250
265
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
251
|
-
const codeResult = await languageService.getSignatureHelp(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asSignatureHelpContext(context)
|
|
266
|
+
const codeResult = await languageService.getSignatureHelp(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asSignatureHelpContext(context));
|
|
252
267
|
if (codeResult) {
|
|
253
268
|
return {
|
|
254
269
|
value: protocol2monaco.asSignatureHelp(codeResult),
|
|
@@ -256,33 +271,46 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
256
271
|
};
|
|
257
272
|
}
|
|
258
273
|
},
|
|
259
|
-
async provideRenameEdits(model, position, newName
|
|
274
|
+
async provideRenameEdits(model, position, newName) {
|
|
260
275
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
261
|
-
const codeResult = await languageService.doRename(model.uri.toString(), monaco2protocol.asPosition(position), newName
|
|
276
|
+
const codeResult = await languageService.doRename(model.uri.toString(), monaco2protocol.asPosition(position), newName);
|
|
262
277
|
if (codeResult) {
|
|
263
278
|
return protocol2monaco.asWorkspaceEdit(codeResult);
|
|
264
279
|
}
|
|
265
280
|
},
|
|
266
|
-
async provideReferences(model, position, _context
|
|
281
|
+
async provideReferences(model, position, _context) {
|
|
267
282
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
268
|
-
const codeResult = await languageService.findReferences(model.uri.toString(), monaco2protocol.asPosition(position)
|
|
283
|
+
const codeResult = await languageService.findReferences(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
269
284
|
if (codeResult) {
|
|
270
285
|
return codeResult.map(protocol2monaco.asLocation);
|
|
271
286
|
}
|
|
272
287
|
},
|
|
273
|
-
async provideInlayHints(model, range
|
|
288
|
+
async provideInlayHints(model, range) {
|
|
274
289
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
275
|
-
const codeResult = await languageService.getInlayHints(model.uri.toString(), monaco2protocol.asRange(range)
|
|
290
|
+
const codeResult = await languageService.getInlayHints(model.uri.toString(), monaco2protocol.asRange(range));
|
|
276
291
|
if (codeResult) {
|
|
277
292
|
return {
|
|
278
|
-
hints: codeResult.map(
|
|
293
|
+
hints: codeResult.map(hint => {
|
|
294
|
+
const monacoHint = protocol2monaco.asInlayHint(hint);
|
|
295
|
+
inlayHints.set(monacoHint, hint);
|
|
296
|
+
return monacoHint;
|
|
297
|
+
}),
|
|
279
298
|
dispose: () => { },
|
|
280
299
|
};
|
|
281
300
|
}
|
|
282
301
|
},
|
|
283
|
-
async
|
|
302
|
+
async resolveInlayHint(hint) {
|
|
303
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
304
|
+
const codeHint = inlayHints.get(hint);
|
|
305
|
+
if (codeHint) {
|
|
306
|
+
const resolvedCodeHint = await languageService.doInlayHintResolve(codeHint);
|
|
307
|
+
return protocol2monaco.asInlayHint(resolvedCodeHint);
|
|
308
|
+
}
|
|
309
|
+
return hint;
|
|
310
|
+
},
|
|
311
|
+
async provideHover(model, position) {
|
|
284
312
|
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
285
|
-
const codeResult = await languageService.doHover(model.uri.toString(), monaco2protocol.asPosition(position)
|
|
313
|
+
const codeResult = await languageService.doHover(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
286
314
|
if (codeResult) {
|
|
287
315
|
return protocol2monaco.asHover(codeResult);
|
|
288
316
|
}
|
package/out/worker.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.createDtsHost = exports.createLanguageService = void 0;
|
|
3
4
|
const language_service_1 = require("@volar/language-service");
|
|
4
5
|
const vscode_uri_1 = require("vscode-uri");
|
|
5
6
|
function createLanguageService(options) {
|
|
7
|
+
const ts = options.typescript?.module;
|
|
6
8
|
const dtsFiles = new Map();
|
|
7
|
-
const ts = options.typescript ? options.typescript.module : undefined;
|
|
8
9
|
const config = options.config ?? {};
|
|
9
10
|
const compilerOptions = options.typescript?.compilerOptions ?? {};
|
|
10
11
|
let host = createLanguageServiceHost();
|
|
11
12
|
let languageService = (0, language_service_1.createLanguageService)({
|
|
13
|
+
modules: { typescript: ts },
|
|
12
14
|
host,
|
|
13
15
|
config,
|
|
14
16
|
uriToFileName: (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/'),
|
|
@@ -39,6 +41,7 @@ function createLanguageService(options) {
|
|
|
39
41
|
dtsVersion = newVersion;
|
|
40
42
|
languageService.dispose();
|
|
41
43
|
languageService = (0, language_service_1.createLanguageService)({
|
|
44
|
+
modules: { typescript: ts },
|
|
42
45
|
host,
|
|
43
46
|
config,
|
|
44
47
|
rootUri: vscode_uri_1.URI.file('/'),
|
|
@@ -142,7 +145,6 @@ function createLanguageService(options) {
|
|
|
142
145
|
}
|
|
143
146
|
return readDtsFile(fileName) !== undefined;
|
|
144
147
|
},
|
|
145
|
-
getTypeScriptModule: ts ? (() => ts) : undefined,
|
|
146
148
|
};
|
|
147
149
|
return host;
|
|
148
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/monaco",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.10",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"directory": "packages/monaco"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@volar/language-service": "1.4.0-alpha.
|
|
18
|
+
"@volar/language-service": "1.4.0-alpha.10",
|
|
19
19
|
"monaco-editor-core": "^0.36.0",
|
|
20
20
|
"vscode-languageserver-protocol": "^3.17.3",
|
|
21
21
|
"vscode-uri": "^3.0.7"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "715bc5f17a0d1cadd4190712dcaff732989eb330"
|
|
24
24
|
}
|