@vue/language-service 1.8.8 → 1.8.10
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/data/language-blocks/en.json +68 -0
- package/data/language-blocks/fr.json +68 -0
- package/data/language-blocks/ja.json +68 -0
- package/data/language-blocks/ko.json +68 -0
- package/data/language-blocks/pt.json +694 -0
- package/data/language-blocks/zh-cn.json +68 -0
- package/data/model-modifiers/en.json +12 -0
- package/data/model-modifiers/fr.json +12 -0
- package/data/model-modifiers/ja.json +12 -0
- package/data/model-modifiers/ko.json +12 -0
- package/data/model-modifiers/pt.json +116 -0
- package/data/model-modifiers/zh-cn.json +12 -0
- package/data/template/en.json +104 -0
- package/data/template/fr.json +104 -0
- package/data/template/ja.json +104 -0
- package/data/template/ko.json +104 -0
- package/data/template/pt.json +978 -0
- package/data/template/zh-cn.json +105 -1
- package/out/helpers.d.ts +1 -0
- package/out/helpers.js +28 -5
- package/out/ideFeatures/nameCasing.d.ts +7 -6
- package/out/ideFeatures/nameCasing.js +15 -16
- package/out/index.d.ts +1 -0
- package/out/languageService.d.ts +5 -4
- package/out/languageService.js +72 -47
- package/out/plugins/data.d.ts +1 -0
- package/out/plugins/data.js +9 -0
- package/out/plugins/vue-autoinsert-dotvalue.d.ts +2 -2
- package/out/plugins/vue-autoinsert-dotvalue.js +5 -4
- package/out/plugins/vue-autoinsert-parentheses.d.ts +2 -2
- package/out/plugins/vue-autoinsert-parentheses.js +3 -1
- package/out/plugins/vue-autoinsert-space.d.ts +2 -2
- package/out/plugins/vue-autoinsert-space.js +3 -1
- package/out/plugins/vue-codelens-references.d.ts +2 -1
- package/out/plugins/vue-codelens-references.js +4 -3
- package/out/plugins/vue-directive-comments.d.ts +2 -2
- package/out/plugins/vue-directive-comments.js +3 -1
- package/out/plugins/vue-extract-file.d.ts +2 -1
- package/out/plugins/vue-extract-file.js +4 -4
- package/out/plugins/vue-template.d.ts +2 -2
- package/out/plugins/vue-template.js +53 -28
- package/out/plugins/vue-toggle-v-bind-codeaction.d.ts +2 -1
- package/out/plugins/vue-toggle-v-bind-codeaction.js +6 -5
- package/out/plugins/vue-twoslash-queries.d.ts +2 -2
- package/out/plugins/vue-twoslash-queries.js +27 -2
- package/out/plugins/vue-visualize-hidden-callback-param.d.ts +2 -2
- package/out/plugins/vue-visualize-hidden-callback-param.js +3 -1
- package/out/plugins/vue.d.ts +2 -2
- package/out/plugins/vue.js +32 -4
- package/out/types.d.ts +1 -0
- package/package.json +11 -11
- package/out/plugins/vue-.d.ts +0 -7
- package/out/plugins/vue-.js +0 -159
- package/out/plugins/vue-autoinsert-dotvalue copy.d.ts +0 -7
- package/out/plugins/vue-autoinsert-dotvalue copy.js +0 -159
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isBlacklistNode = exports.isCharacterTyping = void 0;
|
|
4
|
-
const shared_1 = require("@vue/shared");
|
|
5
|
-
const plugin = (context, modules) => {
|
|
6
|
-
if (!modules?.typescript)
|
|
7
|
-
return {};
|
|
8
|
-
const ts = modules.typescript;
|
|
9
|
-
return {
|
|
10
|
-
async provideAutoInsertionEdit(document, position, insertContext) {
|
|
11
|
-
if (!isTsDocument(document))
|
|
12
|
-
return;
|
|
13
|
-
if (!isCharacterTyping(document, insertContext))
|
|
14
|
-
return;
|
|
15
|
-
const enabled = await context.env.getConfiguration?.('vue.autoInsert.dotValue') ?? true;
|
|
16
|
-
if (!enabled)
|
|
17
|
-
return;
|
|
18
|
-
const program = context.inject('typescript/languageService').getProgram();
|
|
19
|
-
if (!program)
|
|
20
|
-
return;
|
|
21
|
-
const sourceFile = program.getSourceFile(context.env.uriToFileName(document.uri));
|
|
22
|
-
if (!sourceFile)
|
|
23
|
-
return;
|
|
24
|
-
if (isBlacklistNode(ts, sourceFile, document.offsetAt(position), false))
|
|
25
|
-
return;
|
|
26
|
-
const node = findPositionIdentifier(sourceFile, sourceFile, document.offsetAt(position));
|
|
27
|
-
if (!node)
|
|
28
|
-
return;
|
|
29
|
-
const token = context.inject('typescript/languageServiceHost').getCancellationToken?.();
|
|
30
|
-
if (token) {
|
|
31
|
-
context.inject('typescript/languageService').getQuickInfoAtPosition(context.env.uriToFileName(document.uri), node.end);
|
|
32
|
-
if (token?.isCancellationRequested()) {
|
|
33
|
-
return; // check cancel here because type checker do not use cancel token
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const checker = program.getTypeChecker();
|
|
37
|
-
const type = checker.getTypeAtLocation(node);
|
|
38
|
-
const props = type.getProperties();
|
|
39
|
-
if (props.some(prop => prop.name === 'value')) {
|
|
40
|
-
return '${1:.value}';
|
|
41
|
-
}
|
|
42
|
-
function findPositionIdentifier(sourceFile, node, offset) {
|
|
43
|
-
let result;
|
|
44
|
-
node.forEachChild(child => {
|
|
45
|
-
if (!result) {
|
|
46
|
-
if (child.end === offset && ts.isIdentifier(child)) {
|
|
47
|
-
result = child;
|
|
48
|
-
}
|
|
49
|
-
else if (child.end >= offset && child.getStart(sourceFile) < offset) {
|
|
50
|
-
result = findPositionIdentifier(sourceFile, child, offset);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
exports.default = () => plugin;
|
|
60
|
-
function isTsDocument(document) {
|
|
61
|
-
return document.languageId === 'javascript' ||
|
|
62
|
-
document.languageId === 'typescript' ||
|
|
63
|
-
document.languageId === 'javascriptreact' ||
|
|
64
|
-
document.languageId === 'typescriptreact';
|
|
65
|
-
}
|
|
66
|
-
function isCharacterTyping(document, options) {
|
|
67
|
-
const lastCharacter = options.lastChange.text[options.lastChange.text.length - 1];
|
|
68
|
-
const rangeStart = options.lastChange.range.start;
|
|
69
|
-
const position = {
|
|
70
|
-
line: rangeStart.line,
|
|
71
|
-
character: rangeStart.character + options.lastChange.text.length,
|
|
72
|
-
};
|
|
73
|
-
const nextCharacter = document.getText({
|
|
74
|
-
start: position,
|
|
75
|
-
end: { line: position.line, character: position.character + 1 },
|
|
76
|
-
});
|
|
77
|
-
if (lastCharacter === undefined) { // delete text
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
if (options.lastChange.text.indexOf('\n') >= 0) { // multi-line change
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return /\w/.test(lastCharacter) && !/\w/.test(nextCharacter);
|
|
84
|
-
}
|
|
85
|
-
exports.isCharacterTyping = isCharacterTyping;
|
|
86
|
-
function isBlacklistNode(ts, node, pos, allowAccessDotValue) {
|
|
87
|
-
if (ts.isVariableDeclaration(node) && pos >= node.name.getFullStart() && pos <= node.name.getEnd()) {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
else if (ts.isFunctionDeclaration(node) && node.name && pos >= node.name.getFullStart() && pos <= node.name.getEnd()) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
else if (ts.isParameter(node) && pos >= node.name.getFullStart() && pos <= node.name.getEnd()) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
else if (ts.isPropertyAssignment(node) && pos >= node.name.getFullStart() && pos <= node.name.getEnd()) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
else if (ts.isShorthandPropertyAssignment(node)) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
else if (ts.isImportDeclaration(node)) {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
else if (ts.isLiteralTypeNode(node)) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
else if (ts.isTypeReferenceNode(node)) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
else if (!allowAccessDotValue && ts.isPropertyAccessExpression(node) && node.expression.end === pos && node.name.text === 'value') {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
else if (ts.isCallExpression(node)
|
|
115
|
-
&& ts.isIdentifier(node.expression)
|
|
116
|
-
&& isWatchOrUseFunction(node.expression.text)
|
|
117
|
-
&& isTopLevelArgOrArrayTopLevelItemItem(node)) {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
let _isBlacklistNode = false;
|
|
122
|
-
node.forEachChild(node => {
|
|
123
|
-
if (_isBlacklistNode)
|
|
124
|
-
return;
|
|
125
|
-
if (pos >= node.getFullStart() && pos <= node.getEnd()) {
|
|
126
|
-
if (isBlacklistNode(ts, node, pos, allowAccessDotValue)) {
|
|
127
|
-
_isBlacklistNode = true;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
return _isBlacklistNode;
|
|
132
|
-
}
|
|
133
|
-
function isWatchOrUseFunction(fnName) {
|
|
134
|
-
return fnName === 'watch'
|
|
135
|
-
|| fnName === 'unref'
|
|
136
|
-
|| fnName === 'triggerRef'
|
|
137
|
-
|| fnName === 'isRef'
|
|
138
|
-
|| (0, shared_1.hyphenate)(fnName).startsWith('use-');
|
|
139
|
-
}
|
|
140
|
-
function isTopLevelArgOrArrayTopLevelItemItem(node) {
|
|
141
|
-
for (const arg of node.arguments) {
|
|
142
|
-
if (pos >= arg.getFullStart() && pos <= arg.getEnd()) {
|
|
143
|
-
if (ts.isIdentifier(arg)) {
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
if (ts.isArrayLiteralExpression(arg)) {
|
|
147
|
-
for (const el of arg.elements) {
|
|
148
|
-
if (pos >= el.getFullStart() && pos <= el.getEnd()) {
|
|
149
|
-
return ts.isIdentifier(el);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
exports.isBlacklistNode = isBlacklistNode;
|
|
159
|
-
//# sourceMappingURL=vue-autoinsert-dotvalue%20copy.js.map
|