@vue/language-service 3.2.9 → 3.3.0
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/nameCasing.js +1 -1
- package/lib/plugins/css.js +1 -1
- package/lib/plugins/vue-autoinsert-dotvalue.js +2 -2
- package/lib/plugins/vue-compiler-dom-errors.js +1 -1
- package/lib/plugins/vue-component-semantic-tokens.js +1 -1
- package/lib/plugins/vue-document-drop.js +5 -5
- package/lib/plugins/vue-document-highlights.js +1 -1
- package/lib/plugins/vue-extract-file.d.ts +2 -2
- package/lib/plugins/vue-extract-file.js +16 -16
- package/lib/plugins/vue-inlayhints.js +7 -7
- package/lib/plugins/vue-missing-props-hints.d.ts +1 -1
- package/lib/plugins/vue-missing-props-hints.js +5 -9
- package/lib/plugins/vue-scoped-class-links.js +4 -4
- package/lib/plugins/vue-sfc.js +21 -21
- package/lib/plugins/vue-suggest-define-assignment.js +20 -46
- package/lib/plugins/vue-template-ref-links.js +4 -4
- package/lib/plugins/vue-template.js +270 -321
- package/package.json +6 -5
package/lib/nameCasing.js
CHANGED
|
@@ -83,7 +83,7 @@ function detectTagCasing(code) {
|
|
|
83
83
|
function collectTagsWithCache(code) {
|
|
84
84
|
let cache = collectCache.get(code);
|
|
85
85
|
if (!cache) {
|
|
86
|
-
const ast = code.
|
|
86
|
+
const ast = code.ir.template?.ast;
|
|
87
87
|
cache = ast ? collectTags(ast) : new Map();
|
|
88
88
|
collectCache.set(code, cache);
|
|
89
89
|
}
|
package/lib/plugins/css.js
CHANGED
|
@@ -103,7 +103,7 @@ function create({ resolveModuleName }) {
|
|
|
103
103
|
if (!info?.code.id.startsWith('style_')) {
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
|
-
const block = info.root.
|
|
106
|
+
const block = info.root.ir.styles.find(style => style.name === info.code.id);
|
|
107
107
|
if (!block) {
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
@@ -27,8 +27,8 @@ function create(ts, { isRefAtPosition }) {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
let sourceOffset;
|
|
30
|
-
const {
|
|
31
|
-
const scriptBlocks = [
|
|
30
|
+
const { ir } = info.root;
|
|
31
|
+
const scriptBlocks = [ir.script, ir.scriptSetup].filter(block => !!block);
|
|
32
32
|
const map = context.language.maps.get(info.code, info.script);
|
|
33
33
|
if (!scriptBlocks.length) {
|
|
34
34
|
return;
|
|
@@ -34,8 +34,8 @@ function create(ts, { getImportPathForFile }) {
|
|
|
34
34
|
if (!importUri || !info.root.vueCompilerOptions.extensions.some(ext => importUri.endsWith(ext))) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
const {
|
|
38
|
-
const script =
|
|
37
|
+
const { ir } = info.root;
|
|
38
|
+
const script = ir.scriptSetup ?? ir.script;
|
|
39
39
|
if (!script) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -43,7 +43,7 @@ function create(ts, { getImportPathForFile }) {
|
|
|
43
43
|
const baseName = path_browserify_1.posix.basename(importUri);
|
|
44
44
|
const newName = (0, shared_1.capitalize)((0, shared_1.camelize)(baseName.slice(0, baseName.lastIndexOf('.'))));
|
|
45
45
|
const additionalEdit = {};
|
|
46
|
-
const code = [...(0, language_core_1.forEachEmbeddedCode)(info.root)].find(code => code.id === (
|
|
46
|
+
const code = [...(0, language_core_1.forEachEmbeddedCode)(info.root)].find(code => code.id === (ir.scriptSetup ? 'scriptsetup_raw' : 'script_raw'));
|
|
47
47
|
const lastImportNode = (0, vue_extract_file_1.getLastImportNode)(ts, script.ast);
|
|
48
48
|
const incomingFileName = vscode_uri_1.URI.parse(importUri).fsPath.replace(/\\/g, '/');
|
|
49
49
|
let importPath;
|
|
@@ -77,8 +77,8 @@ function create(ts, { getImportPathForFile }) {
|
|
|
77
77
|
newText: `\nimport ${newName} from '${importPath}'`
|
|
78
78
|
+ (lastImportNode ? '' : '\n'),
|
|
79
79
|
});
|
|
80
|
-
if (
|
|
81
|
-
const edit = (0, vue_extract_file_1.createAddComponentToOptionEdit)(ts,
|
|
80
|
+
if (ir.script) {
|
|
81
|
+
const edit = (0, vue_extract_file_1.createAddComponentToOptionEdit)(ts, ir, ir.script.ast, newName);
|
|
82
82
|
if (edit) {
|
|
83
83
|
additionalEdit.changes[embeddedDocumentUriStr].push({
|
|
84
84
|
range: {
|
|
@@ -16,7 +16,7 @@ function create({ getDocumentHighlights }) {
|
|
|
16
16
|
if (info?.script.id.scheme !== 'file' || info.code.id !== 'main') {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
const { template } = info.root.
|
|
19
|
+
const { template } = info.root.ir;
|
|
20
20
|
const offset = document.offsetAt(position);
|
|
21
21
|
if (template?.ast && offset >= template.startTagEnd && offset <= template.endTagStart) {
|
|
22
22
|
const pos = offset - template.startTagEnd;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
-
import { type
|
|
2
|
+
import { type IR } from '@vue/language-core';
|
|
3
3
|
import type * as ts from 'typescript';
|
|
4
4
|
export declare function create(ts: typeof import('typescript'), { collectExtractProps }: import('@vue/typescript-plugin/lib/requests').Requests): LanguageServicePlugin;
|
|
5
5
|
export declare function getLastImportNode(ts: typeof import('typescript'), sourceFile: ts.SourceFile): ts.Node | undefined;
|
|
6
|
-
export declare function createAddComponentToOptionEdit(ts: typeof import('typescript'),
|
|
6
|
+
export declare function createAddComponentToOptionEdit(ts: typeof import('typescript'), ir: IR, ast: ts.SourceFile, componentName: string): {
|
|
7
7
|
range: import("@vue/language-core").TextRange<ts.ObjectLiteralExpression>;
|
|
8
8
|
newText: string;
|
|
9
9
|
} | undefined;
|
|
@@ -31,12 +31,12 @@ function create(ts, { collectExtractProps }) {
|
|
|
31
31
|
if (info?.code.id !== 'template') {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const {
|
|
35
|
-
const script =
|
|
36
|
-
if (!
|
|
34
|
+
const { ir } = info.root;
|
|
35
|
+
const script = ir.scriptSetup ?? ir.script;
|
|
36
|
+
if (!ir.template || !script) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
const templateCodeRange = selectTemplateCode(startOffset, endOffset,
|
|
39
|
+
const templateCodeRange = selectTemplateCode(startOffset, endOffset, ir.template);
|
|
40
40
|
if (!templateCodeRange) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
@@ -59,12 +59,12 @@ function create(ts, { collectExtractProps }) {
|
|
|
59
59
|
if (info?.code.id !== 'template') {
|
|
60
60
|
return codeAction;
|
|
61
61
|
}
|
|
62
|
-
const {
|
|
63
|
-
const script =
|
|
64
|
-
if (!
|
|
62
|
+
const { ir } = info.root;
|
|
63
|
+
const script = ir.scriptSetup ?? ir.script;
|
|
64
|
+
if (!ir.template || !script) {
|
|
65
65
|
return codeAction;
|
|
66
66
|
}
|
|
67
|
-
const templateCodeRange = selectTemplateCode(startOffset, endOffset,
|
|
67
|
+
const templateCodeRange = selectTemplateCode(startOffset, endOffset, ir.template);
|
|
68
68
|
if (!templateCodeRange) {
|
|
69
69
|
return codeAction;
|
|
70
70
|
}
|
|
@@ -77,11 +77,11 @@ function create(ts, { collectExtractProps }) {
|
|
|
77
77
|
const newUri = sfcDocument.uri.slice(0, sfcDocument.uri.lastIndexOf('/') + 1) + `${newName}.vue`;
|
|
78
78
|
const lastImportNode = getLastImportNode(ts, script.ast);
|
|
79
79
|
let newFileTags = [];
|
|
80
|
-
newFileTags.push(constructTag('template', [], templateInitialIndent,
|
|
80
|
+
newFileTags.push(constructTag('template', [], templateInitialIndent, ir.template.content.slice(templateCodeRange[0], templateCodeRange[1])));
|
|
81
81
|
if (toExtract.length) {
|
|
82
82
|
newFileTags.push(constructTag('script', ['setup', 'lang="ts"'], scriptInitialIndent, generateNewScriptContents()));
|
|
83
83
|
}
|
|
84
|
-
if (
|
|
84
|
+
if (ir.template.startTagEnd > script.startTagEnd) {
|
|
85
85
|
newFileTags = newFileTags.reverse();
|
|
86
86
|
}
|
|
87
87
|
const templateEdits = [
|
|
@@ -107,13 +107,13 @@ function create(ts, { collectExtractProps }) {
|
|
|
107
107
|
newText: `\nimport ${newName} from './${newName}.vue'`,
|
|
108
108
|
},
|
|
109
109
|
];
|
|
110
|
-
if (
|
|
111
|
-
const edit = createAddComponentToOptionEdit(ts,
|
|
110
|
+
if (ir.script) {
|
|
111
|
+
const edit = createAddComponentToOptionEdit(ts, ir, ir.script.ast, newName);
|
|
112
112
|
if (edit) {
|
|
113
113
|
sfcEdits.push({
|
|
114
114
|
range: {
|
|
115
|
-
start: sfcDocument.positionAt(
|
|
116
|
-
end: sfcDocument.positionAt(
|
|
115
|
+
start: sfcDocument.positionAt(ir.script.startTagEnd + edit.range.start),
|
|
116
|
+
end: sfcDocument.positionAt(ir.script.startTagEnd + edit.range.end),
|
|
117
117
|
},
|
|
118
118
|
newText: edit.newText,
|
|
119
119
|
});
|
|
@@ -237,8 +237,8 @@ function getLastImportNode(ts, sourceFile) {
|
|
|
237
237
|
}
|
|
238
238
|
return lastImportNode;
|
|
239
239
|
}
|
|
240
|
-
function createAddComponentToOptionEdit(ts,
|
|
241
|
-
const componentOptions = language_core_1.tsCodegen.get(
|
|
240
|
+
function createAddComponentToOptionEdit(ts, ir, ast, componentName) {
|
|
241
|
+
const componentOptions = language_core_1.tsCodegen.get(ir)?.getScriptRanges()?.exportDefault?.options;
|
|
242
242
|
if (!componentOptions) {
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
@@ -22,18 +22,18 @@ function create(ts) {
|
|
|
22
22
|
return settings[key] ??= await context.env.getConfiguration?.(key) ?? false;
|
|
23
23
|
}
|
|
24
24
|
const result = [];
|
|
25
|
-
const {
|
|
26
|
-
const codegen = language_core_1.tsCodegen.get(
|
|
25
|
+
const { ir } = info.root;
|
|
26
|
+
const codegen = language_core_1.tsCodegen.get(ir);
|
|
27
27
|
const inlayHints = [
|
|
28
28
|
...codegen?.getGeneratedTemplate()?.inlayHints ?? [],
|
|
29
29
|
...codegen?.getGeneratedScript().inlayHints ?? [],
|
|
30
30
|
];
|
|
31
31
|
const scriptSetupRanges = codegen?.getScriptSetupRanges();
|
|
32
|
-
if (scriptSetupRanges?.defineProps?.destructured &&
|
|
32
|
+
if (scriptSetupRanges?.defineProps?.destructured && ir.scriptSetup?.ast) {
|
|
33
33
|
const setting = 'vue.inlayHints.destructuredProps';
|
|
34
34
|
const enabled = await getSettingEnabled(setting);
|
|
35
35
|
if (enabled) {
|
|
36
|
-
for (const [prop, isShorthand] of findDestructuredProps(ts,
|
|
36
|
+
for (const [prop, isShorthand] of findDestructuredProps(ts, ir.scriptSetup.ast, scriptSetupRanges.defineProps.destructured.keys())) {
|
|
37
37
|
const name = prop.text;
|
|
38
38
|
const end = prop.getEnd();
|
|
39
39
|
const pos = isShorthand ? end : end - name.length;
|
|
@@ -48,9 +48,9 @@ function create(ts) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
const blocks = [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
ir.template,
|
|
52
|
+
ir.script,
|
|
53
|
+
ir.scriptSetup,
|
|
54
54
|
];
|
|
55
55
|
const start = document.offsetAt(range.start);
|
|
56
56
|
const end = document.offsetAt(range.end);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
-
export declare function create({ getComponentNames,
|
|
2
|
+
export declare function create({ getComponentNames, getComponentProps, getElementNames }: import('@vue/typescript-plugin/lib/requests').Requests): LanguageServicePlugin;
|
|
@@ -38,7 +38,7 @@ const language_core_1 = require("@vue/language-core");
|
|
|
38
38
|
const html = __importStar(require("vscode-html-languageservice"));
|
|
39
39
|
const nameCasing_1 = require("../nameCasing");
|
|
40
40
|
const utils_1 = require("../utils");
|
|
41
|
-
function create({ getComponentNames,
|
|
41
|
+
function create({ getComponentNames, getComponentProps, getElementNames }) {
|
|
42
42
|
return {
|
|
43
43
|
name: 'vue-missing-props-hints',
|
|
44
44
|
capabilities: {
|
|
@@ -63,7 +63,6 @@ function create({ getComponentNames, getElementNames, getComponentMeta }) {
|
|
|
63
63
|
const result = [];
|
|
64
64
|
const attrNameCasing = await (0, nameCasing_1.getAttrNameCasing)(context, info.script.id);
|
|
65
65
|
const components = await getComponentNames(info.root.fileName) ?? [];
|
|
66
|
-
const componentProps = new Map();
|
|
67
66
|
intrinsicElementNames ??= new Set(await getElementNames(info.root.fileName) ?? []);
|
|
68
67
|
let token;
|
|
69
68
|
let current;
|
|
@@ -83,15 +82,12 @@ function create({ getComponentNames, getElementNames, getComponentMeta }) {
|
|
|
83
82
|
if (tagOffset > document.offsetAt(range.end)) {
|
|
84
83
|
break;
|
|
85
84
|
}
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
componentProps.set(checkTag, ((await getComponentMeta(info.root.fileName, checkTag))?.props ?? [])
|
|
91
|
-
.filter(prop => prop.required));
|
|
85
|
+
if (cancellationToken.isCancellationRequested) {
|
|
86
|
+
break;
|
|
92
87
|
}
|
|
93
88
|
current = {
|
|
94
|
-
unburnedRequiredProps:
|
|
89
|
+
unburnedRequiredProps: (await getComponentProps(info.root.fileName, tagOffset) ?? [])
|
|
90
|
+
.filter(prop => !prop.optional),
|
|
95
91
|
labelOffset: scanner.getTokenOffset() + scanner.getTokenLength(),
|
|
96
92
|
};
|
|
97
93
|
}
|
|
@@ -16,17 +16,17 @@ function create() {
|
|
|
16
16
|
if (info?.code.id !== 'template') {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
const {
|
|
20
|
-
if (!
|
|
19
|
+
const { ir } = info.root;
|
|
20
|
+
if (!ir.template) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
const { resolveStyleClassNames } = info.root.vueCompilerOptions;
|
|
24
24
|
if (!resolveStyleClassNames) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
const scopedClasses = styleScopedClasses_1.references.get(
|
|
27
|
+
const scopedClasses = styleScopedClasses_1.references.get(ir.template)?.[1] ?? [];
|
|
28
28
|
const styleClasses = new Map();
|
|
29
|
-
for (const style of
|
|
29
|
+
for (const style of ir.styles) {
|
|
30
30
|
if (!(resolveStyleClassNames === true || style.scoped)) {
|
|
31
31
|
continue;
|
|
32
32
|
}
|
package/lib/plugins/vue-sfc.js
CHANGED
|
@@ -55,7 +55,7 @@ function create() {
|
|
|
55
55
|
}
|
|
56
56
|
const formatSettings = await context.env.getConfiguration?.('html.format') ?? {};
|
|
57
57
|
const blockTypes = ['template', 'script', 'style'];
|
|
58
|
-
for (const customBlock of info.root.
|
|
58
|
+
for (const customBlock of info.root.ir.customBlocks) {
|
|
59
59
|
blockTypes.push(customBlock.type);
|
|
60
60
|
}
|
|
61
61
|
return {
|
|
@@ -112,13 +112,13 @@ function create() {
|
|
|
112
112
|
if (info?.code.id !== 'root_tags') {
|
|
113
113
|
return [];
|
|
114
114
|
}
|
|
115
|
-
const { vueSfc,
|
|
115
|
+
const { vueSfc, ir } = info.root;
|
|
116
116
|
if (!vueSfc) {
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
119
|
const originalResult = await htmlServiceInstance.provideDiagnostics?.(document, token);
|
|
120
120
|
const sfcErrors = [];
|
|
121
|
-
const { template } =
|
|
121
|
+
const { template } = ir;
|
|
122
122
|
const { startTagEnd = Infinity, endTagStart = -Infinity, } = template ?? {};
|
|
123
123
|
for (const error of vueSfc.errors) {
|
|
124
124
|
if ('code' in error) {
|
|
@@ -149,50 +149,50 @@ function create() {
|
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
const result = [];
|
|
152
|
-
const {
|
|
153
|
-
if (
|
|
152
|
+
const { ir } = info.root;
|
|
153
|
+
if (ir.template) {
|
|
154
154
|
result.push({
|
|
155
155
|
name: 'template',
|
|
156
156
|
kind: 2,
|
|
157
157
|
range: {
|
|
158
|
-
start: document.positionAt(
|
|
159
|
-
end: document.positionAt(
|
|
158
|
+
start: document.positionAt(ir.template.start),
|
|
159
|
+
end: document.positionAt(ir.template.end),
|
|
160
160
|
},
|
|
161
161
|
selectionRange: {
|
|
162
|
-
start: document.positionAt(
|
|
163
|
-
end: document.positionAt(
|
|
162
|
+
start: document.positionAt(ir.template.start),
|
|
163
|
+
end: document.positionAt(ir.template.startTagEnd),
|
|
164
164
|
},
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
if (
|
|
167
|
+
if (ir.script) {
|
|
168
168
|
result.push({
|
|
169
169
|
name: 'script',
|
|
170
170
|
kind: 2,
|
|
171
171
|
range: {
|
|
172
|
-
start: document.positionAt(
|
|
173
|
-
end: document.positionAt(
|
|
172
|
+
start: document.positionAt(ir.script.start),
|
|
173
|
+
end: document.positionAt(ir.script.end),
|
|
174
174
|
},
|
|
175
175
|
selectionRange: {
|
|
176
|
-
start: document.positionAt(
|
|
177
|
-
end: document.positionAt(
|
|
176
|
+
start: document.positionAt(ir.script.start),
|
|
177
|
+
end: document.positionAt(ir.script.startTagEnd),
|
|
178
178
|
},
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
|
-
if (
|
|
181
|
+
if (ir.scriptSetup) {
|
|
182
182
|
result.push({
|
|
183
183
|
name: 'script setup',
|
|
184
184
|
kind: 2,
|
|
185
185
|
range: {
|
|
186
|
-
start: document.positionAt(
|
|
187
|
-
end: document.positionAt(
|
|
186
|
+
start: document.positionAt(ir.scriptSetup.start),
|
|
187
|
+
end: document.positionAt(ir.scriptSetup.end),
|
|
188
188
|
},
|
|
189
189
|
selectionRange: {
|
|
190
|
-
start: document.positionAt(
|
|
191
|
-
end: document.positionAt(
|
|
190
|
+
start: document.positionAt(ir.scriptSetup.start),
|
|
191
|
+
end: document.positionAt(ir.scriptSetup.startTagEnd),
|
|
192
192
|
},
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
-
for (const style of
|
|
195
|
+
for (const style of ir.styles) {
|
|
196
196
|
let name = 'style';
|
|
197
197
|
if (style.scoped) {
|
|
198
198
|
name += ' scoped';
|
|
@@ -213,7 +213,7 @@ function create() {
|
|
|
213
213
|
},
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
|
-
for (const customBlock of
|
|
216
|
+
for (const customBlock of ir.customBlocks) {
|
|
217
217
|
result.push({
|
|
218
218
|
name: customBlock.type,
|
|
219
219
|
kind: 2,
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.create = create;
|
|
4
4
|
const language_core_1 = require("@vue/language-core");
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
6
5
|
const utils_1 = require("../utils");
|
|
7
|
-
const documentToSourceFile = new WeakMap();
|
|
8
6
|
function create(ts) {
|
|
9
7
|
return {
|
|
10
8
|
name: 'vue-suggest-define-assignment',
|
|
@@ -23,19 +21,27 @@ function create(ts) {
|
|
|
23
21
|
if (!enabled) {
|
|
24
22
|
return;
|
|
25
23
|
}
|
|
26
|
-
const {
|
|
27
|
-
const codegen = language_core_1.tsCodegen.get(
|
|
28
|
-
const scriptSetup =
|
|
24
|
+
const { ir } = info.root;
|
|
25
|
+
const codegen = language_core_1.tsCodegen.get(ir);
|
|
26
|
+
const scriptSetup = ir.scriptSetup;
|
|
29
27
|
const scriptSetupRanges = codegen?.getScriptSetupRanges();
|
|
30
28
|
if (!scriptSetup || !scriptSetupRanges) {
|
|
31
29
|
return;
|
|
32
30
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
31
|
+
const map = context.language.maps.get(info.code, info.script);
|
|
32
|
+
let sourceOffset;
|
|
33
|
+
for (const [offset] of map.toSourceLocation(document.offsetAt(position))) {
|
|
34
|
+
sourceOffset = offset;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
if (sourceOffset === undefined) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const node = ts.getTouchingPropertyName(scriptSetup.ast, sourceOffset - scriptSetup.startTagEnd);
|
|
41
|
+
if (ts.isStringLiteralLike(node)) {
|
|
35
42
|
return;
|
|
36
43
|
}
|
|
37
44
|
const result = [];
|
|
38
|
-
const mappings = [...context.language.maps.forEach(info.code)];
|
|
39
45
|
addDefineCompletionItem(scriptSetupRanges.defineProps?.statement, scriptSetupRanges.withDefaults?.exp ?? scriptSetupRanges.defineProps?.exp, 'props');
|
|
40
46
|
addDefineCompletionItem(scriptSetupRanges.defineEmits?.statement, scriptSetupRanges.defineEmits?.exp, 'emit');
|
|
41
47
|
addDefineCompletionItem(scriptSetupRanges.defineSlots?.statement, scriptSetupRanges.defineSlots?.exp, 'slots');
|
|
@@ -47,17 +53,15 @@ function create(ts) {
|
|
|
47
53
|
if (!exp || exp.start !== statement?.start) {
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
50
|
-
let
|
|
51
|
-
for (const [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
+
let generatedOffset;
|
|
57
|
+
for (const [offset] of map.toGeneratedLocation(scriptSetup.startTagEnd + exp.start)) {
|
|
58
|
+
generatedOffset = offset;
|
|
59
|
+
break;
|
|
56
60
|
}
|
|
57
|
-
if (
|
|
61
|
+
if (generatedOffset === undefined) {
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
60
|
-
const pos = document.positionAt(
|
|
64
|
+
const pos = document.positionAt(generatedOffset);
|
|
61
65
|
result.push({
|
|
62
66
|
label: name,
|
|
63
67
|
kind: 6,
|
|
@@ -76,34 +80,4 @@ function create(ts) {
|
|
|
76
80
|
},
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
|
-
function shouldSkip(ts, node, pos) {
|
|
80
|
-
if (ts.isStringLiteral(node) && pos >= node.getFullStart() && pos <= node.getEnd()) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
else if (ts.isTemplateLiteral(node) && pos >= node.getFullStart() && pos <= node.getEnd()) {
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
let _shouldSkip = false;
|
|
88
|
-
node.forEachChild(node => {
|
|
89
|
-
if (_shouldSkip) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (pos >= node.getFullStart() && pos <= node.getEnd()) {
|
|
93
|
-
if (shouldSkip(ts, node, pos)) {
|
|
94
|
-
_shouldSkip = true;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return _shouldSkip;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function getSourceFile(ts, document) {
|
|
102
|
-
let sourceFile = documentToSourceFile.get(document);
|
|
103
|
-
if (!sourceFile) {
|
|
104
|
-
sourceFile = ts.createSourceFile(vscode_uri_1.URI.parse(document.uri).path, document.getText(), ts.ScriptTarget.Latest);
|
|
105
|
-
documentToSourceFile.set(document, sourceFile);
|
|
106
|
-
}
|
|
107
|
-
return sourceFile;
|
|
108
|
-
}
|
|
109
83
|
//# sourceMappingURL=vue-suggest-define-assignment.js.map
|
|
@@ -16,9 +16,9 @@ function create() {
|
|
|
16
16
|
if (info?.code.id !== 'scriptsetup_raw') {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
const {
|
|
20
|
-
const codegen = language_core_1.tsCodegen.get(
|
|
21
|
-
if (!
|
|
19
|
+
const { ir } = info.root;
|
|
20
|
+
const codegen = language_core_1.tsCodegen.get(ir);
|
|
21
|
+
if (!ir.scriptSetup) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
const templateVirtualCode = info.script.generated.embeddedCodes.get('template');
|
|
@@ -33,7 +33,7 @@ function create() {
|
|
|
33
33
|
if (!arg) {
|
|
34
34
|
return [];
|
|
35
35
|
}
|
|
36
|
-
const name =
|
|
36
|
+
const name = ir.scriptSetup.content.slice(arg.start + 1, arg.end - 1);
|
|
37
37
|
const range = {
|
|
38
38
|
start: document.positionAt(arg.start + 1),
|
|
39
39
|
end: document.positionAt(arg.end - 1),
|