@vue/typescript-plugin 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 +25 -16
- package/lib/common.js +17 -11
- package/lib/requests/getComponentProps.js +1 -1
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -29,7 +29,7 @@ module.exports = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)(
|
|
|
29
29
|
info.project['program'].__vue__ = { language };
|
|
30
30
|
}
|
|
31
31
|
}, 50);
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
};
|
|
34
34
|
function getVueCompilerOptions() {
|
|
35
35
|
if (info.project.projectKind === ts.server.ProjectKind.Configured) {
|
|
@@ -37,68 +37,77 @@ module.exports = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)(
|
|
|
37
37
|
return vue.createParsedCommandLine(ts, ts.sys, tsconfig.replace(windowsPathReg, '/')).vueOptions;
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
return vue.createParsedCommandLineByJson(ts, ts.sys, info.languageServiceHost.getCurrentDirectory(), {})
|
|
40
|
+
return vue.createParsedCommandLineByJson(ts, ts.sys, info.languageServiceHost.getCurrentDirectory(), {})
|
|
41
|
+
.vueOptions;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
// https://github.com/JetBrains/intellij-plugins/blob/6435723ad88fa296b41144162ebe3b8513f4949b/Angular/src-js/angular-service/src/index.ts#L69
|
|
44
45
|
function addVueCommands() {
|
|
45
46
|
const projectService = info.project.projectService;
|
|
46
|
-
projectService.logger.info(
|
|
47
|
+
projectService.logger.info('Vue: called handler processing ' + info.project.projectKind);
|
|
47
48
|
const session = info.session;
|
|
48
49
|
if (session == undefined) {
|
|
49
|
-
projectService.logger.info(
|
|
50
|
+
projectService.logger.info('Vue: there is no session in info.');
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
if (session.addProtocolHandler == undefined) {
|
|
53
54
|
// addProtocolHandler was introduced in TS 4.4 or 4.5 in 2021, see https://github.com/microsoft/TypeScript/issues/43893
|
|
54
|
-
projectService.logger.info(
|
|
55
|
+
projectService.logger.info('Vue: there is no addProtocolHandler method.');
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
|
-
if (session.
|
|
58
|
+
if (session.handlers.has('_vue:projectInfo')) {
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
session.
|
|
61
|
-
|
|
61
|
+
session.addProtocolHandler('_vue:projectInfo', ({ arguments: args }) => {
|
|
62
|
+
return session.handlers.get('projectInfo')?.({ arguments: args });
|
|
63
|
+
});
|
|
64
|
+
session.addProtocolHandler('_vue:documentHighlights-full', ({ arguments: args }) => {
|
|
65
|
+
return session.handlers.get('documentHighlights-full')?.({ arguments: args });
|
|
66
|
+
});
|
|
67
|
+
session.addProtocolHandler('_vue:quickinfo', ({ arguments: args }) => {
|
|
68
|
+
return session.handlers.get('quickinfo')?.({ arguments: args });
|
|
69
|
+
});
|
|
70
|
+
session.addProtocolHandler('_vue:collectExtractProps', ({ arguments: args }) => {
|
|
62
71
|
return {
|
|
63
72
|
response: collectExtractProps_1.collectExtractProps.apply(getRequestContext(args[0]), args),
|
|
64
73
|
};
|
|
65
74
|
});
|
|
66
|
-
session.addProtocolHandler('
|
|
75
|
+
session.addProtocolHandler('_vue:getImportPathForFile', ({ arguments: args }) => {
|
|
67
76
|
return {
|
|
68
77
|
response: getImportPathForFile_1.getImportPathForFile.apply(getRequestContext(args[0]), args),
|
|
69
78
|
};
|
|
70
79
|
});
|
|
71
|
-
session.addProtocolHandler('
|
|
80
|
+
session.addProtocolHandler('_vue:getPropertiesAtLocation', ({ arguments: args }) => {
|
|
72
81
|
return {
|
|
73
82
|
response: getPropertiesAtLocation_1.getPropertiesAtLocation.apply(getRequestContext(args[0]), args),
|
|
74
83
|
};
|
|
75
84
|
});
|
|
76
|
-
session.addProtocolHandler('
|
|
85
|
+
session.addProtocolHandler('_vue:getComponentNames', ({ arguments: args }) => {
|
|
77
86
|
return {
|
|
78
87
|
response: getComponentNames_1.getComponentNames.apply(getRequestContext(args[0]), args) ?? [],
|
|
79
88
|
};
|
|
80
89
|
});
|
|
81
|
-
session.addProtocolHandler('
|
|
90
|
+
session.addProtocolHandler('_vue:getComponentProps', ({ arguments: args }) => {
|
|
82
91
|
return {
|
|
83
92
|
response: getComponentProps_1.getComponentProps.apply(getRequestContext(args[0]), args),
|
|
84
93
|
};
|
|
85
94
|
});
|
|
86
|
-
session.addProtocolHandler('
|
|
95
|
+
session.addProtocolHandler('_vue:getComponentEvents', ({ arguments: args }) => {
|
|
87
96
|
return {
|
|
88
97
|
response: getComponentEvents_1.getComponentEvents.apply(getRequestContext(args[0]), args),
|
|
89
98
|
};
|
|
90
99
|
});
|
|
91
|
-
session.addProtocolHandler('
|
|
100
|
+
session.addProtocolHandler('_vue:getComponentDirectives', ({ arguments: args }) => {
|
|
92
101
|
return {
|
|
93
102
|
response: getComponentDirectives_1.getComponentDirectives.apply(getRequestContext(args[0]), args),
|
|
94
103
|
};
|
|
95
104
|
});
|
|
96
|
-
session.addProtocolHandler('
|
|
105
|
+
session.addProtocolHandler('_vue:getElementAttrs', ({ arguments: args }) => {
|
|
97
106
|
return {
|
|
98
107
|
response: getElementAttrs_1.getElementAttrs.apply(getRequestContext(args[0]), args),
|
|
99
108
|
};
|
|
100
109
|
});
|
|
101
|
-
session.addProtocolHandler('
|
|
110
|
+
session.addProtocolHandler('_vue:getElementNames', ({ arguments: args }) => {
|
|
102
111
|
return {
|
|
103
112
|
response: getElementNames_1.getElementNames.apply(getRequestContext(args[0]), args),
|
|
104
113
|
};
|
package/lib/common.js
CHANGED
|
@@ -10,13 +10,19 @@ function createVueLanguageServiceProxy(ts, language, languageService, vueOptions
|
|
|
10
10
|
const proxyCache = new Map();
|
|
11
11
|
const getProxyMethod = (target, p) => {
|
|
12
12
|
switch (p) {
|
|
13
|
-
case 'getCompletionsAtPosition':
|
|
14
|
-
|
|
15
|
-
case '
|
|
16
|
-
|
|
17
|
-
case '
|
|
13
|
+
case 'getCompletionsAtPosition':
|
|
14
|
+
return getCompletionsAtPosition(ts, language, vueOptions, asScriptId, target[p]);
|
|
15
|
+
case 'getCompletionEntryDetails':
|
|
16
|
+
return getCompletionEntryDetails(language, asScriptId, target[p]);
|
|
17
|
+
case 'getCodeFixesAtPosition':
|
|
18
|
+
return getCodeFixesAtPosition(target[p]);
|
|
19
|
+
case 'getDefinitionAndBoundSpan':
|
|
20
|
+
return getDefinitionAndBoundSpan(ts, language, languageService, vueOptions, asScriptId, target[p]);
|
|
21
|
+
case 'getQuickInfoAtPosition':
|
|
22
|
+
return getQuickInfoAtPosition(ts, target, target[p]);
|
|
18
23
|
// TS plugin only
|
|
19
|
-
case 'getEncodedSemanticClassifications':
|
|
24
|
+
case 'getEncodedSemanticClassifications':
|
|
25
|
+
return getEncodedSemanticClassifications(ts, language, target, asScriptId, target[p]);
|
|
20
26
|
}
|
|
21
27
|
};
|
|
22
28
|
return new Proxy(languageService, {
|
|
@@ -112,7 +118,7 @@ function getCompletionEntryDetails(language, asScriptId, getCompletionEntryDetai
|
|
|
112
118
|
// @ts-expect-error
|
|
113
119
|
if (args[6]?.__isComponentAutoImport) {
|
|
114
120
|
// @ts-expect-error
|
|
115
|
-
const {
|
|
121
|
+
const { originalName, newName } = args[6].__isComponentAutoImport;
|
|
116
122
|
for (const codeAction of details?.codeActions ?? []) {
|
|
117
123
|
for (const change of codeAction.changes) {
|
|
118
124
|
for (const textChange of change.textChanges) {
|
|
@@ -124,7 +130,7 @@ function getCompletionEntryDetails(language, asScriptId, getCompletionEntryDetai
|
|
|
124
130
|
// @ts-expect-error
|
|
125
131
|
if (args[6]?.__isAutoImport) {
|
|
126
132
|
// @ts-expect-error
|
|
127
|
-
const { fileName } = args[6]
|
|
133
|
+
const { fileName } = args[6].__isAutoImport;
|
|
128
134
|
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
129
135
|
if (sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode) {
|
|
130
136
|
const sfc = sourceScript.generated.root.vueSfc;
|
|
@@ -284,8 +290,7 @@ function getEncodedSemanticClassifications(ts, language, languageService, asScri
|
|
|
284
290
|
start: span.start - template.startTagEnd,
|
|
285
291
|
length: span.length,
|
|
286
292
|
})) {
|
|
287
|
-
result.spans.push(componentSpan.start + template.startTagEnd, componentSpan.length, 256
|
|
288
|
-
);
|
|
293
|
+
result.spans.push(componentSpan.start + template.startTagEnd, componentSpan.length, 256);
|
|
289
294
|
}
|
|
290
295
|
}
|
|
291
296
|
}
|
|
@@ -303,7 +308,8 @@ function getComponentSpans(vueCode, template, spanTemplateRange) {
|
|
|
303
308
|
]);
|
|
304
309
|
if (template.ast) {
|
|
305
310
|
for (const node of (0, language_core_1.forEachElementNode)(template.ast)) {
|
|
306
|
-
if (node.loc.end.offset <= spanTemplateRange.start
|
|
311
|
+
if (node.loc.end.offset <= spanTemplateRange.start
|
|
312
|
+
|| node.loc.start.offset >= (spanTemplateRange.start + spanTemplateRange.length)) {
|
|
307
313
|
continue;
|
|
308
314
|
}
|
|
309
315
|
if (components.has(node.tag) && !elements.has(node.tag)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/typescript-plugin",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/typescript-plugin"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/typescript": "2.4.
|
|
17
|
-
"@vue/language-core": "3.0.0-beta.
|
|
16
|
+
"@volar/typescript": "2.4.15",
|
|
17
|
+
"@vue/language-core": "3.0.0-beta.4",
|
|
18
18
|
"@vue/shared": "^3.5.0",
|
|
19
19
|
"path-browserify": "^1.0.1"
|
|
20
20
|
},
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"@types/node": "^22.10.4",
|
|
23
23
|
"@types/path-browserify": "^1.0.1"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "5cb41faacbfe2d9e2d64637c6c1ae8769d9cba3f"
|
|
26
26
|
}
|