@vue/language-service 3.3.0 → 3.3.2
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.
|
@@ -4,7 +4,6 @@ exports.create = create;
|
|
|
4
4
|
const language_core_1 = require("@vue/language-core");
|
|
5
5
|
const shared_1 = require("@vue/shared");
|
|
6
6
|
const path_browserify_1 = require("path-browserify");
|
|
7
|
-
const getUserPreferences_1 = require("volar-service-typescript/lib/configs/getUserPreferences");
|
|
8
7
|
const vscode_uri_1 = require("vscode-uri");
|
|
9
8
|
const nameCasing_1 = require("../nameCasing");
|
|
10
9
|
const vue_extract_file_1 = require("../plugins/vue-extract-file");
|
|
@@ -46,14 +45,7 @@ function create(ts, { getImportPathForFile }) {
|
|
|
46
45
|
const code = [...(0, language_core_1.forEachEmbeddedCode)(info.root)].find(code => code.id === (ir.scriptSetup ? 'scriptsetup_raw' : 'script_raw'));
|
|
47
46
|
const lastImportNode = (0, vue_extract_file_1.getLastImportNode)(ts, script.ast);
|
|
48
47
|
const incomingFileName = vscode_uri_1.URI.parse(importUri).fsPath.replace(/\\/g, '/');
|
|
49
|
-
let importPath;
|
|
50
|
-
const serviceScript = info.script.generated.languagePlugin.typescript?.getServiceScript(info.root);
|
|
51
|
-
if (serviceScript) {
|
|
52
|
-
const tsDocumentUri = context.encodeEmbeddedDocumentUri(info.script.id, serviceScript.code.id);
|
|
53
|
-
const tsDocument = context.documents.get(tsDocumentUri, serviceScript.code.languageId, serviceScript.code.snapshot);
|
|
54
|
-
const preferences = await (0, getUserPreferences_1.getUserPreferences)(context, tsDocument);
|
|
55
|
-
importPath = await getImportPathForFile(info.root.fileName, incomingFileName, preferences);
|
|
56
|
-
}
|
|
48
|
+
let importPath = await getImportPathForFile(info.root.fileName, incomingFileName);
|
|
57
49
|
if (!importPath) {
|
|
58
50
|
importPath = path_browserify_1.posix.relative(path_browserify_1.posix.dirname(info.root.fileName), incomingFileName)
|
|
59
51
|
|| importUri.slice(importUri.lastIndexOf('/') + 1);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
-
export declare function create({
|
|
2
|
+
export declare function create({ getComponentProps }: import('@vue/typescript-plugin/lib/requests').Requests): LanguageServicePlugin;
|
|
@@ -1,51 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.create = create;
|
|
37
4
|
const language_core_1 = require("@vue/language-core");
|
|
38
|
-
const html = __importStar(require("vscode-html-languageservice"));
|
|
39
5
|
const nameCasing_1 = require("../nameCasing");
|
|
40
6
|
const utils_1 = require("../utils");
|
|
41
|
-
function create({
|
|
7
|
+
function create({ getComponentProps }) {
|
|
42
8
|
return {
|
|
43
9
|
name: 'vue-missing-props-hints',
|
|
44
10
|
capabilities: {
|
|
45
11
|
inlayHintProvider: {},
|
|
46
12
|
},
|
|
47
13
|
create(context) {
|
|
48
|
-
let intrinsicElementNames;
|
|
49
14
|
return {
|
|
50
15
|
async provideInlayHints(document, range, cancellationToken) {
|
|
51
16
|
const info = (0, utils_1.resolveEmbeddedCode)(context, document.uri);
|
|
@@ -56,97 +21,78 @@ function create({ getComponentNames, getComponentProps, getElementNames }) {
|
|
|
56
21
|
if (!enabled) {
|
|
57
22
|
return;
|
|
58
23
|
}
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
24
|
+
const { template } = info.root.ir;
|
|
25
|
+
if (!template?.ast) {
|
|
61
26
|
return;
|
|
62
27
|
}
|
|
63
28
|
const result = [];
|
|
64
29
|
const attrNameCasing = await (0, nameCasing_1.getAttrNameCasing)(context, info.script.id);
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
while ((token = scanner.scan()) !== html.TokenType.EOS) {
|
|
70
|
-
if (token === html.TokenType.StartTag) {
|
|
71
|
-
const tagName = scanner.getTokenText();
|
|
72
|
-
const tagOffset = scanner.getTokenOffset();
|
|
73
|
-
const checkTag = tagName.includes('.')
|
|
74
|
-
? tagName
|
|
75
|
-
: components.find(component => component === tagName || (0, language_core_1.hyphenateTag)(component) === tagName);
|
|
76
|
-
if (intrinsicElementNames.has(tagName) || !checkTag) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (tagOffset < document.offsetAt(range.start)) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (tagOffset > document.offsetAt(range.end)) {
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
if (cancellationToken.isCancellationRequested) {
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
current = {
|
|
89
|
-
unburnedRequiredProps: (await getComponentProps(info.root.fileName, tagOffset) ?? [])
|
|
90
|
-
.filter(prop => !prop.optional),
|
|
91
|
-
labelOffset: scanner.getTokenOffset() + scanner.getTokenLength(),
|
|
92
|
-
};
|
|
30
|
+
const map = context.language.maps.get(info.code, info.script);
|
|
31
|
+
for (const node of (0, language_core_1.forEachElementNode)(template.ast)) {
|
|
32
|
+
if (cancellationToken.isCancellationRequested) {
|
|
33
|
+
break;
|
|
93
34
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
35
|
+
if (node.tagType !== 1) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const [startTagOffset] = (0, language_core_1.getElementTagOffsets)(node, template);
|
|
39
|
+
const sourceOffset = startTagOffset + node.tag.length;
|
|
40
|
+
let generatedOffset;
|
|
41
|
+
for (const [offset] of map.toGeneratedLocation(template.startTagEnd + sourceOffset)) {
|
|
42
|
+
generatedOffset = offset;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
if (generatedOffset === undefined
|
|
46
|
+
|| generatedOffset < document.offsetAt(range.start)
|
|
47
|
+
|| generatedOffset > document.offsetAt(range.end)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const props = await getComponentProps(info.root.fileName, node.loc.start.offset) ?? [];
|
|
51
|
+
const missingProps = new Map(props.filter(prop => !prop.optional).map(prop => [(0, language_core_1.hyphenateAttr)(prop.name), prop.name]));
|
|
52
|
+
for (const prop of node.props) {
|
|
53
|
+
if (prop.type === 6) {
|
|
54
|
+
missingProps.delete((0, language_core_1.hyphenateAttr)(prop.name));
|
|
55
|
+
}
|
|
56
|
+
else if (prop.type === 7) {
|
|
57
|
+
if (prop.name === 'bind') {
|
|
58
|
+
if (prop.arg?.type === 4 && prop.arg.isStatic) {
|
|
59
|
+
missingProps.delete((0, language_core_1.hyphenateAttr)(prop.arg.content));
|
|
111
60
|
}
|
|
112
|
-
else if (
|
|
113
|
-
|
|
61
|
+
else if (!prop.arg) {
|
|
62
|
+
missingProps.clear();
|
|
114
63
|
}
|
|
115
|
-
|
|
116
|
-
|
|
64
|
+
}
|
|
65
|
+
else if (prop.name === 'model') {
|
|
66
|
+
if (prop.arg?.type === 4 && prop.arg.isStatic) {
|
|
67
|
+
missingProps.delete((0, language_core_1.hyphenateAttr)(prop.arg.content));
|
|
68
|
+
missingProps.delete('on-update:' + (0, language_core_1.hyphenateAttr)(prop.arg.content));
|
|
117
69
|
}
|
|
118
|
-
else if (
|
|
119
|
-
|
|
70
|
+
else if (!prop.arg) {
|
|
71
|
+
missingProps.delete('model-value');
|
|
72
|
+
missingProps.delete('on-update:model-value');
|
|
120
73
|
}
|
|
121
|
-
|
|
122
|
-
|
|
74
|
+
}
|
|
75
|
+
else if (prop.name === 'on') {
|
|
76
|
+
if (prop.arg?.type === 4 && prop.arg.isStatic) {
|
|
77
|
+
missingProps.delete('on-' + (0, language_core_1.hyphenateAttr)(prop.arg.content));
|
|
123
78
|
}
|
|
124
|
-
current.unburnedRequiredProps = current.unburnedRequiredProps.filter(prop => {
|
|
125
|
-
return attrText !== prop.name
|
|
126
|
-
&& attrText !== (0, language_core_1.hyphenateAttr)(prop.name);
|
|
127
|
-
});
|
|
128
79
|
}
|
|
129
80
|
}
|
|
130
81
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}],
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
current = undefined;
|
|
149
|
-
}
|
|
82
|
+
for (const name of missingProps.values()) {
|
|
83
|
+
result.push({
|
|
84
|
+
label: name,
|
|
85
|
+
paddingLeft: true,
|
|
86
|
+
position: document.positionAt(generatedOffset),
|
|
87
|
+
kind: 2,
|
|
88
|
+
textEdits: [{
|
|
89
|
+
range: {
|
|
90
|
+
start: document.positionAt(generatedOffset),
|
|
91
|
+
end: document.positionAt(generatedOffset),
|
|
92
|
+
},
|
|
93
|
+
newText: ` :${attrNameCasing === 0 /* AttrNameCasing.Kebab */ ? (0, language_core_1.hyphenateAttr)(name) : name}=`,
|
|
94
|
+
}],
|
|
95
|
+
});
|
|
150
96
|
}
|
|
151
97
|
}
|
|
152
98
|
return result;
|
|
@@ -154,16 +100,5 @@ function create({ getComponentNames, getComponentProps, getElementNames }) {
|
|
|
154
100
|
};
|
|
155
101
|
},
|
|
156
102
|
};
|
|
157
|
-
function getScanner(context, document) {
|
|
158
|
-
if (document.languageId === 'html') {
|
|
159
|
-
return context.inject('html/languageService').createScanner(document.getText());
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
const pugDocument = context.inject('pug/pugDocument', document);
|
|
163
|
-
if (pugDocument) {
|
|
164
|
-
return context.inject('pug/languageService').createScanner(pugDocument);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
103
|
}
|
|
169
104
|
//# sourceMappingURL=vue-missing-props-hints.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-service",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"data",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@volar/language-service": "2.4.28",
|
|
23
|
-
"@vue/language-core": "3.3.
|
|
23
|
+
"@vue/language-core": "3.3.2",
|
|
24
24
|
"@vue/shared": "^3.5.0",
|
|
25
25
|
"path-browserify": "^1.0.1",
|
|
26
26
|
"volar-service-css": "0.0.71",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@volar/kit": "2.4.28",
|
|
40
40
|
"@volar/typescript": "2.4.28",
|
|
41
41
|
"@vue/compiler-dom": "^3.5.0",
|
|
42
|
-
"@vue/typescript-plugin": "3.3.
|
|
42
|
+
"@vue/typescript-plugin": "3.3.2",
|
|
43
43
|
"vscode-css-languageservice": "^6.3.10",
|
|
44
|
-
"vue-component-meta": "3.3.
|
|
44
|
+
"vue-component-meta": "3.3.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "7a00047bb6d133bf26fa6e916e856fdca40b3c49"
|
|
47
47
|
}
|