@vue/language-service 3.2.0 → 3.2.2

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.
@@ -225,21 +225,18 @@ function create(ts, languageId, tsserver) {
225
225
  return;
226
226
  }
227
227
  const prevText = document.getText({ start: { line: 0, character: 0 }, end: position });
228
- const hint = prevText.match(/\bv[\S]*$/)
229
- ? 'v'
230
- : prevText.match(/[:][\S]*$/)
231
- ? ':'
232
- : prevText.match(/[@][\S]*$/)
233
- ? '@'
234
- : undefined;
228
+ const hint = prevText.match(/(\S)[\S]*$/)?.[1];
235
229
  const { result: htmlCompletion, info: { tagNameCasing, components, }, } = await runWithVueDataProvider(info.script.id, info.root, hint, 'completion', () => baseServiceInstance.provideCompletionItems(document, position, completionContext, token));
236
230
  const componentSet = new Set(components);
237
231
  if (!htmlCompletion) {
238
232
  return;
239
233
  }
240
- if (!prevText.match(/[\S]+$/)) {
234
+ if (!hint) {
241
235
  htmlCompletion.isIncomplete = true;
242
236
  }
237
+ if (htmlCompletion.items[0]?.kind === 12) {
238
+ addDirectiveModifiers(htmlCompletion, htmlCompletion.items[0], document);
239
+ }
243
240
  await resolveAutoImportPlaceholder(htmlCompletion, info);
244
241
  resolveComponentItemKinds(htmlCompletion);
245
242
  return htmlCompletion;
@@ -291,7 +288,6 @@ function create(ts, languageId, tsserver) {
291
288
  }
292
289
  break;
293
290
  case 12:
294
- addDirectiveModifiers(htmlCompletion, item, document);
295
291
  if (typeof item.documentation === 'object' && item.documentation.value.includes('*@deprecated*')) {
296
292
  item.tags = [1];
297
293
  }
@@ -564,6 +560,28 @@ function create(ts, languageId, tsserver) {
564
560
  const directives = getDirectives();
565
561
  const { attrs, meta } = getTagData(tag);
566
562
  const attributes = [];
563
+ let addPlainAttrs = false;
564
+ let addVBinds = false;
565
+ let addVBindShorthands = false;
566
+ let addVOns = false;
567
+ let addVOnShorthands = false;
568
+ if (!hint) {
569
+ addVBindShorthands = true;
570
+ addVOnShorthands = true;
571
+ }
572
+ else if (hint === ':') {
573
+ addVBindShorthands = true;
574
+ }
575
+ else if (hint === '@') {
576
+ addVOnShorthands = true;
577
+ }
578
+ else {
579
+ addPlainAttrs = true;
580
+ addVBinds = true;
581
+ addVOns = true;
582
+ addVBindShorthands = true;
583
+ addVOnShorthands = true;
584
+ }
567
585
  for (const attr of builtInData?.globalAttributes ?? []) {
568
586
  if (attr.name === 'is' && tag.toLowerCase() !== 'component') {
569
587
  continue;
@@ -572,21 +590,14 @@ function create(ts, languageId, tsserver) {
572
590
  attributes.push(attr);
573
591
  continue;
574
592
  }
575
- if (!hint || hint === ':') {
576
- attributes.push({
577
- ...attr,
578
- name: V_BIND_SHORTHAND + attr.name,
579
- });
593
+ if (addPlainAttrs) {
594
+ attributes.push({ ...attr, name: attr.name });
580
595
  }
581
- if (!hint || hint === 'v') {
582
- attributes.push({
583
- ...attr,
584
- name: DIRECTIVE_V_BIND + attr.name,
585
- });
586
- attributes.push({
587
- ...attr,
588
- name: attr.name,
589
- });
596
+ if (addVBindShorthands) {
597
+ attributes.push({ ...attr, name: V_BIND_SHORTHAND + attr.name });
598
+ }
599
+ if (addVBinds) {
600
+ attributes.push({ ...attr, name: DIRECTIVE_V_BIND + attr.name });
590
601
  }
591
602
  }
592
603
  for (const [propName, propMeta] of [
@@ -599,13 +610,13 @@ function create(ts, languageId, tsserver) {
599
610
  if (attrNameCasing === 0 /* AttrNameCasing.Kebab */) {
600
611
  labelName = (0, language_core_1.hyphenateAttr)(labelName);
601
612
  }
602
- if (!hint || hint === '@') {
613
+ if (addVOnShorthands) {
603
614
  attributes.push({
604
615
  name: V_ON_SHORTHAND + labelName,
605
616
  description: propMeta && createDescription(propMeta),
606
617
  });
607
618
  }
608
- if (!hint || hint === 'v') {
619
+ if (addVOns) {
609
620
  attributes.push({
610
621
  name: DIRECTIVE_V_ON + labelName,
611
622
  description: propMeta && createDescription(propMeta),
@@ -618,33 +629,38 @@ function create(ts, languageId, tsserver) {
618
629
  const name = attrNameCasing === 1 /* AttrNameCasing.Camel */ ? prop.name : (0, language_core_1.hyphenateAttr)(prop.name);
619
630
  return name === labelName;
620
631
  });
621
- if (!hint || hint === ':') {
632
+ const isBoolean = propMeta2?.type === 'boolean' || propMeta2?.type.startsWith('boolean ');
633
+ if (addPlainAttrs) {
622
634
  attributes.push({
623
- name: V_BIND_SHORTHAND + labelName,
635
+ name: labelName,
624
636
  description: propMeta2 && createDescription(propMeta2),
625
637
  });
626
638
  }
627
- if (!hint || hint === 'v') {
639
+ if (addVBindShorthands) {
628
640
  attributes.push({
629
- name: DIRECTIVE_V_BIND + labelName,
641
+ name: V_BIND_SHORTHAND + labelName,
630
642
  description: propMeta2 && createDescription(propMeta2),
643
+ valueSet: isBoolean ? 'v' : undefined,
631
644
  });
645
+ }
646
+ if (addVBinds) {
632
647
  attributes.push({
633
- name: labelName,
648
+ name: DIRECTIVE_V_BIND + labelName,
634
649
  description: propMeta2 && createDescription(propMeta2),
650
+ valueSet: isBoolean ? 'v' : undefined,
635
651
  });
636
652
  }
637
653
  }
638
654
  }
639
655
  for (const event of meta?.events ?? []) {
640
656
  const eventName = attrNameCasing === 1 /* AttrNameCasing.Camel */ ? event.name : (0, language_core_1.hyphenateAttr)(event.name);
641
- if (!hint || hint === '@') {
657
+ if (addVOnShorthands) {
642
658
  attributes.push({
643
659
  name: V_ON_SHORTHAND + eventName,
644
660
  description: event && createDescription(event),
645
661
  });
646
662
  }
647
- if (!hint || hint === 'v') {
663
+ if (addVOns) {
648
664
  attributes.push({
649
665
  name: DIRECTIVE_V_ON + eventName,
650
666
  description: event && createDescription(event),
@@ -670,17 +686,15 @@ function create(ts, languageId, tsserver) {
670
686
  });
671
687
  }
672
688
  }
673
- if (!hint || hint === 'v') {
674
- for (const event of meta?.events ?? []) {
675
- if (event.name.startsWith(UPDATE_EVENT_PREFIX)) {
676
- const model = event.name.slice(UPDATE_EVENT_PREFIX.length);
677
- const label = DIRECTIVE_V_MODEL
678
- + (attrNameCasing === 1 /* AttrNameCasing.Camel */ ? model : (0, language_core_1.hyphenateAttr)(model));
679
- attributes.push({
680
- name: label,
681
- description: createDescription(event),
682
- });
683
- }
689
+ for (const event of meta?.events ?? []) {
690
+ if (event.name.startsWith(UPDATE_EVENT_PREFIX)) {
691
+ const model = event.name.slice(UPDATE_EVENT_PREFIX.length);
692
+ const label = DIRECTIVE_V_MODEL
693
+ + (attrNameCasing === 1 /* AttrNameCasing.Camel */ ? model : (0, language_core_1.hyphenateAttr)(model));
694
+ attributes.push({
695
+ name: label,
696
+ description: createDescription(event),
697
+ });
684
698
  }
685
699
  }
686
700
  return attributes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-service",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "data",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@volar/language-service": "2.4.27",
21
- "@vue/language-core": "3.2.0",
21
+ "@vue/language-core": "3.2.2",
22
22
  "@vue/shared": "^3.5.0",
23
23
  "path-browserify": "^1.0.1",
24
24
  "volar-service-css": "0.0.68",
@@ -37,8 +37,8 @@
37
37
  "@volar/kit": "2.4.27",
38
38
  "@volar/typescript": "2.4.27",
39
39
  "@vue/compiler-dom": "^3.5.0",
40
- "@vue/typescript-plugin": "3.2.0",
40
+ "@vue/typescript-plugin": "3.2.2",
41
41
  "vscode-css-languageservice": "^6.3.1"
42
42
  },
43
- "gitHead": "3138110d767d3d6110899bc46518b53c4b456271"
43
+ "gitHead": "17394f4e80c2267e8b7159468ab40c948ea37d65"
44
44
  }