@volar/monaco 1.4.0-alpha.9 → 1.4.1

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.
@@ -10,6 +10,8 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
10
10
  const codeLens = new WeakMap();
11
11
  const codeActions = new WeakMap();
12
12
  const colorInfos = new WeakMap();
13
+ const documentLinks = new WeakMap();
14
+ const inlayHints = new WeakMap();
13
15
  const languageService = await worker.getProxy();
14
16
  return {
15
17
  triggerCharacters: await languageService.triggerCharacters(),
@@ -178,10 +180,22 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
178
180
  const codeResult = await languageService.findDocumentLinks(model.uri.toString());
179
181
  if (codeResult) {
180
182
  return {
181
- links: codeResult.map(protocol2monaco.asLink),
183
+ links: codeResult.map(link => {
184
+ const monacoLink = protocol2monaco.asLink(link);
185
+ documentLinks.set(monacoLink, link);
186
+ return monacoLink;
187
+ }),
182
188
  };
183
189
  }
184
190
  },
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
+ },
185
199
  async provideCompletionItems(model, position, context) {
186
200
  const languageService = await worker.withSyncedResources(getSyncUris());
187
201
  const codeResult = await languageService.doComplete(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asCompletionContext(context));
@@ -276,11 +290,24 @@ async function createLanguageFeaturesProvider(worker, getSyncUris) {
276
290
  const codeResult = await languageService.getInlayHints(model.uri.toString(), monaco2protocol.asRange(range));
277
291
  if (codeResult) {
278
292
  return {
279
- hints: codeResult.map(protocol2monaco.asInlayHint),
293
+ hints: codeResult.map(hint => {
294
+ const monacoHint = protocol2monaco.asInlayHint(hint);
295
+ inlayHints.set(monacoHint, hint);
296
+ return monacoHint;
297
+ }),
280
298
  dispose: () => { },
281
299
  };
282
300
  }
283
301
  },
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
+ },
284
311
  async provideHover(model, position) {
285
312
  const languageService = await worker.withSyncedResources(getSyncUris());
286
313
  const codeResult = await languageService.doHover(model.uri.toString(), monaco2protocol.asPosition(position));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/monaco",
3
- "version": "1.4.0-alpha.9",
3
+ "version": "1.4.1",
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.9",
18
+ "@volar/language-service": "1.4.1",
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": "d3993bafc6a8fac5ab34cee2ab5d682a5b405831"
23
+ "gitHead": "2c8a783542ace3292649a04490919b515e387b9e"
24
24
  }