@volar/language-service 1.2.0-alpha.1 → 1.2.0-alpha.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.
- package/out/languageFeatures/callHierarchy.d.ts +1 -1
- package/out/languageFeatures/callHierarchy.js +5 -3
- package/out/languageFeatures/codeActionResolve.js +1 -1
- package/out/languageFeatures/codeActions.d.ts +1 -1
- package/out/languageFeatures/codeActions.js +4 -2
- package/out/languageFeatures/codeLens.d.ts +1 -1
- package/out/languageFeatures/codeLens.js +3 -1
- package/out/languageFeatures/codeLensResolve.js +1 -1
- package/out/languageFeatures/complete.d.ts +1 -1
- package/out/languageFeatures/complete.js +20 -4
- package/out/languageFeatures/completeResolve.js +1 -1
- package/out/languageFeatures/validation.d.ts +1 -1
- package/out/languageFeatures/validation.js +6 -2
- package/package.json +6 -6
- package/out/languageFeatures/validation copy.d.ts +0 -7
- package/out/languageFeatures/validation copy.js +0 -234
|
@@ -2,7 +2,7 @@ import type * as vscode from 'vscode-languageserver-protocol';
|
|
|
2
2
|
import type { LanguageServiceRuntimeContext } from '../types';
|
|
3
3
|
export interface PluginCallHierarchyData {
|
|
4
4
|
uri: string;
|
|
5
|
-
|
|
5
|
+
original: Pick<vscode.CallHierarchyItem, 'data'>;
|
|
6
6
|
pluginId: string;
|
|
7
7
|
map: {
|
|
8
8
|
embeddedDocumentUri: string;
|
|
@@ -22,7 +22,9 @@ function register(context) {
|
|
|
22
22
|
items === null || items === void 0 ? void 0 : items.forEach(item => {
|
|
23
23
|
item.data = {
|
|
24
24
|
uri,
|
|
25
|
-
|
|
25
|
+
original: {
|
|
26
|
+
data: item.data,
|
|
27
|
+
},
|
|
26
28
|
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
27
29
|
map: map ? {
|
|
28
30
|
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
@@ -42,7 +44,7 @@ function register(context) {
|
|
|
42
44
|
const plugin = context.plugins[data.pluginId];
|
|
43
45
|
if (!plugin.callHierarchy)
|
|
44
46
|
return incomingItems;
|
|
45
|
-
item
|
|
47
|
+
Object.assign(item, data.original);
|
|
46
48
|
if (data.map) {
|
|
47
49
|
if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
|
|
48
50
|
const _calls = yield plugin.callHierarchy.onIncomingCalls(item);
|
|
@@ -81,7 +83,7 @@ function register(context) {
|
|
|
81
83
|
const plugin = context.plugins[data.pluginId];
|
|
82
84
|
if (!plugin.callHierarchy)
|
|
83
85
|
return items;
|
|
84
|
-
item
|
|
86
|
+
Object.assign(item, data.original);
|
|
85
87
|
if (data.map) {
|
|
86
88
|
if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
|
|
87
89
|
const _calls = yield plugin.callHierarchy.onOutgoingCalls(item);
|
|
@@ -18,7 +18,7 @@ function register(context) {
|
|
|
18
18
|
const plugin = context.plugins[data.pluginId];
|
|
19
19
|
if (!((_a = plugin.codeAction) === null || _a === void 0 ? void 0 : _a.resolve))
|
|
20
20
|
return item;
|
|
21
|
-
item
|
|
21
|
+
Object.assign(item, data.original);
|
|
22
22
|
if (data.map) {
|
|
23
23
|
if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
|
|
24
24
|
const resolvedItem = yield ((_b = plugin.codeAction) === null || _b === void 0 ? void 0 : _b.resolve(item));
|
|
@@ -2,7 +2,7 @@ import * as vscode from 'vscode-languageserver-protocol';
|
|
|
2
2
|
import type { LanguageServiceRuntimeContext } from '../types';
|
|
3
3
|
export interface PluginCodeActionData {
|
|
4
4
|
uri: string;
|
|
5
|
-
|
|
5
|
+
original: Pick<vscode.CodeAction, 'data'>;
|
|
6
6
|
pluginId: string;
|
|
7
7
|
map: {
|
|
8
8
|
embeddedDocumentUri: string;
|
|
@@ -61,13 +61,15 @@ function register(context) {
|
|
|
61
61
|
return (data === null || data === void 0 ? void 0 : data.type) === 'plugin' && (data === null || data === void 0 ? void 0 : data.pluginOrRuleId) === pluginId;
|
|
62
62
|
}).map(diagnostic => {
|
|
63
63
|
const data = diagnostic.data;
|
|
64
|
-
return Object.assign(Object.assign({}, diagnostic),
|
|
64
|
+
return Object.assign(Object.assign({}, diagnostic), data.original);
|
|
65
65
|
});
|
|
66
66
|
const codeActions = yield ((_b = (_a = plugin.codeAction) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, document, range, Object.assign(Object.assign({}, codeActionContext), { diagnostics })));
|
|
67
67
|
return codeActions === null || codeActions === void 0 ? void 0 : codeActions.map(_codeAction => {
|
|
68
68
|
return Object.assign(Object.assign({}, _codeAction), { data: {
|
|
69
69
|
uri,
|
|
70
|
-
|
|
70
|
+
original: {
|
|
71
|
+
data: _codeAction.data,
|
|
72
|
+
},
|
|
71
73
|
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
72
74
|
map: map ? {
|
|
73
75
|
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
@@ -2,7 +2,7 @@ import type { LanguageServiceRuntimeContext } from '../types';
|
|
|
2
2
|
import type * as _ from 'vscode-languageserver-protocol';
|
|
3
3
|
export interface PluginCodeLensData {
|
|
4
4
|
uri: string;
|
|
5
|
-
|
|
5
|
+
original: Pick<_.CodeLens, 'data'>;
|
|
6
6
|
pluginId: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function register(context: LanguageServiceRuntimeContext): (uri: string) => Promise<_.CodeLens[]>;
|
|
@@ -18,7 +18,7 @@ function register(context) {
|
|
|
18
18
|
const plugin = context.plugins[data.pluginId];
|
|
19
19
|
if (!((_a = plugin.codeLens) === null || _a === void 0 ? void 0 : _a.resolve))
|
|
20
20
|
return item;
|
|
21
|
-
item
|
|
21
|
+
Object.assign(item, data.original);
|
|
22
22
|
item = yield plugin.codeLens.resolve(item);
|
|
23
23
|
if (item.command) {
|
|
24
24
|
item.command = {
|
|
@@ -2,7 +2,7 @@ import * as vscode from 'vscode-languageserver-protocol';
|
|
|
2
2
|
import type { LanguageServiceRuntimeContext } from '../types';
|
|
3
3
|
export interface PluginCompletionData {
|
|
4
4
|
uri: string;
|
|
5
|
-
|
|
5
|
+
original: Pick<vscode.CompletionItem, 'additionalTextEdits' | 'textEdit' | 'data'>;
|
|
6
6
|
pluginId: string;
|
|
7
7
|
map: {
|
|
8
8
|
embeddedDocumentUri: string;
|
|
@@ -34,7 +34,11 @@ function register(context) {
|
|
|
34
34
|
}
|
|
35
35
|
cacheData.list = transformer.asCompletionList(embeddedCompletionList, range => map.toSourceRange(range), map.virtualFileDocument, (newItem, oldItem) => newItem.data = {
|
|
36
36
|
uri,
|
|
37
|
-
|
|
37
|
+
original: {
|
|
38
|
+
additionalTextEdits: oldItem.additionalTextEdits,
|
|
39
|
+
textEdit: oldItem.textEdit,
|
|
40
|
+
data: oldItem.data,
|
|
41
|
+
},
|
|
38
42
|
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === cacheData.plugin),
|
|
39
43
|
map: {
|
|
40
44
|
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
@@ -54,7 +58,11 @@ function register(context) {
|
|
|
54
58
|
completionList.items.forEach(item => {
|
|
55
59
|
item.data = {
|
|
56
60
|
uri,
|
|
57
|
-
|
|
61
|
+
original: {
|
|
62
|
+
additionalTextEdits: item.additionalTextEdits,
|
|
63
|
+
textEdit: item.textEdit,
|
|
64
|
+
data: item.data,
|
|
65
|
+
},
|
|
58
66
|
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === cacheData.plugin),
|
|
59
67
|
map: undefined,
|
|
60
68
|
};
|
|
@@ -104,7 +112,11 @@ function register(context) {
|
|
|
104
112
|
}
|
|
105
113
|
const completionList = transformer.asCompletionList(embeddedCompletionList, range => map.toSourceRange(range), map.virtualFileDocument, (newItem, oldItem) => newItem.data = {
|
|
106
114
|
uri,
|
|
107
|
-
|
|
115
|
+
original: {
|
|
116
|
+
additionalTextEdits: oldItem.additionalTextEdits,
|
|
117
|
+
textEdit: oldItem.textEdit,
|
|
118
|
+
data: oldItem.data,
|
|
119
|
+
},
|
|
108
120
|
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
109
121
|
map: {
|
|
110
122
|
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
@@ -146,7 +158,11 @@ function register(context) {
|
|
|
146
158
|
completionList.items.forEach(item => {
|
|
147
159
|
item.data = {
|
|
148
160
|
uri,
|
|
149
|
-
|
|
161
|
+
original: {
|
|
162
|
+
additionalTextEdits: item.additionalTextEdits,
|
|
163
|
+
textEdit: item.textEdit,
|
|
164
|
+
data: item.data,
|
|
165
|
+
},
|
|
150
166
|
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
151
167
|
map: undefined,
|
|
152
168
|
};
|
|
@@ -18,7 +18,7 @@ function register(context) {
|
|
|
18
18
|
const plugin = context.plugins[data.pluginId];
|
|
19
19
|
if (!((_a = plugin.complete) === null || _a === void 0 ? void 0 : _a.resolve))
|
|
20
20
|
return item;
|
|
21
|
-
item
|
|
21
|
+
item = Object.assign(item, data.original);
|
|
22
22
|
if (data.map) {
|
|
23
23
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
24
24
|
const resolvedItem = yield plugin.complete.resolve(item);
|
|
@@ -6,7 +6,7 @@ export declare function updateRange(range: vscode.Range, change: {
|
|
|
6
6
|
}): vscode.Range | undefined;
|
|
7
7
|
export interface PluginDiagnosticData {
|
|
8
8
|
uri: string;
|
|
9
|
-
|
|
9
|
+
original: Pick<vscode.Diagnostic, 'data'>;
|
|
10
10
|
type: 'plugin' | 'rule';
|
|
11
11
|
pluginOrRuleId: string;
|
|
12
12
|
}
|
|
@@ -195,7 +195,9 @@ function register(context) {
|
|
|
195
195
|
uri,
|
|
196
196
|
type: 'rule',
|
|
197
197
|
pluginOrRuleId: ruleCtx.ruleId,
|
|
198
|
-
|
|
198
|
+
original: {
|
|
199
|
+
data: error.data,
|
|
200
|
+
},
|
|
199
201
|
};
|
|
200
202
|
});
|
|
201
203
|
errorsUpdated = true;
|
|
@@ -249,7 +251,9 @@ function register(context) {
|
|
|
249
251
|
uri,
|
|
250
252
|
type: 'plugin',
|
|
251
253
|
pluginOrRuleId: pluginId,
|
|
252
|
-
|
|
254
|
+
original: {
|
|
255
|
+
data: error.data,
|
|
256
|
+
},
|
|
253
257
|
};
|
|
254
258
|
});
|
|
255
259
|
errorsUpdated = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.2",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.2.0-alpha.
|
|
17
|
-
"@volar/shared": "1.2.0-alpha.
|
|
18
|
-
"@volar/source-map": "1.2.0-alpha.
|
|
19
|
-
"@volar/typescript-faster": "1.2.0-alpha.
|
|
16
|
+
"@volar/language-core": "1.2.0-alpha.2",
|
|
17
|
+
"@volar/shared": "1.2.0-alpha.2",
|
|
18
|
+
"@volar/source-map": "1.2.0-alpha.2",
|
|
19
|
+
"@volar/typescript-faster": "1.2.0-alpha.2",
|
|
20
20
|
"vscode-html-languageservice": "^5.0.3",
|
|
21
21
|
"vscode-json-languageservice": "^5.1.3",
|
|
22
22
|
"vscode-languageserver-protocol": "^3.17.2",
|
|
23
23
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
24
24
|
"vscode-uri": "^3.0.7"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "cc4da3728cbbc0933c9957c298d0a36090fbedc1"
|
|
27
27
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type { LanguageServiceRuntimeContext } from '../types';
|
|
3
|
-
export declare function updateRange(range: vscode.Range, change: {
|
|
4
|
-
range: vscode.Range;
|
|
5
|
-
newEnd: vscode.Position;
|
|
6
|
-
}): vscode.Range | undefined;
|
|
7
|
-
export declare function register(context: LanguageServiceRuntimeContext): (uri: string, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.register = exports.updateRange = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
|
-
const dedupe = require("../utils/dedupe");
|
|
14
|
-
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
15
|
-
function updateRange(range, change) {
|
|
16
|
-
if (!updatePosition(range.start, change, false)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!updatePosition(range.end, change, true)) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (range.end.line === range.start.line && range.end.character <= range.start.character) {
|
|
23
|
-
range.end.character++;
|
|
24
|
-
}
|
|
25
|
-
return range;
|
|
26
|
-
}
|
|
27
|
-
exports.updateRange = updateRange;
|
|
28
|
-
function updatePosition(position, change, isEnd) {
|
|
29
|
-
if (change.range.end.line > position.line) {
|
|
30
|
-
if (change.newEnd.line > position.line) {
|
|
31
|
-
// No change
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
else if (change.newEnd.line === position.line) {
|
|
35
|
-
position.character = Math.min(position.character, change.newEnd.character);
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
else if (change.newEnd.line < position.line) {
|
|
39
|
-
position.line = change.newEnd.line;
|
|
40
|
-
position.character = change.newEnd.character;
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (change.range.end.line === position.line) {
|
|
45
|
-
const characterDiff = change.newEnd.character - change.range.end.character;
|
|
46
|
-
if (position.character >= change.range.end.character) {
|
|
47
|
-
if (change.newEnd.line !== change.range.end.line) {
|
|
48
|
-
position.line = change.newEnd.line;
|
|
49
|
-
position.character = change.newEnd.character + position.character - change.range.end.character;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
if (isEnd ? change.range.end.character < position.character : change.range.end.character <= position.character) {
|
|
53
|
-
position.character += characterDiff;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
const offset = change.range.end.character - position.character;
|
|
57
|
-
if (-characterDiff > offset) {
|
|
58
|
-
position.character += characterDiff + offset;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
if (change.newEnd.line === change.range.end.line) {
|
|
66
|
-
const offset = change.range.end.character - position.character;
|
|
67
|
-
if (-characterDiff > offset) {
|
|
68
|
-
position.character += characterDiff + offset;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (change.newEnd.line < change.range.end.line) {
|
|
72
|
-
position.line = change.newEnd.line;
|
|
73
|
-
position.character = change.newEnd.character;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// No change
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else if (change.range.end.line < position.line) {
|
|
82
|
-
position.line += change.newEnd.line - change.range.end.line;
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
function register(context) {
|
|
88
|
-
const responseCache = new Map();
|
|
89
|
-
const cacheMaps = {
|
|
90
|
-
semantic: new Map(),
|
|
91
|
-
declaration: new Map(),
|
|
92
|
-
syntactic: new Map(),
|
|
93
|
-
suggestion: new Map(),
|
|
94
|
-
};
|
|
95
|
-
return (uri, token, response) => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
var _a;
|
|
97
|
-
const lastResponse = (_a = responseCache.get(uri)) !== null && _a !== void 0 ? _a : responseCache.set(uri, {
|
|
98
|
-
semantic: { errors: [] },
|
|
99
|
-
declaration: { errors: [] },
|
|
100
|
-
suggestion: { errors: [] },
|
|
101
|
-
syntactic: { errors: [] },
|
|
102
|
-
}).get(uri);
|
|
103
|
-
const newSnapshot = context.host.getScriptSnapshot(shared.uriToFileName(uri));
|
|
104
|
-
const newDocument = context.getTextDocument(uri);
|
|
105
|
-
let updateCacheRangeFailed = false;
|
|
106
|
-
let errorsUpdated = false;
|
|
107
|
-
let lastCheckCancelAt = 0;
|
|
108
|
-
for (const cache of Object.values(lastResponse)) {
|
|
109
|
-
const oldSnapshot = cache.snapshot;
|
|
110
|
-
const oldDocument = cache.document;
|
|
111
|
-
const change = oldSnapshot ? newSnapshot === null || newSnapshot === void 0 ? void 0 : newSnapshot.getChangeRange(oldSnapshot) : undefined;
|
|
112
|
-
cache.snapshot = newSnapshot;
|
|
113
|
-
cache.document = newDocument;
|
|
114
|
-
if (!updateCacheRangeFailed && newDocument && oldSnapshot && oldDocument && newSnapshot && change) {
|
|
115
|
-
const changeRange = {
|
|
116
|
-
range: {
|
|
117
|
-
start: oldDocument.positionAt(change.span.start),
|
|
118
|
-
end: oldDocument.positionAt(change.span.start + change.span.length),
|
|
119
|
-
},
|
|
120
|
-
newEnd: newDocument.positionAt(change.span.start + change.newLength),
|
|
121
|
-
};
|
|
122
|
-
for (const error of cache.errors) {
|
|
123
|
-
if (!updateRange(error.range, changeRange)) {
|
|
124
|
-
updateCacheRangeFailed = true;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
yield worker('onSyntactic', cacheMaps.syntactic, lastResponse.syntactic);
|
|
131
|
-
doResponse();
|
|
132
|
-
yield worker('onSuggestion', cacheMaps.suggestion, lastResponse.suggestion);
|
|
133
|
-
doResponse();
|
|
134
|
-
yield worker('onSemantic', cacheMaps.semantic, lastResponse.semantic);
|
|
135
|
-
doResponse();
|
|
136
|
-
yield worker('onDeclaration', cacheMaps.declaration, lastResponse.declaration);
|
|
137
|
-
return collectErrors();
|
|
138
|
-
function doResponse() {
|
|
139
|
-
if (errorsUpdated && !updateCacheRangeFailed) {
|
|
140
|
-
response === null || response === void 0 ? void 0 : response(collectErrors());
|
|
141
|
-
errorsUpdated = false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function collectErrors() {
|
|
145
|
-
return Object.values(lastResponse).flatMap(({ errors }) => errors);
|
|
146
|
-
}
|
|
147
|
-
function worker(api, cacheMap, cache) {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
const result = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, true, function* (arg, _, file) {
|
|
150
|
-
if (file.capabilities.diagnostic) {
|
|
151
|
-
yield arg;
|
|
152
|
-
}
|
|
153
|
-
}, (plugin, document) => __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
var _a, _b, _c, _d, _e;
|
|
155
|
-
if (token) {
|
|
156
|
-
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
157
|
-
yield shared.sleep(5); // wait for LSP event polling
|
|
158
|
-
lastCheckCancelAt = Date.now();
|
|
159
|
-
}
|
|
160
|
-
if (token.isCancellationRequested)
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const pluginId = context.plugins.indexOf(plugin);
|
|
164
|
-
const pluginCache = (_a = cacheMap.get(pluginId)) !== null && _a !== void 0 ? _a : cacheMap.set(pluginId, new Map()).get(pluginId);
|
|
165
|
-
const cache = pluginCache.get(document.uri);
|
|
166
|
-
const tsProjectVersion = (api === 'onDeclaration' || api === 'onSemantic') ? (_c = (_b = context.core.typescript.languageServiceHost).getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(_b) : undefined;
|
|
167
|
-
if (api === 'onDeclaration' || api === 'onSemantic') {
|
|
168
|
-
if (cache && cache.documentVersion === document.version && cache.tsProjectVersion === tsProjectVersion) {
|
|
169
|
-
return cache.errors;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
if (cache && cache.documentVersion === document.version) {
|
|
174
|
-
return cache.errors;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const errors = yield ((_e = (_d = plugin.validation) === null || _d === void 0 ? void 0 : _d[api]) === null || _e === void 0 ? void 0 : _e.call(_d, document));
|
|
178
|
-
errorsUpdated = true;
|
|
179
|
-
pluginCache.set(document.uri, {
|
|
180
|
-
documentVersion: document.version,
|
|
181
|
-
errors,
|
|
182
|
-
tsProjectVersion,
|
|
183
|
-
});
|
|
184
|
-
return errors;
|
|
185
|
-
}), (errors, map) => transformErrorRange(map, errors), arr => dedupe.withDiagnostics(arr.flat()));
|
|
186
|
-
if (result) {
|
|
187
|
-
cache.errors = result;
|
|
188
|
-
cache.snapshot = newSnapshot;
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
function transformErrorRange(map, errors) {
|
|
194
|
-
const result = [];
|
|
195
|
-
for (const error of errors) {
|
|
196
|
-
// clone it to avoid modify cache
|
|
197
|
-
let _error = Object.assign({}, error);
|
|
198
|
-
if (map) {
|
|
199
|
-
const range = map.toSourceRange(error.range, data => !!data.diagnostic);
|
|
200
|
-
if (!range) {
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
_error.range = range;
|
|
204
|
-
}
|
|
205
|
-
if (_error.relatedInformation) {
|
|
206
|
-
const relatedInfos = [];
|
|
207
|
-
for (const info of _error.relatedInformation) {
|
|
208
|
-
if (context.documents.hasVirtualFileByUri(info.location.uri)) {
|
|
209
|
-
for (const [_, map] of context.documents.getMapsByVirtualFileUri(info.location.uri)) {
|
|
210
|
-
const range = map.toSourceRange(info.location.range, data => !!data.diagnostic);
|
|
211
|
-
if (range) {
|
|
212
|
-
relatedInfos.push({
|
|
213
|
-
location: {
|
|
214
|
-
uri: map.sourceFileDocument.uri,
|
|
215
|
-
range,
|
|
216
|
-
},
|
|
217
|
-
message: info.message,
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
relatedInfos.push(info);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
_error.relatedInformation = relatedInfos;
|
|
227
|
-
}
|
|
228
|
-
result.push(_error);
|
|
229
|
-
}
|
|
230
|
-
return result;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
exports.register = register;
|
|
234
|
-
//# sourceMappingURL=validation%20copy.js.map
|