@vue/language-server 3.0.0-beta.2 → 3.0.0-beta.4
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/index.js +12 -19
- package/lib/reactionsAnalyze.js +12 -8
- package/lib/reactionsAnalyzeLS.js +7 -4
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -39,7 +39,7 @@ connection.onInitialize(params => {
|
|
|
39
39
|
const fileName = uri.fsPath.replace(/\\/g, '/');
|
|
40
40
|
let projectInfoPromise = file2ProjectInfo.get(fileName);
|
|
41
41
|
if (!projectInfoPromise) {
|
|
42
|
-
projectInfoPromise = sendTsRequest(ts.server.protocol.CommandTypes.ProjectInfo, {
|
|
42
|
+
projectInfoPromise = sendTsRequest('_vue:' + ts.server.protocol.CommandTypes.ProjectInfo, {
|
|
43
43
|
file: fileName,
|
|
44
44
|
needFileNameList: false,
|
|
45
45
|
});
|
|
@@ -76,42 +76,41 @@ connection.onInitialize(params => {
|
|
|
76
76
|
},
|
|
77
77
|
}, (0, language_service_1.createVueLanguageServicePlugins)(ts, {
|
|
78
78
|
collectExtractProps(...args) {
|
|
79
|
-
return sendTsRequest('
|
|
79
|
+
return sendTsRequest('_vue:collectExtractProps', args);
|
|
80
80
|
},
|
|
81
81
|
getComponentDirectives(...args) {
|
|
82
|
-
return sendTsRequest('
|
|
82
|
+
return sendTsRequest('_vue:getComponentDirectives', args);
|
|
83
83
|
},
|
|
84
84
|
getComponentEvents(...args) {
|
|
85
|
-
return sendTsRequest('
|
|
85
|
+
return sendTsRequest('_vue:getComponentEvents', args);
|
|
86
86
|
},
|
|
87
87
|
getComponentNames(...args) {
|
|
88
|
-
return sendTsRequest('
|
|
88
|
+
return sendTsRequest('_vue:getComponentNames', args);
|
|
89
89
|
},
|
|
90
90
|
getComponentProps(...args) {
|
|
91
|
-
return sendTsRequest('
|
|
91
|
+
return sendTsRequest('_vue:getComponentProps', args);
|
|
92
92
|
},
|
|
93
93
|
getElementAttrs(...args) {
|
|
94
|
-
return sendTsRequest('
|
|
94
|
+
return sendTsRequest('_vue:getElementAttrs', args);
|
|
95
95
|
},
|
|
96
96
|
getElementNames(...args) {
|
|
97
|
-
return sendTsRequest('
|
|
97
|
+
return sendTsRequest('_vue:getElementNames', args);
|
|
98
98
|
},
|
|
99
99
|
getImportPathForFile(...args) {
|
|
100
|
-
return sendTsRequest('
|
|
100
|
+
return sendTsRequest('_vue:getImportPathForFile', args);
|
|
101
101
|
},
|
|
102
102
|
getPropertiesAtLocation(...args) {
|
|
103
|
-
return sendTsRequest('
|
|
103
|
+
return sendTsRequest('_vue:getPropertiesAtLocation', args);
|
|
104
104
|
},
|
|
105
105
|
getDocumentHighlights(fileName, position) {
|
|
106
|
-
return sendTsRequest('documentHighlights-full',
|
|
107
|
-
{
|
|
106
|
+
return sendTsRequest('_vue:documentHighlights-full', {
|
|
108
107
|
file: fileName,
|
|
109
108
|
...{ position },
|
|
110
109
|
filesToSearch: [fileName],
|
|
111
110
|
});
|
|
112
111
|
},
|
|
113
112
|
async getQuickInfoAtPosition(fileName, { line, character }) {
|
|
114
|
-
const result = await sendTsRequest(ts.server.protocol.CommandTypes.Quickinfo, {
|
|
113
|
+
const result = await sendTsRequest('_vue:' + ts.server.protocol.CommandTypes.Quickinfo, {
|
|
115
114
|
file: fileName,
|
|
116
115
|
line: line + 1,
|
|
117
116
|
offset: character + 1,
|
|
@@ -152,12 +151,6 @@ connection.onInitialize(params => {
|
|
|
152
151
|
});
|
|
153
152
|
connection.onInitialized(server.initialized);
|
|
154
153
|
connection.onShutdown(server.shutdown);
|
|
155
|
-
connection.onRequest('vue/parseSfc', (params) => {
|
|
156
|
-
const document = server.documents.get(vscode_uri_1.URI.parse(params.textDocument.uri));
|
|
157
|
-
if (document) {
|
|
158
|
-
return (0, language_core_1.parse)(document.getText());
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
154
|
connection.onRequest('vue/interpolationRanges', async (params) => {
|
|
162
155
|
const uri = vscode_uri_1.URI.parse(params.textDocument.uri);
|
|
163
156
|
const languageService = await server.project.getLanguageService(uri);
|
package/lib/reactionsAnalyze.js
CHANGED
|
@@ -121,7 +121,6 @@ function analyze(ts, languageService, fileName, position) {
|
|
|
121
121
|
}
|
|
122
122
|
node.forEachChild(child => visit(child, needToUse, ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)));
|
|
123
123
|
}
|
|
124
|
-
;
|
|
125
124
|
}
|
|
126
125
|
function findSubscribers(refName, trackKinds, visited = new Set()) {
|
|
127
126
|
return (0, language_core_1.findBindingVars)(ts, refName, sourceFile)
|
|
@@ -180,13 +179,16 @@ function analyze(ts, languageService, fileName, position) {
|
|
|
180
179
|
return result;
|
|
181
180
|
}
|
|
182
181
|
function findSignalByNamePosition(position) {
|
|
183
|
-
return signals.find(ref => ref.bindingInfo && ref.bindingInfo.name.getStart(sourceFile) <= position
|
|
182
|
+
return signals.find(ref => ref.bindingInfo && ref.bindingInfo.name.getStart(sourceFile) <= position
|
|
183
|
+
&& ref.bindingInfo.name.getEnd() >= position);
|
|
184
184
|
}
|
|
185
185
|
function findEffectByEffectHandlerPosition(position) {
|
|
186
|
-
return signals.find(ref => ref.sideEffectInfo && ref.sideEffectInfo.handler.getStart(sourceFile) <= position
|
|
186
|
+
return signals.find(ref => ref.sideEffectInfo && ref.sideEffectInfo.handler.getStart(sourceFile) <= position
|
|
187
|
+
&& ref.sideEffectInfo.handler.getEnd() >= position);
|
|
187
188
|
}
|
|
188
189
|
function findEffectByDepsHandlerPosition(position) {
|
|
189
|
-
return signals.find(ref => ref.trackInfo && ref.trackInfo.depsHandler.getStart(sourceFile) <= position
|
|
190
|
+
return signals.find(ref => ref.trackInfo && ref.trackInfo.depsHandler.getStart(sourceFile) <= position
|
|
191
|
+
&& ref.trackInfo.depsHandler.getEnd() >= position);
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
function collect(ts, sourceFile) {
|
|
@@ -200,7 +202,8 @@ function collect(ts, sourceFile) {
|
|
|
200
202
|
const call = node.initializer;
|
|
201
203
|
if (ts.isIdentifier(call.expression)) {
|
|
202
204
|
const callName = call.expression.escapedText;
|
|
203
|
-
if (callName === 'ref' || callName === 'shallowRef' || callName === 'toRef' || callName === 'useTemplateRef'
|
|
205
|
+
if (callName === 'ref' || callName === 'shallowRef' || callName === 'toRef' || callName === 'useTemplateRef'
|
|
206
|
+
|| callName === 'defineModel') {
|
|
204
207
|
signals.push({
|
|
205
208
|
bindingInfo: {
|
|
206
209
|
isRef: true,
|
|
@@ -209,7 +212,8 @@ function collect(ts, sourceFile) {
|
|
|
209
212
|
},
|
|
210
213
|
});
|
|
211
214
|
}
|
|
212
|
-
else if (callName === 'reactive' || callName === 'shallowReactive' || callName === 'defineProps'
|
|
215
|
+
else if (callName === 'reactive' || callName === 'shallowReactive' || callName === 'defineProps'
|
|
216
|
+
|| callName === 'withDefaults') {
|
|
213
217
|
signals.push({
|
|
214
218
|
bindingInfo: {
|
|
215
219
|
isRef: true,
|
|
@@ -265,7 +269,7 @@ function collect(ts, sourceFile) {
|
|
|
265
269
|
}
|
|
266
270
|
}
|
|
267
271
|
else if (ts.isParameter(node)) {
|
|
268
|
-
if (node.type &&
|
|
272
|
+
if (node.type && ts.isTypeReferenceNode(node.type)) {
|
|
269
273
|
const typeName = node.type.typeName.getText(sourceFile);
|
|
270
274
|
if (typeName.endsWith('Ref')) {
|
|
271
275
|
signals.push({
|
|
@@ -321,7 +325,7 @@ function collect(ts, sourceFile) {
|
|
|
321
325
|
sideEffectInfo: {
|
|
322
326
|
isEffect: true,
|
|
323
327
|
handler: effectCallback.body,
|
|
324
|
-
}
|
|
328
|
+
},
|
|
325
329
|
});
|
|
326
330
|
}
|
|
327
331
|
}
|
|
@@ -20,10 +20,13 @@ const host = {
|
|
|
20
20
|
function getLanguageService(ts, snapshot, languageId) {
|
|
21
21
|
if (currentSnapshot !== snapshot) {
|
|
22
22
|
currentSnapshot = snapshot;
|
|
23
|
-
currentFileName = '/tmp.' + (languageId === 'javascript'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
currentFileName = '/tmp.' + (languageId === 'javascript'
|
|
24
|
+
? 'js'
|
|
25
|
+
: languageId === 'typescriptreact'
|
|
26
|
+
? 'tsx'
|
|
27
|
+
: languageId === 'javascriptreact'
|
|
28
|
+
? 'jsx'
|
|
29
|
+
: 'ts');
|
|
27
30
|
currentProjectVersion++;
|
|
28
31
|
}
|
|
29
32
|
languageService ??= ts.createLanguageService(host);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-server",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
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.0-beta.
|
|
21
|
-
"@vue/language-service": "3.0.0-beta.
|
|
22
|
-
"@vue/typescript-plugin": "3.0.0-beta.
|
|
19
|
+
"@volar/language-server": "2.4.15",
|
|
20
|
+
"@vue/language-core": "3.0.0-beta.4",
|
|
21
|
+
"@vue/language-service": "3.0.0-beta.4",
|
|
22
|
+
"@vue/typescript-plugin": "3.0.0-beta.4",
|
|
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.15"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "5cb41faacbfe2d9e2d64637c6c1ae8769d9cba3f"
|
|
33
33
|
}
|