@vue/language-server 3.0.5 → 3.0.6
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/package.json +7 -7
- package/lib/reactionsAnalyze.d.ts +0 -27
- package/lib/reactionsAnalyze.js +0 -460
- package/lib/reactionsAnalyzeLS.d.ts +0 -5
- package/lib/reactionsAnalyzeLS.js +0 -38
- package/lib/types.d.ts +0 -2
- package/lib/types.js +0 -19
- package/node.d.ts +0 -1
- package/node.js +0 -152
- package/protocol.d.ts +0 -1
- package/protocol.js +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-server",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"directory": "packages/language-server"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@volar/language-server": "2.4.
|
|
20
|
-
"@vue/language-core": "3.0.
|
|
21
|
-
"@vue/language-service": "3.0.
|
|
22
|
-
"@vue/typescript-plugin": "3.0.
|
|
19
|
+
"@volar/language-server": "2.4.23",
|
|
20
|
+
"@vue/language-core": "3.0.6",
|
|
21
|
+
"@vue/language-service": "3.0.6",
|
|
22
|
+
"@vue/typescript-plugin": "3.0.6",
|
|
23
23
|
"vscode-uri": "^3.0.8"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@typescript/server-harness": "latest",
|
|
30
|
-
"@volar/test-utils": "2.4.
|
|
30
|
+
"@volar/test-utils": "2.4.23"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "59f8cde8a5148e54294868104312b2b0f4c30d1e"
|
|
33
33
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript';
|
|
2
|
-
declare const enum TrackKind {
|
|
3
|
-
AccessDotValue = 0,
|
|
4
|
-
AccessAnyValue = 1,
|
|
5
|
-
Call = 2
|
|
6
|
-
}
|
|
7
|
-
interface SignalNode {
|
|
8
|
-
bindingInfo?: {
|
|
9
|
-
isRef: boolean;
|
|
10
|
-
name: ts.BindingName;
|
|
11
|
-
trackKinds: TrackKind[];
|
|
12
|
-
};
|
|
13
|
-
trackInfo?: {
|
|
14
|
-
depsHandler: ts.Node;
|
|
15
|
-
needToUse: boolean;
|
|
16
|
-
};
|
|
17
|
-
sideEffectInfo?: {
|
|
18
|
-
isEffect: boolean;
|
|
19
|
-
handler: ts.Node;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export declare function analyze(ts: typeof import('typescript'), languageService: ts.LanguageService, fileName: string, position: number): {
|
|
23
|
-
sourceFile: ts.SourceFile;
|
|
24
|
-
subscribers: SignalNode[];
|
|
25
|
-
dependencies: ts.Node[];
|
|
26
|
-
} | undefined;
|
|
27
|
-
export {};
|
package/lib/reactionsAnalyze.js
DELETED
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.analyze = analyze;
|
|
4
|
-
const language_core_1 = require("@vue/language-core");
|
|
5
|
-
function analyze(ts, languageService, fileName, position) {
|
|
6
|
-
const sourceFile = languageService.getProgram().getSourceFile(fileName);
|
|
7
|
-
const { signals, dotValueAccesses, dotAnyAccesses, functionCalls } = collect(ts, sourceFile);
|
|
8
|
-
let signal = findSignalByNamePosition(position);
|
|
9
|
-
if (!signal) {
|
|
10
|
-
signal = findEffectByEffectHandlerPosition(position);
|
|
11
|
-
if (signal?.bindingInfo) {
|
|
12
|
-
position = signal.bindingInfo.name.getStart(sourceFile);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (!signal) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const subscribers = signal.bindingInfo
|
|
19
|
-
? findSubscribers(signal.bindingInfo.name, signal.bindingInfo.trackKinds)
|
|
20
|
-
: [];
|
|
21
|
-
const dependencies = signal
|
|
22
|
-
? findDependencies(signal)
|
|
23
|
-
: [];
|
|
24
|
-
if ((!signal.sideEffectInfo?.isEffect && !subscribers.length)
|
|
25
|
-
|| (!signal.bindingInfo?.isRef && !dependencies.length)) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
sourceFile,
|
|
30
|
-
subscribers: [...new Set(subscribers)],
|
|
31
|
-
dependencies: [...new Set(dependencies)],
|
|
32
|
-
};
|
|
33
|
-
function findDependencies(signal, visited = new Set()) {
|
|
34
|
-
if (visited.has(signal)) {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
visited.add(signal);
|
|
38
|
-
const nodes = [];
|
|
39
|
-
let hasRef = signal.bindingInfo?.isRef ?? false;
|
|
40
|
-
if (signal.trackInfo) {
|
|
41
|
-
const { needToUse } = signal.trackInfo;
|
|
42
|
-
visit(signal.trackInfo.depsHandler, needToUse);
|
|
43
|
-
signal.trackInfo.depsHandler.forEachChild(child => visit(child, needToUse));
|
|
44
|
-
}
|
|
45
|
-
if (!hasRef) {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
return nodes;
|
|
49
|
-
function visit(node, needToUse, parentIsPropertyAccess = false) {
|
|
50
|
-
if (!needToUse) {
|
|
51
|
-
if (!parentIsPropertyAccess && ts.isIdentifier(node)) {
|
|
52
|
-
const definition = languageService.getDefinitionAtPosition(fileName, node.getStart(sourceFile));
|
|
53
|
-
for (const info of definition ?? []) {
|
|
54
|
-
if (info.fileName !== fileName) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const signal = findSignalByNamePosition(info.textSpan.start);
|
|
58
|
-
if (!signal) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
if (signal.bindingInfo) {
|
|
62
|
-
nodes.push(signal.bindingInfo.name);
|
|
63
|
-
hasRef ||= signal.bindingInfo.isRef;
|
|
64
|
-
}
|
|
65
|
-
if (signal.sideEffectInfo) {
|
|
66
|
-
nodes.push(signal.sideEffectInfo.handler);
|
|
67
|
-
}
|
|
68
|
-
const deps = findDependencies(signal, visited);
|
|
69
|
-
nodes.push(...deps);
|
|
70
|
-
hasRef ||= deps.length > 0;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) || ts.isCallExpression(node)) {
|
|
75
|
-
const definition = languageService.getDefinitionAtPosition(fileName, node.expression.getStart(sourceFile));
|
|
76
|
-
for (const info of definition ?? []) {
|
|
77
|
-
if (info.fileName !== fileName) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
const signal = findSignalByNamePosition(info.textSpan.start);
|
|
81
|
-
if (!signal) {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const oldSize = nodes.length;
|
|
85
|
-
if (signal.bindingInfo) {
|
|
86
|
-
for (const trackKind of signal.bindingInfo.trackKinds) {
|
|
87
|
-
if (ts.isPropertyAccessExpression(node)) {
|
|
88
|
-
if (trackKind === 0 /* TrackKind.AccessDotValue */ && node.name.text === 'value') {
|
|
89
|
-
nodes.push(signal.bindingInfo.name);
|
|
90
|
-
hasRef ||= signal.bindingInfo.isRef;
|
|
91
|
-
}
|
|
92
|
-
if (trackKind === 1 /* TrackKind.AccessAnyValue */ && node.name.text !== '') {
|
|
93
|
-
nodes.push(signal.bindingInfo.name);
|
|
94
|
-
hasRef ||= signal.bindingInfo.isRef;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else if (ts.isElementAccessExpression(node)) {
|
|
98
|
-
if (trackKind === 1 /* TrackKind.AccessAnyValue */) {
|
|
99
|
-
nodes.push(signal.bindingInfo.name);
|
|
100
|
-
hasRef ||= signal.bindingInfo.isRef;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else if (ts.isCallExpression(node)) {
|
|
104
|
-
if (trackKind === 2 /* TrackKind.Call */) {
|
|
105
|
-
nodes.push(signal.bindingInfo.name);
|
|
106
|
-
hasRef ||= signal.bindingInfo.isRef;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const signalDetected = nodes.length > oldSize;
|
|
112
|
-
if (signalDetected) {
|
|
113
|
-
if (signal.sideEffectInfo) {
|
|
114
|
-
nodes.push(signal.sideEffectInfo.handler);
|
|
115
|
-
}
|
|
116
|
-
const deps = findDependencies(signal, visited);
|
|
117
|
-
nodes.push(...deps);
|
|
118
|
-
hasRef ||= deps.length > 0;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
node.forEachChild(child => visit(child, needToUse, ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function findSubscribers(refName, trackKinds, visited = new Set()) {
|
|
126
|
-
return (0, language_core_1.findBindingVars)(ts, refName, sourceFile)
|
|
127
|
-
.map(binding => findSubscribersWorker(binding, trackKinds, visited))
|
|
128
|
-
.flat();
|
|
129
|
-
}
|
|
130
|
-
function findSubscribersWorker(refName, trackKinds, visited = new Set()) {
|
|
131
|
-
if (visited.has(refName.start)) {
|
|
132
|
-
return [];
|
|
133
|
-
}
|
|
134
|
-
visited.add(refName.start);
|
|
135
|
-
const references = languageService.findReferences(fileName, refName.start);
|
|
136
|
-
if (!references) {
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
const result = [];
|
|
140
|
-
for (const reference of references) {
|
|
141
|
-
for (const reference2 of reference.references) {
|
|
142
|
-
if (reference2.fileName !== fileName) {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
const effect = findEffectByDepsHandlerPosition(reference2.textSpan.start);
|
|
146
|
-
if (effect?.trackInfo) {
|
|
147
|
-
if (effect.trackInfo.needToUse) {
|
|
148
|
-
let match = false;
|
|
149
|
-
for (const trackKind of trackKinds) {
|
|
150
|
-
if (trackKind === 1 /* TrackKind.AccessAnyValue */) {
|
|
151
|
-
match = dotAnyAccesses.has(reference2.textSpan.start + reference2.textSpan.length);
|
|
152
|
-
}
|
|
153
|
-
else if (trackKind === 0 /* TrackKind.AccessDotValue */) {
|
|
154
|
-
match = dotValueAccesses.has(reference2.textSpan.start + reference2.textSpan.length);
|
|
155
|
-
}
|
|
156
|
-
else if (trackKind === 2 /* TrackKind.Call */) {
|
|
157
|
-
match = functionCalls.has(reference2.textSpan.start + reference2.textSpan.length);
|
|
158
|
-
}
|
|
159
|
-
if (match) {
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (!match) {
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
let hasEffect = effect.sideEffectInfo?.isEffect;
|
|
168
|
-
if (effect.bindingInfo) {
|
|
169
|
-
const subs = findSubscribers(effect.bindingInfo.name, effect.bindingInfo.trackKinds, visited);
|
|
170
|
-
result.push(...subs);
|
|
171
|
-
hasEffect ||= subs.length > 0;
|
|
172
|
-
}
|
|
173
|
-
if (hasEffect) {
|
|
174
|
-
result.push(effect);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
181
|
-
function findSignalByNamePosition(position) {
|
|
182
|
-
return signals.find(ref => ref.bindingInfo && ref.bindingInfo.name.getStart(sourceFile) <= position
|
|
183
|
-
&& ref.bindingInfo.name.getEnd() >= position);
|
|
184
|
-
}
|
|
185
|
-
function findEffectByEffectHandlerPosition(position) {
|
|
186
|
-
return signals.find(ref => ref.sideEffectInfo && ref.sideEffectInfo.handler.getStart(sourceFile) <= position
|
|
187
|
-
&& ref.sideEffectInfo.handler.getEnd() >= position);
|
|
188
|
-
}
|
|
189
|
-
function findEffectByDepsHandlerPosition(position) {
|
|
190
|
-
return signals.find(ref => ref.trackInfo && ref.trackInfo.depsHandler.getStart(sourceFile) <= position
|
|
191
|
-
&& ref.trackInfo.depsHandler.getEnd() >= position);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function collect(ts, sourceFile) {
|
|
195
|
-
const signals = [];
|
|
196
|
-
const dotValueAccesses = new Set();
|
|
197
|
-
const dotAnyAccesses = new Set();
|
|
198
|
-
const functionCalls = new Set();
|
|
199
|
-
sourceFile.forEachChild(function visit(node) {
|
|
200
|
-
if (ts.isVariableDeclaration(node)) {
|
|
201
|
-
if (node.initializer && ts.isCallExpression(node.initializer)) {
|
|
202
|
-
const call = node.initializer;
|
|
203
|
-
if (ts.isIdentifier(call.expression)) {
|
|
204
|
-
const callName = call.expression.escapedText;
|
|
205
|
-
if (callName === 'ref' || callName === 'shallowRef' || callName === 'toRef' || callName === 'useTemplateRef'
|
|
206
|
-
|| callName === 'defineModel') {
|
|
207
|
-
signals.push({
|
|
208
|
-
bindingInfo: {
|
|
209
|
-
isRef: true,
|
|
210
|
-
name: node.name,
|
|
211
|
-
trackKinds: [0 /* TrackKind.AccessDotValue */],
|
|
212
|
-
},
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
else if (callName === 'reactive' || callName === 'shallowReactive' || callName === 'defineProps'
|
|
216
|
-
|| callName === 'withDefaults') {
|
|
217
|
-
signals.push({
|
|
218
|
-
bindingInfo: {
|
|
219
|
-
isRef: true,
|
|
220
|
-
name: node.name,
|
|
221
|
-
trackKinds: [1 /* TrackKind.AccessAnyValue */],
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
// TODO: toRefs
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
else if (ts.isFunctionDeclaration(node)) {
|
|
230
|
-
if (node.name && node.body) {
|
|
231
|
-
signals.push({
|
|
232
|
-
bindingInfo: {
|
|
233
|
-
isRef: false,
|
|
234
|
-
name: node.name,
|
|
235
|
-
trackKinds: [2 /* TrackKind.Call */],
|
|
236
|
-
},
|
|
237
|
-
trackInfo: {
|
|
238
|
-
depsHandler: node.body,
|
|
239
|
-
needToUse: true,
|
|
240
|
-
},
|
|
241
|
-
sideEffectInfo: {
|
|
242
|
-
isEffect: false,
|
|
243
|
-
handler: node.body,
|
|
244
|
-
},
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else if (ts.isVariableStatement(node)) {
|
|
249
|
-
for (const declaration of node.declarationList.declarations) {
|
|
250
|
-
const name = declaration.name;
|
|
251
|
-
const callback = declaration.initializer;
|
|
252
|
-
if (callback && ts.isIdentifier(name) && (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback))) {
|
|
253
|
-
signals.push({
|
|
254
|
-
bindingInfo: {
|
|
255
|
-
isRef: false,
|
|
256
|
-
name: name,
|
|
257
|
-
trackKinds: [2 /* TrackKind.Call */],
|
|
258
|
-
},
|
|
259
|
-
trackInfo: {
|
|
260
|
-
depsHandler: callback,
|
|
261
|
-
needToUse: true,
|
|
262
|
-
},
|
|
263
|
-
sideEffectInfo: {
|
|
264
|
-
isEffect: false,
|
|
265
|
-
handler: callback,
|
|
266
|
-
},
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
else if (ts.isParameter(node)) {
|
|
272
|
-
if (node.type && ts.isTypeReferenceNode(node.type)) {
|
|
273
|
-
const typeName = node.type.typeName.getText(sourceFile);
|
|
274
|
-
if (typeName.endsWith('Ref')) {
|
|
275
|
-
signals.push({
|
|
276
|
-
bindingInfo: {
|
|
277
|
-
isRef: true,
|
|
278
|
-
name: node.name,
|
|
279
|
-
trackKinds: [0 /* TrackKind.AccessDotValue */],
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
else if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
|
|
286
|
-
const call = node;
|
|
287
|
-
const callName = node.expression.escapedText;
|
|
288
|
-
if ((callName === 'effect' || callName === 'watchEffect') && call.arguments.length) {
|
|
289
|
-
const callback = call.arguments[0];
|
|
290
|
-
if (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback)) {
|
|
291
|
-
signals.push({
|
|
292
|
-
trackInfo: {
|
|
293
|
-
depsHandler: callback.body,
|
|
294
|
-
needToUse: true,
|
|
295
|
-
},
|
|
296
|
-
sideEffectInfo: {
|
|
297
|
-
isEffect: true,
|
|
298
|
-
handler: callback.body,
|
|
299
|
-
},
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (callName === 'watch' && call.arguments.length >= 2) {
|
|
304
|
-
const depsCallback = call.arguments[0];
|
|
305
|
-
const effectCallback = call.arguments[1];
|
|
306
|
-
if (ts.isArrowFunction(effectCallback) || ts.isFunctionExpression(effectCallback)) {
|
|
307
|
-
if (ts.isArrowFunction(depsCallback) || ts.isFunctionExpression(depsCallback)) {
|
|
308
|
-
signals.push({
|
|
309
|
-
trackInfo: {
|
|
310
|
-
depsHandler: depsCallback.body,
|
|
311
|
-
needToUse: true,
|
|
312
|
-
},
|
|
313
|
-
sideEffectInfo: {
|
|
314
|
-
isEffect: true,
|
|
315
|
-
handler: effectCallback.body,
|
|
316
|
-
},
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
signals.push({
|
|
321
|
-
trackInfo: {
|
|
322
|
-
depsHandler: depsCallback,
|
|
323
|
-
needToUse: false,
|
|
324
|
-
},
|
|
325
|
-
sideEffectInfo: {
|
|
326
|
-
isEffect: true,
|
|
327
|
-
handler: effectCallback.body,
|
|
328
|
-
},
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
else if ((0, language_core_1.hyphenateAttr)(callName).startsWith('use-')) {
|
|
334
|
-
signals.push({
|
|
335
|
-
bindingInfo: ts.isVariableDeclaration(call.parent)
|
|
336
|
-
? {
|
|
337
|
-
isRef: true,
|
|
338
|
-
name: call.parent.name,
|
|
339
|
-
trackKinds: [1 /* TrackKind.AccessAnyValue */, 2 /* TrackKind.Call */],
|
|
340
|
-
}
|
|
341
|
-
: undefined,
|
|
342
|
-
trackInfo: {
|
|
343
|
-
depsHandler: call,
|
|
344
|
-
needToUse: false,
|
|
345
|
-
},
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
else if ((callName === 'computed' || (0, language_core_1.hyphenateAttr)(callName).endsWith('-computed')) && call.arguments.length) {
|
|
349
|
-
const arg = call.arguments[0];
|
|
350
|
-
if (ts.isArrowFunction(arg) || ts.isFunctionExpression(arg)) {
|
|
351
|
-
signals.push({
|
|
352
|
-
bindingInfo: ts.isVariableDeclaration(call.parent)
|
|
353
|
-
? {
|
|
354
|
-
isRef: true,
|
|
355
|
-
name: call.parent.name,
|
|
356
|
-
trackKinds: [0 /* TrackKind.AccessDotValue */],
|
|
357
|
-
}
|
|
358
|
-
: undefined,
|
|
359
|
-
trackInfo: {
|
|
360
|
-
depsHandler: arg.body,
|
|
361
|
-
needToUse: true,
|
|
362
|
-
},
|
|
363
|
-
sideEffectInfo: {
|
|
364
|
-
isEffect: true,
|
|
365
|
-
handler: arg.body,
|
|
366
|
-
},
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
else if (ts.isIdentifier(arg)) {
|
|
370
|
-
signals.push({
|
|
371
|
-
bindingInfo: ts.isVariableDeclaration(call.parent)
|
|
372
|
-
? {
|
|
373
|
-
isRef: true,
|
|
374
|
-
name: call.parent.name,
|
|
375
|
-
trackKinds: [0 /* TrackKind.AccessDotValue */],
|
|
376
|
-
}
|
|
377
|
-
: undefined,
|
|
378
|
-
trackInfo: {
|
|
379
|
-
depsHandler: arg,
|
|
380
|
-
needToUse: false,
|
|
381
|
-
},
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
else if (ts.isObjectLiteralExpression(arg)) {
|
|
385
|
-
for (const prop of arg.properties) {
|
|
386
|
-
if (prop.name?.getText(sourceFile) === 'get') {
|
|
387
|
-
if (ts.isPropertyAssignment(prop)) {
|
|
388
|
-
const callback = prop.initializer;
|
|
389
|
-
if (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback)) {
|
|
390
|
-
signals.push({
|
|
391
|
-
bindingInfo: ts.isVariableDeclaration(call.parent)
|
|
392
|
-
? {
|
|
393
|
-
isRef: true,
|
|
394
|
-
name: call.parent.name,
|
|
395
|
-
trackKinds: [0 /* TrackKind.AccessDotValue */],
|
|
396
|
-
}
|
|
397
|
-
: undefined,
|
|
398
|
-
trackInfo: {
|
|
399
|
-
depsHandler: callback.body,
|
|
400
|
-
needToUse: true,
|
|
401
|
-
},
|
|
402
|
-
sideEffectInfo: {
|
|
403
|
-
isEffect: true,
|
|
404
|
-
handler: callback.body,
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
else if (ts.isMethodDeclaration(prop) && prop.body) {
|
|
410
|
-
signals.push({
|
|
411
|
-
bindingInfo: ts.isVariableDeclaration(call.parent)
|
|
412
|
-
? {
|
|
413
|
-
isRef: true,
|
|
414
|
-
name: call.parent.name,
|
|
415
|
-
trackKinds: [0 /* TrackKind.AccessDotValue */],
|
|
416
|
-
}
|
|
417
|
-
: undefined,
|
|
418
|
-
trackInfo: {
|
|
419
|
-
depsHandler: prop.body,
|
|
420
|
-
needToUse: true,
|
|
421
|
-
},
|
|
422
|
-
sideEffectInfo: {
|
|
423
|
-
isEffect: true,
|
|
424
|
-
handler: prop.body,
|
|
425
|
-
},
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
node.forEachChild(visit);
|
|
434
|
-
});
|
|
435
|
-
sourceFile.forEachChild(function visit(node) {
|
|
436
|
-
if (ts.isPropertyAccessExpression(node)) {
|
|
437
|
-
if (node.name.text === 'value') {
|
|
438
|
-
dotValueAccesses.add(node.expression.getEnd());
|
|
439
|
-
dotAnyAccesses.add(node.expression.getEnd());
|
|
440
|
-
}
|
|
441
|
-
else if (node.name.text !== '') {
|
|
442
|
-
dotAnyAccesses.add(node.expression.getEnd());
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
else if (ts.isElementAccessExpression(node)) {
|
|
446
|
-
dotAnyAccesses.add(node.expression.getEnd());
|
|
447
|
-
}
|
|
448
|
-
else if (ts.isCallExpression(node)) {
|
|
449
|
-
functionCalls.add(node.expression.getEnd());
|
|
450
|
-
}
|
|
451
|
-
node.forEachChild(visit);
|
|
452
|
-
});
|
|
453
|
-
return {
|
|
454
|
-
signals,
|
|
455
|
-
dotValueAccesses,
|
|
456
|
-
dotAnyAccesses,
|
|
457
|
-
functionCalls,
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
//# sourceMappingURL=reactionsAnalyze.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLanguageService = getLanguageService;
|
|
4
|
-
let currentProjectVersion = -1;
|
|
5
|
-
let currentFileName = '';
|
|
6
|
-
let currentSnapshot;
|
|
7
|
-
let languageService;
|
|
8
|
-
const host = {
|
|
9
|
-
getProjectVersion: () => currentProjectVersion.toString(),
|
|
10
|
-
getScriptFileNames: () => [currentFileName],
|
|
11
|
-
getScriptVersion: () => currentProjectVersion.toString(),
|
|
12
|
-
getScriptSnapshot: fileName => fileName === currentFileName ? currentSnapshot : undefined,
|
|
13
|
-
getCompilationSettings: () => ({}),
|
|
14
|
-
getCurrentDirectory: () => '',
|
|
15
|
-
getDefaultLibFileName: () => '',
|
|
16
|
-
readFile: () => undefined,
|
|
17
|
-
fileExists: fileName => fileName === currentFileName,
|
|
18
|
-
};
|
|
19
|
-
// TODO: share with volar-service-typescript
|
|
20
|
-
function getLanguageService(ts, snapshot, languageId) {
|
|
21
|
-
if (currentSnapshot !== snapshot) {
|
|
22
|
-
currentSnapshot = snapshot;
|
|
23
|
-
currentFileName = '/tmp.' + (languageId === 'javascript'
|
|
24
|
-
? 'js'
|
|
25
|
-
: languageId === 'typescriptreact'
|
|
26
|
-
? 'tsx'
|
|
27
|
-
: languageId === 'javascriptreact'
|
|
28
|
-
? 'jsx'
|
|
29
|
-
: 'ts');
|
|
30
|
-
currentProjectVersion++;
|
|
31
|
-
}
|
|
32
|
-
languageService ??= ts.createLanguageService(host);
|
|
33
|
-
return {
|
|
34
|
-
languageService,
|
|
35
|
-
fileName: currentFileName,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=reactionsAnalyzeLS.js.map
|
package/lib/types.d.ts
DELETED
package/lib/types.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("@volar/language-server/lib/types"), exports);
|
|
18
|
-
__exportStar(require("@vue/language-service/lib/types"), exports);
|
|
19
|
-
//# sourceMappingURL=types.js.map
|
package/node.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/node.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const simpleProject_1 = require("@volar/language-server/lib/project/simpleProject");
|
|
4
|
-
const node_1 = require("@volar/language-server/node");
|
|
5
|
-
const language_core_1 = require("@vue/language-core");
|
|
6
|
-
const language_service_1 = require("@vue/language-service");
|
|
7
|
-
const ts = require("typescript");
|
|
8
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
9
|
-
const connection = (0, node_1.createConnection)();
|
|
10
|
-
const server = (0, node_1.createServer)(connection);
|
|
11
|
-
connection.listen();
|
|
12
|
-
connection.onInitialize(params => {
|
|
13
|
-
const tsconfigProjects = (0, language_service_1.createUriMap)();
|
|
14
|
-
const file2ProjectInfo = new Map();
|
|
15
|
-
server.fileWatcher.onDidChangeWatchedFiles(({ changes }) => {
|
|
16
|
-
for (const change of changes) {
|
|
17
|
-
const changeUri = vscode_uri_1.URI.parse(change.uri);
|
|
18
|
-
if (tsconfigProjects.has(changeUri)) {
|
|
19
|
-
tsconfigProjects.get(changeUri).dispose();
|
|
20
|
-
tsconfigProjects.delete(changeUri);
|
|
21
|
-
file2ProjectInfo.clear();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
let simpleLs;
|
|
26
|
-
let tsserverRequestId = 0;
|
|
27
|
-
const tsserverRequestHandlers = new Map();
|
|
28
|
-
connection.onNotification('tsserver/response', ([id, res]) => {
|
|
29
|
-
tsserverRequestHandlers.get(id)?.(res);
|
|
30
|
-
tsserverRequestHandlers.delete(id);
|
|
31
|
-
});
|
|
32
|
-
return server.initialize(params, {
|
|
33
|
-
setup() { },
|
|
34
|
-
async getLanguageService(uri) {
|
|
35
|
-
if (uri.scheme === 'file') {
|
|
36
|
-
const fileName = uri.fsPath.replace(/\\/g, '/');
|
|
37
|
-
let projectInfoPromise = file2ProjectInfo.get(fileName);
|
|
38
|
-
if (!projectInfoPromise) {
|
|
39
|
-
projectInfoPromise = sendTsRequest(ts.server.protocol.CommandTypes.ProjectInfo, {
|
|
40
|
-
file: fileName,
|
|
41
|
-
needFileNameList: false,
|
|
42
|
-
});
|
|
43
|
-
file2ProjectInfo.set(fileName, projectInfoPromise);
|
|
44
|
-
}
|
|
45
|
-
const projectInfo = await projectInfoPromise;
|
|
46
|
-
if (projectInfo) {
|
|
47
|
-
const { configFileName } = projectInfo;
|
|
48
|
-
let ls = tsconfigProjects.get(vscode_uri_1.URI.file(configFileName));
|
|
49
|
-
if (!ls) {
|
|
50
|
-
ls = createLs(server, configFileName);
|
|
51
|
-
tsconfigProjects.set(vscode_uri_1.URI.file(configFileName), ls);
|
|
52
|
-
}
|
|
53
|
-
return ls;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return simpleLs ??= createLs(server, undefined);
|
|
57
|
-
},
|
|
58
|
-
getExistingLanguageServices() {
|
|
59
|
-
return Promise.all([
|
|
60
|
-
...tsconfigProjects.values(),
|
|
61
|
-
simpleLs,
|
|
62
|
-
].filter(promise => !!promise));
|
|
63
|
-
},
|
|
64
|
-
reload() {
|
|
65
|
-
for (const ls of tsconfigProjects.values()) {
|
|
66
|
-
ls.dispose();
|
|
67
|
-
}
|
|
68
|
-
tsconfigProjects.clear();
|
|
69
|
-
if (simpleLs) {
|
|
70
|
-
simpleLs.dispose();
|
|
71
|
-
simpleLs = undefined;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
}, (0, language_service_1.getHybridModeLanguageServicePlugins)(ts, {
|
|
75
|
-
collectExtractProps(...args) {
|
|
76
|
-
return sendTsRequest('vue:collectExtractProps', args);
|
|
77
|
-
},
|
|
78
|
-
getComponentDirectives(...args) {
|
|
79
|
-
return sendTsRequest('vue:getComponentDirectives', args);
|
|
80
|
-
},
|
|
81
|
-
getComponentEvents(...args) {
|
|
82
|
-
return sendTsRequest('vue:getComponentEvents', args);
|
|
83
|
-
},
|
|
84
|
-
getComponentNames(...args) {
|
|
85
|
-
return sendTsRequest('vue:getComponentNames', args);
|
|
86
|
-
},
|
|
87
|
-
getComponentProps(...args) {
|
|
88
|
-
return sendTsRequest('vue:getComponentProps', args);
|
|
89
|
-
},
|
|
90
|
-
getElementAttrs(...args) {
|
|
91
|
-
return sendTsRequest('vue:getElementAttrs', args);
|
|
92
|
-
},
|
|
93
|
-
getElementNames(...args) {
|
|
94
|
-
return sendTsRequest('vue:getElementNames', args);
|
|
95
|
-
},
|
|
96
|
-
getImportPathForFile(...args) {
|
|
97
|
-
return sendTsRequest('vue:getImportPathForFile', args);
|
|
98
|
-
},
|
|
99
|
-
getPropertiesAtLocation(...args) {
|
|
100
|
-
return sendTsRequest('vue:getPropertiesAtLocation', args);
|
|
101
|
-
},
|
|
102
|
-
getDocumentHighlights(fileName, position) {
|
|
103
|
-
return sendTsRequest('documentHighlights-full', // internal command
|
|
104
|
-
{
|
|
105
|
-
file: fileName,
|
|
106
|
-
...{ position },
|
|
107
|
-
filesToSearch: [fileName],
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
async getQuickInfoAtPosition(fileName, { line, character }) {
|
|
111
|
-
const result = await sendTsRequest(ts.server.protocol.CommandTypes.Quickinfo, {
|
|
112
|
-
file: fileName,
|
|
113
|
-
line: line + 1,
|
|
114
|
-
offset: character + 1,
|
|
115
|
-
});
|
|
116
|
-
return ts.displayPartsToString(result?.displayParts ?? []);
|
|
117
|
-
},
|
|
118
|
-
}));
|
|
119
|
-
async function sendTsRequest(command, args) {
|
|
120
|
-
return await new Promise(resolve => {
|
|
121
|
-
const requestId = ++tsserverRequestId;
|
|
122
|
-
tsserverRequestHandlers.set(requestId, resolve);
|
|
123
|
-
connection.sendNotification('tsserver/request', [requestId, command, args]);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function createLs(server, tsconfig) {
|
|
127
|
-
const commonLine = tsconfig
|
|
128
|
-
? (0, language_core_1.createParsedCommandLine)(ts, ts.sys, tsconfig)
|
|
129
|
-
: {
|
|
130
|
-
options: ts.getDefaultCompilerOptions(),
|
|
131
|
-
vueOptions: (0, language_core_1.getDefaultCompilerOptions)(),
|
|
132
|
-
};
|
|
133
|
-
const language = (0, language_core_1.createLanguage)([
|
|
134
|
-
{
|
|
135
|
-
getLanguageId: uri => server.documents.get(uri)?.languageId,
|
|
136
|
-
},
|
|
137
|
-
(0, language_core_1.createVueLanguagePlugin)(ts, commonLine.options, commonLine.vueOptions, uri => uri.fsPath.replace(/\\/g, '/')),
|
|
138
|
-
], (0, language_service_1.createUriMap)(), uri => {
|
|
139
|
-
const document = server.documents.get(uri);
|
|
140
|
-
if (document) {
|
|
141
|
-
language.scripts.set(uri, document.getSnapshot(), document.languageId);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
language.scripts.delete(uri);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
return (0, language_service_1.createLanguageService)(language, server.languageServicePlugins, (0, simpleProject_1.createLanguageServiceEnvironment)(server, [...server.workspaceFolders.all]), { vue: { compilerOptions: commonLine.vueOptions } });
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
connection.onInitialized(server.initialized);
|
|
151
|
-
connection.onShutdown(server.shutdown);
|
|
152
|
-
//# sourceMappingURL=node.js.map
|
package/protocol.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@volar/language-server/protocol';
|
package/protocol.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("@volar/language-server/protocol"), exports);
|
|
18
|
-
//# sourceMappingURL=protocol.js.map
|