@vue/language-service 3.2.9 → 3.3.1
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 +6 -14
- 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 +60 -129
- 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
|
@@ -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),
|