@vue/language-service 3.0.0-alpha.0 → 3.0.0-alpha.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.d.ts +4 -1
- package/index.js +17 -14
- package/lib/plugins/vue-autoinsert-self-closing.d.ts +2 -0
- package/lib/plugins/vue-autoinsert-self-closing.js +33 -0
- package/lib/plugins/vue-document-highlights.d.ts +3 -0
- package/lib/plugins/vue-document-highlights.js +46 -0
- package/lib/plugins/vue-sfc.js +3 -1
- package/lib/plugins/vue-template.js +20 -11
- package/lib/plugins/vue-twoslash-queries.js +1 -1
- package/package.json +12 -12
package/index.d.ts
CHANGED
|
@@ -12,4 +12,7 @@ declare module '@volar/language-service' {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export declare function getFullLanguageServicePlugins(ts: typeof import('typescript')): LanguageServicePlugin<any>[];
|
|
15
|
-
|
|
15
|
+
import type * as ts from 'typescript';
|
|
16
|
+
export declare function getHybridModeLanguageServicePlugins(ts: typeof import('typescript'), tsPluginClient: (import('@vue/typescript-plugin/lib/requests').Requests & {
|
|
17
|
+
getDocumentHighlights: (fileName: string, position: number) => Promise<ts.DocumentHighlights[] | null>;
|
|
18
|
+
}) | undefined): LanguageServicePlugin<any>[];
|
package/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const vue_compiler_dom_errors_1 = require("./lib/plugins/vue-compiler-dom-errors
|
|
|
36
36
|
const vue_complete_define_assignment_1 = require("./lib/plugins/vue-complete-define-assignment");
|
|
37
37
|
const vue_directive_comments_1 = require("./lib/plugins/vue-directive-comments");
|
|
38
38
|
const vue_document_drop_1 = require("./lib/plugins/vue-document-drop");
|
|
39
|
+
const vue_document_highlights_1 = require("./lib/plugins/vue-document-highlights");
|
|
39
40
|
const vue_document_links_1 = require("./lib/plugins/vue-document-links");
|
|
40
41
|
const vue_extract_file_1 = require("./lib/plugins/vue-extract-file");
|
|
41
42
|
const vue_inlayhints_1 = require("./lib/plugins/vue-inlayhints");
|
|
@@ -105,31 +106,31 @@ function getFullLanguageServicePlugins(ts) {
|
|
|
105
106
|
};
|
|
106
107
|
return {
|
|
107
108
|
async collectExtractProps(...args) {
|
|
108
|
-
return
|
|
109
|
+
return collectExtractProps_1.collectExtractProps.apply(requestContext, args);
|
|
109
110
|
},
|
|
110
111
|
async getPropertiesAtLocation(...args) {
|
|
111
|
-
return
|
|
112
|
+
return getPropertiesAtLocation_1.getPropertiesAtLocation.apply(requestContext, args);
|
|
112
113
|
},
|
|
113
114
|
async getImportPathForFile(...args) {
|
|
114
|
-
return
|
|
115
|
+
return getImportPathForFile_1.getImportPathForFile.apply(requestContext, args);
|
|
115
116
|
},
|
|
116
117
|
async getComponentEvents(...args) {
|
|
117
|
-
return
|
|
118
|
+
return getComponentEvents_1.getComponentEvents.apply(requestContext, args);
|
|
118
119
|
},
|
|
119
120
|
async getComponentDirectives(...args) {
|
|
120
|
-
return
|
|
121
|
+
return getComponentDirectives_1.getComponentDirectives.apply(requestContext, args);
|
|
121
122
|
},
|
|
122
123
|
async getComponentNames(...args) {
|
|
123
|
-
return
|
|
124
|
+
return getComponentNames_1.getComponentNames.apply(requestContext, args);
|
|
124
125
|
},
|
|
125
126
|
async getComponentProps(...args) {
|
|
126
|
-
return
|
|
127
|
+
return getComponentProps_1.getComponentProps.apply(requestContext, args);
|
|
127
128
|
},
|
|
128
129
|
async getElementAttrs(...args) {
|
|
129
|
-
return
|
|
130
|
+
return getElementAttrs_1.getElementAttrs.apply(requestContext, args);
|
|
130
131
|
},
|
|
131
132
|
async getElementNames(...args) {
|
|
132
|
-
return
|
|
133
|
+
return getElementNames_1.getElementNames.apply(requestContext, args);
|
|
133
134
|
},
|
|
134
135
|
async getQuickInfoAtPosition(fileName, position) {
|
|
135
136
|
const languageService = context.getLanguageService();
|
|
@@ -138,8 +139,7 @@ function getFullLanguageServicePlugins(ts) {
|
|
|
138
139
|
if (!sourceScript) {
|
|
139
140
|
return;
|
|
140
141
|
}
|
|
141
|
-
const
|
|
142
|
-
const hover = await languageService.getHover(uri, document.positionAt(position));
|
|
142
|
+
const hover = await languageService.getHover(uri, position);
|
|
143
143
|
let text = '';
|
|
144
144
|
if (typeof hover?.contents === 'string') {
|
|
145
145
|
text = hover.contents;
|
|
@@ -167,12 +167,15 @@ function getFullLanguageServicePlugins(ts) {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
function getHybridModeLanguageServicePlugins(ts,
|
|
170
|
+
function getHybridModeLanguageServicePlugins(ts, tsPluginClient) {
|
|
171
171
|
const plugins = [
|
|
172
172
|
(0, syntactic_1.create)(ts),
|
|
173
173
|
(0, docCommentTemplate_1.create)(ts),
|
|
174
|
-
...getCommonLanguageServicePlugins(ts, () =>
|
|
174
|
+
...getCommonLanguageServicePlugins(ts, () => tsPluginClient)
|
|
175
175
|
];
|
|
176
|
+
if (tsPluginClient) {
|
|
177
|
+
plugins.push((0, vue_document_highlights_1.create)(tsPluginClient.getDocumentHighlights));
|
|
178
|
+
}
|
|
176
179
|
for (const plugin of plugins) {
|
|
177
180
|
// avoid affecting TS plugin
|
|
178
181
|
delete plugin.capabilities.semanticTokensProvider;
|
|
@@ -191,8 +194,8 @@ function getCommonLanguageServicePlugins(ts, getTsPluginClient) {
|
|
|
191
194
|
(0, vue_compiler_dom_errors_1.create)(),
|
|
192
195
|
(0, vue_sfc_1.create)(),
|
|
193
196
|
(0, vue_twoslash_queries_1.create)(getTsPluginClient),
|
|
194
|
-
(0, vue_document_links_1.create)(),
|
|
195
197
|
(0, vue_document_drop_1.create)(ts, getTsPluginClient),
|
|
198
|
+
(0, vue_document_links_1.create)(),
|
|
196
199
|
(0, vue_complete_define_assignment_1.create)(),
|
|
197
200
|
(0, vue_autoinsert_dotvalue_1.create)(ts, getTsPluginClient),
|
|
198
201
|
(0, vue_autoinsert_space_1.create)(),
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = create;
|
|
4
|
+
function create() {
|
|
5
|
+
return {
|
|
6
|
+
name: 'vue-autoinsert-selfClosing',
|
|
7
|
+
capabilities: {
|
|
8
|
+
autoInsertionProvider: {
|
|
9
|
+
triggerCharacters: ['/'],
|
|
10
|
+
configurationSections: ['vue.autoInsert.selfClosing'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
async provideAutoInsertSnippet(document, selection, change) {
|
|
16
|
+
if (document.languageId !== 'html') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const enabled = await context.env.getConfiguration?.('vue.autoInsert.selfClosing') ?? true;
|
|
20
|
+
if (!enabled) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (change.text === '{}'
|
|
24
|
+
&& document.getText().slice(change.rangeOffset - 1, change.rangeOffset + 3) === '{{}}'
|
|
25
|
+
&& document.offsetAt(selection) === change.rangeOffset + 1) {
|
|
26
|
+
return ` $0 `;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=vue-autoinsert-self-closing.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = create;
|
|
4
|
+
const language_core_1 = require("@vue/language-core");
|
|
5
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
6
|
+
function create(getDocumentHighlights) {
|
|
7
|
+
return {
|
|
8
|
+
name: 'vue-document-highlights',
|
|
9
|
+
capabilities: {
|
|
10
|
+
documentHighlightProvider: true,
|
|
11
|
+
},
|
|
12
|
+
create(context) {
|
|
13
|
+
return {
|
|
14
|
+
async provideDocumentHighlights(document, position) {
|
|
15
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
16
|
+
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
17
|
+
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
18
|
+
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
19
|
+
if (!sourceScript?.generated || virtualCode?.id !== 'main') {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const root = sourceScript.generated.root;
|
|
23
|
+
if (!(root instanceof language_core_1.VueVirtualCode)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const result = await getDocumentHighlights(root.fileName, document.offsetAt(position));
|
|
27
|
+
return result
|
|
28
|
+
?.filter(({ fileName }) => fileName === root.fileName)
|
|
29
|
+
.flatMap(({ highlightSpans }) => highlightSpans)
|
|
30
|
+
.map(({ textSpan, kind }) => ({
|
|
31
|
+
range: {
|
|
32
|
+
start: document.positionAt(textSpan.start),
|
|
33
|
+
end: document.positionAt(textSpan.start + textSpan.length),
|
|
34
|
+
},
|
|
35
|
+
kind: kind === 'reference'
|
|
36
|
+
? 2
|
|
37
|
+
: kind === 'writtenReference'
|
|
38
|
+
? 3
|
|
39
|
+
: 1,
|
|
40
|
+
}));
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=vue-document-highlights.js.map
|
package/lib/plugins/vue-sfc.js
CHANGED
|
@@ -193,7 +193,9 @@ function create() {
|
|
|
193
193
|
if (!result) {
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
|
-
result.items = result.items.filter(item => item.label !== '!DOCTYPE' &&
|
|
196
|
+
result.items = result.items.filter(item => item.label !== '!DOCTYPE' &&
|
|
197
|
+
item.label !== 'Custom Blocks' &&
|
|
198
|
+
item.label !== 'data-');
|
|
197
199
|
const tags = sfcDataProvider?.provideTags();
|
|
198
200
|
const scriptLangs = getLangs('script');
|
|
199
201
|
const scriptItems = result.items.filter(item => item.label === 'script' || item.label === 'script setup');
|
|
@@ -247,14 +247,19 @@ function create(mode, getTsPluginClient) {
|
|
|
247
247
|
return [];
|
|
248
248
|
}
|
|
249
249
|
const { attrs, propInfos, events, directives } = tagInfo;
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
for (const prop of propInfos) {
|
|
251
|
+
if ((0, language_core_1.hyphenateTag)(prop.name).startsWith('on-vnode-')) {
|
|
252
|
+
prop.name = 'onVue:' + prop.name.slice('onVnode'.length);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
253
255
|
const attributes = [];
|
|
254
|
-
const propsSet = new Set(
|
|
255
|
-
for (const prop of [
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
const propsSet = new Set(propInfos.map(prop => prop.name));
|
|
257
|
+
for (const prop of [
|
|
258
|
+
...propInfos,
|
|
259
|
+
...attrs.map(attr => ({ name: attr })),
|
|
260
|
+
]) {
|
|
261
|
+
const isGlobal = !propsSet.has(prop.name);
|
|
262
|
+
const name = casing.attr === types_1.AttrNameCasing.Camel ? prop.name : (0, language_core_1.hyphenateAttr)(prop.name);
|
|
258
263
|
const isEvent = (0, language_core_1.hyphenateAttr)(name).startsWith('on-');
|
|
259
264
|
if (isEvent) {
|
|
260
265
|
const propNameBase = name.startsWith('on-')
|
|
@@ -282,6 +287,7 @@ function create(mode, getTsPluginClient) {
|
|
|
282
287
|
attributes.push({
|
|
283
288
|
name: propName,
|
|
284
289
|
description: propKey,
|
|
290
|
+
valueSet: prop.values?.some(value => typeof value === 'string') ? '__deferred__' : undefined,
|
|
285
291
|
}, {
|
|
286
292
|
name: ':' + propName,
|
|
287
293
|
description: propKey,
|
|
@@ -309,10 +315,13 @@ function create(mode, getTsPluginClient) {
|
|
|
309
315
|
});
|
|
310
316
|
}
|
|
311
317
|
const models = [];
|
|
312
|
-
for (const prop of [
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
318
|
+
for (const prop of [
|
|
319
|
+
...propInfos,
|
|
320
|
+
...attrs.map(attr => ({ name: attr })),
|
|
321
|
+
]) {
|
|
322
|
+
if (prop.name.startsWith('onUpdate:')) {
|
|
323
|
+
const isGlobal = !propsSet.has(prop.name);
|
|
324
|
+
models.push([isGlobal, prop.name.slice('onUpdate:'.length)]);
|
|
316
325
|
}
|
|
317
326
|
}
|
|
318
327
|
for (const event of events) {
|
|
@@ -38,7 +38,7 @@ function create(getTsPluginClient) {
|
|
|
38
38
|
for (const [pointerPosition, hoverOffset] of hoverOffsets) {
|
|
39
39
|
const map = context.language.maps.get(virtualCode, sourceScript);
|
|
40
40
|
for (const [sourceOffset] of map.toSourceLocation(hoverOffset)) {
|
|
41
|
-
const quickInfo = await tsPluginClient?.getQuickInfoAtPosition(root.fileName, sourceOffset);
|
|
41
|
+
const quickInfo = await tsPluginClient?.getQuickInfoAtPosition(root.fileName, document.positionAt(sourceOffset));
|
|
42
42
|
if (quickInfo) {
|
|
43
43
|
inlayHints.push({
|
|
44
44
|
position: { line: pointerPosition.line, character: pointerPosition.character + 2 },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-service",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"data",
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"@volar/language-service": "~2.4.11",
|
|
22
22
|
"@volar/typescript": "~2.4.11",
|
|
23
23
|
"@vue/compiler-dom": "^3.5.0",
|
|
24
|
-
"@vue/language-core": "3.0.0-alpha.
|
|
24
|
+
"@vue/language-core": "3.0.0-alpha.4",
|
|
25
25
|
"@vue/shared": "^3.5.0",
|
|
26
|
-
"@vue/typescript-plugin": "3.0.0-alpha.
|
|
26
|
+
"@vue/typescript-plugin": "3.0.0-alpha.4",
|
|
27
27
|
"alien-signals": "^1.0.3",
|
|
28
28
|
"path-browserify": "^1.0.1",
|
|
29
|
-
"volar-service-css": "0.0.
|
|
30
|
-
"volar-service-emmet": "0.0.
|
|
31
|
-
"volar-service-html": "0.0.
|
|
32
|
-
"volar-service-json": "0.0.
|
|
33
|
-
"volar-service-pug": "0.0.
|
|
34
|
-
"volar-service-pug-beautify": "0.0.
|
|
35
|
-
"volar-service-typescript": "0.0.
|
|
36
|
-
"volar-service-typescript-twoslash-queries": "0.0.
|
|
29
|
+
"volar-service-css": "0.0.64",
|
|
30
|
+
"volar-service-emmet": "0.0.64",
|
|
31
|
+
"volar-service-html": "0.0.64",
|
|
32
|
+
"volar-service-json": "0.0.64",
|
|
33
|
+
"volar-service-pug": "0.0.64",
|
|
34
|
+
"volar-service-pug-beautify": "0.0.64",
|
|
35
|
+
"volar-service-typescript": "0.0.64",
|
|
36
|
+
"volar-service-typescript-twoslash-queries": "0.0.64",
|
|
37
37
|
"vscode-css-languageservice": "^6.3.1",
|
|
38
38
|
"vscode-html-languageservice": "^5.2.0",
|
|
39
39
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"@volar/kit": "~2.4.11",
|
|
46
46
|
"vscode-languageserver-protocol": "^3.17.5"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "1769cd6b94ec9e0cc2681b8dbba904f35856ba1c"
|
|
49
49
|
}
|