@vue/typescript-plugin 3.0.7 → 3.0.8
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 +2 -2
- package/lib/common.js +2 -2
- package/lib/requests/getReactiveReferences.d.ts +3 -10
- package/lib/requests/getReactiveReferences.js +44 -595
- package/package.json +4 -3
- package/lib/proxy.d.ts +0 -3
- package/lib/proxy.js +0 -227
- package/lib/requests/getComponentHighlights.d.ts +0 -1
- package/lib/requests/getComponentHighlights.js +0 -3
- package/lib/requests/getCurrentComponentSlots.d.ts +0 -1
- package/lib/requests/getCurrentComponentSlots.js +0 -3
- package/lib/requests/getDefineSlotNames.d.ts +0 -1
- package/lib/requests/getDefineSlotNames.js +0 -3
- package/lib/requests/getDefineSlots.d.ts +0 -2
- package/lib/requests/getDefineSlots.js +0 -16
- package/lib/requests/getMissingPropsDiagnostics.d.ts +0 -10
- package/lib/requests/getMissingPropsDiagnostics.js +0 -40
- package/lib/requests/getPropertiesAtLocation.d.ts +0 -2
- package/lib/requests/getPropertiesAtLocation.js +0 -63
- package/lib/requests/getReactiveVariableSpans.d.ts +0 -3
- package/lib/requests/getReactiveVariableSpans.js +0 -30
- package/lib/requests/getSemanticClassfications.d.ts +0 -3
- package/lib/requests/getSemanticClassfications.js +0 -8
- package/lib/requests/getVariableProperties.d.ts +0 -10
- package/lib/requests/getVariableProperties.js +0 -16
- package/lib/requests/isRefAtLocation.d.ts +0 -3
- package/lib/requests/isRefAtLocation.js +0 -55
- package/lib/requests/resolveModuleName.d.ts +0 -4
- package/lib/requests/resolveModuleName.js +0 -28
- package/lib/requests/types.d.ts +0 -8
- package/lib/requests/types.js +0 -3
package/lib/proxy.js
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createVueLanguageServiceProxy = createVueLanguageServiceProxy;
|
|
4
|
-
const language_core_1 = require("@vue/language-core");
|
|
5
|
-
const shared_1 = require("@vue/shared");
|
|
6
|
-
const windowsPathReg = /\\/g;
|
|
7
|
-
function createVueLanguageServiceProxy(ts, language, languageService, vueOptions) {
|
|
8
|
-
const proxyCache = new Map();
|
|
9
|
-
const getProxyMethod = (target, p) => {
|
|
10
|
-
switch (p) {
|
|
11
|
-
case 'getCompletionsAtPosition':
|
|
12
|
-
return getCompletionsAtPosition(ts, language, vueOptions, target[p]);
|
|
13
|
-
case 'getCompletionEntryDetails':
|
|
14
|
-
return getCompletionEntryDetails(language, target[p]);
|
|
15
|
-
case 'getCodeFixesAtPosition':
|
|
16
|
-
return getCodeFixesAtPosition(target[p]);
|
|
17
|
-
case 'getDefinitionAndBoundSpan':
|
|
18
|
-
return getDefinitionAndBoundSpan(ts, language, languageService, vueOptions, target[p]);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
return new Proxy(languageService, {
|
|
22
|
-
get(target, p, receiver) {
|
|
23
|
-
if (!proxyCache.has(p)) {
|
|
24
|
-
proxyCache.set(p, getProxyMethod(target, p));
|
|
25
|
-
}
|
|
26
|
-
return proxyCache.get(p) ?? Reflect.get(target, p, receiver);
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function getCompletionsAtPosition(ts, language, vueOptions, getCompletionsAtPosition) {
|
|
31
|
-
return (filePath, position, options, formattingSettings) => {
|
|
32
|
-
const fileName = filePath.replace(windowsPathReg, '/');
|
|
33
|
-
const result = getCompletionsAtPosition(fileName, position, options, formattingSettings);
|
|
34
|
-
if (result) {
|
|
35
|
-
// filter __VLS_
|
|
36
|
-
result.entries = result.entries.filter(entry => !entry.name.includes('__VLS_')
|
|
37
|
-
&& !entry.labelDetails?.description?.includes('__VLS_'));
|
|
38
|
-
// filter global variables in template and styles
|
|
39
|
-
const sourceScript = language.scripts.get(fileName);
|
|
40
|
-
const root = sourceScript?.generated?.root;
|
|
41
|
-
if (root instanceof language_core_1.VueVirtualCode) {
|
|
42
|
-
const blocks = [
|
|
43
|
-
root.sfc.template,
|
|
44
|
-
...root.sfc.styles,
|
|
45
|
-
];
|
|
46
|
-
const ranges = blocks.filter(Boolean).map(block => [
|
|
47
|
-
block.startTagEnd,
|
|
48
|
-
block.endTagStart,
|
|
49
|
-
]);
|
|
50
|
-
if (ranges.some(([start, end]) => position >= start && position <= end)) {
|
|
51
|
-
const globalKinds = new Set(['var', 'function', 'module']);
|
|
52
|
-
const globalsOrKeywords = ts.Completions.SortText.GlobalsOrKeywords;
|
|
53
|
-
const sortTexts = new Set([
|
|
54
|
-
globalsOrKeywords,
|
|
55
|
-
'z' + globalsOrKeywords,
|
|
56
|
-
globalsOrKeywords + '1',
|
|
57
|
-
]);
|
|
58
|
-
result.entries = result.entries.filter(entry => !(entry.kind === 'const' && entry.name in vueOptions.macros) && (!globalKinds.has(entry.kind)
|
|
59
|
-
|| !sortTexts.has(entry.sortText)
|
|
60
|
-
|| (0, shared_1.isGloballyAllowed)(entry.name)));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// modify label
|
|
64
|
-
for (const item of result.entries) {
|
|
65
|
-
if (item.source) {
|
|
66
|
-
const originalName = item.name;
|
|
67
|
-
for (const vueExt of vueOptions.extensions) {
|
|
68
|
-
const suffix = (0, shared_1.capitalize)(vueExt.slice(1)); // .vue -> Vue
|
|
69
|
-
if (item.source.endsWith(vueExt) && item.name.endsWith(suffix)) {
|
|
70
|
-
item.name = (0, shared_1.capitalize)(item.name.slice(0, -suffix.length));
|
|
71
|
-
if (item.insertText) {
|
|
72
|
-
// #2286
|
|
73
|
-
item.insertText = item.insertText.replace(`${suffix}$1`, '$1');
|
|
74
|
-
}
|
|
75
|
-
if (item.data) {
|
|
76
|
-
// @ts-expect-error
|
|
77
|
-
item.data.__isComponentAutoImport = {
|
|
78
|
-
ext: vueExt,
|
|
79
|
-
suffix,
|
|
80
|
-
originalName,
|
|
81
|
-
newName: item.insertText,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (item.data) {
|
|
88
|
-
// @ts-expect-error
|
|
89
|
-
item.data.__isAutoImport = {
|
|
90
|
-
fileName,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return result;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function getCompletionEntryDetails(language, getCompletionEntryDetails) {
|
|
100
|
-
return (...args) => {
|
|
101
|
-
const details = getCompletionEntryDetails(...args);
|
|
102
|
-
// modify import statement
|
|
103
|
-
// @ts-expect-error
|
|
104
|
-
if (args[6]?.__isComponentAutoImport) {
|
|
105
|
-
// @ts-expect-error
|
|
106
|
-
const { originalName, newName } = args[6].__isComponentAutoImport;
|
|
107
|
-
for (const codeAction of details?.codeActions ?? []) {
|
|
108
|
-
for (const change of codeAction.changes) {
|
|
109
|
-
for (const textChange of change.textChanges) {
|
|
110
|
-
textChange.newText = textChange.newText.replace('import ' + originalName + ' from ', 'import ' + newName + ' from ');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// @ts-expect-error
|
|
116
|
-
if (args[6]?.__isAutoImport) {
|
|
117
|
-
// @ts-expect-error
|
|
118
|
-
const { fileName } = args[6].__isAutoImport;
|
|
119
|
-
const sourceScript = language.scripts.get(fileName);
|
|
120
|
-
if (sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode) {
|
|
121
|
-
const { sfc } = sourceScript.generated.root;
|
|
122
|
-
if (!sfc.script && !sfc.scriptSetup) {
|
|
123
|
-
for (const codeAction of details?.codeActions ?? []) {
|
|
124
|
-
for (const change of codeAction.changes) {
|
|
125
|
-
for (const textChange of change.textChanges) {
|
|
126
|
-
textChange.newText = `<script setup lang="ts">${textChange.newText}</script>\n\n`;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return details;
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function getCodeFixesAtPosition(getCodeFixesAtPosition) {
|
|
140
|
-
return (...args) => {
|
|
141
|
-
let result = getCodeFixesAtPosition(...args);
|
|
142
|
-
// filter __VLS_
|
|
143
|
-
result = result.filter(entry => !entry.description.includes('__VLS_'));
|
|
144
|
-
return result;
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function getDefinitionAndBoundSpan(ts, language, languageService, vueOptions, getDefinitionAndBoundSpan) {
|
|
148
|
-
return (fileName, position) => {
|
|
149
|
-
const result = getDefinitionAndBoundSpan(fileName, position);
|
|
150
|
-
if (!result?.definitions?.length) {
|
|
151
|
-
return result;
|
|
152
|
-
}
|
|
153
|
-
const program = languageService.getProgram();
|
|
154
|
-
const sourceScript = language.scripts.get(fileName);
|
|
155
|
-
if (!sourceScript?.generated) {
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
|
-
const root = sourceScript.generated.root;
|
|
159
|
-
if (!(root instanceof language_core_1.VueVirtualCode)) {
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
if (!root.sfc.template
|
|
163
|
-
|| position < root.sfc.template.startTagEnd
|
|
164
|
-
|| position > root.sfc.template.endTagStart) {
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
const definitions = new Set(result.definitions);
|
|
168
|
-
const skippedDefinitions = [];
|
|
169
|
-
// #5275
|
|
170
|
-
if (result.definitions.length >= 2) {
|
|
171
|
-
for (const definition of result.definitions) {
|
|
172
|
-
if (root.sfc.content[definition.textSpan.start - 1] === '@'
|
|
173
|
-
|| root.sfc.content.slice(definition.textSpan.start - 5, definition.textSpan.start) === 'v-on:') {
|
|
174
|
-
skippedDefinitions.push(definition);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
for (const definition of result.definitions) {
|
|
179
|
-
if (vueOptions.extensions.some(ext => definition.fileName.endsWith(ext))) {
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
const sourceFile = program.getSourceFile(definition.fileName);
|
|
183
|
-
if (!sourceFile) {
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
visit(sourceFile, definition, sourceFile);
|
|
187
|
-
}
|
|
188
|
-
for (const definition of skippedDefinitions) {
|
|
189
|
-
definitions.delete(definition);
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
definitions: [...definitions],
|
|
193
|
-
textSpan: result.textSpan,
|
|
194
|
-
};
|
|
195
|
-
function visit(node, definition, sourceFile) {
|
|
196
|
-
if (ts.isPropertySignature(node) && node.type) {
|
|
197
|
-
proxy(node.name, node.type, definition, sourceFile);
|
|
198
|
-
}
|
|
199
|
-
else if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.type && !node.initializer) {
|
|
200
|
-
proxy(node.name, node.type, definition, sourceFile);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
ts.forEachChild(node, child => visit(child, definition, sourceFile));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function proxy(name, type, definition, sourceFile) {
|
|
207
|
-
const { textSpan, fileName } = definition;
|
|
208
|
-
const start = name.getStart(sourceFile);
|
|
209
|
-
const end = name.getEnd();
|
|
210
|
-
if (start !== textSpan.start || end - start !== textSpan.length) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (!ts.isIndexedAccessTypeNode(type)) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const pos = type.indexType.getStart(sourceFile);
|
|
217
|
-
const res = getDefinitionAndBoundSpan(fileName, pos);
|
|
218
|
-
if (res?.definitions?.length) {
|
|
219
|
-
for (const definition of res.definitions) {
|
|
220
|
-
definitions.add(definition);
|
|
221
|
-
}
|
|
222
|
-
skippedDefinitions.push(definition);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
//# sourceMappingURL=proxy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefineSlots = getDefineSlots;
|
|
4
|
-
const language_core_1 = require("@vue/language-core");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
function getDefineSlots(fileName) {
|
|
7
|
-
const { typescript: ts, language, languageService, getFileId } = this;
|
|
8
|
-
const volarFile = language.scripts.get(getFileId(fileName));
|
|
9
|
-
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const vueCode = volarFile.generated.root;
|
|
13
|
-
const slots = (0, utils_1.getTypeAliasType)(ts, languageService, vueCode, '__VLS_Slots');
|
|
14
|
-
return slots?.type.getProperties().map(prop => prop.getName());
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=getDefineSlots.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RequestContext } from './types';
|
|
2
|
-
export interface ComponentPropInfo {
|
|
3
|
-
name: string;
|
|
4
|
-
required?: boolean;
|
|
5
|
-
deprecated?: boolean;
|
|
6
|
-
isAttribute?: boolean;
|
|
7
|
-
commentMarkdown?: string;
|
|
8
|
-
values?: string[];
|
|
9
|
-
}
|
|
10
|
-
export declare function getMissingPropsDiagnostics(this: RequestContext, fileName: string): undefined;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMissingPropsDiagnostics = getMissingPropsDiagnostics;
|
|
4
|
-
const language_core_1 = require("@vue/language-core");
|
|
5
|
-
function getMissingPropsDiagnostics(fileName) {
|
|
6
|
-
const { typescript: ts, language, languageService, asScriptId } = this;
|
|
7
|
-
const volarFile = language.scripts.get(asScriptId(fileName));
|
|
8
|
-
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const vueCode = volarFile.generated.root;
|
|
12
|
-
const program = languageService.getProgram();
|
|
13
|
-
const sourceFile = program.getSourceFile(vueCode.fileName);
|
|
14
|
-
if (!sourceFile) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const checker = program.getTypeChecker();
|
|
18
|
-
ts.forEachChild(sourceFile, function visit(node) {
|
|
19
|
-
if (ts.isVariableDeclaration(node)
|
|
20
|
-
&& node.initializer
|
|
21
|
-
&& ts.isCallExpression(node.initializer)
|
|
22
|
-
&& ts.isIdentifier(node.initializer.expression)
|
|
23
|
-
&& /^__VLS_\d+$/.test(node.initializer.expression.text)) {
|
|
24
|
-
const firstArg = node.initializer.arguments[0];
|
|
25
|
-
const type = checker.getTypeAtLocation(firstArg);
|
|
26
|
-
const contextualType = checker.getContextualType(firstArg);
|
|
27
|
-
if (contextualType) {
|
|
28
|
-
const subtype = contextualType.isUnion()
|
|
29
|
-
? contextualType.types.find(subtype => checker.isTypeAssignableTo(subtype, type))
|
|
30
|
-
: contextualType;
|
|
31
|
-
void subtype;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
ts.forEachChild(node, visit);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=getMissingPropsDiagnostics.js.map
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/// <reference types="@volar/typescript" />
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getPropertiesAtLocation = getPropertiesAtLocation;
|
|
5
|
-
const language_core_1 = require("@vue/language-core");
|
|
6
|
-
function getPropertiesAtLocation(fileName, position) {
|
|
7
|
-
const { languageService, language, typescript: ts } = this;
|
|
8
|
-
// mapping
|
|
9
|
-
const sourceScript = language.scripts.get(fileName);
|
|
10
|
-
const root = sourceScript?.generated?.root;
|
|
11
|
-
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
const virtualScript = sourceScript.generated.languagePlugin.typescript?.getServiceScript(root);
|
|
15
|
-
if (!virtualScript) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
let mapped = false;
|
|
19
|
-
for (const [_sourceScript, map] of language.maps.forEach(virtualScript.code)) {
|
|
20
|
-
for (const [position2, mapping] of map.toGeneratedLocation(position)) {
|
|
21
|
-
if ((0, language_core_1.isCompletionEnabled)(mapping.data)) {
|
|
22
|
-
position = position2;
|
|
23
|
-
mapped = true;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (mapped) {
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (!mapped) {
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
position += sourceScript.snapshot.getLength();
|
|
35
|
-
const program = languageService.getProgram();
|
|
36
|
-
const sourceFile = program.getSourceFile(fileName);
|
|
37
|
-
if (!sourceFile) {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
const node = findPositionIdentifier(sourceFile, sourceFile, position);
|
|
41
|
-
if (!node) {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
const checker = program.getTypeChecker();
|
|
45
|
-
const type = checker.getTypeAtLocation(node);
|
|
46
|
-
const props = type.getProperties();
|
|
47
|
-
return props.map(prop => prop.name);
|
|
48
|
-
function findPositionIdentifier(sourceFile, node, offset) {
|
|
49
|
-
let result;
|
|
50
|
-
node.forEachChild(child => {
|
|
51
|
-
if (!result) {
|
|
52
|
-
if (child.end === offset && ts.isIdentifier(child)) {
|
|
53
|
-
result = child;
|
|
54
|
-
}
|
|
55
|
-
else if (child.end >= offset && child.getStart(sourceFile) < offset) {
|
|
56
|
-
result = findPositionIdentifier(sourceFile, child, offset);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=getPropertiesAtLocation.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { SourceScript } from '@vue/language-core';
|
|
2
|
-
import type * as ts from 'typescript';
|
|
3
|
-
export declare function getReactiveVariableSpans(ts: typeof import('typescript'), program: ts.Program, sourceScript: SourceScript, fileName: string, isTsPlugin: boolean): ts.TextSpan[];
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getReactiveVariableSpans = getReactiveVariableSpans;
|
|
4
|
-
function getReactiveVariableSpans(ts, program, sourceScript, fileName, isTsPlugin) {
|
|
5
|
-
const sourceFile = program.getSourceFile(fileName);
|
|
6
|
-
if (!sourceFile) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
const checker = program.getTypeChecker();
|
|
10
|
-
const minusOffset = isTsPlugin ? sourceScript.snapshot.getLength() : 0;
|
|
11
|
-
const variableSpans = [];
|
|
12
|
-
ts.forEachChild(sourceFile, function visit(node) {
|
|
13
|
-
if (ts.isIdentifier(node)) {
|
|
14
|
-
const symbol = checker.getSymbolAtLocation(node);
|
|
15
|
-
if (symbol) {
|
|
16
|
-
const type = checker.getTypeOfSymbol(symbol);
|
|
17
|
-
const properties = type.getProperties();
|
|
18
|
-
if (properties.some(prop => prop.getName().startsWith('__@RefSymbol@'))) {
|
|
19
|
-
variableSpans.push({
|
|
20
|
-
start: node.getStart(sourceFile) - minusOffset,
|
|
21
|
-
length: node.getWidth(),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
ts.forEachChild(node, visit);
|
|
27
|
-
});
|
|
28
|
-
return variableSpans;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=getReactiveVariableSpans.js.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSemanticClassifications = getSemanticClassifications;
|
|
4
|
-
function getSemanticClassifications(fileName, span) {
|
|
5
|
-
const { languageService, typescript: ts } = this;
|
|
6
|
-
return languageService.getSemanticClassifications(fileName, span, ts.SemanticClassificationFormat.TwentyTwenty);
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=getSemanticClassfications.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RequestContext } from './types';
|
|
2
|
-
export interface ComponentPropInfo {
|
|
3
|
-
name: string;
|
|
4
|
-
required?: boolean;
|
|
5
|
-
deprecated?: boolean;
|
|
6
|
-
isAttribute?: boolean;
|
|
7
|
-
commentMarkdown?: string;
|
|
8
|
-
values?: string[];
|
|
9
|
-
}
|
|
10
|
-
export declare function getVariableProperties(this: RequestContext, fileName: string, variableName: string): string[] | undefined;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVariableProperties = getVariableProperties;
|
|
4
|
-
const language_core_1 = require("@vue/language-core");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
function getVariableProperties(fileName, variableName) {
|
|
7
|
-
const { typescript: ts, language, languageService, asScriptId } = this;
|
|
8
|
-
const volarFile = language.scripts.get(asScriptId(fileName));
|
|
9
|
-
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const vueCode = volarFile.generated.root;
|
|
13
|
-
const variable = (0, utils_1.getVariableType)(ts, languageService, vueCode, variableName);
|
|
14
|
-
return variable?.type.getProperties().map(prop => prop.name);
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=getVariableProperties.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { type Language, type SourceScript, type VueVirtualCode } from '@vue/language-core';
|
|
2
|
-
import type * as ts from 'typescript';
|
|
3
|
-
export declare function isRefAtLocation(ts: typeof import('typescript'), language: Language, program: ts.Program, sourceScript: SourceScript, virtualCode: VueVirtualCode, position: number, isTsPlugin: boolean): boolean;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/// <reference types="@volar/typescript" />
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.isRefAtLocation = isRefAtLocation;
|
|
5
|
-
const language_core_1 = require("@vue/language-core");
|
|
6
|
-
function isRefAtLocation(ts, language, program, sourceScript, virtualCode, position, isTsPlugin) {
|
|
7
|
-
const serviceScript = sourceScript.generated.languagePlugin.typescript?.getServiceScript(virtualCode);
|
|
8
|
-
if (!serviceScript) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
let mapped = false;
|
|
12
|
-
for (const [_sourceScript, map] of language.maps.forEach(serviceScript.code)) {
|
|
13
|
-
for (const [position2, mapping] of map.toGeneratedLocation(position)) {
|
|
14
|
-
if ((0, language_core_1.isCompletionEnabled)(mapping.data)) {
|
|
15
|
-
position = position2;
|
|
16
|
-
mapped = true;
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (mapped) {
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (!mapped) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
position += isTsPlugin ? sourceScript.snapshot.getLength() : 0;
|
|
28
|
-
const sourceFile = program.getSourceFile(virtualCode.fileName);
|
|
29
|
-
if (!sourceFile) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const node = findPositionIdentifier(sourceFile, sourceFile, position);
|
|
33
|
-
if (!node) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
const checker = program.getTypeChecker();
|
|
37
|
-
const type = checker.getTypeAtLocation(node);
|
|
38
|
-
const props = type.getProperties();
|
|
39
|
-
return props.some(prop => prop.escapedName === 'value' && prop.flags & ts.SymbolFlags.Accessor);
|
|
40
|
-
function findPositionIdentifier(sourceFile, node, offset) {
|
|
41
|
-
let result;
|
|
42
|
-
node.forEachChild(child => {
|
|
43
|
-
if (!result) {
|
|
44
|
-
if (child.end === offset && ts.isIdentifier(child)) {
|
|
45
|
-
result = child;
|
|
46
|
-
}
|
|
47
|
-
else if (child.end >= offset && child.getStart(sourceFile) < offset) {
|
|
48
|
-
result = findPositionIdentifier(sourceFile, child, offset);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=isRefAtLocation.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveModuleName = resolveModuleName;
|
|
4
|
-
function resolveModuleName(fileName, moduleName) {
|
|
5
|
-
const { typescript: ts, languageServiceHost } = this;
|
|
6
|
-
const compilerOptions = languageServiceHost.getCompilationSettings();
|
|
7
|
-
const ext = moduleName.split('.').pop();
|
|
8
|
-
const result = ts.resolveModuleName(moduleName, fileName, {
|
|
9
|
-
...compilerOptions,
|
|
10
|
-
allowArbitraryExtensions: true,
|
|
11
|
-
}, {
|
|
12
|
-
fileExists(fileName) {
|
|
13
|
-
fileName = transformFileName(fileName, ext);
|
|
14
|
-
return languageServiceHost.fileExists(fileName);
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
const resolveFileName = result.resolvedModule?.resolvedFileName;
|
|
18
|
-
return {
|
|
19
|
-
name: resolveFileName ? transformFileName(resolveFileName, ext) : undefined,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function transformFileName(fileName, ext) {
|
|
23
|
-
if (ext && fileName.endsWith(`.d.${ext}.ts`)) {
|
|
24
|
-
return fileName.slice(0, -`.d.${ext}.ts`.length) + `.${ext}`;
|
|
25
|
-
}
|
|
26
|
-
return fileName;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=resolveModuleName.js.map
|
package/lib/requests/types.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Language } from '@vue/language-core';
|
|
2
|
-
import type * as ts from 'typescript';
|
|
3
|
-
export interface RequestContext {
|
|
4
|
-
typescript: typeof ts;
|
|
5
|
-
languageService: ts.LanguageService;
|
|
6
|
-
languageServiceHost: ts.LanguageServiceHost;
|
|
7
|
-
language: Language<string>;
|
|
8
|
-
}
|
package/lib/requests/types.js
DELETED