@volar/language-service 2.4.0 → 2.4.2

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.
@@ -52,15 +52,20 @@ function register(context) {
52
52
  diagnostics,
53
53
  }, token);
54
54
  codeActions?.forEach(codeAction => {
55
- codeAction.data = {
56
- uri: uri.toString(),
57
- version: document.version,
58
- original: {
59
- data: codeAction.data,
60
- edit: codeAction.edit,
61
- },
62
- pluginIndex: context.plugins.indexOf(plugin),
63
- };
55
+ if (plugin[1].resolveCodeAction) {
56
+ codeAction.data = {
57
+ uri: uri.toString(),
58
+ version: document.version,
59
+ original: {
60
+ data: codeAction.data,
61
+ edit: codeAction.edit,
62
+ },
63
+ pluginIndex: context.plugins.indexOf(plugin),
64
+ };
65
+ }
66
+ else {
67
+ delete codeAction.data;
68
+ }
64
69
  });
65
70
  if (codeActions && plugin[1].transformCodeAction) {
66
71
  for (let i = 0; i < codeActions.length; i++) {
@@ -13,14 +13,19 @@ function register(context) {
13
13
  let codeLens = await plugin[1].provideCodeLenses?.(document, token);
14
14
  const pluginIndex = context.plugins.indexOf(plugin);
15
15
  codeLens?.forEach(codeLens => {
16
- codeLens.data = {
17
- kind: 'normal',
18
- uri: uri.toString(),
19
- original: {
20
- data: codeLens.data,
21
- },
22
- pluginIndex,
23
- };
16
+ if (plugin[1].resolveCodeLens) {
17
+ codeLens.data = {
18
+ kind: 'normal',
19
+ uri: uri.toString(),
20
+ original: {
21
+ data: codeLens.data,
22
+ },
23
+ pluginIndex,
24
+ };
25
+ }
26
+ else {
27
+ delete codeLens.data;
28
+ }
24
29
  });
25
30
  const ranges = await plugin[1].provideReferencesCodeLensRanges?.(document, token);
26
31
  const referencesCodeLens = ranges?.map(range => ({
@@ -52,16 +52,21 @@ function register(context) {
52
52
  continue;
53
53
  }
54
54
  for (const item of cacheData.list.items) {
55
- item.data = {
56
- uri: uri.toString(),
57
- original: {
58
- additionalTextEdits: item.additionalTextEdits,
59
- textEdit: item.textEdit,
60
- data: item.data,
61
- },
62
- pluginIndex: pluginIndex,
63
- embeddedDocumentUri: embeddedDocument.uri,
64
- };
55
+ if (cacheData.plugin.resolveCompletionItem) {
56
+ item.data = {
57
+ uri: uri.toString(),
58
+ original: {
59
+ additionalTextEdits: item.additionalTextEdits,
60
+ textEdit: item.textEdit,
61
+ data: item.data,
62
+ },
63
+ pluginIndex: pluginIndex,
64
+ embeddedDocumentUri: embeddedDocument.uri,
65
+ };
66
+ }
67
+ else {
68
+ delete item.data;
69
+ }
65
70
  }
66
71
  cacheData.list = (0, transform_1.transformCompletionList)(cacheData.list, range => (0, featureWorkers_1.getSourceRange)(docs, range), embeddedDocument, context);
67
72
  }
@@ -77,16 +82,21 @@ function register(context) {
77
82
  continue;
78
83
  }
79
84
  for (const item of cacheData.list.items) {
80
- item.data = {
81
- uri: uri.toString(),
82
- original: {
83
- additionalTextEdits: item.additionalTextEdits,
84
- textEdit: item.textEdit,
85
- data: item.data,
86
- },
87
- pluginIndex: pluginIndex,
88
- embeddedDocumentUri: undefined,
89
- };
85
+ if (cacheData.plugin.resolveCompletionItem) {
86
+ item.data = {
87
+ uri: uri.toString(),
88
+ original: {
89
+ additionalTextEdits: item.additionalTextEdits,
90
+ textEdit: item.textEdit,
91
+ data: item.data,
92
+ },
93
+ pluginIndex: pluginIndex,
94
+ embeddedDocumentUri: undefined,
95
+ };
96
+ }
97
+ else {
98
+ delete item.data;
99
+ }
90
100
  }
91
101
  }
92
102
  }
@@ -136,16 +146,21 @@ function register(context) {
136
146
  }
137
147
  const pluginIndex = context.plugins.indexOf(plugin);
138
148
  for (const item of completionList.items) {
139
- item.data = {
140
- uri: uri.toString(),
141
- original: {
142
- additionalTextEdits: item.additionalTextEdits,
143
- textEdit: item.textEdit,
144
- data: item.data,
145
- },
146
- pluginIndex,
147
- embeddedDocumentUri: docs ? document.uri : undefined,
148
- };
149
+ if (plugin[1].resolveCompletionItem) {
150
+ item.data = {
151
+ uri: uri.toString(),
152
+ original: {
153
+ additionalTextEdits: item.additionalTextEdits,
154
+ textEdit: item.textEdit,
155
+ data: item.data,
156
+ },
157
+ pluginIndex,
158
+ embeddedDocumentUri: docs ? document.uri : undefined,
159
+ };
160
+ }
161
+ else {
162
+ delete item.data;
163
+ }
149
164
  }
150
165
  if (docs) {
151
166
  completionList = (0, transform_1.transformCompletionList)(completionList, range => (0, featureWorkers_1.getSourceRange)(docs, range, language_core_1.isCompletionEnabled), document, context);
@@ -1,4 +1,3 @@
1
- import { type CodeInformation } from '@volar/language-core';
2
1
  import type * as vscode from 'vscode-languageserver-protocol';
3
2
  import { URI } from 'vscode-uri';
4
3
  import type { LanguageServiceContext } from '../types';
@@ -16,7 +15,7 @@ export declare const errorMarkups: Map<URI, {
16
15
  markup: vscode.MarkupContent;
17
16
  }[]>;
18
17
  export declare function register(context: LanguageServiceContext): (uri: URI, response?: (result: vscode.Diagnostic[]) => void, token?: vscode.CancellationToken) => Promise<vscode.Diagnostic[]>;
19
- export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic, docs: DocumentsAndMap | undefined, filter: (data: CodeInformation) => boolean): vscode.Diagnostic | undefined;
18
+ export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic, docs: DocumentsAndMap | undefined): vscode.Diagnostic | undefined;
20
19
  export declare function updateRange(range: vscode.Range, change: {
21
20
  range: vscode.Range;
22
21
  newEnd: vscode.Position;
@@ -118,7 +118,7 @@ function register(context) {
118
118
  return errors;
119
119
  }, (errors, map) => {
120
120
  return errors
121
- .map(error => transformDiagnostic(context, error, map, language_core_1.shouldReportDiagnostics))
121
+ .map(error => transformDiagnostic(context, error, map))
122
122
  .filter(error => !!error);
123
123
  }, arr => dedupe.withDiagnostics(arr.flat()));
124
124
  if (result) {
@@ -128,11 +128,11 @@ function register(context) {
128
128
  }
129
129
  };
130
130
  }
131
- function transformDiagnostic(context, error, docs, filter) {
131
+ function transformDiagnostic(context, error, docs) {
132
132
  // clone it to avoid modify cache
133
133
  let _error = { ...error };
134
134
  if (docs) {
135
- const range = (0, featureWorkers_1.getSourceRange)(docs, error.range, filter);
135
+ const range = (0, featureWorkers_1.getSourceRange)(docs, error.range, data => (0, language_core_1.shouldReportDiagnostics)(data, error.source, error.code));
136
136
  if (!range) {
137
137
  return;
138
138
  }
@@ -149,7 +149,7 @@ function transformDiagnostic(context, error, docs, filter) {
149
149
  for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
150
150
  const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
151
151
  const docs = [sourceDocument, embeddedDocument, map];
152
- const range = (0, featureWorkers_1.getSourceRange)(docs, info.location.range, filter);
152
+ const range = (0, featureWorkers_1.getSourceRange)(docs, info.location.range, data => (0, language_core_1.shouldReportDiagnostics)(data, undefined, undefined));
153
153
  if (range) {
154
154
  relatedInfos.push({
155
155
  location: {
@@ -13,13 +13,18 @@ function register(context) {
13
13
  }
14
14
  const links = await plugin[1].provideDocumentLinks?.(document, token);
15
15
  for (const link of links ?? []) {
16
- link.data = {
17
- uri: uri.toString(),
18
- original: {
19
- data: link.data,
20
- },
21
- pluginIndex: context.plugins.indexOf(plugin),
22
- };
16
+ if (plugin[1].resolveDocumentLink) {
17
+ link.data = {
18
+ uri: uri.toString(),
19
+ original: {
20
+ data: link.data,
21
+ },
22
+ pluginIndex: context.plugins.indexOf(plugin),
23
+ };
24
+ }
25
+ else {
26
+ delete link.data;
27
+ }
23
28
  }
24
29
  return links;
25
30
  }, (links, docs) => {
@@ -26,13 +26,18 @@ function register(context) {
26
26
  }
27
27
  const hints = await plugin[1].provideInlayHints?.(document, arg, token);
28
28
  hints?.forEach(link => {
29
- link.data = {
30
- uri: uri.toString(),
31
- original: {
32
- data: link.data,
33
- },
34
- pluginIndex: context.plugins.indexOf(plugin),
35
- };
29
+ if (plugin[1].resolveInlayHint) {
30
+ link.data = {
31
+ uri: uri.toString(),
32
+ original: {
33
+ data: link.data,
34
+ },
35
+ pluginIndex: context.plugins.indexOf(plugin),
36
+ };
37
+ }
38
+ else {
39
+ delete link.data;
40
+ }
36
41
  });
37
42
  return hints;
38
43
  }, (inlayHints, docs) => {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.register = register;
4
- const language_core_1 = require("@volar/language-core");
5
4
  const vscode_uri_1 = require("vscode-uri");
6
5
  const cancellation_1 = require("../utils/cancellation");
7
6
  const provideDiagnostics_1 = require("./provideDiagnostics");
@@ -44,7 +43,7 @@ function register(context) {
44
43
  return {
45
44
  ...item,
46
45
  items: item.items
47
- .map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, docs, language_core_1.shouldReportDiagnostics))
46
+ .map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, docs))
48
47
  .filter(error => !!error)
49
48
  };
50
49
  }
@@ -56,7 +55,7 @@ function register(context) {
56
55
  return {
57
56
  ...item,
58
57
  items: item.items
59
- .map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, undefined, language_core_1.shouldReportDiagnostics))
58
+ .map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, undefined))
60
59
  .filter(error => !!error)
61
60
  };
62
61
  }
@@ -44,12 +44,17 @@ function register(context) {
44
44
  }))
45
45
  .filter(symbol => !!symbol);
46
46
  symbols?.forEach(symbol => {
47
- symbol.data = {
48
- original: {
49
- data: symbol.data,
50
- },
51
- pluginIndex: context.plugins.indexOf(plugin),
52
- };
47
+ if (plugin[1].resolveWorkspaceSymbol) {
48
+ symbol.data = {
49
+ original: {
50
+ data: symbol.data,
51
+ },
52
+ pluginIndex: context.plugins.indexOf(plugin),
53
+ };
54
+ }
55
+ else {
56
+ delete symbol.data;
57
+ }
53
58
  });
54
59
  symbolsList.push(symbols);
55
60
  }
@@ -9,6 +9,7 @@ function register(context) {
9
9
  if (data) {
10
10
  const plugin = context.plugins[data.pluginIndex];
11
11
  if (!plugin[1].resolveCodeAction) {
12
+ delete item.data;
12
13
  return item;
13
14
  }
14
15
  Object.assign(item, data.original);
@@ -21,6 +22,7 @@ function register(context) {
21
22
  }
22
23
  : item);
23
24
  }
25
+ delete item.data;
24
26
  return item;
25
27
  };
26
28
  }
@@ -11,16 +11,18 @@ function register(context) {
11
11
  if (data?.kind === 'normal') {
12
12
  const plugin = context.plugins[data.pluginIndex];
13
13
  if (!plugin[1].resolveCodeLens) {
14
+ delete item.data;
14
15
  return item;
15
16
  }
16
17
  Object.assign(item, data.original);
17
18
  item = await plugin[1].resolveCodeLens(item, token);
18
19
  // item.range already transformed in codeLens request
19
20
  }
20
- if (data?.kind === 'references') {
21
+ else if (data?.kind === 'references') {
21
22
  const references = await findReferences(vscode_uri_1.URI.parse(data.sourceFileUri), item.range.start, { includeDeclaration: false }, token) ?? [];
22
23
  item.command = context.commands.showReferences.create(data.sourceFileUri, item.range.start, references);
23
24
  }
25
+ delete item.data;
24
26
  return item;
25
27
  };
26
28
  }
@@ -11,6 +11,7 @@ function register(context) {
11
11
  if (data) {
12
12
  const plugin = context.plugins[data.pluginIndex];
13
13
  if (!plugin[1].resolveCompletionItem) {
14
+ delete item.data;
14
15
  return item;
15
16
  }
16
17
  item = Object.assign(item, data.original);
@@ -36,6 +37,7 @@ function register(context) {
36
37
  if (item.detail !== item.detail + '.ts') {
37
38
  item.detail = item.detail;
38
39
  }
40
+ delete item.data;
39
41
  return item;
40
42
  };
41
43
  }
@@ -9,6 +9,7 @@ function register(context) {
9
9
  if (data) {
10
10
  const plugin = context.plugins[data.pluginIndex];
11
11
  if (!plugin[1].resolveDocumentLink) {
12
+ delete item.data;
12
13
  return item;
13
14
  }
14
15
  Object.assign(item, data.original);
@@ -17,6 +18,7 @@ function register(context) {
17
18
  item.target = (0, transform_1.transformDocumentLinkTarget)(item.target, context).toString();
18
19
  }
19
20
  }
21
+ delete item.data;
20
22
  return item;
21
23
  };
22
24
  }
@@ -8,11 +8,13 @@ function register(context) {
8
8
  if (data) {
9
9
  const plugin = context.plugins[data.pluginIndex];
10
10
  if (!plugin[1].resolveInlayHint) {
11
+ delete item.data;
11
12
  return item;
12
13
  }
13
14
  Object.assign(item, data.original);
14
15
  item = await plugin[1].resolveInlayHint(item, token);
15
16
  }
17
+ delete item.data;
16
18
  return item;
17
19
  };
18
20
  }
@@ -1,3 +1,3 @@
1
1
  import type * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServiceContext } from '../types';
3
- export declare function register(context: LanguageServiceContext): (symbol: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
3
+ export declare function register(context: LanguageServiceContext): (item: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
@@ -3,17 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.register = register;
4
4
  const cancellation_1 = require("../utils/cancellation");
5
5
  function register(context) {
6
- return async (symbol, token = cancellation_1.NoneCancellationToken) => {
7
- const data = symbol.data;
6
+ return async (item, token = cancellation_1.NoneCancellationToken) => {
7
+ const data = item.data;
8
8
  if (data) {
9
9
  const plugin = context.plugins[data.pluginIndex];
10
10
  if (!plugin[1].resolveWorkspaceSymbol) {
11
- return symbol;
11
+ delete item.data;
12
+ return item;
12
13
  }
13
- Object.assign(symbol, data.original);
14
- symbol = await plugin[1].resolveWorkspaceSymbol(symbol, token);
14
+ Object.assign(item, data.original);
15
+ item = await plugin[1].resolveWorkspaceSymbol(item, token);
15
16
  }
16
- return symbol;
17
+ delete item.data;
18
+ return item;
17
19
  };
18
20
  }
19
21
  //# sourceMappingURL=resolveWorkspaceSymbol.js.map
@@ -72,7 +72,7 @@ export declare function createLanguageService(language: Language<URI>, plugins:
72
72
  resolveCodeLens: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
73
73
  resolveDocumentLink: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
74
74
  resolveInlayHint: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
75
- resolveWorkspaceSymbol: (symbol: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
75
+ resolveWorkspaceSymbol: (item: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
76
76
  };
77
77
  export declare function decodeEmbeddedDocumentUri(maybeEmbeddedContentUri: URI): [
78
78
  documentUri: URI,
@@ -147,6 +147,6 @@ declare function createLanguageServiceBase(plugins: LanguageServicePlugin[], con
147
147
  resolveCodeLens: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
148
148
  resolveDocumentLink: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
149
149
  resolveInlayHint: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
150
- resolveWorkspaceSymbol: (symbol: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
150
+ resolveWorkspaceSymbol: (item: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
151
151
  };
152
152
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-service",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,10 +12,10 @@
12
12
  "directory": "packages/language-service"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "2.4.0",
15
+ "@volar/language-core": "2.4.2",
16
16
  "vscode-languageserver-protocol": "^3.17.5",
17
17
  "vscode-languageserver-textdocument": "^1.0.11",
18
18
  "vscode-uri": "^3.0.8"
19
19
  },
20
- "gitHead": "7e98885cfe284451e655cf1c3954786b51aea2f8"
20
+ "gitHead": "f384d55ef4ae21e9f9a6796c9676a4a710458ed9"
21
21
  }