@vue/language-service 3.0.0-beta.2 → 3.0.0-beta.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/index.js +1 -1
- package/lib/plugins/css.js +1 -1
- package/lib/plugins/data.js +2 -1
- package/lib/plugins/utils.js +4 -4
- package/lib/plugins/vue-autoinsert-dotvalue.js +2 -1
- package/lib/plugins/vue-complete-define-assignment.js +4 -4
- package/lib/plugins/vue-directive-comments.js +1 -1
- package/lib/plugins/vue-document-drop.js +9 -7
- package/lib/plugins/vue-document-links.js +5 -3
- package/lib/plugins/vue-extract-file.js +11 -8
- package/lib/plugins/vue-inlayhints.js +28 -22
- package/lib/plugins/vue-sfc.js +28 -20
- package/lib/plugins/vue-template.js +18 -12
- package/lib/plugins/vue-twoslash-queries.js +5 -2
- package/package.json +7 -7
- package/scripts/update-html-data.js +16 -20
package/index.js
CHANGED
|
@@ -44,7 +44,7 @@ function createVueLanguageServicePlugins(ts, tsPluginClient) {
|
|
|
44
44
|
const plugins = [
|
|
45
45
|
(0, syntactic_1.create)(ts),
|
|
46
46
|
(0, docCommentTemplate_1.create)(ts),
|
|
47
|
-
...getCommonLanguageServicePlugins(ts, () => tsPluginClient)
|
|
47
|
+
...getCommonLanguageServicePlugins(ts, () => tsPluginClient),
|
|
48
48
|
];
|
|
49
49
|
if (tsPluginClient) {
|
|
50
50
|
plugins.push((0, vue_document_highlights_1.create)(tsPluginClient.getDocumentHighlights));
|
package/lib/plugins/css.js
CHANGED
|
@@ -41,7 +41,7 @@ function create() {
|
|
|
41
41
|
return worker(document, (stylesheet, cssLs) => {
|
|
42
42
|
return cssLs.prepareRename(document, position, stylesheet);
|
|
43
43
|
});
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
45
|
};
|
|
46
46
|
function isWithinNavigationVirtualCode(document, position) {
|
|
47
47
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
package/lib/plugins/data.js
CHANGED
|
@@ -38,6 +38,7 @@ function loadTemplateData(lang) {
|
|
|
38
38
|
data = require('../../data/template/en.json');
|
|
39
39
|
}
|
|
40
40
|
resolveReferences(data);
|
|
41
|
+
// oxlint-disable-next-line no-useless-spread
|
|
41
42
|
for (const attr of [...data.globalAttributes ?? []]) {
|
|
42
43
|
if (!attr.name.startsWith('v-')) {
|
|
43
44
|
data.globalAttributes?.push({ ...attr, name: `:${attr.name}` }, { ...attr, name: `v-bind:${attr.name}` });
|
|
@@ -139,7 +140,7 @@ function resolveReferences(data) {
|
|
|
139
140
|
const relativeUrl = item.references;
|
|
140
141
|
item.references = locale.map(({ name, url }) => ({
|
|
141
142
|
name,
|
|
142
|
-
url: url + relativeUrl
|
|
143
|
+
url: url + relativeUrl,
|
|
143
144
|
}));
|
|
144
145
|
}
|
|
145
146
|
}
|
package/lib/plugins/utils.js
CHANGED
|
@@ -6,9 +6,9 @@ function sleep(ms) {
|
|
|
6
6
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
7
7
|
}
|
|
8
8
|
function isTsDocument(document) {
|
|
9
|
-
return document.languageId === 'javascript'
|
|
10
|
-
document.languageId === 'typescript'
|
|
11
|
-
document.languageId === 'javascriptreact'
|
|
12
|
-
document.languageId === 'typescriptreact';
|
|
9
|
+
return document.languageId === 'javascript'
|
|
10
|
+
|| document.languageId === 'typescript'
|
|
11
|
+
|| document.languageId === 'javascriptreact'
|
|
12
|
+
|| document.languageId === 'typescriptreact';
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=utils.js.map
|
|
@@ -123,7 +123,8 @@ function isBlacklistNode(ts, node, pos, allowAccessDotValue) {
|
|
|
123
123
|
else if (ts.isTypeReferenceNode(node)) {
|
|
124
124
|
return true;
|
|
125
125
|
}
|
|
126
|
-
else if (!allowAccessDotValue && ts.isPropertyAccessExpression(node) && node.expression.end === pos
|
|
126
|
+
else if (!allowAccessDotValue && ts.isPropertyAccessExpression(node) && node.expression.end === pos
|
|
127
|
+
&& node.name.text === 'value') {
|
|
127
128
|
return true;
|
|
128
129
|
}
|
|
129
130
|
else if (ts.isCallExpression(node)
|
|
@@ -46,7 +46,7 @@ function create() {
|
|
|
46
46
|
addDefineCompletionItem(scriptSetupRanges.defineSlots?.statement, scriptSetupRanges.defineSlots?.exp, 'slots');
|
|
47
47
|
return {
|
|
48
48
|
isIncomplete: false,
|
|
49
|
-
items: result
|
|
49
|
+
items: result,
|
|
50
50
|
};
|
|
51
51
|
function addDefineCompletionItem(statement, exp, name) {
|
|
52
52
|
if (!exp || exp.start !== statement?.start) {
|
|
@@ -71,9 +71,9 @@ function create() {
|
|
|
71
71
|
newText: `const ${name} = `,
|
|
72
72
|
range: {
|
|
73
73
|
start: pos,
|
|
74
|
-
end: pos
|
|
75
|
-
}
|
|
76
|
-
}]
|
|
74
|
+
end: pos,
|
|
75
|
+
},
|
|
76
|
+
}],
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
},
|
|
@@ -80,13 +80,15 @@ function create(ts, getTsPluginClient) {
|
|
|
80
80
|
additionalEdit.changes ??= {};
|
|
81
81
|
additionalEdit.changes[embeddedDocumentUriStr] = [];
|
|
82
82
|
additionalEdit.changes[embeddedDocumentUriStr].push({
|
|
83
|
-
range: lastImportNode
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
range: lastImportNode
|
|
84
|
+
? {
|
|
85
|
+
start: script.ast.getLineAndCharacterOfPosition(lastImportNode.end),
|
|
86
|
+
end: script.ast.getLineAndCharacterOfPosition(lastImportNode.end),
|
|
87
|
+
}
|
|
88
|
+
: {
|
|
89
|
+
start: script.ast.getLineAndCharacterOfPosition(0),
|
|
90
|
+
end: script.ast.getLineAndCharacterOfPosition(0),
|
|
91
|
+
},
|
|
90
92
|
newText: `\nimport ${newName} from '${importPath}'`
|
|
91
93
|
+ (lastImportNode ? '' : '\n'),
|
|
92
94
|
});
|
|
@@ -16,7 +16,7 @@ function create() {
|
|
|
16
16
|
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
17
17
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
18
18
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
19
|
-
if (!sourceScript?.generated || (virtualCode?.id !== 'template' && virtualCode?.id !==
|
|
19
|
+
if (!sourceScript?.generated || (virtualCode?.id !== 'template' && virtualCode?.id !== 'scriptsetup_raw')) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
const root = sourceScript.generated.root;
|
|
@@ -62,7 +62,8 @@ function create() {
|
|
|
62
62
|
start: document.positionAt(offset),
|
|
63
63
|
end: document.positionAt(offset + className.length),
|
|
64
64
|
},
|
|
65
|
-
target: context.encodeEmbeddedDocumentUri(decoded[0], 'style_' + style.index)
|
|
65
|
+
target: context.encodeEmbeddedDocumentUri(decoded[0], 'style_' + style.index)
|
|
66
|
+
+ `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`,
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -93,7 +94,8 @@ function create() {
|
|
|
93
94
|
start: document.positionAt(arg.start + 1),
|
|
94
95
|
end: document.positionAt(arg.end - 1),
|
|
95
96
|
},
|
|
96
|
-
target: templateDocumentUri
|
|
97
|
+
target: templateDocumentUri
|
|
98
|
+
+ `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`,
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
}
|
|
@@ -87,7 +87,8 @@ function create(ts, getTsPluginClient) {
|
|
|
87
87
|
return codeAction;
|
|
88
88
|
}
|
|
89
89
|
const templateInitialIndent = await context.env.getConfiguration('vue.format.template.initialIndent') ?? true;
|
|
90
|
-
const scriptInitialIndent = await context.env.getConfiguration('vue.format.script.initialIndent')
|
|
90
|
+
const scriptInitialIndent = await context.env.getConfiguration('vue.format.script.initialIndent')
|
|
91
|
+
?? false;
|
|
91
92
|
const document = context.documents.get(parsedUri, virtualCode.languageId, virtualCode.snapshot);
|
|
92
93
|
const sfcDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
|
93
94
|
const newUri = sfcDocument.uri.slice(0, sfcDocument.uri.lastIndexOf('/') + 1) + `${newName}.vue`;
|
|
@@ -111,13 +112,15 @@ function create(ts, getTsPluginClient) {
|
|
|
111
112
|
];
|
|
112
113
|
const sfcEdits = [
|
|
113
114
|
{
|
|
114
|
-
range: lastImportNode
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
range: lastImportNode
|
|
116
|
+
? {
|
|
117
|
+
start: sfcDocument.positionAt(script.startTagEnd + lastImportNode.end),
|
|
118
|
+
end: sfcDocument.positionAt(script.startTagEnd + lastImportNode.end),
|
|
119
|
+
}
|
|
120
|
+
: {
|
|
121
|
+
start: sfcDocument.positionAt(script.startTagEnd),
|
|
122
|
+
end: sfcDocument.positionAt(script.startTagEnd),
|
|
123
|
+
},
|
|
121
124
|
newText: `\nimport ${newName} from './${newName}.vue'`,
|
|
122
125
|
},
|
|
123
126
|
];
|
|
@@ -75,10 +75,12 @@ function create(ts) {
|
|
|
75
75
|
paddingLeft: hint.paddingLeft,
|
|
76
76
|
position: document.positionAt(hintOffset),
|
|
77
77
|
kind: 2,
|
|
78
|
-
tooltip: hint.tooltip
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
tooltip: hint.tooltip
|
|
79
|
+
? {
|
|
80
|
+
kind: 'markdown',
|
|
81
|
+
value: hint.tooltip,
|
|
82
|
+
}
|
|
83
|
+
: undefined,
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
86
|
return result;
|
|
@@ -100,7 +102,7 @@ function findDestructuredProps(ts, ast, props) {
|
|
|
100
102
|
rootScope[prop] = true;
|
|
101
103
|
}
|
|
102
104
|
function pushScope() {
|
|
103
|
-
scopeStack.push(
|
|
105
|
+
scopeStack.push(currentScope = Object.create(currentScope));
|
|
104
106
|
}
|
|
105
107
|
function popScope() {
|
|
106
108
|
scopeStack.pop();
|
|
@@ -123,20 +125,20 @@ function findDestructuredProps(ts, ast, props) {
|
|
|
123
125
|
walkVariableDeclaration(decl, isRoot);
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
else if (ts.isFunctionDeclaration(stmt)
|
|
127
|
-
ts.isClassDeclaration(stmt)) {
|
|
128
|
+
else if (ts.isFunctionDeclaration(stmt)
|
|
129
|
+
|| ts.isClassDeclaration(stmt)) {
|
|
128
130
|
const declare = ts.getModifiers(stmt)?.find(modifier => modifier.kind === ts.SyntaxKind.DeclareKeyword);
|
|
129
131
|
if (!stmt.name || declare) {
|
|
130
132
|
return;
|
|
131
133
|
}
|
|
132
134
|
registerLocalBinding(stmt.name);
|
|
133
135
|
}
|
|
134
|
-
else if ((ts.isForOfStatement(stmt) || ts.isForInStatement(stmt))
|
|
135
|
-
ts.isVariableDeclarationList(stmt.initializer)) {
|
|
136
|
+
else if ((ts.isForOfStatement(stmt) || ts.isForInStatement(stmt))
|
|
137
|
+
&& ts.isVariableDeclarationList(stmt.initializer)) {
|
|
136
138
|
walkVariableDeclaration(stmt.initializer.declarations[0], isRoot);
|
|
137
139
|
}
|
|
138
|
-
else if (ts.isLabeledStatement(stmt)
|
|
139
|
-
ts.isVariableDeclaration(stmt.statement)) {
|
|
140
|
+
else if (ts.isLabeledStatement(stmt)
|
|
141
|
+
&& ts.isVariableDeclaration(stmt.statement)) {
|
|
140
142
|
walkVariableDeclaration(stmt.statement, isRoot);
|
|
141
143
|
}
|
|
142
144
|
});
|
|
@@ -175,9 +177,11 @@ function findDestructuredProps(ts, ast, props) {
|
|
|
175
177
|
}
|
|
176
178
|
});
|
|
177
179
|
function enter(node) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
if (parent) {
|
|
181
|
+
parentStack.push(parent);
|
|
182
|
+
}
|
|
183
|
+
if (ts.isTypeLiteralNode(node)
|
|
184
|
+
|| ts.isTypeReferenceNode(node)) {
|
|
181
185
|
return false;
|
|
182
186
|
}
|
|
183
187
|
if (ts.isFunctionLike(node)) {
|
|
@@ -215,7 +219,9 @@ function findDestructuredProps(ts, ast, props) {
|
|
|
215
219
|
}
|
|
216
220
|
}
|
|
217
221
|
function leave(node) {
|
|
218
|
-
|
|
222
|
+
if (parent) {
|
|
223
|
+
parentStack.pop();
|
|
224
|
+
}
|
|
219
225
|
if (ts.isFunctionLike(node)
|
|
220
226
|
|| ts.isCatchClause(node)
|
|
221
227
|
|| (ts.isBlock(node)
|
|
@@ -233,15 +239,15 @@ function findDestructuredProps(ts, ast, props) {
|
|
|
233
239
|
if (id.text === 'arguments') {
|
|
234
240
|
return false;
|
|
235
241
|
}
|
|
236
|
-
if (ts.isExpressionWithTypeArguments(parent)
|
|
237
|
-
ts.isInterfaceDeclaration(parent)
|
|
238
|
-
ts.isTypeAliasDeclaration(parent)
|
|
239
|
-
ts.isPropertySignature(parent)) {
|
|
242
|
+
if (ts.isExpressionWithTypeArguments(parent)
|
|
243
|
+
|| ts.isInterfaceDeclaration(parent)
|
|
244
|
+
|| ts.isTypeAliasDeclaration(parent)
|
|
245
|
+
|| ts.isPropertySignature(parent)) {
|
|
240
246
|
return false;
|
|
241
247
|
}
|
|
242
|
-
if (ts.isPropertyAccessExpression(parent)
|
|
243
|
-
ts.isPropertyAssignment(parent)
|
|
244
|
-
ts.isPropertyDeclaration(parent)) {
|
|
248
|
+
if (ts.isPropertyAccessExpression(parent)
|
|
249
|
+
|| ts.isPropertyAssignment(parent)
|
|
250
|
+
|| ts.isPropertyDeclaration(parent)) {
|
|
245
251
|
if (parent.name === id) {
|
|
246
252
|
return false;
|
|
247
253
|
}
|
package/lib/plugins/vue-sfc.js
CHANGED
|
@@ -28,8 +28,10 @@ function create() {
|
|
|
28
28
|
wrapAttributes: await context.env.getConfiguration?.('vue.format.wrapAttributes') ?? 'auto',
|
|
29
29
|
unformatted: '',
|
|
30
30
|
contentUnformatted: blockTypes.join(','),
|
|
31
|
-
endWithNewline: options.insertFinalNewline
|
|
32
|
-
|
|
31
|
+
endWithNewline: options.insertFinalNewline
|
|
32
|
+
? true
|
|
33
|
+
: options.trimFinalNewlines
|
|
34
|
+
? false
|
|
33
35
|
: document.getText().endsWith('\n'),
|
|
34
36
|
};
|
|
35
37
|
}) ?? {};
|
|
@@ -43,7 +45,7 @@ function create() {
|
|
|
43
45
|
diagnosticProvider: {
|
|
44
46
|
interFileDependencies: false,
|
|
45
47
|
workspaceDiagnostics: false,
|
|
46
|
-
}
|
|
48
|
+
},
|
|
47
49
|
},
|
|
48
50
|
create(context) {
|
|
49
51
|
const htmlServiceInstance = htmlService.create(context);
|
|
@@ -79,7 +81,7 @@ function create() {
|
|
|
79
81
|
const originalResult = await htmlServiceInstance.provideDiagnostics?.(document, token);
|
|
80
82
|
const sfcErrors = [];
|
|
81
83
|
const { template } = sfc;
|
|
82
|
-
const { startTagEnd = Infinity, endTagStart = -Infinity } = template ?? {};
|
|
84
|
+
const { startTagEnd = Infinity, endTagStart = -Infinity, } = template ?? {};
|
|
83
85
|
for (const error of vueSfc.errors) {
|
|
84
86
|
if ('code' in error) {
|
|
85
87
|
const start = error.loc?.start.offset ?? 0;
|
|
@@ -100,7 +102,7 @@ function create() {
|
|
|
100
102
|
}
|
|
101
103
|
return [
|
|
102
104
|
...originalResult ?? [],
|
|
103
|
-
...sfcErrors
|
|
105
|
+
...sfcErrors,
|
|
104
106
|
];
|
|
105
107
|
});
|
|
106
108
|
},
|
|
@@ -193,9 +195,9 @@ function create() {
|
|
|
193
195
|
if (!result) {
|
|
194
196
|
return;
|
|
195
197
|
}
|
|
196
|
-
result.items = result.items.filter(item => item.label !== '!DOCTYPE'
|
|
197
|
-
item.label !== 'Custom Blocks'
|
|
198
|
-
item.label !== 'data-');
|
|
198
|
+
result.items = result.items.filter(item => item.label !== '!DOCTYPE'
|
|
199
|
+
&& item.label !== 'Custom Blocks'
|
|
200
|
+
&& item.label !== 'data-');
|
|
199
201
|
const tags = sfcDataProvider?.provideTags();
|
|
200
202
|
const scriptLangs = getLangs('script');
|
|
201
203
|
const scriptItems = result.items.filter(item => item.label === 'script' || item.label === 'script setup');
|
|
@@ -208,10 +210,12 @@ function create() {
|
|
|
208
210
|
detail: `.${lang}`,
|
|
209
211
|
kind: 17,
|
|
210
212
|
label: scriptItem.label + ' lang="' + lang + '"',
|
|
211
|
-
textEdit: scriptItem.textEdit
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
textEdit: scriptItem.textEdit
|
|
214
|
+
? {
|
|
215
|
+
...scriptItem.textEdit,
|
|
216
|
+
newText: scriptItem.textEdit.newText + ' lang="' + lang + '"',
|
|
217
|
+
}
|
|
218
|
+
: undefined,
|
|
215
219
|
});
|
|
216
220
|
}
|
|
217
221
|
}
|
|
@@ -238,10 +242,12 @@ function create() {
|
|
|
238
242
|
kind: 17,
|
|
239
243
|
detail: `.${lang}`,
|
|
240
244
|
label: templateItem.label + ' lang="' + lang + '"',
|
|
241
|
-
textEdit: templateItem.textEdit
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
+
textEdit: templateItem.textEdit
|
|
246
|
+
? {
|
|
247
|
+
...templateItem.textEdit,
|
|
248
|
+
newText: templateItem.textEdit.newText + ' lang="' + lang + '"',
|
|
249
|
+
}
|
|
250
|
+
: undefined,
|
|
245
251
|
});
|
|
246
252
|
}
|
|
247
253
|
}
|
|
@@ -275,10 +281,12 @@ function getStyleCompletionItem(styleItem, lang, attr) {
|
|
|
275
281
|
kind: 17,
|
|
276
282
|
detail: lang === 'postcss' ? '.css' : `.${lang}`,
|
|
277
283
|
label: styleItem.label + ' lang="' + lang + '"' + (attr ? ` ${attr}` : ''),
|
|
278
|
-
textEdit: styleItem.textEdit
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
284
|
+
textEdit: styleItem.textEdit
|
|
285
|
+
? {
|
|
286
|
+
...styleItem.textEdit,
|
|
287
|
+
newText: styleItem.textEdit.newText + ' lang="' + lang + '"' + (attr ? ` ${attr}` : ''),
|
|
288
|
+
}
|
|
289
|
+
: undefined,
|
|
282
290
|
};
|
|
283
291
|
}
|
|
284
292
|
//# sourceMappingURL=vue-sfc.js.map
|
|
@@ -107,7 +107,9 @@ function create(mode, getTsPluginClient) {
|
|
|
107
107
|
}
|
|
108
108
|
if (vModel) {
|
|
109
109
|
for (const modifier of modelData.globalAttributes ?? []) {
|
|
110
|
-
const description = typeof modifier.description === 'object'
|
|
110
|
+
const description = typeof modifier.description === 'object'
|
|
111
|
+
? modifier.description.value
|
|
112
|
+
: modifier.description;
|
|
111
113
|
const references = modifier.references?.map(ref => `[${ref.name}](${ref.url})`).join(' | ');
|
|
112
114
|
vModelModifiers[modifier.name] = description + '\n\n' + references;
|
|
113
115
|
}
|
|
@@ -319,7 +321,7 @@ function create(mode, getTsPluginClient) {
|
|
|
319
321
|
for (const directive of directives) {
|
|
320
322
|
const name = (0, language_core_1.hyphenateAttr)(directive);
|
|
321
323
|
attributes.push({
|
|
322
|
-
name
|
|
324
|
+
name,
|
|
323
325
|
});
|
|
324
326
|
}
|
|
325
327
|
const models = [];
|
|
@@ -360,7 +362,7 @@ function create(mode, getTsPluginClient) {
|
|
|
360
362
|
async sync() {
|
|
361
363
|
await Promise.all(promises);
|
|
362
364
|
return version;
|
|
363
|
-
}
|
|
365
|
+
},
|
|
364
366
|
};
|
|
365
367
|
}
|
|
366
368
|
function afterHtmlCompletion(completionList, document) {
|
|
@@ -374,9 +376,12 @@ function create(mode, getTsPluginClient) {
|
|
|
374
376
|
const isVOn = text.startsWith('v-on:') || text.startsWith('@') && text.length > 1;
|
|
375
377
|
const isVBind = text.startsWith('v-bind:') || text.startsWith(':') && text.length > 1;
|
|
376
378
|
const isVModel = text.startsWith('v-model:') || text === 'v-model';
|
|
377
|
-
const currentModifiers = isVOn
|
|
378
|
-
|
|
379
|
-
|
|
379
|
+
const currentModifiers = isVOn
|
|
380
|
+
? vOnModifiers
|
|
381
|
+
: isVBind
|
|
382
|
+
? vBindModifiers
|
|
383
|
+
: isVModel
|
|
384
|
+
? vModelModifiers
|
|
380
385
|
: undefined;
|
|
381
386
|
if (!currentModifiers) {
|
|
382
387
|
return;
|
|
@@ -420,7 +425,6 @@ function create(mode, getTsPluginClient) {
|
|
|
420
425
|
if (item.textEdit) {
|
|
421
426
|
item.textEdit.newText = text;
|
|
422
427
|
}
|
|
423
|
-
;
|
|
424
428
|
if (item.insertText) {
|
|
425
429
|
item.insertText = text;
|
|
426
430
|
}
|
|
@@ -470,12 +474,14 @@ function create(mode, getTsPluginClient) {
|
|
|
470
474
|
tag: '^',
|
|
471
475
|
prop: propName,
|
|
472
476
|
deprecated: false,
|
|
473
|
-
leadingSlash: false
|
|
477
|
+
leadingSlash: false,
|
|
474
478
|
};
|
|
475
479
|
}
|
|
476
480
|
propInfo = cachedPropInfos.get(propName);
|
|
477
481
|
if (propInfo?.commentMarkdown) {
|
|
478
|
-
const originalDocumentation = typeof item.documentation === 'string'
|
|
482
|
+
const originalDocumentation = typeof item.documentation === 'string'
|
|
483
|
+
? item.documentation
|
|
484
|
+
: item.documentation?.value;
|
|
479
485
|
item.documentation = {
|
|
480
486
|
kind: 'markdown',
|
|
481
487
|
value: [
|
|
@@ -597,7 +603,7 @@ function parseLabel(label) {
|
|
|
597
603
|
const name = label.slice(leadingSlash ? 1 : 0);
|
|
598
604
|
return {
|
|
599
605
|
name,
|
|
600
|
-
leadingSlash
|
|
606
|
+
leadingSlash,
|
|
601
607
|
};
|
|
602
608
|
}
|
|
603
609
|
function generateItemKey(type, tag, prop, deprecated) {
|
|
@@ -615,7 +621,7 @@ function parseItemKey(key) {
|
|
|
615
621
|
tag: strs[1],
|
|
616
622
|
prop: strs[2],
|
|
617
623
|
deprecated: strs[3] === '1',
|
|
618
|
-
leadingSlash
|
|
624
|
+
leadingSlash,
|
|
619
625
|
};
|
|
620
626
|
}
|
|
621
627
|
}
|
|
@@ -625,7 +631,7 @@ function getReplacement(list, doc) {
|
|
|
625
631
|
return {
|
|
626
632
|
item: item,
|
|
627
633
|
textEdit: item.textEdit,
|
|
628
|
-
text: doc.getText(item.textEdit.range)
|
|
634
|
+
text: doc.getText(item.textEdit.range),
|
|
629
635
|
};
|
|
630
636
|
}
|
|
631
637
|
}
|
|
@@ -30,10 +30,13 @@ function create(getTsPluginClient) {
|
|
|
30
30
|
for (const pointer of document.getText(range).matchAll(twoslashReg)) {
|
|
31
31
|
const offset = pointer.index + pointer[0].indexOf('^?') + document.offsetAt(range.start);
|
|
32
32
|
const position = document.positionAt(offset);
|
|
33
|
-
hoverOffsets.push([
|
|
33
|
+
hoverOffsets.push([
|
|
34
|
+
position,
|
|
35
|
+
document.offsetAt({
|
|
34
36
|
line: position.line - 1,
|
|
35
37
|
character: position.character,
|
|
36
|
-
})
|
|
38
|
+
}),
|
|
39
|
+
]);
|
|
37
40
|
}
|
|
38
41
|
for (const [pointerPosition, hoverOffset] of hoverOffsets) {
|
|
39
42
|
const map = context.language.maps.get(virtualCode, sourceScript);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-service",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"data",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"update-html-data": "node ./scripts/update-html-data.js"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@volar/language-service": "2.4.
|
|
21
|
-
"@vue/language-core": "3.0.0-beta.
|
|
20
|
+
"@volar/language-service": "2.4.15",
|
|
21
|
+
"@vue/language-core": "3.0.0-beta.4",
|
|
22
22
|
"@vue/shared": "^3.5.0",
|
|
23
23
|
"path-browserify": "^1.0.1",
|
|
24
24
|
"volar-service-css": "0.0.64",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^22.10.4",
|
|
37
37
|
"@types/path-browserify": "^1.0.1",
|
|
38
|
-
"@volar/kit": "2.4.
|
|
39
|
-
"@volar/typescript": "2.4.
|
|
38
|
+
"@volar/kit": "2.4.15",
|
|
39
|
+
"@volar/typescript": "2.4.15",
|
|
40
40
|
"@vue/compiler-dom": "^3.5.0",
|
|
41
|
-
"@vue/typescript-plugin": "3.0.0-beta.
|
|
41
|
+
"@vue/typescript-plugin": "3.0.0-beta.4",
|
|
42
42
|
"vscode-css-languageservice": "^6.3.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "5cb41faacbfe2d9e2d64637c6c1ae8769d9cba3f"
|
|
45
45
|
}
|
|
@@ -82,17 +82,16 @@ const langs = [
|
|
|
82
82
|
},
|
|
83
83
|
];
|
|
84
84
|
|
|
85
|
+
localeWorker();
|
|
85
86
|
for (const lang of langs) {
|
|
86
87
|
if (lang.supported) {
|
|
87
|
-
localeWorker(lang);
|
|
88
88
|
templateWorker(lang);
|
|
89
89
|
sfcWorker(lang);
|
|
90
90
|
modelWorker(lang);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
function localeWorker(
|
|
95
|
-
|
|
94
|
+
function localeWorker() {
|
|
96
95
|
const data = langs.map(({ name, url }) => ({ name, url }));
|
|
97
96
|
|
|
98
97
|
const writePath = path.resolve(__dirname, '../data/locale.json');
|
|
@@ -101,7 +100,6 @@ function localeWorker(lang) {
|
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
async function sfcWorker(lang) {
|
|
104
|
-
|
|
105
103
|
const sfcDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/sfc-spec.md', lang.url);
|
|
106
104
|
const cssFeaturesDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/sfc-css-features.md', lang.url);
|
|
107
105
|
|
|
@@ -142,7 +140,7 @@ async function sfcWorker(lang) {
|
|
|
142
140
|
.split('\n## ')[2]
|
|
143
141
|
.split('\n### ')
|
|
144
142
|
.slice(1)
|
|
145
|
-
.map(
|
|
143
|
+
.map(section => {
|
|
146
144
|
const lines = section.split('\n');
|
|
147
145
|
const name = normalizeTagName(lines[0]);
|
|
148
146
|
/**
|
|
@@ -241,13 +239,12 @@ async function sfcWorker(lang) {
|
|
|
241
239
|
}
|
|
242
240
|
|
|
243
241
|
async function modelWorker(lang) {
|
|
244
|
-
|
|
245
242
|
const formsDoc = await fetchText(lang.repoUrl + 'HEAD/src/guide/essentials/forms.md', lang.url);
|
|
246
243
|
const modifiers = formsDoc
|
|
247
244
|
.split('\n## ')[3]
|
|
248
245
|
.split('\n### ')
|
|
249
246
|
.slice(1)
|
|
250
|
-
.map(
|
|
247
|
+
.map(section => {
|
|
251
248
|
const lines = section.split('\n');
|
|
252
249
|
let name = normalizeAttrName(lines[0]);
|
|
253
250
|
name = name.split('.')[1];
|
|
@@ -279,7 +276,6 @@ async function modelWorker(lang) {
|
|
|
279
276
|
}
|
|
280
277
|
|
|
281
278
|
async function templateWorker(lang) {
|
|
282
|
-
|
|
283
279
|
const componentsDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/built-in-components.md', lang.url);
|
|
284
280
|
const elementsDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/built-in-special-elements.md', lang.url);
|
|
285
281
|
const directivesDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/built-in-directives.md', lang.url);
|
|
@@ -289,7 +285,7 @@ async function templateWorker(lang) {
|
|
|
289
285
|
const components = componentsDoc
|
|
290
286
|
.split('\n## ')
|
|
291
287
|
.slice(1)
|
|
292
|
-
.map(
|
|
288
|
+
.map(section => {
|
|
293
289
|
const lines = section.split('\n');
|
|
294
290
|
const name = normalizeTagName(lines[0]);
|
|
295
291
|
/**
|
|
@@ -309,7 +305,7 @@ async function templateWorker(lang) {
|
|
|
309
305
|
const elements = elementsDoc
|
|
310
306
|
.split('\n## ')
|
|
311
307
|
.slice(1)
|
|
312
|
-
.map(
|
|
308
|
+
.map(section => {
|
|
313
309
|
const lines = section.split('\n');
|
|
314
310
|
const name = normalizeTagName(lines[0]);
|
|
315
311
|
/**
|
|
@@ -329,7 +325,7 @@ async function templateWorker(lang) {
|
|
|
329
325
|
const directives = directivesDoc
|
|
330
326
|
.split('\n## ')
|
|
331
327
|
.slice(1)
|
|
332
|
-
.map(
|
|
328
|
+
.map(section => {
|
|
333
329
|
const lines = section.split('\n');
|
|
334
330
|
const name = normalizeAttrName(lines[0]);
|
|
335
331
|
/**
|
|
@@ -337,12 +333,12 @@ async function templateWorker(lang) {
|
|
|
337
333
|
*/
|
|
338
334
|
const data = {
|
|
339
335
|
name,
|
|
340
|
-
valueSet:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
336
|
+
valueSet: name === 'v-cloak'
|
|
337
|
+
|| name === 'v-else'
|
|
338
|
+
|| name === 'v-once'
|
|
339
|
+
|| name === 'v-pre'
|
|
340
|
+
? 'v'
|
|
341
|
+
: undefined,
|
|
346
342
|
description: {
|
|
347
343
|
kind: 'markdown',
|
|
348
344
|
value: lines.slice(1).join('\n').trim(),
|
|
@@ -354,7 +350,7 @@ async function templateWorker(lang) {
|
|
|
354
350
|
const attributes = attributesDoc
|
|
355
351
|
.split('\n## ')
|
|
356
352
|
.slice(1)
|
|
357
|
-
.map(
|
|
353
|
+
.map(section => {
|
|
358
354
|
const lines = section.split('\n');
|
|
359
355
|
const name = normalizeAttrName(lines[0]);
|
|
360
356
|
/**
|
|
@@ -373,7 +369,7 @@ async function templateWorker(lang) {
|
|
|
373
369
|
const dataAllowMismatch = ssrDoc
|
|
374
370
|
.split(/## data-allow-mismatch.*\n/)
|
|
375
371
|
.slice(1)
|
|
376
|
-
.map(
|
|
372
|
+
.map(section => {
|
|
377
373
|
const lines = section.split('\n');
|
|
378
374
|
const name = 'data-allow-mismatch';
|
|
379
375
|
/**
|
|
@@ -417,7 +413,7 @@ async function templateWorker(lang) {
|
|
|
417
413
|
async function fetchText(url, baseUrl) {
|
|
418
414
|
let text = await (await fetch(url)).text();
|
|
419
415
|
text = text.replace(/```vue-html/g, '```html');
|
|
420
|
-
text = text.replace(/\{
|
|
416
|
+
text = text.replace(/\{#.*?\}/g, '');
|
|
421
417
|
text = resolveMarkdownLinks(text, baseUrl);
|
|
422
418
|
return text;
|
|
423
419
|
}
|