@marko/language-server 1.1.2 → 1.1.3

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/dist/index.mjs CHANGED
@@ -2034,6 +2034,9 @@ import {
2034
2034
 
2035
2035
  // src/ts-plugin/host.ts
2036
2036
  import path6 from "path";
2037
+ import * as defaultCompiler from "@marko/compiler";
2038
+ import * as defaultConfig from "@marko/compiler/config";
2039
+ import * as defaultTranslator from "@marko/translator-default";
2037
2040
  import {
2038
2041
  Processors,
2039
2042
  Project as Project4,
@@ -2046,6 +2049,10 @@ Project4.setDefaultTypePaths({
2046
2049
  internalTypesFile: path6.join(__dirname, "marko.internal.d.ts"),
2047
2050
  markoTypesFile: path6.join(__dirname, "marko.runtime.d.ts")
2048
2051
  });
2052
+ Project4.setDefaultCompilerMeta(defaultCompiler, {
2053
+ ...defaultConfig,
2054
+ translator: defaultTranslator
2055
+ });
2049
2056
  function patch(ts2, configFile, extractCache3, resolutionCache, host, ps) {
2050
2057
  var _a, _b, _c;
2051
2058
  const processors = Processors.create({
@@ -3583,39 +3590,31 @@ var service = {
3583
3590
  );
3584
3591
  },
3585
3592
  async doComplete(doc, params, cancel) {
3586
- const itemsByLabel = /* @__PURE__ */ new Map();
3587
- await Promise.allSettled(
3588
- plugins.map(async (plugin) => {
3593
+ const results = await Promise.allSettled(
3594
+ plugins.map((plugin) => {
3589
3595
  var _a;
3590
- const cur = await ((_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3591
- if (cancel.isCancellationRequested)
3592
- return;
3593
- if (cur) {
3594
- let curItems;
3595
- if (Array.isArray(cur)) {
3596
- curItems = cur;
3597
- } else {
3598
- curItems = cur.items;
3599
- }
3600
- for (const item of curItems) {
3601
- const { label } = item;
3602
- const existingItem = itemsByLabel.get(label);
3603
- if (existingItem) {
3604
- if ((existingItem.sortText || label) < (item.sortText || label)) {
3605
- itemsByLabel.set(label, item);
3606
- }
3607
- } else {
3608
- itemsByLabel.set(label, item);
3609
- }
3610
- }
3611
- }
3596
+ return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3612
3597
  })
3613
3598
  );
3614
3599
  if (cancel.isCancellationRequested)
3615
3600
  return;
3616
- if (itemsByLabel.size) {
3617
- return { items: [...itemsByLabel.values()], isIncomplete: true };
3601
+ const itemsByLabel = /* @__PURE__ */ new Map();
3602
+ for (const result of results) {
3603
+ if (result.status !== "fulfilled" || !result.value)
3604
+ continue;
3605
+ for (const item of Array.isArray(result.value) ? result.value : result.value.items) {
3606
+ const { label } = item;
3607
+ const existingItem = itemsByLabel.get(label);
3608
+ if (existingItem) {
3609
+ if ((existingItem.sortText || label) < (item.sortText || label)) {
3610
+ itemsByLabel.set(label, item);
3611
+ }
3612
+ } else {
3613
+ itemsByLabel.set(label, item);
3614
+ }
3615
+ }
3618
3616
  }
3617
+ return { items: [...itemsByLabel.values()], isIncomplete: true };
3619
3618
  },
3620
3619
  async doCompletionResolve(item, cancel) {
3621
3620
  var _a;
@@ -3631,172 +3630,189 @@ var service = {
3631
3630
  }
3632
3631
  },
3633
3632
  async findDefinition(doc, params, cancel) {
3634
- let result;
3635
- await Promise.allSettled(
3636
- plugins.map(async (plugin) => {
3633
+ const results = await Promise.allSettled(
3634
+ plugins.map((plugin) => {
3637
3635
  var _a;
3638
- const cur = await ((_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3639
- if (cancel.isCancellationRequested)
3640
- return;
3641
- if (cur)
3642
- result = (result || []).concat(cur);
3636
+ return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3643
3637
  })
3644
3638
  );
3645
3639
  if (cancel.isCancellationRequested)
3646
3640
  return;
3647
- return result;
3641
+ let links;
3642
+ for (const result of results) {
3643
+ if (result.status !== "fulfilled" || !result.value)
3644
+ continue;
3645
+ links = (links || []).concat(result.value);
3646
+ }
3647
+ return links;
3648
3648
  },
3649
3649
  async findReferences(doc, params, cancel) {
3650
- let result;
3651
- await Promise.allSettled(
3652
- plugins.map(async (plugin) => {
3650
+ const results = await Promise.allSettled(
3651
+ plugins.map((plugin) => {
3653
3652
  var _a;
3654
- const cur = await ((_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3655
- if (cancel.isCancellationRequested)
3656
- return;
3657
- if (cur)
3658
- result = (result || []).concat(cur);
3653
+ return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3659
3654
  })
3660
3655
  );
3661
3656
  if (cancel.isCancellationRequested)
3662
3657
  return;
3663
- return result;
3658
+ let references;
3659
+ for (const result of results) {
3660
+ if (result.status !== "fulfilled" || !result.value)
3661
+ continue;
3662
+ references = (references || []).concat(result.value);
3663
+ }
3664
+ return references;
3664
3665
  },
3665
3666
  async findDocumentSymbols(doc, params, cancel) {
3666
- let result;
3667
- await Promise.allSettled(
3668
- plugins.map(async (plugin) => {
3667
+ const results = await Promise.allSettled(
3668
+ plugins.map((plugin) => {
3669
3669
  var _a;
3670
- const cur = await ((_a = plugin.findDocumentSymbols) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3671
- if (cancel.isCancellationRequested)
3672
- return;
3673
- if (cur)
3674
- result = (result || []).concat(cur);
3670
+ return (_a = plugin.findDocumentSymbols) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3675
3671
  })
3676
3672
  );
3677
3673
  if (cancel.isCancellationRequested)
3678
3674
  return;
3679
- return result;
3675
+ let symbols;
3676
+ for (const result of results) {
3677
+ if (result.status !== "fulfilled" || !result.value)
3678
+ continue;
3679
+ symbols = (symbols || []).concat(result.value);
3680
+ }
3681
+ return symbols;
3680
3682
  },
3681
3683
  async findDocumentLinks(doc, params, cancel) {
3682
- let result;
3683
- await Promise.allSettled(
3684
- plugins.map(async (plugin) => {
3684
+ const results = await Promise.allSettled(
3685
+ plugins.map((plugin) => {
3685
3686
  var _a;
3686
- const cur = await ((_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3687
- if (cancel.isCancellationRequested)
3688
- return;
3689
- if (cur)
3690
- result = (result || []).concat(cur);
3687
+ return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3691
3688
  })
3692
3689
  );
3693
3690
  if (cancel.isCancellationRequested)
3694
3691
  return;
3695
- return result;
3692
+ let links;
3693
+ for (const result of results) {
3694
+ if (result.status !== "fulfilled" || !result.value)
3695
+ continue;
3696
+ links = (links || []).concat(result.value);
3697
+ }
3698
+ return links;
3696
3699
  },
3697
3700
  async findDocumentHighlights(doc, params, cancel) {
3698
- let result;
3699
- await Promise.allSettled(
3700
- plugins.map(async (plugin) => {
3701
- var _a;
3702
- const cur = await ((_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3703
- if (cancel.isCancellationRequested)
3704
- return;
3705
- if (cur)
3706
- result = (result || []).concat(cur);
3707
- })
3701
+ const results = await Promise.allSettled(
3702
+ plugins.map(
3703
+ (plugin) => {
3704
+ var _a;
3705
+ return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3706
+ }
3707
+ )
3708
3708
  );
3709
3709
  if (cancel.isCancellationRequested)
3710
3710
  return;
3711
- return result;
3711
+ let highlights;
3712
+ for (const result of results) {
3713
+ if (result.status !== "fulfilled" || !result.value)
3714
+ continue;
3715
+ highlights = (highlights || []).concat(result.value);
3716
+ }
3717
+ return highlights;
3712
3718
  },
3713
3719
  async findDocumentColors(doc, params, cancel) {
3714
- let result;
3715
- await Promise.allSettled(
3716
- plugins.map(async (plugin) => {
3720
+ const results = await Promise.allSettled(
3721
+ plugins.map((plugin) => {
3717
3722
  var _a;
3718
- const cur = await ((_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3719
- if (cancel.isCancellationRequested)
3720
- return;
3721
- if (cur)
3722
- result = (result || []).concat(cur);
3723
+ return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3723
3724
  })
3724
3725
  );
3725
3726
  if (cancel.isCancellationRequested)
3726
3727
  return;
3727
- return result;
3728
+ let colors;
3729
+ for (const result of results) {
3730
+ if (result.status !== "fulfilled" || !result.value)
3731
+ continue;
3732
+ colors = (colors || []).concat(result.value);
3733
+ }
3734
+ return colors;
3728
3735
  },
3729
3736
  async getColorPresentations(doc, params, cancel) {
3730
- let result;
3731
- await Promise.allSettled(
3732
- plugins.map(async (plugin) => {
3733
- var _a;
3734
- const cur = await ((_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3735
- if (cancel.isCancellationRequested)
3736
- return;
3737
- if (cur)
3738
- result = (result || []).concat(cur);
3739
- })
3737
+ const results = await Promise.allSettled(
3738
+ plugins.map(
3739
+ (plugin) => {
3740
+ var _a;
3741
+ return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3742
+ }
3743
+ )
3740
3744
  );
3741
3745
  if (cancel.isCancellationRequested)
3742
3746
  return;
3743
- return result;
3747
+ let presentations;
3748
+ for (const result of results) {
3749
+ if (result.status !== "fulfilled" || !result.value)
3750
+ continue;
3751
+ presentations = (presentations || []).concat(result.value);
3752
+ }
3753
+ return presentations;
3744
3754
  },
3745
3755
  async doHover(doc, params, cancel) {
3746
- let result;
3747
- await Promise.allSettled(
3748
- plugins.map(async (plugin) => {
3756
+ const results = await Promise.allSettled(
3757
+ plugins.map((plugin) => {
3749
3758
  var _a;
3750
- const cur = await ((_a = plugin.doHover) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3751
- if (cancel.isCancellationRequested)
3752
- return;
3753
- if (cur) {
3754
- if (result) {
3755
- result.range = maxRange(result.range, cur.range);
3756
- result.contents = mergeHoverContents(result.contents, cur.contents);
3757
- } else {
3758
- result = cur;
3759
- }
3760
- }
3759
+ return (_a = plugin.doHover) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3761
3760
  })
3762
3761
  );
3763
- return result;
3762
+ if (cancel.isCancellationRequested)
3763
+ return;
3764
+ let hovers;
3765
+ for (const result of results) {
3766
+ if (result.status !== "fulfilled" || !result.value)
3767
+ continue;
3768
+ if (hovers) {
3769
+ hovers.range = maxRange(hovers.range, result.value.range);
3770
+ hovers.contents = mergeHoverContents(
3771
+ hovers.contents,
3772
+ result.value.contents
3773
+ );
3774
+ } else {
3775
+ hovers = result.value;
3776
+ }
3777
+ }
3778
+ return hovers;
3764
3779
  },
3765
3780
  async doRename(doc, params, cancel) {
3766
- let changes;
3767
- let changeAnnotations;
3768
- let documentChanges;
3769
- await Promise.allSettled(
3770
- plugins.map(async (plugin) => {
3781
+ const results = await Promise.allSettled(
3782
+ plugins.map((plugin) => {
3771
3783
  var _a;
3772
- const cur = await ((_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3773
- if (cancel.isCancellationRequested)
3774
- return;
3775
- if (cur) {
3776
- if (cur.changes) {
3777
- if (changes) {
3778
- changes = { ...changes };
3779
- for (const uri in cur.changes) {
3780
- changes[uri] = changes[uri] ? changes[uri].concat(cur.changes[uri]) : cur.changes[uri];
3781
- }
3782
- } else {
3783
- changes = cur.changes;
3784
- }
3785
- }
3786
- if (cur.changeAnnotations) {
3787
- changeAnnotations = changeAnnotations ? {
3788
- ...changeAnnotations,
3789
- ...cur.changeAnnotations
3790
- } : cur.changeAnnotations;
3791
- }
3792
- if (cur.documentChanges) {
3793
- documentChanges = documentChanges ? documentChanges.concat(cur.documentChanges) : cur.documentChanges;
3794
- }
3795
- }
3784
+ return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3796
3785
  })
3797
3786
  );
3798
3787
  if (cancel.isCancellationRequested)
3799
3788
  return;
3789
+ let changes;
3790
+ let changeAnnotations;
3791
+ let documentChanges;
3792
+ for (const result of results) {
3793
+ if (result.status !== "fulfilled" || !result.value)
3794
+ continue;
3795
+ const { value } = result;
3796
+ if (value.changes) {
3797
+ if (changes) {
3798
+ changes = { ...changes };
3799
+ for (const uri in value.changes) {
3800
+ changes[uri] = changes[uri] ? changes[uri].concat(value.changes[uri]) : value.changes[uri];
3801
+ }
3802
+ } else {
3803
+ changes = value.changes;
3804
+ }
3805
+ }
3806
+ if (value.changeAnnotations) {
3807
+ changeAnnotations = changeAnnotations ? {
3808
+ ...changeAnnotations,
3809
+ ...value.changeAnnotations
3810
+ } : value.changeAnnotations;
3811
+ }
3812
+ if (value.documentChanges) {
3813
+ documentChanges = documentChanges ? documentChanges.concat(value.documentChanges) : value.documentChanges;
3814
+ }
3815
+ }
3800
3816
  if (changes || changeAnnotations || documentChanges) {
3801
3817
  return {
3802
3818
  changes,
@@ -3806,32 +3822,36 @@ var service = {
3806
3822
  }
3807
3823
  },
3808
3824
  async doCodeActions(doc, params, cancel) {
3809
- let result;
3810
- await Promise.allSettled(
3811
- plugins.map(async (plugin) => {
3825
+ const results = await Promise.allSettled(
3826
+ plugins.map((plugin) => {
3812
3827
  var _a;
3813
- const cur = await ((_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3814
- if (cancel.isCancellationRequested)
3815
- return;
3816
- if (cur)
3817
- result = (result || []).concat(cur);
3828
+ return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3818
3829
  })
3819
3830
  );
3820
3831
  if (cancel.isCancellationRequested)
3821
3832
  return;
3822
- return result;
3833
+ let actions;
3834
+ for (const result of results) {
3835
+ if (result.status !== "fulfilled" || !result.value)
3836
+ continue;
3837
+ actions = (actions || []).concat(result.value);
3838
+ }
3839
+ return actions;
3823
3840
  },
3824
3841
  async doValidate(doc) {
3825
- let result;
3826
- await Promise.allSettled(
3827
- plugins.map(async (plugin) => {
3842
+ const results = await Promise.allSettled(
3843
+ plugins.map((plugin) => {
3828
3844
  var _a;
3829
- const cur = await ((_a = plugin.doValidate) == null ? void 0 : _a.call(plugin, doc));
3830
- if (cur)
3831
- result = (result || []).concat(cur);
3845
+ return (_a = plugin.doValidate) == null ? void 0 : _a.call(plugin, doc);
3832
3846
  })
3833
3847
  );
3834
- return result;
3848
+ let diagnostics;
3849
+ for (const result of results) {
3850
+ if (result.status !== "fulfilled" || !result.value)
3851
+ continue;
3852
+ diagnostics = (diagnostics || []).concat(result.value);
3853
+ }
3854
+ return diagnostics;
3835
3855
  },
3836
3856
  format: marko_default.format
3837
3857
  };