@vue/typescript-plugin 2.2.2 → 2.2.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/lib/common.js +2 -2
- package/lib/requests/collectExtractProps.js +1 -1
- package/lib/utils.js +3 -1
- package/package.json +3 -3
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -39
- package/lib/requests/componentInfos.d.ts +0 -15
- package/lib/requests/componentInfos.js +0 -268
- package/lib/requests/getSlotNames.d.ts +0 -6
- package/lib/requests/getSlotNames.js +0 -30
- package/lib/requests/goToDefinition.d.ts +0 -2
- package/lib/requests/goToDefinition.js +0 -26
package/lib/common.js
CHANGED
|
@@ -102,7 +102,7 @@ function getCompletionEntryDetails(language, asScriptId, getCompletionEntryDetai
|
|
|
102
102
|
const { fileName } = args[6]?.__isAutoImport;
|
|
103
103
|
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
104
104
|
if (sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode) {
|
|
105
|
-
const sfc = sourceScript.generated.root.
|
|
105
|
+
const sfc = sourceScript.generated.root.vueSfc;
|
|
106
106
|
if (!sfc?.descriptor.script && !sfc?.descriptor.scriptSetup) {
|
|
107
107
|
for (const codeAction of details?.codeActions ?? []) {
|
|
108
108
|
for (const change of codeAction.changes) {
|
|
@@ -173,7 +173,7 @@ function getEncodedSemanticClassifications(ts, language, languageService, asScri
|
|
|
173
173
|
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
174
174
|
const root = sourceScript?.generated?.root;
|
|
175
175
|
if (root instanceof language_core_1.VueVirtualCode) {
|
|
176
|
-
const { template } = root.
|
|
176
|
+
const { template } = root.sfc;
|
|
177
177
|
if (template) {
|
|
178
178
|
for (const componentSpan of getComponentSpans.call({ typescript: ts, languageService }, root, template, {
|
|
179
179
|
start: span.start - template.startTagEnd,
|
|
@@ -18,7 +18,7 @@ function collectExtractProps(fileName, templateCodeRange) {
|
|
|
18
18
|
const checker = program.getTypeChecker();
|
|
19
19
|
const script = sourceScript.generated?.languagePlugin.typescript?.getServiceScript(root);
|
|
20
20
|
const maps = script ? [...language.maps.forEach(script.code)].map(([_sourceScript, map]) => map) : [];
|
|
21
|
-
const sfc = root
|
|
21
|
+
const { sfc } = root;
|
|
22
22
|
sourceFile.forEachChild(function visit(node) {
|
|
23
23
|
if (ts.isPropertyAccessExpression(node)
|
|
24
24
|
&& ts.isIdentifier(node.expression)
|
package/lib/utils.js
CHANGED
|
@@ -153,7 +153,9 @@ class NamedPipeServer {
|
|
|
153
153
|
else if (type === 'componentPropsUpdated') {
|
|
154
154
|
const components = this.componentNamesAndProps.get(fileName) ?? {};
|
|
155
155
|
const [name, props] = data;
|
|
156
|
-
|
|
156
|
+
if (name in components) {
|
|
157
|
+
components[name] = props;
|
|
158
|
+
}
|
|
157
159
|
}
|
|
158
160
|
else {
|
|
159
161
|
console.error('Unknown notification type:', type);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/typescript-plugin",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@volar/typescript": "~2.4.11",
|
|
17
|
-
"@vue/language-core": "2.2.
|
|
17
|
+
"@vue/language-core": "2.2.4",
|
|
18
18
|
"@vue/shared": "^3.5.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^22.10.4"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "c28986596935cb43979c9d437c25f292bdb36cef"
|
|
24
24
|
}
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createLanguageServicePlugin } from '@volar/typescript/lib/quickstart/createLanguageServicePlugin';
|
|
2
|
-
import * as vue from '@vue/language-core';
|
|
3
|
-
import { proxyLanguageServiceForVue } from './common';
|
|
4
|
-
import { startNamedPipeServer } from './server';
|
|
5
|
-
const windowsPathReg = /\\/g;
|
|
6
|
-
const vueCompilerOptions = new WeakMap();
|
|
7
|
-
const plugin = createLanguageServicePlugin((ts, info) => {
|
|
8
|
-
const vueOptions = getVueCompilerOptions();
|
|
9
|
-
const languagePlugin = vue.createVueLanguagePlugin(ts, info.languageServiceHost.getCompilationSettings(), vueOptions, id => id);
|
|
10
|
-
vueCompilerOptions.set(info.project, vueOptions);
|
|
11
|
-
return {
|
|
12
|
-
languagePlugins: [languagePlugin],
|
|
13
|
-
setup: language => {
|
|
14
|
-
info.languageService = proxyLanguageServiceForVue(ts, language, info.languageService, vueOptions, fileName => fileName);
|
|
15
|
-
if (info.project.projectKind === ts.server.ProjectKind.Configured
|
|
16
|
-
|| info.project.projectKind === ts.server.ProjectKind.Inferred) {
|
|
17
|
-
startNamedPipeServer(ts, info, language, info.project.projectKind);
|
|
18
|
-
}
|
|
19
|
-
// #3963
|
|
20
|
-
const timer = setInterval(() => {
|
|
21
|
-
if (info.project['program']) {
|
|
22
|
-
clearInterval(timer);
|
|
23
|
-
info.project['program'].__vue__ = { language };
|
|
24
|
-
}
|
|
25
|
-
}, 50);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
function getVueCompilerOptions() {
|
|
29
|
-
if (info.project.projectKind === ts.server.ProjectKind.Configured) {
|
|
30
|
-
const tsconfig = info.project.getProjectName();
|
|
31
|
-
return vue.createParsedCommandLine(ts, ts.sys, tsconfig.replace(windowsPathReg, '/')).vueOptions;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return vue.createParsedCommandLineByJson(ts, ts.sys, info.languageServiceHost.getCurrentDirectory(), {}).vueOptions;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
export default plugin;
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as vue from '@vue/language-core';
|
|
2
|
-
import type * as ts from 'typescript';
|
|
3
|
-
import type { RequestContext } from './types';
|
|
4
|
-
export interface ComponentPropInfo {
|
|
5
|
-
name: string;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
deprecated?: boolean;
|
|
8
|
-
commentMarkdown?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function getComponentProps(this: RequestContext, fileName: string, tag: string): ComponentPropInfo[] | undefined;
|
|
11
|
-
export declare function getComponentEvents(this: RequestContext, fileName: string, tag: string): string[] | undefined;
|
|
12
|
-
export declare function getComponentDirectives(this: RequestContext, fileName: string): string[] | undefined;
|
|
13
|
-
export declare function getComponentNames(this: RequestContext, fileName: string): string[] | undefined;
|
|
14
|
-
export declare function _getComponentNames(ts: typeof import('typescript'), tsLs: ts.LanguageService, vueCode: vue.VueVirtualCode): string[];
|
|
15
|
-
export declare function getElementAttrs(this: RequestContext, fileName: string, tagName: string): string[] | undefined;
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getComponentProps = getComponentProps;
|
|
4
|
-
exports.getComponentEvents = getComponentEvents;
|
|
5
|
-
exports.getComponentDirectives = getComponentDirectives;
|
|
6
|
-
exports.getComponentNames = getComponentNames;
|
|
7
|
-
exports._getComponentNames = _getComponentNames;
|
|
8
|
-
exports.getElementAttrs = getElementAttrs;
|
|
9
|
-
const vue = require("@vue/language-core");
|
|
10
|
-
const shared_1 = require("@vue/shared");
|
|
11
|
-
const path = require("node:path");
|
|
12
|
-
function getComponentProps(fileName, tag) {
|
|
13
|
-
const { typescript: ts, language, languageService, getFileId } = this;
|
|
14
|
-
const volarFile = language.scripts.get(getFileId(fileName));
|
|
15
|
-
if (!(volarFile?.generated?.root instanceof vue.VueVirtualCode)) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const vueCode = volarFile.generated.root;
|
|
19
|
-
const program = languageService.getProgram();
|
|
20
|
-
const checker = program.getTypeChecker();
|
|
21
|
-
const components = getVariableType(ts, languageService, vueCode, '__VLS_components');
|
|
22
|
-
if (!components) {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
const componentType = getComponentType(ts, languageService, vueCode, components, fileName, tag);
|
|
26
|
-
if (!componentType) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
const result = new Map();
|
|
30
|
-
for (const sig of componentType.getCallSignatures()) {
|
|
31
|
-
const propParam = sig.parameters[0];
|
|
32
|
-
if (propParam) {
|
|
33
|
-
const propsType = checker.getTypeOfSymbolAtLocation(propParam, components.node);
|
|
34
|
-
const props = propsType.getProperties();
|
|
35
|
-
for (const prop of props) {
|
|
36
|
-
const name = prop.name;
|
|
37
|
-
const required = !(prop.flags & ts.SymbolFlags.Optional) || undefined;
|
|
38
|
-
const { content: commentMarkdown, deprecated } = generateCommentMarkdown(prop.getDocumentationComment(checker), prop.getJsDocTags());
|
|
39
|
-
result.set(name, {
|
|
40
|
-
name,
|
|
41
|
-
required,
|
|
42
|
-
deprecated,
|
|
43
|
-
commentMarkdown
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
for (const sig of componentType.getConstructSignatures()) {
|
|
49
|
-
const instanceType = sig.getReturnType();
|
|
50
|
-
const propsSymbol = instanceType.getProperty('$props');
|
|
51
|
-
if (propsSymbol) {
|
|
52
|
-
const propsType = checker.getTypeOfSymbolAtLocation(propsSymbol, components.node);
|
|
53
|
-
const props = propsType.getProperties();
|
|
54
|
-
for (const prop of props) {
|
|
55
|
-
if (prop.flags & ts.SymbolFlags.Method) { // #2443
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
const name = prop.name;
|
|
59
|
-
const required = !(prop.flags & ts.SymbolFlags.Optional) || undefined;
|
|
60
|
-
const { content: commentMarkdown, deprecated } = generateCommentMarkdown(prop.getDocumentationComment(checker), prop.getJsDocTags());
|
|
61
|
-
result.set(name, {
|
|
62
|
-
name,
|
|
63
|
-
required,
|
|
64
|
-
deprecated,
|
|
65
|
-
commentMarkdown
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return [...result.values()];
|
|
71
|
-
}
|
|
72
|
-
function getComponentEvents(fileName, tag) {
|
|
73
|
-
const { typescript: ts, language, languageService, getFileId } = this;
|
|
74
|
-
const volarFile = language.scripts.get(getFileId(fileName));
|
|
75
|
-
if (!(volarFile?.generated?.root instanceof vue.VueVirtualCode)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const vueCode = volarFile.generated.root;
|
|
79
|
-
const program = languageService.getProgram();
|
|
80
|
-
const checker = program.getTypeChecker();
|
|
81
|
-
const components = getVariableType(ts, languageService, vueCode, '__VLS_components');
|
|
82
|
-
if (!components) {
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
const componentType = getComponentType(ts, languageService, vueCode, components, fileName, tag);
|
|
86
|
-
if (!componentType) {
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
const result = new Set();
|
|
90
|
-
// for (const sig of componentType.getCallSignatures()) {
|
|
91
|
-
// const emitParam = sig.parameters[1];
|
|
92
|
-
// if (emitParam) {
|
|
93
|
-
// // TODO
|
|
94
|
-
// }
|
|
95
|
-
// }
|
|
96
|
-
for (const sig of componentType.getConstructSignatures()) {
|
|
97
|
-
const instanceType = sig.getReturnType();
|
|
98
|
-
const emitSymbol = instanceType.getProperty('$emit');
|
|
99
|
-
if (emitSymbol) {
|
|
100
|
-
const emitType = checker.getTypeOfSymbolAtLocation(emitSymbol, components.node);
|
|
101
|
-
for (const call of emitType.getCallSignatures()) {
|
|
102
|
-
const eventNameParamSymbol = call.parameters[0];
|
|
103
|
-
if (eventNameParamSymbol) {
|
|
104
|
-
const eventNameParamType = checker.getTypeOfSymbolAtLocation(eventNameParamSymbol, components.node);
|
|
105
|
-
if (eventNameParamType.isStringLiteral()) {
|
|
106
|
-
result.add(eventNameParamType.value);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return [...result];
|
|
113
|
-
}
|
|
114
|
-
function getComponentDirectives(fileName) {
|
|
115
|
-
const { typescript: ts, language, languageService, getFileId } = this;
|
|
116
|
-
const volarFile = language.scripts.get(getFileId(fileName));
|
|
117
|
-
if (!(volarFile?.generated?.root instanceof vue.VueVirtualCode)) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const vueCode = volarFile.generated.root;
|
|
121
|
-
const directives = getVariableType(ts, languageService, vueCode, '__VLS_directives');
|
|
122
|
-
if (!directives) {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
return directives.type.getProperties()
|
|
126
|
-
.map(({ name }) => name)
|
|
127
|
-
.filter(name => name.startsWith('v') && name.length >= 2 && name[1] === name[1].toUpperCase())
|
|
128
|
-
.filter(name => !['vBind', 'vIf', 'vOn', 'VOnce', 'vShow', 'VSlot'].includes(name));
|
|
129
|
-
}
|
|
130
|
-
function getComponentNames(fileName) {
|
|
131
|
-
const { typescript: ts, language, languageService, getFileId } = this;
|
|
132
|
-
const volarFile = language.scripts.get(getFileId(fileName));
|
|
133
|
-
if (!(volarFile?.generated?.root instanceof vue.VueVirtualCode)) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const vueCode = volarFile.generated.root;
|
|
137
|
-
return _getComponentNames(ts, languageService, vueCode);
|
|
138
|
-
}
|
|
139
|
-
function _getComponentNames(ts, tsLs, vueCode) {
|
|
140
|
-
const names = getVariableType(ts, tsLs, vueCode, '__VLS_components')
|
|
141
|
-
?.type
|
|
142
|
-
?.getProperties()
|
|
143
|
-
.map(c => c.name)
|
|
144
|
-
.filter(entry => !entry.includes('$') && !entry.startsWith('_'))
|
|
145
|
-
?? [];
|
|
146
|
-
names.push(getSelfComponentName(vueCode.fileName));
|
|
147
|
-
return names;
|
|
148
|
-
}
|
|
149
|
-
function getElementAttrs(fileName, tagName) {
|
|
150
|
-
const { typescript: ts, language, languageService, getFileId } = this;
|
|
151
|
-
const volarFile = language.scripts.get(getFileId(fileName));
|
|
152
|
-
if (!(volarFile?.generated?.root instanceof vue.VueVirtualCode)) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const program = languageService.getProgram();
|
|
156
|
-
let tsSourceFile;
|
|
157
|
-
if (tsSourceFile = program.getSourceFile(fileName)) {
|
|
158
|
-
const typeNode = tsSourceFile.statements
|
|
159
|
-
.filter(ts.isTypeAliasDeclaration)
|
|
160
|
-
.find(node => node.name.getText() === '__VLS_IntrinsicElementsCompletion');
|
|
161
|
-
const checker = program.getTypeChecker();
|
|
162
|
-
if (checker && typeNode) {
|
|
163
|
-
const type = checker.getTypeFromTypeNode(typeNode.type);
|
|
164
|
-
const el = type.getProperty(tagName);
|
|
165
|
-
if (el) {
|
|
166
|
-
const attrs = checker.getTypeOfSymbolAtLocation(el, typeNode).getProperties();
|
|
167
|
-
return attrs.map(c => c.name);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return [];
|
|
172
|
-
}
|
|
173
|
-
function getComponentType(ts, languageService, vueCode, components, fileName, tag) {
|
|
174
|
-
const program = languageService.getProgram();
|
|
175
|
-
const checker = program.getTypeChecker();
|
|
176
|
-
const name = tag.split('.');
|
|
177
|
-
let componentSymbol = components.type.getProperty(name[0])
|
|
178
|
-
?? components.type.getProperty((0, shared_1.camelize)(name[0]))
|
|
179
|
-
?? components.type.getProperty((0, shared_1.capitalize)((0, shared_1.camelize)(name[0])));
|
|
180
|
-
let componentType;
|
|
181
|
-
if (!componentSymbol) {
|
|
182
|
-
const name = getSelfComponentName(fileName);
|
|
183
|
-
if (name === (0, shared_1.capitalize)((0, shared_1.camelize)(tag))) {
|
|
184
|
-
componentType = getVariableType(ts, languageService, vueCode, '__VLS_self')?.type;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
componentType = checker.getTypeOfSymbolAtLocation(componentSymbol, components.node);
|
|
189
|
-
for (let i = 1; i < name.length; i++) {
|
|
190
|
-
componentSymbol = componentType.getProperty(name[i]);
|
|
191
|
-
if (componentSymbol) {
|
|
192
|
-
componentType = checker.getTypeOfSymbolAtLocation(componentSymbol, components.node);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return componentType;
|
|
197
|
-
}
|
|
198
|
-
function getVariableType(ts, languageService, vueCode, name) {
|
|
199
|
-
const program = languageService.getProgram();
|
|
200
|
-
let tsSourceFile;
|
|
201
|
-
if (tsSourceFile = program.getSourceFile(vueCode.fileName)) {
|
|
202
|
-
const node = searchVariableDeclarationNode(ts, tsSourceFile, name);
|
|
203
|
-
const checker = program.getTypeChecker();
|
|
204
|
-
if (checker && node) {
|
|
205
|
-
return {
|
|
206
|
-
node: node,
|
|
207
|
-
type: checker.getTypeAtLocation(node),
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
function getSelfComponentName(fileName) {
|
|
213
|
-
const baseName = path.basename(fileName);
|
|
214
|
-
return (0, shared_1.capitalize)((0, shared_1.camelize)(baseName.slice(0, baseName.lastIndexOf('.'))));
|
|
215
|
-
}
|
|
216
|
-
function searchVariableDeclarationNode(ts, sourceFile, name) {
|
|
217
|
-
let componentsNode;
|
|
218
|
-
walk(sourceFile);
|
|
219
|
-
return componentsNode;
|
|
220
|
-
function walk(node) {
|
|
221
|
-
if (componentsNode) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
else if (ts.isVariableDeclaration(node) && node.name.getText() === name) {
|
|
225
|
-
componentsNode = node;
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
node.forEachChild(walk);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function generateCommentMarkdown(parts, jsDocTags) {
|
|
233
|
-
const parsedComment = _symbolDisplayPartsToMarkdown(parts);
|
|
234
|
-
const parsedJsDoc = _jsDocTagInfoToMarkdown(jsDocTags);
|
|
235
|
-
const content = [parsedComment, parsedJsDoc].filter(str => !!str).join('\n\n');
|
|
236
|
-
const deprecated = jsDocTags.some(tag => tag.name === 'deprecated');
|
|
237
|
-
return {
|
|
238
|
-
content,
|
|
239
|
-
deprecated
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
function _symbolDisplayPartsToMarkdown(parts) {
|
|
243
|
-
return parts.map(part => {
|
|
244
|
-
switch (part.kind) {
|
|
245
|
-
case 'keyword':
|
|
246
|
-
return `\`${part.text}\``;
|
|
247
|
-
case 'functionName':
|
|
248
|
-
return `**${part.text}**`;
|
|
249
|
-
default:
|
|
250
|
-
return part.text;
|
|
251
|
-
}
|
|
252
|
-
}).join('');
|
|
253
|
-
}
|
|
254
|
-
function _jsDocTagInfoToMarkdown(jsDocTags) {
|
|
255
|
-
return jsDocTags.map(tag => {
|
|
256
|
-
const tagName = `*@${tag.name}*`;
|
|
257
|
-
const tagText = tag.text?.map(t => {
|
|
258
|
-
if (t.kind === 'parameterName') {
|
|
259
|
-
return `\`${t.text}\``;
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
return t.text;
|
|
263
|
-
}
|
|
264
|
-
}).join('') || '';
|
|
265
|
-
return `${tagName} ${tagText}`;
|
|
266
|
-
}).join('\n\n');
|
|
267
|
-
}
|
|
268
|
-
//# sourceMappingURL=componentInfos.js.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSlotNames = getSlotNames;
|
|
4
|
-
const language_core_1 = require("@vue/language-core");
|
|
5
|
-
function getSlotNames(fileName) {
|
|
6
|
-
const { typescript: ts, language, languageService, getFileId } = this;
|
|
7
|
-
const sourceScript = language.scripts.get(getFileId(fileName));
|
|
8
|
-
if (!sourceScript?.generated) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const root = sourceScript.generated.root;
|
|
12
|
-
if (!(root instanceof language_core_1.VueVirtualCode)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const program = languageService.getProgram();
|
|
16
|
-
const tsSourceFile = program.getSourceFile(fileName);
|
|
17
|
-
if (!tsSourceFile) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const checker = program.getTypeChecker();
|
|
21
|
-
const typeNode = tsSourceFile.statements
|
|
22
|
-
.filter(ts.isTypeAliasDeclaration)
|
|
23
|
-
.find(node => node.name.getText() === '__VLS_Slots');
|
|
24
|
-
if (typeNode) {
|
|
25
|
-
const attrs = checker.getTypeFromTypeNode(typeNode.type).getProperties();
|
|
26
|
-
return attrs.map(attr => attr.name);
|
|
27
|
-
}
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=getSlotNames.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.goToDefinition = goToDefinition;
|
|
4
|
-
const vue = require("@vue/language-core");
|
|
5
|
-
const componentInfos_1 = require("./componentInfos");
|
|
6
|
-
function goToDefinition(fileName, tag) {
|
|
7
|
-
const { typescript: ts, language, languageService, getFileId } = this;
|
|
8
|
-
const volarFile = language.scripts.get(getFileId(fileName));
|
|
9
|
-
if (!(volarFile?.generated?.root instanceof vue.VueVirtualCode)) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const vueCode = volarFile.generated.root;
|
|
13
|
-
const components = (0, componentInfos_1.getVariableType)(ts, languageService, vueCode, '__VLS_components');
|
|
14
|
-
if (!components) {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
const componentType = (0, componentInfos_1.getComponentType)(ts, languageService, vueCode, components, fileName, tag);
|
|
18
|
-
if (!componentType) {
|
|
19
|
-
return '';
|
|
20
|
-
}
|
|
21
|
-
const decls = componentType.symbol.declarations ?? [];
|
|
22
|
-
for (const decl of decls) {
|
|
23
|
-
return decl.getSourceFile().fileName;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=goToDefinition.js.map
|