@vue/language-service 3.0.3 → 3.0.5
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 +1 -12
- package/index.js +25 -20
- package/lib/data.d.ts +4 -0
- package/lib/data.js +148 -0
- package/lib/plugins/css.js +9 -17
- package/lib/plugins/typescript-semantic-tokens.d.ts +2 -2
- package/lib/plugins/typescript-semantic-tokens.js +7 -15
- package/lib/plugins/vue-autoinsert-dotvalue.d copy.d.ts +2 -0
- package/lib/plugins/vue-autoinsert-dotvalue.d copy.js +3 -0
- package/lib/plugins/vue-autoinsert-dotvalue.d.ts +2 -2
- package/lib/plugins/vue-autoinsert-dotvalue.js +19 -47
- package/lib/plugins/vue-autoinsert-space.js +2 -6
- package/lib/plugins/vue-compiler-dom-errors.js +17 -35
- package/lib/plugins/vue-component-semantic-tokens.d.ts +2 -2
- package/lib/plugins/vue-component-semantic-tokens.js +35 -49
- package/lib/plugins/vue-destructured-props-hints.d.ts +7 -0
- package/lib/plugins/vue-destructured-props-hints.js +220 -0
- package/lib/plugins/vue-document-drop.d.ts +2 -2
- package/lib/plugins/vue-document-drop.js +14 -31
- package/lib/plugins/vue-document-highlights.d.ts +1 -2
- package/lib/plugins/vue-document-highlights.js +5 -12
- package/lib/plugins/vue-extract-file.d.ts +2 -2
- package/lib/plugins/vue-extract-file.js +11 -26
- package/lib/plugins/vue-global-types-error.js +17 -14
- package/lib/plugins/vue-inlayhints.js +14 -15
- package/lib/plugins/vue-missing-props-hints.d.ts +2 -2
- package/lib/plugins/vue-missing-props-hints.js +10 -26
- package/lib/plugins/vue-scoped-class-links.d.ts +2 -0
- package/lib/plugins/vue-scoped-class-links.js +62 -0
- package/lib/plugins/vue-sfc.js +141 -144
- package/lib/plugins/vue-suggest-define-assignment.js +4 -14
- package/lib/plugins/vue-template-ref-links.d.ts +2 -0
- package/lib/plugins/vue-template-ref-links.js +57 -0
- package/lib/plugins/vue-template.d.ts +2 -2
- package/lib/plugins/vue-template.js +322 -356
- package/lib/plugins/vue-twoslash-queries.d.ts +2 -2
- package/lib/plugins/vue-twoslash-queries.js +7 -16
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +43 -0
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
export * from '@volar/language-service';
|
|
2
2
|
export * from '@volar/language-service/lib/utils/featureWorkers';
|
|
3
|
-
|
|
4
|
-
import type * as ts from 'typescript';
|
|
5
|
-
declare module '@volar/language-service' {
|
|
6
|
-
interface ProjectContext {
|
|
7
|
-
vue?: {
|
|
8
|
-
compilerOptions: VueCompilerOptions;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export declare function createVueLanguageServicePlugins(ts: typeof import('typescript'), tsPluginClient: (import('@vue/typescript-plugin/lib/requests').Requests & {
|
|
13
|
-
getDocumentHighlights: (fileName: string, position: number) => Promise<ts.DocumentHighlights[] | null>;
|
|
14
|
-
}) | undefined): import("@volar/language-service").LanguageServicePlugin<any>[];
|
|
3
|
+
export declare function createVueLanguageServicePlugins(ts: typeof import('typescript'), tsPluginClient?: import('@vue/typescript-plugin/lib/requests').Requests): import("@volar/language-service").LanguageServicePlugin<any>[];
|
package/index.js
CHANGED
|
@@ -33,50 +33,55 @@ const vue_component_semantic_tokens_1 = require("./lib/plugins/vue-component-sem
|
|
|
33
33
|
const vue_directive_comments_1 = require("./lib/plugins/vue-directive-comments");
|
|
34
34
|
const vue_document_drop_1 = require("./lib/plugins/vue-document-drop");
|
|
35
35
|
const vue_document_highlights_1 = require("./lib/plugins/vue-document-highlights");
|
|
36
|
-
const vue_document_links_1 = require("./lib/plugins/vue-document-links");
|
|
37
36
|
const vue_extract_file_1 = require("./lib/plugins/vue-extract-file");
|
|
38
37
|
const vue_global_types_error_1 = require("./lib/plugins/vue-global-types-error");
|
|
39
38
|
const vue_inlayhints_1 = require("./lib/plugins/vue-inlayhints");
|
|
40
39
|
const vue_missing_props_hints_1 = require("./lib/plugins/vue-missing-props-hints");
|
|
40
|
+
const vue_scoped_class_links_1 = require("./lib/plugins/vue-scoped-class-links");
|
|
41
41
|
const vue_sfc_1 = require("./lib/plugins/vue-sfc");
|
|
42
42
|
const vue_suggest_define_assignment_1 = require("./lib/plugins/vue-suggest-define-assignment");
|
|
43
43
|
const vue_template_1 = require("./lib/plugins/vue-template");
|
|
44
|
+
const vue_template_ref_links_1 = require("./lib/plugins/vue-template-ref-links");
|
|
44
45
|
const vue_twoslash_queries_1 = require("./lib/plugins/vue-twoslash-queries");
|
|
45
46
|
function createVueLanguageServicePlugins(ts, tsPluginClient) {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
tsPluginClient ??= new Proxy({}, {
|
|
48
|
+
get() {
|
|
49
|
+
return () => undefined;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return [
|
|
48
53
|
(0, css_1.create)(),
|
|
49
54
|
(0, volar_service_json_1.create)(),
|
|
50
55
|
(0, volar_service_pug_beautify_1.create)(),
|
|
51
|
-
(0, docCommentTemplate_1.create)(ts),
|
|
52
|
-
(0, typescript_semantic_tokens_1.create)(getTsPluginClient),
|
|
53
|
-
(0, syntactic_1.create)(ts),
|
|
54
56
|
(0, vue_autoinsert_space_1.create)(),
|
|
55
|
-
(0, vue_autoinsert_dotvalue_1.create)(ts, getTsPluginClient),
|
|
56
57
|
(0, vue_compiler_dom_errors_1.create)(),
|
|
57
|
-
(0, vue_component_semantic_tokens_1.create)(getTsPluginClient),
|
|
58
|
-
(0, vue_document_drop_1.create)(ts, getTsPluginClient),
|
|
59
|
-
(0, vue_document_links_1.create)(),
|
|
60
58
|
(0, vue_directive_comments_1.create)(),
|
|
61
|
-
(0, vue_extract_file_1.create)(ts, getTsPluginClient),
|
|
62
59
|
(0, vue_global_types_error_1.create)(),
|
|
63
|
-
(0,
|
|
64
|
-
(0, vue_missing_props_hints_1.create)(getTsPluginClient),
|
|
60
|
+
(0, vue_scoped_class_links_1.create)(),
|
|
65
61
|
(0, vue_sfc_1.create)(),
|
|
66
62
|
(0, vue_suggest_define_assignment_1.create)(),
|
|
67
|
-
(0,
|
|
68
|
-
(0, vue_template_1.create)('pug', getTsPluginClient),
|
|
69
|
-
(0, vue_twoslash_queries_1.create)(getTsPluginClient),
|
|
63
|
+
(0, vue_template_ref_links_1.create)(),
|
|
70
64
|
(0, volar_service_emmet_1.create)({
|
|
71
65
|
mappedLanguages: {
|
|
72
66
|
'vue-root-tags': 'html',
|
|
73
67
|
'postcss': 'scss',
|
|
74
68
|
},
|
|
75
69
|
}),
|
|
70
|
+
// TS related plugins
|
|
71
|
+
(0, docCommentTemplate_1.create)(ts),
|
|
72
|
+
(0, syntactic_1.create)(ts),
|
|
73
|
+
(0, vue_inlayhints_1.create)(ts),
|
|
74
|
+
// type aware plugins
|
|
75
|
+
(0, typescript_semantic_tokens_1.create)(tsPluginClient),
|
|
76
|
+
(0, vue_autoinsert_dotvalue_1.create)(ts, tsPluginClient),
|
|
77
|
+
(0, vue_component_semantic_tokens_1.create)(tsPluginClient),
|
|
78
|
+
(0, vue_document_drop_1.create)(ts, tsPluginClient),
|
|
79
|
+
(0, vue_document_highlights_1.create)(tsPluginClient),
|
|
80
|
+
(0, vue_extract_file_1.create)(ts, tsPluginClient),
|
|
81
|
+
(0, vue_missing_props_hints_1.create)(tsPluginClient),
|
|
82
|
+
(0, vue_template_1.create)('html', tsPluginClient),
|
|
83
|
+
(0, vue_template_1.create)('jade', tsPluginClient),
|
|
84
|
+
(0, vue_twoslash_queries_1.create)(tsPluginClient),
|
|
76
85
|
];
|
|
77
|
-
if (tsPluginClient) {
|
|
78
|
-
plugins.push((0, vue_document_highlights_1.create)(tsPluginClient.getDocumentHighlights));
|
|
79
|
-
}
|
|
80
|
-
return plugins;
|
|
81
86
|
}
|
|
82
87
|
//# sourceMappingURL=index.js.map
|
package/lib/data.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as html from 'vscode-html-languageservice';
|
|
2
|
+
export declare function loadTemplateData(lang: string): html.HTMLDataV1;
|
|
3
|
+
export declare function loadLanguageBlocks(lang: string): html.HTMLDataV1;
|
|
4
|
+
export declare function loadModelModifiersData(lang: string): html.HTMLDataV1;
|
package/lib/data.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadTemplateData = loadTemplateData;
|
|
4
|
+
exports.loadLanguageBlocks = loadLanguageBlocks;
|
|
5
|
+
exports.loadModelModifiersData = loadModelModifiersData;
|
|
6
|
+
let locale;
|
|
7
|
+
function loadTemplateData(lang) {
|
|
8
|
+
lang = lang.toLowerCase();
|
|
9
|
+
let data;
|
|
10
|
+
if (lang === 'ja') {
|
|
11
|
+
data = require('../data/template/ja.json');
|
|
12
|
+
}
|
|
13
|
+
else if (lang === 'fr') {
|
|
14
|
+
data = require('../data/template/fr.json');
|
|
15
|
+
}
|
|
16
|
+
else if (lang === 'ko') {
|
|
17
|
+
data = require('../data/template/ko.json');
|
|
18
|
+
}
|
|
19
|
+
else if (lang === 'pt-br') {
|
|
20
|
+
data = require('../data/template/pt.json');
|
|
21
|
+
}
|
|
22
|
+
else if (lang === 'zh-cn') {
|
|
23
|
+
data = require('../data/template/zh-cn.json');
|
|
24
|
+
}
|
|
25
|
+
else if (lang === 'zh-tw') {
|
|
26
|
+
data = require('../data/template/zh-hk.json');
|
|
27
|
+
}
|
|
28
|
+
else if (lang === 'it') {
|
|
29
|
+
data = require('../data/template/it.json');
|
|
30
|
+
}
|
|
31
|
+
else if (lang === 'cs') {
|
|
32
|
+
data = require('../data/template/cs.json');
|
|
33
|
+
}
|
|
34
|
+
else if (lang === 'ru') {
|
|
35
|
+
data = require('../data/template/ru.json');
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
data = require('../data/template/en.json');
|
|
39
|
+
}
|
|
40
|
+
resolveReferences(data);
|
|
41
|
+
// oxlint-disable-next-line no-useless-spread
|
|
42
|
+
for (const attr of [...data.globalAttributes ?? []]) {
|
|
43
|
+
if (!attr.name.startsWith('v-')) {
|
|
44
|
+
data.globalAttributes?.push({ ...attr, name: `:${attr.name}` }, { ...attr, name: `v-bind:${attr.name}` });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const vOn = data.globalAttributes?.find(d => d.name === 'v-on');
|
|
48
|
+
const vSlot = data.globalAttributes?.find(d => d.name === 'v-slot');
|
|
49
|
+
const vBind = data.globalAttributes?.find(d => d.name === 'v-bind');
|
|
50
|
+
if (vOn) {
|
|
51
|
+
data.globalAttributes?.push({ ...vOn, name: '@' });
|
|
52
|
+
}
|
|
53
|
+
if (vSlot) {
|
|
54
|
+
data.globalAttributes?.push({ ...vSlot, name: '#' });
|
|
55
|
+
}
|
|
56
|
+
if (vBind) {
|
|
57
|
+
data.globalAttributes?.push({ ...vBind, name: ':' });
|
|
58
|
+
}
|
|
59
|
+
return data;
|
|
60
|
+
}
|
|
61
|
+
function loadLanguageBlocks(lang) {
|
|
62
|
+
lang = lang.toLowerCase();
|
|
63
|
+
let data;
|
|
64
|
+
if (lang === 'ja') {
|
|
65
|
+
data = require('../data/language-blocks/ja.json');
|
|
66
|
+
}
|
|
67
|
+
else if (lang === 'fr') {
|
|
68
|
+
data = require('../data/language-blocks/fr.json');
|
|
69
|
+
}
|
|
70
|
+
else if (lang === 'ko') {
|
|
71
|
+
data = require('../data/language-blocks/ko.json');
|
|
72
|
+
}
|
|
73
|
+
else if (lang === 'pt-br') {
|
|
74
|
+
data = require('../data/language-blocks/pt.json');
|
|
75
|
+
}
|
|
76
|
+
else if (lang === 'zh-cn') {
|
|
77
|
+
data = require('../data/language-blocks/zh-cn.json');
|
|
78
|
+
}
|
|
79
|
+
else if (lang === 'zh-tw') {
|
|
80
|
+
data = require('../data/language-blocks/zh-hk.json');
|
|
81
|
+
}
|
|
82
|
+
else if (lang === 'it') {
|
|
83
|
+
data = require('../data/language-blocks/it.json');
|
|
84
|
+
}
|
|
85
|
+
else if (lang === 'cs') {
|
|
86
|
+
data = require('../data/language-blocks/cs.json');
|
|
87
|
+
}
|
|
88
|
+
else if (lang === 'ru') {
|
|
89
|
+
data = require('../data/language-blocks/ru.json');
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
data = require('../data/language-blocks/en.json');
|
|
93
|
+
}
|
|
94
|
+
resolveReferences(data);
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
function loadModelModifiersData(lang) {
|
|
98
|
+
lang = lang.toLowerCase();
|
|
99
|
+
let data;
|
|
100
|
+
if (lang === 'ja') {
|
|
101
|
+
data = require('../data/model-modifiers/ja.json');
|
|
102
|
+
}
|
|
103
|
+
else if (lang === 'fr') {
|
|
104
|
+
data = require('../data/model-modifiers/fr.json');
|
|
105
|
+
}
|
|
106
|
+
else if (lang === 'ko') {
|
|
107
|
+
data = require('../data/model-modifiers/ko.json');
|
|
108
|
+
}
|
|
109
|
+
else if (lang === 'pt-br') {
|
|
110
|
+
data = require('../data/model-modifiers/pt.json');
|
|
111
|
+
}
|
|
112
|
+
else if (lang === 'zh-cn') {
|
|
113
|
+
data = require('../data/model-modifiers/zh-cn.json');
|
|
114
|
+
}
|
|
115
|
+
else if (lang === 'zh-tw') {
|
|
116
|
+
data = require('../data/model-modifiers/zh-hk.json');
|
|
117
|
+
}
|
|
118
|
+
else if (lang === 'it') {
|
|
119
|
+
data = require('../data/model-modifiers/it.json');
|
|
120
|
+
}
|
|
121
|
+
else if (lang === 'cs') {
|
|
122
|
+
data = require('../data/model-modifiers/cs.json');
|
|
123
|
+
}
|
|
124
|
+
else if (lang === 'ru') {
|
|
125
|
+
data = require('../data/model-modifiers/ru.json');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
data = require('../data/model-modifiers/en.json');
|
|
129
|
+
}
|
|
130
|
+
resolveReferences(data);
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
function resolveReferences(data) {
|
|
134
|
+
locale ??= require('../data/locale.json');
|
|
135
|
+
for (const item of [
|
|
136
|
+
...data.globalAttributes ?? [],
|
|
137
|
+
...data.tags?.flatMap(tag => [tag, ...tag.attributes]) ?? [],
|
|
138
|
+
]) {
|
|
139
|
+
if (typeof item.references === 'string') {
|
|
140
|
+
const relativeUrl = item.references;
|
|
141
|
+
item.references = locale.map(({ name, url }) => ({
|
|
142
|
+
name,
|
|
143
|
+
url: url + relativeUrl,
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=data.js.map
|
package/lib/plugins/css.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.create = create;
|
|
4
4
|
const language_core_1 = require("@vue/language-core");
|
|
5
5
|
const volar_service_css_1 = require("volar-service-css");
|
|
6
|
-
const
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
7
|
function create() {
|
|
8
8
|
const base = (0, volar_service_css_1.create)({ scssDocumentSelector: ['scss', 'postcss'] });
|
|
9
9
|
return {
|
|
@@ -16,9 +16,9 @@ function create() {
|
|
|
16
16
|
async provideDiagnostics(document, token) {
|
|
17
17
|
let diagnostics = await baseInstance.provideDiagnostics?.(document, token) ?? [];
|
|
18
18
|
if (document.languageId === 'postcss') {
|
|
19
|
-
diagnostics = diagnostics.filter(diag => diag.code !== 'css-semicolonexpected'
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
diagnostics = diagnostics.filter(diag => diag.code !== 'css-semicolonexpected'
|
|
20
|
+
&& diag.code !== 'css-ruleorselectorexpected'
|
|
21
|
+
&& diag.code !== 'unknownAtRules');
|
|
22
22
|
}
|
|
23
23
|
return diagnostics;
|
|
24
24
|
},
|
|
@@ -44,18 +44,12 @@ function create() {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
function isWithinNavigationVirtualCode(document, position) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
50
|
-
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
51
|
-
if (!sourceScript?.generated || !virtualCode?.id.startsWith('style_')) {
|
|
47
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, id => id.startsWith('style_'));
|
|
48
|
+
if (!info) {
|
|
52
49
|
return false;
|
|
53
50
|
}
|
|
54
|
-
const root =
|
|
55
|
-
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
const block = root.sfc.styles.find(style => style.name === decoded[1]);
|
|
51
|
+
const { sourceScript, virtualCode, root } = info;
|
|
52
|
+
const block = root.sfc.styles.find(style => style.name === virtualCode.id);
|
|
59
53
|
if (!block) {
|
|
60
54
|
return false;
|
|
61
55
|
}
|
|
@@ -71,9 +65,7 @@ function create() {
|
|
|
71
65
|
}
|
|
72
66
|
const offset = document.offsetAt(position) + block.startTagEnd;
|
|
73
67
|
for (const { sourceOffsets, lengths, data } of script.mappings) {
|
|
74
|
-
if (!sourceOffsets.length
|
|
75
|
-
|| !data.navigation
|
|
76
|
-
|| typeof data.navigation === 'object' && !data.navigation.shouldRename) {
|
|
68
|
+
if (!sourceOffsets.length || !(0, language_core_1.isRenameEnabled)(data)) {
|
|
77
69
|
continue;
|
|
78
70
|
}
|
|
79
71
|
const start = sourceOffsets[0];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function create(
|
|
1
|
+
import type { LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
+
export declare function create({ getEncodedSemanticClassifications }: import('@vue/typescript-plugin/lib/requests').Requests): LanguageServicePlugin;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.create = create;
|
|
4
|
-
const language_core_1 = require("@vue/language-core");
|
|
5
4
|
const semanticTokens_1 = require("volar-service-typescript/lib/semanticFeatures/semanticTokens");
|
|
6
|
-
const
|
|
7
|
-
function create(
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
function create({ getEncodedSemanticClassifications }) {
|
|
8
7
|
return {
|
|
9
|
-
name: 'typescript-
|
|
8
|
+
name: 'typescript-semantic-tokens',
|
|
10
9
|
capabilities: {
|
|
11
10
|
semanticTokensProvider: {
|
|
12
11
|
legend: {
|
|
@@ -36,27 +35,20 @@ function create(getTsPluginClient) {
|
|
|
36
35
|
},
|
|
37
36
|
},
|
|
38
37
|
create(context) {
|
|
39
|
-
const tsPluginClient = getTsPluginClient?.(context);
|
|
40
38
|
return {
|
|
41
39
|
async provideDocumentSemanticTokens(document, range, legend) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
45
|
-
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
46
|
-
if (!sourceScript?.generated || virtualCode?.id !== 'main') {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const root = sourceScript.generated.root;
|
|
50
|
-
if (!(root instanceof language_core_1.VueVirtualCode)) {
|
|
40
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, 'main');
|
|
41
|
+
if (!info) {
|
|
51
42
|
return;
|
|
52
43
|
}
|
|
44
|
+
const { root } = info;
|
|
53
45
|
const start = document.offsetAt(range.start);
|
|
54
46
|
const end = document.offsetAt(range.end);
|
|
55
47
|
const span = {
|
|
56
48
|
start: start,
|
|
57
49
|
length: end - start,
|
|
58
50
|
};
|
|
59
|
-
const classifications = await
|
|
51
|
+
const classifications = await getEncodedSemanticClassifications(root.fileName, span);
|
|
60
52
|
if (classifications) {
|
|
61
53
|
return (0, semanticTokens_1.convertClassificationsToSemanticTokens)(document, span, legend, classifications);
|
|
62
54
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
+
export declare function create(ts: typeof import('typescript'), getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function create(ts: typeof import('typescript'),
|
|
1
|
+
import type { LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
+
export declare function create(ts: typeof import('typescript'), { getPropertiesAtLocation }: import('@vue/typescript-plugin/lib/requests').Requests): LanguageServicePlugin;
|
|
@@ -2,9 +2,8 @@
|
|
|
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
|
|
6
|
-
|
|
7
|
-
function create(ts, getTsPluginClient) {
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
function create(ts, { getPropertiesAtLocation }) {
|
|
8
7
|
return {
|
|
9
8
|
name: 'vue-autoinsert-dotvalue',
|
|
10
9
|
capabilities: {
|
|
@@ -14,70 +13,43 @@ function create(ts, getTsPluginClient) {
|
|
|
14
13
|
},
|
|
15
14
|
},
|
|
16
15
|
create(context) {
|
|
17
|
-
const tsPluginClient = getTsPluginClient?.(context);
|
|
18
|
-
let currentReq = 0;
|
|
19
16
|
return {
|
|
20
17
|
async provideAutoInsertSnippet(document, selection, change) {
|
|
21
|
-
|
|
22
|
-
if (
|
|
18
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, id => id.startsWith('script_'));
|
|
19
|
+
if (!info) {
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
// selection must at end of change
|
|
23
|
+
if (document.offsetAt(selection) !== change.rangeOffset + change.text.length) {
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
26
|
if (!isCharacterTyping(document, change)) {
|
|
29
27
|
return;
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await (0, utils_1.sleep)(250);
|
|
34
|
-
if (req !== currentReq) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const enabled = await context.env.getConfiguration?.('vue.autoInsert.dotValue') ?? true;
|
|
38
|
-
if (!enabled) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
42
|
-
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
43
|
-
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
44
|
-
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
45
|
-
if (!sourceScript?.generated || !virtualCode) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const root = sourceScript.generated.root;
|
|
49
|
-
if (!(root instanceof language_core_1.VueVirtualCode)) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
29
|
+
let sourceOffset;
|
|
30
|
+
const { sourceScript, virtualCode, root } = info;
|
|
52
31
|
const { sfc } = root;
|
|
53
|
-
const
|
|
54
|
-
|
|
32
|
+
const scriptBlocks = [sfc.script, sfc.scriptSetup].filter(block => !!block);
|
|
33
|
+
const map = context.language.maps.get(virtualCode, sourceScript);
|
|
34
|
+
if (!scriptBlocks.length) {
|
|
55
35
|
return;
|
|
56
36
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
for (const [sourceOffset] of map.toSourceLocation(sourceCodeOffset)) {
|
|
61
|
-
sourceCodeOffset = sourceOffset;
|
|
62
|
-
mapped = true;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
if (mapped) {
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
37
|
+
for (const [offset] of map.toSourceLocation(document.offsetAt(selection))) {
|
|
38
|
+
sourceOffset = offset;
|
|
39
|
+
break;
|
|
68
40
|
}
|
|
69
|
-
if (
|
|
41
|
+
if (sourceOffset === undefined) {
|
|
70
42
|
return;
|
|
71
43
|
}
|
|
72
|
-
for (const { ast, startTagEnd, endTagStart } of
|
|
73
|
-
if (
|
|
44
|
+
for (const { ast, startTagEnd, endTagStart } of scriptBlocks) {
|
|
45
|
+
if (sourceOffset < startTagEnd || sourceOffset > endTagStart) {
|
|
74
46
|
continue;
|
|
75
47
|
}
|
|
76
|
-
if (isBlacklistNode(ts, ast,
|
|
48
|
+
if (isBlacklistNode(ts, ast, sourceOffset - startTagEnd, false)) {
|
|
77
49
|
return;
|
|
78
50
|
}
|
|
79
51
|
}
|
|
80
|
-
const props = await
|
|
52
|
+
const props = await getPropertiesAtLocation(root.fileName, sourceOffset) ?? [];
|
|
81
53
|
if (props.some(prop => prop === 'value')) {
|
|
82
54
|
return '${1:.value}';
|
|
83
55
|
}
|
|
@@ -10,14 +10,10 @@ function create() {
|
|
|
10
10
|
configurationSections: ['vue.autoInsert.bracketSpacing'],
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
|
-
create(
|
|
13
|
+
create() {
|
|
14
14
|
return {
|
|
15
|
-
|
|
15
|
+
provideAutoInsertSnippet(document, selection, change) {
|
|
16
16
|
if (document.languageId === 'html' || document.languageId === 'jade') {
|
|
17
|
-
const enabled = await context.env.getConfiguration?.('vue.autoInsert.bracketSpacing') ?? true;
|
|
18
|
-
if (!enabled) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
17
|
if (change.text === '{}'
|
|
22
18
|
&& document.getText().slice(change.rangeOffset - 1, change.rangeOffset + 3) === '{{}}'
|
|
23
19
|
&& document.offsetAt(selection) === change.rangeOffset + 1) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.create = create;
|
|
4
|
-
const
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
6
5
|
function create() {
|
|
7
6
|
return {
|
|
8
7
|
name: 'vue-compiler-dom-errors',
|
|
@@ -15,54 +14,37 @@ function create() {
|
|
|
15
14
|
create(context) {
|
|
16
15
|
return {
|
|
17
16
|
provideDiagnostics(document) {
|
|
18
|
-
|
|
17
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, 'template');
|
|
18
|
+
if (!info) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
25
|
-
if (!virtualCode) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const root = sourceScript?.generated?.root;
|
|
29
|
-
if (!(root instanceof language_core_1.VueVirtualCode)) {
|
|
21
|
+
const { root } = info;
|
|
22
|
+
const { template } = root.sfc;
|
|
23
|
+
if (!template) {
|
|
30
24
|
return;
|
|
31
25
|
}
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
onCompilerError(warning, 2);
|
|
40
|
-
}
|
|
41
|
-
function onCompilerError(error, severity) {
|
|
42
|
-
const templateHtmlRange = {
|
|
43
|
-
start: error.loc?.start.offset ?? 0,
|
|
44
|
-
end: error.loc?.end.offset ?? 0,
|
|
45
|
-
};
|
|
46
|
-
let errorMessage = error.message;
|
|
47
|
-
templateErrors.push({
|
|
26
|
+
const diagnostics = [];
|
|
27
|
+
for (const [errors, severity] of [
|
|
28
|
+
[template.errors, 1],
|
|
29
|
+
[template.warnings, 2],
|
|
30
|
+
]) {
|
|
31
|
+
for (const error of errors) {
|
|
32
|
+
diagnostics.push({
|
|
48
33
|
range: {
|
|
49
|
-
start: document.positionAt(
|
|
50
|
-
end: document.positionAt(
|
|
34
|
+
start: document.positionAt(error.loc?.start.offset ?? 0),
|
|
35
|
+
end: document.positionAt(error.loc?.end.offset ?? 0),
|
|
51
36
|
},
|
|
52
37
|
severity,
|
|
53
38
|
code: error.code,
|
|
54
39
|
source: 'vue',
|
|
55
|
-
message:
|
|
40
|
+
message: error.message,
|
|
56
41
|
});
|
|
57
42
|
}
|
|
58
43
|
}
|
|
59
|
-
return
|
|
44
|
+
return diagnostics;
|
|
60
45
|
},
|
|
61
46
|
};
|
|
62
47
|
},
|
|
63
48
|
};
|
|
64
|
-
function isSupportedDocument(document) {
|
|
65
|
-
return document.languageId === 'jade' || document.languageId === 'html';
|
|
66
|
-
}
|
|
67
49
|
}
|
|
68
50
|
//# sourceMappingURL=vue-compiler-dom-errors.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function create(
|
|
1
|
+
import type { LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
+
export declare function create({ getComponentNames, getElementNames }: import('@vue/typescript-plugin/lib/requests').Requests): LanguageServicePlugin;
|