@vue/language-service 1.7.6 → 1.7.8

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.
@@ -1,5 +1,5 @@
1
1
  import { ServiceContext } from '@volar/language-service';
2
- import * as vscode from 'vscode-languageserver-protocol';
2
+ import type * as vscode from 'vscode-languageserver-protocol';
3
3
  import { AttrNameCasing, TagNameCasing } from '../types';
4
4
  export declare function convertTagName(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string, casing: TagNameCasing): Promise<vscode.TextEdit[] | undefined>;
5
5
  export declare function convertAttrName(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string, casing: AttrNameCasing): Promise<vscode.TextEdit[] | undefined>;
@@ -4,7 +4,6 @@ exports.detect = exports.getNameCasing = exports.convertAttrName = exports.conve
4
4
  const shared_1 = require("@vue/shared");
5
5
  const helpers_1 = require("../helpers");
6
6
  const vue = require("@vue/language-core");
7
- const vscode = require("vscode-languageserver-protocol");
8
7
  const types_1 = require("../types");
9
8
  async function convertTagName(ts, context, uri, casing) {
10
9
  if (!context.typescript)
@@ -27,12 +26,12 @@ async function convertTagName(ts, context, uri, casing) {
27
26
  for (const offset of offsets) {
28
27
  const start = document.positionAt(template.startTagEnd + offset);
29
28
  const end = document.positionAt(template.startTagEnd + offset + tagName.length);
30
- const range = vscode.Range.create(start, end);
29
+ const range = { start, end };
31
30
  if (casing === types_1.TagNameCasing.Kebab && tagName !== (0, shared_1.hyphenate)(componentName)) {
32
- edits.push(vscode.TextEdit.replace(range, (0, shared_1.hyphenate)(componentName)));
31
+ edits.push({ range, newText: (0, shared_1.hyphenate)(componentName) });
33
32
  }
34
33
  if (casing === types_1.TagNameCasing.Pascal && tagName !== componentName) {
35
- edits.push(vscode.TextEdit.replace(range, componentName));
34
+ edits.push({ range, newText: componentName });
36
35
  }
37
36
  }
38
37
  }
@@ -65,12 +64,12 @@ async function convertAttrName(ts, context, uri, casing) {
65
64
  for (const offset of offsets) {
66
65
  const start = document.positionAt(template.startTagEnd + offset);
67
66
  const end = document.positionAt(template.startTagEnd + offset + attrName.length);
68
- const range = vscode.Range.create(start, end);
67
+ const range = { start, end };
69
68
  if (casing === types_1.AttrNameCasing.Kebab && attrName !== (0, shared_1.hyphenate)(propName)) {
70
- edits.push(vscode.TextEdit.replace(range, (0, shared_1.hyphenate)(propName)));
69
+ edits.push({ range, newText: (0, shared_1.hyphenate)(propName) });
71
70
  }
72
71
  if (casing === types_1.AttrNameCasing.Camel && attrName !== propName) {
73
- edits.push(vscode.TextEdit.replace(range, propName));
72
+ edits.push({ range, newText: propName });
74
73
  }
75
74
  }
76
75
  }
@@ -11,7 +11,6 @@ const volar_service_pug_1 = require("volar-service-pug");
11
11
  const volar_service_pug_beautify_1 = require("volar-service-pug-beautify");
12
12
  const volar_service_typescript_1 = require("volar-service-typescript");
13
13
  const volar_service_typescript_twoslash_queries_1 = require("volar-service-typescript-twoslash-queries");
14
- const vscode = require("vscode-languageserver-protocol");
15
14
  const nameCasing_1 = require("./ideFeatures/nameCasing");
16
15
  const vue_1 = require("./plugins/vue");
17
16
  const vue_autoinsert_dotvalue_1 = require("./plugins/vue-autoinsert-dotvalue");
@@ -141,10 +140,16 @@ function resolvePlugins(services, vueCompilerOptions, settings) {
141
140
  ],
142
141
  };
143
142
  const printText = printer.printNode(ts.EmitHint.Expression, newNode, sfc.scriptAst);
144
- const editRange = vscode.Range.create(textDoc.positionAt(sfc.script.startTagEnd + exportDefault.componentsOption.start), textDoc.positionAt(sfc.script.startTagEnd + exportDefault.componentsOption.end));
143
+ const editRange = {
144
+ start: textDoc.positionAt(sfc.script.startTagEnd + exportDefault.componentsOption.start),
145
+ end: textDoc.positionAt(sfc.script.startTagEnd + exportDefault.componentsOption.end),
146
+ };
145
147
  autoImportPositions.add(editRange.start);
146
148
  autoImportPositions.add(editRange.end);
147
- item.additionalTextEdits.push(vscode.TextEdit.replace(editRange, unescape(printText.replace(/\\u/g, '%u'))));
149
+ item.additionalTextEdits.push({
150
+ range: editRange,
151
+ newText: unescape(printText.replace(/\\u/g, '%u')),
152
+ });
148
153
  }
149
154
  else if (exportDefault.args && exportDefault.argsNode) {
150
155
  const newNode = {
@@ -155,10 +160,16 @@ function resolvePlugins(services, vueCompilerOptions, settings) {
155
160
  ],
156
161
  };
157
162
  const printText = printer.printNode(ts.EmitHint.Expression, newNode, sfc.scriptAst);
158
- const editRange = vscode.Range.create(textDoc.positionAt(sfc.script.startTagEnd + exportDefault.args.start), textDoc.positionAt(sfc.script.startTagEnd + exportDefault.args.end));
163
+ const editRange = {
164
+ start: textDoc.positionAt(sfc.script.startTagEnd + exportDefault.args.start),
165
+ end: textDoc.positionAt(sfc.script.startTagEnd + exportDefault.args.end),
166
+ };
159
167
  autoImportPositions.add(editRange.start);
160
168
  autoImportPositions.add(editRange.end);
161
- item.additionalTextEdits.push(vscode.TextEdit.replace(editRange, unescape(printText.replace(/\\u/g, '%u'))));
169
+ item.additionalTextEdits.push({
170
+ range: editRange,
171
+ newText: unescape(printText.replace(/\\u/g, '%u')),
172
+ });
162
173
  }
163
174
  }
164
175
  }
@@ -183,7 +194,7 @@ function resolvePlugins(services, vueCompilerOptions, settings) {
183
194
  }
184
195
  if (result?.edit?.documentChanges) {
185
196
  for (const documentChange of result.edit.documentChanges) {
186
- if (vscode.TextDocumentEdit.is(documentChange)) {
197
+ if ('textDocument' in documentChange) {
187
198
  patchAdditionalTextEdits(documentChange.textDocument.uri, documentChange.edits);
188
199
  }
189
200
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isBlacklistNode = exports.isCharacterTyping = void 0;
4
4
  const shared_1 = require("@vue/shared");
5
- const vscode = require("vscode-languageserver-protocol");
6
5
  const plugin = (context, modules) => {
7
6
  if (!modules?.typescript)
8
7
  return {};
@@ -70,8 +69,14 @@ function isTsDocument(document) {
70
69
  function isCharacterTyping(document, options) {
71
70
  const lastCharacter = options.lastChange.text[options.lastChange.text.length - 1];
72
71
  const rangeStart = options.lastChange.range.start;
73
- const position = vscode.Position.create(rangeStart.line, rangeStart.character + options.lastChange.text.length);
74
- const nextCharacter = document.getText(vscode.Range.create(position, document.positionAt(document.offsetAt(position) + 1)));
72
+ const position = {
73
+ line: rangeStart.line,
74
+ character: rangeStart.character + options.lastChange.text.length,
75
+ };
76
+ const nextCharacter = document.getText({
77
+ start: position,
78
+ end: { line: position.line, character: position.character + 1 },
79
+ });
75
80
  if (lastCharacter === undefined) { // delete text
76
81
  return false;
77
82
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const embedded = require("@volar/language-core");
4
4
  const language_core_1 = require("@vue/language-core");
5
- const vscode = require("vscode-languageserver-protocol");
6
5
  const vue_autoinsert_dotvalue_1 = require("./vue-autoinsert-dotvalue");
7
6
  const plugin = (context, modules) => {
8
7
  if (!context) {
@@ -52,10 +51,13 @@ const plugin = (context, modules) => {
52
51
  .replaceAll('\\', '\\\\')
53
52
  .replaceAll('$', '\\$')
54
53
  .replaceAll('}', '\\}');
55
- return vscode.TextEdit.replace({
56
- start: document.positionAt(mappedRange.sourceRange[0]),
57
- end: document.positionAt(mappedRange.sourceRange[1]),
58
- }, '(' + escapedText + '$0' + ')');
54
+ return {
55
+ range: {
56
+ start: document.positionAt(mappedRange.sourceRange[1]),
57
+ end: document.positionAt(mappedRange.sourceRange[1]),
58
+ },
59
+ newText: '(' + escapedText + '$0' + ')',
60
+ };
59
61
  }
60
62
  }
61
63
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vue = require("@vue/language-core");
4
4
  const shared_1 = require("@vue/shared");
5
5
  const html = require("vscode-html-languageservice");
6
- const vscode = require("vscode-languageserver-protocol");
7
6
  const helpers_1 = require("../helpers");
8
7
  const nameCasing_1 = require("../ideFeatures/nameCasing");
9
8
  const types_1 = require("../types");
@@ -148,7 +147,7 @@ exports.default = (options) => (_context, modules) => {
148
147
  label: `${requiredProp}!`,
149
148
  paddingLeft: true,
150
149
  position: document.positionAt(current.labelOffset),
151
- kind: vscode.InlayHintKind.Parameter,
150
+ kind: 2,
152
151
  textEdits: [{
153
152
  range: {
154
153
  start: document.positionAt(current.insertOffset),
@@ -190,10 +189,10 @@ exports.default = (options) => (_context, modules) => {
190
189
  const sfcVueTemplateCompiled = virtualFile.compiledSFCTemplate;
191
190
  if (sfcVueTemplateCompiled) {
192
191
  for (const error of sfcVueTemplateCompiled.errors) {
193
- onCompilerError(error, vscode.DiagnosticSeverity.Error);
192
+ onCompilerError(error, 1);
194
193
  }
195
194
  for (const warning of sfcVueTemplateCompiled.warnings) {
196
- onCompilerError(warning, vscode.DiagnosticSeverity.Warning);
195
+ onCompilerError(warning, 2);
197
196
  }
198
197
  function onCompilerError(error, severity) {
199
198
  const templateHtmlRange = {
@@ -436,7 +435,7 @@ exports.default = (options) => (_context, modules) => {
436
435
  range: replacement.textEdit.range,
437
436
  newText: insertText,
438
437
  },
439
- kind: vscode.CompletionItemKind.EnumMember,
438
+ kind: 20,
440
439
  };
441
440
  completionList.items.push(newItem);
442
441
  }
@@ -458,7 +457,7 @@ exports.default = (options) => (_context, modules) => {
458
457
  range: replacement.textEdit.range,
459
458
  newText: insertText,
460
459
  },
461
- kind: vscode.CompletionItemKind.EnumMember,
460
+ kind: 20,
462
461
  };
463
462
  completionList.items.push(newItem);
464
463
  }
@@ -478,30 +477,30 @@ exports.default = (options) => (_context, modules) => {
478
477
  }
479
478
  if (itemId.type === 'componentProp') {
480
479
  if (componentName !== '*') {
481
- item.kind = vscode.CompletionItemKind.Field;
480
+ item.kind = 5;
482
481
  }
483
482
  }
484
483
  else {
485
- item.kind = componentName !== '*' ? vscode.CompletionItemKind.Function : vscode.CompletionItemKind.Event;
484
+ item.kind = componentName !== '*' ? 3 : 23;
486
485
  }
487
486
  }
488
487
  else if (item.label === 'v-if'
489
488
  || item.label === 'v-else-if'
490
489
  || item.label === 'v-else'
491
490
  || item.label === 'v-for') {
492
- item.kind = vscode.CompletionItemKind.Method;
491
+ item.kind = 2;
493
492
  item.sortText = '\u0003' + (item.sortText ?? item.label);
494
493
  }
495
494
  else if (item.label.startsWith('v-')) {
496
- item.kind = vscode.CompletionItemKind.Function;
495
+ item.kind = 3;
497
496
  item.sortText = '\u0002' + (item.sortText ?? item.label);
498
497
  }
499
498
  else {
500
499
  item.sortText = '\u0001' + (item.sortText ?? item.label);
501
500
  }
502
501
  }
503
- else if (item.kind === vscode.CompletionItemKind.Property && componentNames.has((0, shared_1.hyphenate)(item.label))) {
504
- item.kind = vscode.CompletionItemKind.Variable;
502
+ else if (item.kind === 10 && componentNames.has((0, shared_1.hyphenate)(item.label))) {
503
+ item.kind = 6;
505
504
  item.sortText = '\u0000' + (item.sortText ?? item.label);
506
505
  }
507
506
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const vscode = require("vscode-languageserver-protocol");
4
3
  const plugin = (context) => {
5
4
  if (!context)
6
5
  return {};
@@ -25,7 +24,7 @@ const plugin = (context) => {
25
24
  paddingRight: hint.paddingRight,
26
25
  paddingLeft: hint.paddingLeft,
27
26
  position: document.positionAt(mapping.generatedRange[0]),
28
- kind: vscode.InlayHintKind.Parameter,
27
+ kind: 2,
29
28
  tooltip: {
30
29
  kind: 'markdown',
31
30
  value: hint.tooltip,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const html = require("vscode-html-languageservice");
4
- const vscode = require("vscode-languageserver-protocol");
5
4
  const volar_service_html_1 = require("volar-service-html");
6
5
  const vue = require("@vue/language-core");
7
6
  const data_1 = require("./data");
@@ -31,10 +30,15 @@ exports.default = () => (context, modules) => {
31
30
  for (const script of [sfc.script, sfc.scriptSetup]) {
32
31
  if (!script || script.content === '')
33
32
  continue;
34
- const error = vscode.Diagnostic.create({
35
- start: document.positionAt(script.start),
36
- end: document.positionAt(script.startTagEnd),
37
- }, `Virtual script ${JSON.stringify(vueSourceFile.mainScriptName)} not found, may missing <script lang="ts"> / "allowJs": true / jsconfig.json.`, vscode.DiagnosticSeverity.Information, undefined, 'volar');
33
+ const error = {
34
+ range: {
35
+ start: document.positionAt(script.start),
36
+ end: document.positionAt(script.startTagEnd),
37
+ },
38
+ message: `Virtual script ${JSON.stringify(vueSourceFile.mainScriptName)} not found, may missing <script lang="ts"> / "allowJs": true / jsconfig.json.`,
39
+ severity: 3,
40
+ source: 'volar',
41
+ };
38
42
  result.push(error);
39
43
  }
40
44
  }
@@ -49,25 +53,43 @@ exports.default = () => (context, modules) => {
49
53
  if (descriptor.template) {
50
54
  result.push({
51
55
  name: 'template',
52
- kind: vscode.SymbolKind.Module,
53
- range: vscode.Range.create(document.positionAt(descriptor.template.start), document.positionAt(descriptor.template.end)),
54
- selectionRange: vscode.Range.create(document.positionAt(descriptor.template.start), document.positionAt(descriptor.template.startTagEnd)),
56
+ kind: 2,
57
+ range: {
58
+ start: document.positionAt(descriptor.template.start),
59
+ end: document.positionAt(descriptor.template.end),
60
+ },
61
+ selectionRange: {
62
+ start: document.positionAt(descriptor.template.start),
63
+ end: document.positionAt(descriptor.template.startTagEnd),
64
+ },
55
65
  });
56
66
  }
57
67
  if (descriptor.script) {
58
68
  result.push({
59
69
  name: 'script',
60
- kind: vscode.SymbolKind.Module,
61
- range: vscode.Range.create(document.positionAt(descriptor.script.start), document.positionAt(descriptor.script.end)),
62
- selectionRange: vscode.Range.create(document.positionAt(descriptor.script.start), document.positionAt(descriptor.script.startTagEnd)),
70
+ kind: 2,
71
+ range: {
72
+ start: document.positionAt(descriptor.script.start),
73
+ end: document.positionAt(descriptor.script.end),
74
+ },
75
+ selectionRange: {
76
+ start: document.positionAt(descriptor.script.start),
77
+ end: document.positionAt(descriptor.script.startTagEnd),
78
+ },
63
79
  });
64
80
  }
65
81
  if (descriptor.scriptSetup) {
66
82
  result.push({
67
83
  name: 'script setup',
68
- kind: vscode.SymbolKind.Module,
69
- range: vscode.Range.create(document.positionAt(descriptor.scriptSetup.start), document.positionAt(descriptor.scriptSetup.end)),
70
- selectionRange: vscode.Range.create(document.positionAt(descriptor.scriptSetup.start), document.positionAt(descriptor.scriptSetup.startTagEnd)),
84
+ kind: 2,
85
+ range: {
86
+ start: document.positionAt(descriptor.scriptSetup.start),
87
+ end: document.positionAt(descriptor.scriptSetup.end),
88
+ },
89
+ selectionRange: {
90
+ start: document.positionAt(descriptor.scriptSetup.start),
91
+ end: document.positionAt(descriptor.scriptSetup.startTagEnd),
92
+ },
71
93
  });
72
94
  }
73
95
  for (const style of descriptor.styles) {
@@ -78,17 +100,29 @@ exports.default = () => (context, modules) => {
78
100
  name += ' module';
79
101
  result.push({
80
102
  name,
81
- kind: vscode.SymbolKind.Module,
82
- range: vscode.Range.create(document.positionAt(style.start), document.positionAt(style.end)),
83
- selectionRange: vscode.Range.create(document.positionAt(style.start), document.positionAt(style.startTagEnd)),
103
+ kind: 2,
104
+ range: {
105
+ start: document.positionAt(style.start),
106
+ end: document.positionAt(style.end),
107
+ },
108
+ selectionRange: {
109
+ start: document.positionAt(style.start),
110
+ end: document.positionAt(style.startTagEnd),
111
+ },
84
112
  });
85
113
  }
86
114
  for (const customBlock of descriptor.customBlocks) {
87
115
  result.push({
88
116
  name: `${customBlock.type}`,
89
- kind: vscode.SymbolKind.Module,
90
- range: vscode.Range.create(document.positionAt(customBlock.start), document.positionAt(customBlock.end)),
91
- selectionRange: vscode.Range.create(document.positionAt(customBlock.start), document.positionAt(customBlock.startTagEnd)),
117
+ kind: 2,
118
+ range: {
119
+ start: document.positionAt(customBlock.start),
120
+ end: document.positionAt(customBlock.end),
121
+ },
122
+ selectionRange: {
123
+ start: document.positionAt(customBlock.start),
124
+ end: document.positionAt(customBlock.startTagEnd),
125
+ },
92
126
  });
93
127
  }
94
128
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-service",
3
- "version": "1.7.6",
3
+ "version": "1.7.8",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -17,29 +17,27 @@
17
17
  "update-html-data": "node ./scripts/update-html-data.js"
18
18
  },
19
19
  "dependencies": {
20
- "@volar/language-core": "1.6.7",
21
- "@volar/language-service": "1.6.7",
22
- "@volar/source-map": "1.6.7",
20
+ "@volar/language-core": "1.6.9",
21
+ "@volar/language-service": "1.6.9",
23
22
  "@vue/compiler-dom": "^3.3.0",
24
- "@vue/language-core": "1.7.6",
23
+ "@vue/language-core": "1.7.8",
25
24
  "@vue/reactivity": "^3.3.0",
26
25
  "@vue/shared": "^3.3.0",
27
- "volar-service-css": "0.0.3",
28
- "volar-service-emmet": "0.0.3",
29
- "volar-service-html": "0.0.3",
30
- "volar-service-json": "0.0.3",
31
- "volar-service-pug": "0.0.3",
32
- "volar-service-pug-beautify": "0.0.3",
33
- "volar-service-typescript": "0.0.3",
34
- "volar-service-typescript-twoslash-queries": "0.0.3",
26
+ "volar-service-css": "0.0.4",
27
+ "volar-service-emmet": "0.0.4",
28
+ "volar-service-html": "0.0.4",
29
+ "volar-service-json": "0.0.4",
30
+ "volar-service-pug": "0.0.4",
31
+ "volar-service-pug-beautify": "0.0.4",
32
+ "volar-service-typescript": "0.0.4",
33
+ "volar-service-typescript-twoslash-queries": "0.0.4",
35
34
  "vscode-html-languageservice": "^5.0.4",
36
- "vscode-json-languageservice": "^5.2.0",
37
- "vscode-languageserver-protocol": "^3.17.3",
38
- "vscode-languageserver-textdocument": "^1.0.8",
39
- "vscode-uri": "^3.0.7"
35
+ "vscode-languageserver-textdocument": "^1.0.8"
40
36
  },
41
37
  "devDependencies": {
42
- "@volar/kit": "1.6.7"
38
+ "@volar/kit": "1.6.9",
39
+ "vscode-languageserver-protocol": "^3.17.3",
40
+ "vscode-uri": "^3.0.7"
43
41
  },
44
- "gitHead": "2a17efdae4ac994aea164dfcdfcfb27b4fa3f27d"
42
+ "gitHead": "9841dc5c7b19c2b1d24fcc95a808f29af39710b8"
45
43
  }