@marko/language-server 1.1.1 → 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.js CHANGED
@@ -25,13 +25,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  // src/index.ts
26
26
  var import_util2 = require("util");
27
27
  var import_node = require("vscode-languageserver/node");
28
- var import_language_tools17 = require("@marko/language-tools");
28
+ var import_language_tools18 = require("@marko/language-tools");
29
29
 
30
30
  // src/utils/file.ts
31
31
  var import_path = __toESM(require("path"));
32
32
  var import_language_tools = require("@marko/language-tools");
33
33
  var import_vscode_uri = require("vscode-uri");
34
34
  var processorCaches = /* @__PURE__ */ new WeakMap();
35
+ function getFSDir(doc) {
36
+ const filename = getFSPath(doc);
37
+ return filename ? import_path.default.dirname(filename) : void 0;
38
+ }
35
39
  function getFSPath(doc) {
36
40
  return import_vscode_uri.URI.parse(doc.uri).fsPath;
37
41
  }
@@ -1950,13 +1954,17 @@ function extractDocumentSymbols({
1950
1954
  var import_vscode_languageserver9 = require("vscode-languageserver");
1951
1955
  var prettier = __toESM(require("prettier"));
1952
1956
  var markoPrettier = __toESM(require("prettier-plugin-marko"));
1957
+ var import_language_tools14 = require("@marko/language-tools");
1953
1958
  var format2 = async (doc, params, cancel) => {
1954
1959
  try {
1960
+ const dir = getFSDir(doc);
1955
1961
  const filepath = getFSPath(doc);
1956
1962
  const text = doc.getText();
1957
1963
  const options = {
1958
1964
  parser: "marko",
1959
1965
  filepath,
1966
+ markoCompiler: import_language_tools14.Project.getCompiler(dir),
1967
+ markoCompilerConfig: import_language_tools14.Project.getConfig(dir),
1960
1968
  plugins: [markoPrettier],
1961
1969
  tabWidth: params.options.tabSize,
1962
1970
  useTabs: params.options.insertSpaces === false,
@@ -1999,20 +2007,27 @@ var import_tsserverlibrary = __toESM(require("typescript/lib/tsserverlibrary"));
1999
2007
  var import_vscode_languageserver10 = require("vscode-languageserver");
2000
2008
  var import_vscode_uri6 = require("vscode-uri");
2001
2009
  var prettier2 = __toESM(require("prettier"));
2002
- var import_language_tools15 = require("@marko/language-tools");
2010
+ var import_language_tools16 = require("@marko/language-tools");
2003
2011
 
2004
2012
  // src/ts-plugin/host.ts
2005
2013
  var import_path6 = __toESM(require("path"));
2006
- var import_language_tools14 = require("@marko/language-tools");
2014
+ var defaultCompiler = __toESM(require("@marko/compiler"));
2015
+ var defaultConfig = __toESM(require("@marko/compiler/config"));
2016
+ var defaultTranslator = __toESM(require("@marko/translator-default"));
2017
+ var import_language_tools15 = require("@marko/language-tools");
2007
2018
  var fsPathReg = /^(?:[./\\]|[A-Z]:)/i;
2008
2019
  var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
2009
- import_language_tools14.Project.setDefaultTypePaths({
2020
+ import_language_tools15.Project.setDefaultTypePaths({
2010
2021
  internalTypesFile: import_path6.default.join(__dirname, "marko.internal.d.ts"),
2011
2022
  markoTypesFile: import_path6.default.join(__dirname, "marko.runtime.d.ts")
2012
2023
  });
2024
+ import_language_tools15.Project.setDefaultCompilerMeta(defaultCompiler, {
2025
+ ...defaultConfig,
2026
+ translator: defaultTranslator
2027
+ });
2013
2028
  function patch(ts2, configFile, extractCache3, resolutionCache, host, ps) {
2014
2029
  var _a, _b, _c;
2015
- const processors = import_language_tools14.Processors.create({
2030
+ const processors = import_language_tools15.Processors.create({
2016
2031
  ts: ts2,
2017
2032
  host,
2018
2033
  configFile
@@ -2079,7 +2094,7 @@ function patch(ts2, configFile, extractCache3, resolutionCache, host, ps) {
2079
2094
  host.readDirectory = (path8, extensions, exclude, include, depth) => {
2080
2095
  return readDirectory2(
2081
2096
  path8,
2082
- extensions == null ? void 0 : extensions.concat(import_language_tools14.Processors.extensions),
2097
+ extensions == null ? void 0 : extensions.concat(import_language_tools15.Processors.extensions),
2083
2098
  exclude,
2084
2099
  include,
2085
2100
  depth
@@ -2126,12 +2141,12 @@ function patch(ts2, configFile, extractCache3, resolutionCache, host, ps) {
2126
2141
  }
2127
2142
  }
2128
2143
  if (resolvedFileName) {
2129
- if ((0, import_language_tools14.isDefinitionFile)(resolvedFileName)) {
2144
+ if ((0, import_language_tools15.isDefinitionFile)(resolvedFileName)) {
2130
2145
  if (!host.fileExists(resolvedFileName)) {
2131
2146
  resolvedFileName = void 0;
2132
2147
  }
2133
2148
  } else {
2134
- const ext = (0, import_language_tools14.getExt)(resolvedFileName);
2149
+ const ext = (0, import_language_tools15.getExt)(resolvedFileName);
2135
2150
  const definitionFile = `${resolvedFileName.slice(
2136
2151
  0,
2137
2152
  -ext.length
@@ -2179,7 +2194,7 @@ function patch(ts2, configFile, extractCache3, resolutionCache, host, ps) {
2179
2194
  }
2180
2195
  return host;
2181
2196
  function getProcessor(fileName) {
2182
- const ext = (0, import_language_tools14.getExt)(fileName);
2197
+ const ext = (0, import_language_tools15.getExt)(fileName);
2183
2198
  return ext ? processors[ext] : void 0;
2184
2199
  }
2185
2200
  }
@@ -2385,7 +2400,7 @@ var ScriptService = {
2385
2400
  return;
2386
2401
  const tsProject = getTSProject(filename);
2387
2402
  const extracted = processScript(doc, tsProject);
2388
- const lang = import_language_tools15.Project.getScriptLang(
2403
+ const lang = import_language_tools16.Project.getScriptLang(
2389
2404
  filename,
2390
2405
  tsProject.markoScriptLang,
2391
2406
  import_tsserverlibrary.default,
@@ -2395,14 +2410,14 @@ var ScriptService = {
2395
2410
  const content = (() => {
2396
2411
  try {
2397
2412
  return prettier2.format(generated, {
2398
- parser: lang === import_language_tools15.ScriptLang.ts ? "typescript" : "babel"
2413
+ parser: lang === import_language_tools16.ScriptLang.ts ? "typescript" : "babel"
2399
2414
  });
2400
2415
  } catch {
2401
2416
  return generated;
2402
2417
  }
2403
2418
  })();
2404
2419
  return {
2405
- language: lang === import_language_tools15.ScriptLang.ts ? "typescript" : "javascript",
2420
+ language: lang === import_language_tools16.ScriptLang.ts ? "typescript" : "javascript",
2406
2421
  content
2407
2422
  };
2408
2423
  }
@@ -2765,12 +2780,12 @@ function processScript(doc, tsProject) {
2765
2780
  return processDoc(doc, ({ filename, parsed, lookup }) => {
2766
2781
  var _a;
2767
2782
  const { host, markoScriptLang } = tsProject;
2768
- return (0, import_language_tools15.extractScript)({
2783
+ return (0, import_language_tools16.extractScript)({
2769
2784
  ts: import_tsserverlibrary.default,
2770
2785
  parsed,
2771
2786
  lookup,
2772
- scriptLang: import_language_tools15.Project.getScriptLang(filename, markoScriptLang, import_tsserverlibrary.default, host),
2773
- runtimeTypesCode: (_a = import_language_tools15.Project.getTypeLibs(tsProject.rootDir, import_tsserverlibrary.default, host)) == null ? void 0 : _a.markoTypesCode
2787
+ scriptLang: import_language_tools16.Project.getScriptLang(filename, markoScriptLang, import_tsserverlibrary.default, host),
2788
+ runtimeTypesCode: (_a = import_language_tools16.Project.getTypeLibs(tsProject.rootDir, import_tsserverlibrary.default, host)) == null ? void 0 : _a.markoTypesCode
2774
2789
  });
2775
2790
  });
2776
2791
  }
@@ -2781,9 +2796,9 @@ function getInsertModuleStatementOffset(parsed) {
2781
2796
  let lastImport;
2782
2797
  for (const node of program.static) {
2783
2798
  switch (node.type) {
2784
- case import_language_tools15.NodeType.Export:
2799
+ case import_language_tools16.NodeType.Export:
2785
2800
  return node.start;
2786
- case import_language_tools15.NodeType.Import:
2801
+ case import_language_tools16.NodeType.Import:
2787
2802
  lastImport = node;
2788
2803
  break;
2789
2804
  }
@@ -2824,7 +2839,7 @@ function docLocationAtTextSpan(doc, { start, length }) {
2824
2839
  function getTSProject(docFsPath) {
2825
2840
  var _a;
2826
2841
  let configFile;
2827
- let markoScriptLang = import_language_tools15.ScriptLang.js;
2842
+ let markoScriptLang = import_language_tools16.ScriptLang.js;
2828
2843
  if (docFsPath) {
2829
2844
  configFile = import_tsserverlibrary.default.findConfigFile(
2830
2845
  docFsPath,
@@ -2832,7 +2847,7 @@ function getTSProject(docFsPath) {
2832
2847
  "tsconfig.json"
2833
2848
  );
2834
2849
  if (configFile) {
2835
- markoScriptLang = import_language_tools15.ScriptLang.ts;
2850
+ markoScriptLang = import_language_tools16.ScriptLang.ts;
2836
2851
  } else {
2837
2852
  configFile = import_tsserverlibrary.default.findConfigFile(
2838
2853
  docFsPath,
@@ -2842,7 +2857,7 @@ function getTSProject(docFsPath) {
2842
2857
  }
2843
2858
  }
2844
2859
  const rootDir = configFile && import_path7.default.dirname(configFile) || process.cwd();
2845
- const cache = import_language_tools15.Project.getCache(configFile && rootDir);
2860
+ const cache = import_language_tools16.Project.getCache(configFile && rootDir);
2846
2861
  let projectCache = cache.get(getTSProject);
2847
2862
  let cached;
2848
2863
  if (projectCache) {
@@ -2981,7 +2996,7 @@ function filenameToURI(filename) {
2981
2996
  }
2982
2997
  async function getPreferences(scriptLang) {
2983
2998
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2984
- const configName = scriptLang === import_language_tools15.ScriptLang.js ? "javascript" : "typescript";
2999
+ const configName = scriptLang === import_language_tools16.ScriptLang.js ? "javascript" : "typescript";
2985
3000
  const [preferencesConfig, suggestConfig, inlayHintsConfig] = await Promise.all([
2986
3001
  getConfig(`${configName}.preferences`),
2987
3002
  getConfig(`${configName}.suggest`),
@@ -3138,7 +3153,7 @@ function getCanonicalFileName(fileName) {
3138
3153
  var import_vscode_css_languageservice2 = require("vscode-css-languageservice");
3139
3154
  var import_vscode_languageserver11 = require("vscode-languageserver");
3140
3155
  var import_vscode_languageserver_textdocument2 = require("vscode-languageserver-textdocument");
3141
- var import_language_tools16 = require("@marko/language-tools");
3156
+ var import_language_tools17 = require("@marko/language-tools");
3142
3157
  var services = {
3143
3158
  ".css": import_vscode_css_languageservice2.getCSSLanguageService,
3144
3159
  ".less": import_vscode_css_languageservice2.getLESSLanguageService,
@@ -3445,7 +3460,7 @@ function processStyle(doc) {
3445
3460
  return processDoc(doc, ({ uri, version, parsed, lookup }) => {
3446
3461
  var _a;
3447
3462
  const result = [];
3448
- for (const [ext, extracted] of (0, import_language_tools16.extractStyle)({
3463
+ for (const [ext, extracted] of (0, import_language_tools17.extractStyle)({
3449
3464
  parsed,
3450
3465
  lookup
3451
3466
  })) {
@@ -3541,39 +3556,31 @@ var service = {
3541
3556
  );
3542
3557
  },
3543
3558
  async doComplete(doc, params, cancel) {
3544
- const itemsByLabel = /* @__PURE__ */ new Map();
3545
- await Promise.allSettled(
3546
- plugins.map(async (plugin) => {
3559
+ const results = await Promise.allSettled(
3560
+ plugins.map((plugin) => {
3547
3561
  var _a;
3548
- const cur = await ((_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3549
- if (cancel.isCancellationRequested)
3550
- return;
3551
- if (cur) {
3552
- let curItems;
3553
- if (Array.isArray(cur)) {
3554
- curItems = cur;
3555
- } else {
3556
- curItems = cur.items;
3557
- }
3558
- for (const item of curItems) {
3559
- const { label } = item;
3560
- const existingItem = itemsByLabel.get(label);
3561
- if (existingItem) {
3562
- if ((existingItem.sortText || label) < (item.sortText || label)) {
3563
- itemsByLabel.set(label, item);
3564
- }
3565
- } else {
3566
- itemsByLabel.set(label, item);
3567
- }
3568
- }
3569
- }
3562
+ return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3570
3563
  })
3571
3564
  );
3572
3565
  if (cancel.isCancellationRequested)
3573
3566
  return;
3574
- if (itemsByLabel.size) {
3575
- return { items: [...itemsByLabel.values()], isIncomplete: true };
3567
+ const itemsByLabel = /* @__PURE__ */ new Map();
3568
+ for (const result of results) {
3569
+ if (result.status !== "fulfilled" || !result.value)
3570
+ continue;
3571
+ for (const item of Array.isArray(result.value) ? result.value : result.value.items) {
3572
+ const { label } = item;
3573
+ const existingItem = itemsByLabel.get(label);
3574
+ if (existingItem) {
3575
+ if ((existingItem.sortText || label) < (item.sortText || label)) {
3576
+ itemsByLabel.set(label, item);
3577
+ }
3578
+ } else {
3579
+ itemsByLabel.set(label, item);
3580
+ }
3581
+ }
3576
3582
  }
3583
+ return { items: [...itemsByLabel.values()], isIncomplete: true };
3577
3584
  },
3578
3585
  async doCompletionResolve(item, cancel) {
3579
3586
  var _a;
@@ -3589,172 +3596,189 @@ var service = {
3589
3596
  }
3590
3597
  },
3591
3598
  async findDefinition(doc, params, cancel) {
3592
- let result;
3593
- await Promise.allSettled(
3594
- plugins.map(async (plugin) => {
3599
+ const results = await Promise.allSettled(
3600
+ plugins.map((plugin) => {
3595
3601
  var _a;
3596
- const cur = await ((_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3597
- if (cancel.isCancellationRequested)
3598
- return;
3599
- if (cur)
3600
- result = (result || []).concat(cur);
3602
+ return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3601
3603
  })
3602
3604
  );
3603
3605
  if (cancel.isCancellationRequested)
3604
3606
  return;
3605
- return result;
3607
+ let links;
3608
+ for (const result of results) {
3609
+ if (result.status !== "fulfilled" || !result.value)
3610
+ continue;
3611
+ links = (links || []).concat(result.value);
3612
+ }
3613
+ return links;
3606
3614
  },
3607
3615
  async findReferences(doc, params, cancel) {
3608
- let result;
3609
- await Promise.allSettled(
3610
- plugins.map(async (plugin) => {
3616
+ const results = await Promise.allSettled(
3617
+ plugins.map((plugin) => {
3611
3618
  var _a;
3612
- const cur = await ((_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3613
- if (cancel.isCancellationRequested)
3614
- return;
3615
- if (cur)
3616
- result = (result || []).concat(cur);
3619
+ return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3617
3620
  })
3618
3621
  );
3619
3622
  if (cancel.isCancellationRequested)
3620
3623
  return;
3621
- return result;
3624
+ let references;
3625
+ for (const result of results) {
3626
+ if (result.status !== "fulfilled" || !result.value)
3627
+ continue;
3628
+ references = (references || []).concat(result.value);
3629
+ }
3630
+ return references;
3622
3631
  },
3623
3632
  async findDocumentSymbols(doc, params, cancel) {
3624
- let result;
3625
- await Promise.allSettled(
3626
- plugins.map(async (plugin) => {
3633
+ const results = await Promise.allSettled(
3634
+ plugins.map((plugin) => {
3627
3635
  var _a;
3628
- const cur = await ((_a = plugin.findDocumentSymbols) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3629
- if (cancel.isCancellationRequested)
3630
- return;
3631
- if (cur)
3632
- result = (result || []).concat(cur);
3636
+ return (_a = plugin.findDocumentSymbols) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3633
3637
  })
3634
3638
  );
3635
3639
  if (cancel.isCancellationRequested)
3636
3640
  return;
3637
- return result;
3641
+ let symbols;
3642
+ for (const result of results) {
3643
+ if (result.status !== "fulfilled" || !result.value)
3644
+ continue;
3645
+ symbols = (symbols || []).concat(result.value);
3646
+ }
3647
+ return symbols;
3638
3648
  },
3639
3649
  async findDocumentLinks(doc, params, cancel) {
3640
- let result;
3641
- await Promise.allSettled(
3642
- plugins.map(async (plugin) => {
3650
+ const results = await Promise.allSettled(
3651
+ plugins.map((plugin) => {
3643
3652
  var _a;
3644
- const cur = await ((_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3645
- if (cancel.isCancellationRequested)
3646
- return;
3647
- if (cur)
3648
- result = (result || []).concat(cur);
3653
+ return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3649
3654
  })
3650
3655
  );
3651
3656
  if (cancel.isCancellationRequested)
3652
3657
  return;
3653
- return result;
3658
+ let links;
3659
+ for (const result of results) {
3660
+ if (result.status !== "fulfilled" || !result.value)
3661
+ continue;
3662
+ links = (links || []).concat(result.value);
3663
+ }
3664
+ return links;
3654
3665
  },
3655
3666
  async findDocumentHighlights(doc, params, cancel) {
3656
- let result;
3657
- await Promise.allSettled(
3658
- plugins.map(async (plugin) => {
3659
- var _a;
3660
- const cur = await ((_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3661
- if (cancel.isCancellationRequested)
3662
- return;
3663
- if (cur)
3664
- result = (result || []).concat(cur);
3665
- })
3667
+ const results = await Promise.allSettled(
3668
+ plugins.map(
3669
+ (plugin) => {
3670
+ var _a;
3671
+ return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3672
+ }
3673
+ )
3666
3674
  );
3667
3675
  if (cancel.isCancellationRequested)
3668
3676
  return;
3669
- return result;
3677
+ let highlights;
3678
+ for (const result of results) {
3679
+ if (result.status !== "fulfilled" || !result.value)
3680
+ continue;
3681
+ highlights = (highlights || []).concat(result.value);
3682
+ }
3683
+ return highlights;
3670
3684
  },
3671
3685
  async findDocumentColors(doc, params, cancel) {
3672
- let result;
3673
- await Promise.allSettled(
3674
- plugins.map(async (plugin) => {
3686
+ const results = await Promise.allSettled(
3687
+ plugins.map((plugin) => {
3675
3688
  var _a;
3676
- const cur = await ((_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3677
- if (cancel.isCancellationRequested)
3678
- return;
3679
- if (cur)
3680
- result = (result || []).concat(cur);
3689
+ return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3681
3690
  })
3682
3691
  );
3683
3692
  if (cancel.isCancellationRequested)
3684
3693
  return;
3685
- return result;
3694
+ let colors;
3695
+ for (const result of results) {
3696
+ if (result.status !== "fulfilled" || !result.value)
3697
+ continue;
3698
+ colors = (colors || []).concat(result.value);
3699
+ }
3700
+ return colors;
3686
3701
  },
3687
3702
  async getColorPresentations(doc, params, cancel) {
3688
- let result;
3689
- await Promise.allSettled(
3690
- plugins.map(async (plugin) => {
3691
- var _a;
3692
- const cur = await ((_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3693
- if (cancel.isCancellationRequested)
3694
- return;
3695
- if (cur)
3696
- result = (result || []).concat(cur);
3697
- })
3703
+ const results = await Promise.allSettled(
3704
+ plugins.map(
3705
+ (plugin) => {
3706
+ var _a;
3707
+ return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3708
+ }
3709
+ )
3698
3710
  );
3699
3711
  if (cancel.isCancellationRequested)
3700
3712
  return;
3701
- return result;
3713
+ let presentations;
3714
+ for (const result of results) {
3715
+ if (result.status !== "fulfilled" || !result.value)
3716
+ continue;
3717
+ presentations = (presentations || []).concat(result.value);
3718
+ }
3719
+ return presentations;
3702
3720
  },
3703
3721
  async doHover(doc, params, cancel) {
3704
- let result;
3705
- await Promise.allSettled(
3706
- plugins.map(async (plugin) => {
3722
+ const results = await Promise.allSettled(
3723
+ plugins.map((plugin) => {
3707
3724
  var _a;
3708
- const cur = await ((_a = plugin.doHover) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3709
- if (cancel.isCancellationRequested)
3710
- return;
3711
- if (cur) {
3712
- if (result) {
3713
- result.range = maxRange(result.range, cur.range);
3714
- result.contents = mergeHoverContents(result.contents, cur.contents);
3715
- } else {
3716
- result = cur;
3717
- }
3718
- }
3725
+ return (_a = plugin.doHover) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3719
3726
  })
3720
3727
  );
3721
- return result;
3728
+ if (cancel.isCancellationRequested)
3729
+ return;
3730
+ let hovers;
3731
+ for (const result of results) {
3732
+ if (result.status !== "fulfilled" || !result.value)
3733
+ continue;
3734
+ if (hovers) {
3735
+ hovers.range = maxRange(hovers.range, result.value.range);
3736
+ hovers.contents = mergeHoverContents(
3737
+ hovers.contents,
3738
+ result.value.contents
3739
+ );
3740
+ } else {
3741
+ hovers = result.value;
3742
+ }
3743
+ }
3744
+ return hovers;
3722
3745
  },
3723
3746
  async doRename(doc, params, cancel) {
3724
- let changes;
3725
- let changeAnnotations;
3726
- let documentChanges;
3727
- await Promise.allSettled(
3728
- plugins.map(async (plugin) => {
3747
+ const results = await Promise.allSettled(
3748
+ plugins.map((plugin) => {
3729
3749
  var _a;
3730
- const cur = await ((_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3731
- if (cancel.isCancellationRequested)
3732
- return;
3733
- if (cur) {
3734
- if (cur.changes) {
3735
- if (changes) {
3736
- changes = { ...changes };
3737
- for (const uri in cur.changes) {
3738
- changes[uri] = changes[uri] ? changes[uri].concat(cur.changes[uri]) : cur.changes[uri];
3739
- }
3740
- } else {
3741
- changes = cur.changes;
3742
- }
3743
- }
3744
- if (cur.changeAnnotations) {
3745
- changeAnnotations = changeAnnotations ? {
3746
- ...changeAnnotations,
3747
- ...cur.changeAnnotations
3748
- } : cur.changeAnnotations;
3749
- }
3750
- if (cur.documentChanges) {
3751
- documentChanges = documentChanges ? documentChanges.concat(cur.documentChanges) : cur.documentChanges;
3752
- }
3753
- }
3750
+ return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3754
3751
  })
3755
3752
  );
3756
3753
  if (cancel.isCancellationRequested)
3757
3754
  return;
3755
+ let changes;
3756
+ let changeAnnotations;
3757
+ let documentChanges;
3758
+ for (const result of results) {
3759
+ if (result.status !== "fulfilled" || !result.value)
3760
+ continue;
3761
+ const { value } = result;
3762
+ if (value.changes) {
3763
+ if (changes) {
3764
+ changes = { ...changes };
3765
+ for (const uri in value.changes) {
3766
+ changes[uri] = changes[uri] ? changes[uri].concat(value.changes[uri]) : value.changes[uri];
3767
+ }
3768
+ } else {
3769
+ changes = value.changes;
3770
+ }
3771
+ }
3772
+ if (value.changeAnnotations) {
3773
+ changeAnnotations = changeAnnotations ? {
3774
+ ...changeAnnotations,
3775
+ ...value.changeAnnotations
3776
+ } : value.changeAnnotations;
3777
+ }
3778
+ if (value.documentChanges) {
3779
+ documentChanges = documentChanges ? documentChanges.concat(value.documentChanges) : value.documentChanges;
3780
+ }
3781
+ }
3758
3782
  if (changes || changeAnnotations || documentChanges) {
3759
3783
  return {
3760
3784
  changes,
@@ -3764,32 +3788,36 @@ var service = {
3764
3788
  }
3765
3789
  },
3766
3790
  async doCodeActions(doc, params, cancel) {
3767
- let result;
3768
- await Promise.allSettled(
3769
- plugins.map(async (plugin) => {
3791
+ const results = await Promise.allSettled(
3792
+ plugins.map((plugin) => {
3770
3793
  var _a;
3771
- const cur = await ((_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel));
3772
- if (cancel.isCancellationRequested)
3773
- return;
3774
- if (cur)
3775
- result = (result || []).concat(cur);
3794
+ return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
3776
3795
  })
3777
3796
  );
3778
3797
  if (cancel.isCancellationRequested)
3779
3798
  return;
3780
- return result;
3799
+ let actions;
3800
+ for (const result of results) {
3801
+ if (result.status !== "fulfilled" || !result.value)
3802
+ continue;
3803
+ actions = (actions || []).concat(result.value);
3804
+ }
3805
+ return actions;
3781
3806
  },
3782
3807
  async doValidate(doc) {
3783
- let result;
3784
- await Promise.allSettled(
3785
- plugins.map(async (plugin) => {
3808
+ const results = await Promise.allSettled(
3809
+ plugins.map((plugin) => {
3786
3810
  var _a;
3787
- const cur = await ((_a = plugin.doValidate) == null ? void 0 : _a.call(plugin, doc));
3788
- if (cur)
3789
- result = (result || []).concat(cur);
3811
+ return (_a = plugin.doValidate) == null ? void 0 : _a.call(plugin, doc);
3790
3812
  })
3791
3813
  );
3792
- return result;
3814
+ let diagnostics;
3815
+ for (const result of results) {
3816
+ if (result.status !== "fulfilled" || !result.value)
3817
+ continue;
3818
+ diagnostics = (diagnostics || []).concat(result.value);
3819
+ }
3820
+ return diagnostics;
3793
3821
  },
3794
3822
  format: marko_default.format
3795
3823
  };
@@ -4029,7 +4057,7 @@ for (const command in service.commands) {
4029
4057
  }
4030
4058
  function validateDocs() {
4031
4059
  queueDiagnostic();
4032
- import_language_tools17.Project.clearCaches();
4060
+ import_language_tools18.Project.clearCaches();
4033
4061
  }
4034
4062
  function queueDiagnostic() {
4035
4063
  clearTimeout(diagnosticTimeout);