@marko/language-server 0.12.12 → 0.12.15

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
@@ -13,7 +13,10 @@ var __copyProps = (to, from, except, desc) => {
13
13
  }
14
14
  return to;
15
15
  };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
18
+ mod
19
+ ));
17
20
 
18
21
  // src/index.ts
19
22
  var import_node = require("vscode-languageserver/node");
@@ -280,12 +283,14 @@ function parse(source) {
280
283
  }
281
284
  }
282
285
  program.body.length = i + 1;
283
- program.static.push(curParent = {
284
- type: 20 /* Statement */,
285
- parent: program,
286
- start: range.start,
287
- end: UNFINISHED
288
- });
286
+ program.static.push(
287
+ curParent = {
288
+ type: 20 /* Statement */,
289
+ parent: program,
290
+ start: range.start,
291
+ end: UNFINISHED
292
+ }
293
+ );
289
294
  return curBodyType = import_htmljs_parser.TagType.statement;
290
295
  }
291
296
  default:
@@ -412,15 +417,18 @@ function parse(source) {
412
417
  start: range.start,
413
418
  end: range.end
414
419
  };
415
- pushAttr(parent, curAttr = name.parent = {
416
- type: 8 /* AttrNamed */,
420
+ pushAttr(
417
421
  parent,
418
- name,
419
- value: void 0,
420
- args: void 0,
421
- start: range.start,
422
- end: range.end
423
- });
422
+ curAttr = name.parent = {
423
+ type: 8 /* AttrNamed */,
424
+ parent,
425
+ name,
426
+ value: void 0,
427
+ args: void 0,
428
+ start: range.start,
429
+ end: range.end
430
+ }
431
+ );
424
432
  },
425
433
  onAttrArgs(range) {
426
434
  curAttr.args = {
@@ -575,12 +583,16 @@ function loadCompilerInfo(dir) {
575
583
  const rootDir = import_lasso_package_root.default.getRootDir(dir);
576
584
  const pkgPath = rootDir && import_resolve_from.default.silent(rootDir, "@marko/compiler/package.json");
577
585
  const pkg = pkgPath && require(pkgPath);
578
- const cache3 = /* @__PURE__ */ new Map();
586
+ const cache4 = /* @__PURE__ */ new Map();
579
587
  let translator = builtinTranslator;
580
588
  let compiler = builtinCompiler;
581
589
  if (pkg && /^5\./.test(pkg.version)) {
582
590
  try {
583
- let checkTranslator = [].concat(Object.keys(pkg.dependencies), Object.keys(pkg.peerDependencies), Object.keys(pkg.devDependencies)).find((name) => /^marko$|^(@\/marko\/|marko-)translator-/.test(name));
591
+ let checkTranslator = [].concat(
592
+ Object.keys(pkg.dependencies),
593
+ Object.keys(pkg.peerDependencies),
594
+ Object.keys(pkg.devDependencies)
595
+ ).find((name) => /^marko$|^(@\/marko\/|marko-)translator-/.test(name));
584
596
  if (checkTranslator === "marko" || !checkTranslator) {
585
597
  checkTranslator = require((0, import_resolve_from.default)(dir, "@marko/compiler/config")).translator;
586
598
  }
@@ -592,16 +604,16 @@ function loadCompilerInfo(dir) {
592
604
  }
593
605
  }
594
606
  return {
595
- cache: cache3,
607
+ cache: cache4,
596
608
  get lookup() {
597
- let lookup = cache3.get(lookupKey);
609
+ let lookup = cache4.get(lookupKey);
598
610
  if (lookup === void 0) {
599
611
  try {
600
612
  lookup = compiler.taglib.buildLookup(dir, translator);
601
613
  } catch {
602
614
  lookup = builtinInfo.lookup;
603
615
  }
604
- cache3.set(lookupKey, lookup);
616
+ cache4.set(lookupKey, lookup);
605
617
  }
606
618
  return lookup;
607
619
  },
@@ -625,7 +637,7 @@ function display(type, data) {
625
637
  }
626
638
 
627
639
  // src/service/index.ts
628
- var import_vscode_languageserver14 = require("vscode-languageserver");
640
+ var import_vscode_languageserver15 = require("vscode-languageserver");
629
641
 
630
642
  // src/service/marko/complete/index.ts
631
643
  var import_vscode_languageserver6 = require("vscode-languageserver");
@@ -661,10 +673,13 @@ ${closingTagStr}`
661
673
  label: closingTagStr,
662
674
  kind: import_vscode_languageserver.CompletionItemKind.Class,
663
675
  insertTextFormat: import_vscode_languageserver.InsertTextFormat.Snippet,
664
- textEdit: import_vscode_languageserver.TextEdit.replace(parsed.locationAt({
665
- start,
666
- end
667
- }), closingTagStr)
676
+ textEdit: import_vscode_languageserver.TextEdit.replace(
677
+ parsed.locationAt({
678
+ start,
679
+ end
680
+ }),
681
+ closingTagStr
682
+ )
668
683
  }
669
684
  ];
670
685
  }
@@ -685,12 +700,14 @@ function getTagNameCompletion({
685
700
  let label = tag.isNestedTag ? `@${tag.name}` : tag.name;
686
701
  const fileForTag = tag.template || tag.renderer || tag.filePath;
687
702
  const fileURIForTag = import_vscode_uri2.URI.file(fileForTag).toString();
688
- const nodeModuleMatch = /\/node_modules\/((?:@[^/]+\/)?[^/]+)/.exec(fileForTag);
703
+ const nodeModuleMatch = /\/node_modules\/((?:@[^/]+\/)?[^/]+)/.exec(
704
+ fileForTag
705
+ );
689
706
  const nodeModuleName = nodeModuleMatch && nodeModuleMatch[1];
690
- const isCoreTag = nodeModuleName === "marko";
707
+ const isCoreTag = /^@?marko[/-]/.test(tag.taglibId) || nodeModuleName === "marko";
691
708
  const documentation = {
692
709
  kind: import_vscode_languageserver2.MarkupKind.Markdown,
693
- value: tag.html ? `Built in [<${tag.name}>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/${tag.name}) HTML tag.` : nodeModuleName ? isCoreTag ? `Core Marko [<${tag.name}>](${fileURIForTag}) tag.` : `Custom Marko tag discovered from the ["${nodeModuleName}"](${fileURIForTag}) npm package.` : `Custom Marko tag discovered from:
710
+ value: tag.html ? `Built in [&lt;${tag.name}&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/${tag.name}) HTML tag.` : isCoreTag ? `Core Marko &lt;${tag.name}&gt; tag.` : nodeModuleName ? `Custom Marko tag discovered from the ["${nodeModuleName}"](${fileURIForTag}) npm package.` : `Custom Marko tag discovered from:
694
711
 
695
712
  [${importer ? import_path2.default.relative(importer, fileForTag) : fileForTag}](${fileURIForTag})`
696
713
  };
@@ -748,12 +765,14 @@ function OpenTagName({
748
765
  for (const key in nestedTags) {
749
766
  if (key !== "*") {
750
767
  const tag2 = nestedTags[key];
751
- result.push(getTagNameCompletion({
752
- tag: tag2,
753
- range,
754
- importer,
755
- showAutoComplete: true
756
- }));
768
+ result.push(
769
+ getTagNameCompletion({
770
+ tag: tag2,
771
+ range,
772
+ importer,
773
+ showAutoComplete: true
774
+ })
775
+ );
757
776
  }
758
777
  }
759
778
  }
@@ -761,12 +780,14 @@ function OpenTagName({
761
780
  const skipStatements = !(tag.concise && tag.parent.type === 0 /* Program */);
762
781
  for (const tag2 of lookup.getTagsSorted()) {
763
782
  if (!(tag2.name === "*" || tag2.isNestedTag || skipStatements && ((_a = tag2.parseOptions) == null ? void 0 : _a.statement) || tag2.name[0] === "_" && /^@?marko[/-]|[\\/]node_modules[\\/]/.test(tag2.filePath))) {
764
- result.push(getTagNameCompletion({
765
- tag: tag2,
766
- range,
767
- importer,
768
- showAutoComplete: true
769
- }));
783
+ result.push(
784
+ getTagNameCompletion({
785
+ tag: tag2,
786
+ range,
787
+ importer,
788
+ showAutoComplete: true
789
+ })
790
+ );
770
791
  }
771
792
  }
772
793
  }
@@ -805,10 +826,12 @@ function AttrName({
805
826
  }
806
827
  }
807
828
  const completions = [];
808
- const attrNameLoc = parsed.locationAt(hasModifier ? {
809
- start: node.start,
810
- end: node.start + name.length
811
- } : node);
829
+ const attrNameLoc = parsed.locationAt(
830
+ hasModifier ? {
831
+ start: node.start,
832
+ end: node.start + name.length
833
+ } : node
834
+ );
812
835
  const tagName = node.parent.parent.nameText || "";
813
836
  const tagDef = tagName && lookup.getTag(tagName);
814
837
  const nestedTagAttrs = {};
@@ -942,7 +965,11 @@ async function readDirectory(uri) {
942
965
  try {
943
966
  const entries = await import_promises.default.readdir((0, import_url.fileURLToPath)(uri));
944
967
  const base = uri.at(-1) === "/" ? uri : `${uri}/`;
945
- return (await Promise.all(entries.map(async (entry) => [entry, (await stat(new URL(entry, base).toString())).type]))).filter(([, type]) => type !== import_vscode_css_languageservice.FileType.Unknown);
968
+ return (await Promise.all(
969
+ entries.map(
970
+ async (entry) => [entry, (await stat(new URL(entry, base).toString())).type]
971
+ )
972
+ )).filter(([, type]) => type !== import_vscode_css_languageservice.FileType.Unknown);
946
973
  } catch {
947
974
  return [];
948
975
  }
@@ -986,22 +1013,27 @@ async function AttrValue({
986
1013
  if (uri) {
987
1014
  const result = [];
988
1015
  const curFile = req === "." ? import_path3.default.basename(document.uri) : void 0;
989
- const replaceRange = import_vscode_languageserver4.Range.create(document.positionAt(start + segmentStart + 1), document.positionAt(start + rawValue.length));
1016
+ const replaceRange = import_vscode_languageserver4.Range.create(
1017
+ document.positionAt(start + segmentStart + 1),
1018
+ document.positionAt(start + rawValue.length)
1019
+ );
990
1020
  for (const [entry, type] of await file_system_default.readDirectory(uri)) {
991
1021
  if (entry[0] !== "." && entry !== curFile) {
992
- result.push(type === import_vscode_css_languageservice.FileType.Directory ? {
993
- label: `${entry}/`,
994
- kind: import_vscode_languageserver4.CompletionItemKind.Folder,
995
- textEdit: import_vscode_languageserver4.TextEdit.replace(replaceRange, `${entry}/`),
996
- command: {
997
- title: "Suggest",
998
- command: "editor.action.triggerSuggest"
1022
+ result.push(
1023
+ type === import_vscode_css_languageservice.FileType.Directory ? {
1024
+ label: `${entry}/`,
1025
+ kind: import_vscode_languageserver4.CompletionItemKind.Folder,
1026
+ textEdit: import_vscode_languageserver4.TextEdit.replace(replaceRange, `${entry}/`),
1027
+ command: {
1028
+ title: "Suggest",
1029
+ command: "editor.action.triggerSuggest"
1030
+ }
1031
+ } : {
1032
+ label: entry,
1033
+ kind: import_vscode_languageserver4.CompletionItemKind.File,
1034
+ textEdit: import_vscode_languageserver4.TextEdit.replace(replaceRange, entry)
999
1035
  }
1000
- } : {
1001
- label: entry,
1002
- kind: import_vscode_languageserver4.CompletionItemKind.File,
1003
- textEdit: import_vscode_languageserver4.TextEdit.replace(replaceRange, entry)
1004
- });
1036
+ );
1005
1037
  }
1006
1038
  }
1007
1039
  return result;
@@ -1061,44 +1093,124 @@ var doComplete = async (doc, params) => {
1061
1093
  const parsed = parse2(doc);
1062
1094
  const offset = doc.offsetAt(params.position);
1063
1095
  const node = parsed.nodeAt(offset);
1064
- return import_vscode_languageserver6.CompletionList.create(await ((_a = handlers[NodeType[node.type]]) == null ? void 0 : _a.call(handlers, {
1065
- document: doc,
1066
- params,
1067
- parsed,
1068
- offset,
1069
- node,
1070
- code: doc.getText(),
1071
- ...getCompilerInfo(doc)
1072
- })) || [], true);
1096
+ return import_vscode_languageserver6.CompletionList.create(
1097
+ await ((_a = handlers[NodeType[node.type]]) == null ? void 0 : _a.call(handlers, {
1098
+ document: doc,
1099
+ params,
1100
+ parsed,
1101
+ offset,
1102
+ node,
1103
+ code: doc.getText(),
1104
+ ...getCompilerInfo(doc)
1105
+ })) || [],
1106
+ true
1107
+ );
1073
1108
  };
1074
1109
 
1075
1110
  // src/service/marko/validate.ts
1076
1111
  var import_vscode_languageserver7 = require("vscode-languageserver");
1077
- var markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
1112
+ var markoErrorRegExp = /^(.+?)\.marko(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
1078
1113
  var doValidate = (doc) => {
1079
1114
  const fsPath = getDocFile(doc);
1080
1115
  const diagnostics = [];
1081
- const { compiler, translator, cache: cache3 } = getCompilerInfo(doc);
1116
+ const { compiler, translator, cache: cache4 } = getCompilerInfo(doc);
1082
1117
  try {
1083
1118
  compiler.compileSync(doc.getText(), fsPath || "untitled.marko", {
1084
- cache: cache3,
1119
+ cache: cache4,
1085
1120
  translator,
1086
1121
  code: false,
1087
1122
  output: "source",
1088
- sourceMaps: false
1123
+ sourceMaps: false,
1124
+ babelConfig: {
1125
+ caller: {
1126
+ name: "@marko/language-server",
1127
+ supportsStaticESM: true,
1128
+ supportsDynamicImport: true,
1129
+ supportsTopLevelAwait: true,
1130
+ supportsExportNamespaceFrom: true
1131
+ }
1132
+ }
1089
1133
  });
1090
1134
  } catch (e) {
1091
1135
  let match;
1092
1136
  while (match = markoErrorRegExp.exec(e.message)) {
1093
- const [, fileName, rawLine, rawCol, msg] = match;
1094
- const line = (parseInt(rawLine, 10) || 1) - 1;
1095
- const col = (parseInt(rawCol, 10) || 1) - 1;
1096
- diagnostics.push(import_vscode_languageserver7.Diagnostic.create(import_vscode_languageserver7.Range.create(line, col, line, col), msg, import_vscode_languageserver7.DiagnosticSeverity.Error, void 0, fileName));
1137
+ const [, , rawLine, rawCol, message] = match;
1138
+ const pos = {
1139
+ line: (parseInt(rawLine, 10) || 1) - 1,
1140
+ character: (parseInt(rawCol, 10) || 1) - 1
1141
+ };
1142
+ diagnostics.push({
1143
+ range: { start: pos, end: pos },
1144
+ source: "marko",
1145
+ code: void 0,
1146
+ tags: void 0,
1147
+ severity: import_vscode_languageserver7.DiagnosticSeverity.Error,
1148
+ message
1149
+ });
1097
1150
  }
1098
1151
  }
1099
1152
  return diagnostics;
1100
1153
  };
1101
1154
 
1155
+ // src/utils/utils.ts
1156
+ var import_fs = __toESM(require("fs"));
1157
+ var import_vscode_uri3 = require("vscode-uri");
1158
+ var import_vscode_languageserver8 = require("vscode-languageserver");
1159
+ var import_vscode_languageserver_textdocument = require("vscode-languageserver-textdocument");
1160
+ var START_OF_FILE = import_vscode_languageserver8.Range.create(
1161
+ import_vscode_languageserver8.Position.create(0, 0),
1162
+ import_vscode_languageserver8.Position.create(0, 0)
1163
+ );
1164
+ function createTextDocument(filename) {
1165
+ const uri = import_vscode_uri3.URI.file(filename).toString();
1166
+ const content = import_fs.default.readFileSync(filename, "utf-8");
1167
+ return import_vscode_languageserver_textdocument.TextDocument.create(uri, "plaintext", 0, content);
1168
+ }
1169
+
1170
+ // src/service/marko/hover/OpenTagName.ts
1171
+ function OpenTagName2({
1172
+ document,
1173
+ lookup,
1174
+ parsed,
1175
+ node
1176
+ }) {
1177
+ const importer = getDocFile(document);
1178
+ const tag = node.parent;
1179
+ const range = parsed.locationAt(node);
1180
+ const tagDef = tag.nameText && lookup.getTag(tag.nameText);
1181
+ if (tagDef) {
1182
+ const completion = getTagNameCompletion({
1183
+ tag: tagDef,
1184
+ range: START_OF_FILE,
1185
+ importer
1186
+ });
1187
+ return {
1188
+ range,
1189
+ contents: completion.documentation
1190
+ };
1191
+ }
1192
+ }
1193
+
1194
+ // src/service/marko/hover/index.ts
1195
+ var handlers2 = {
1196
+ OpenTagName: OpenTagName2
1197
+ };
1198
+ var doHover = async (doc, params) => {
1199
+ var _a;
1200
+ const parsed = parse2(doc);
1201
+ const offset = doc.offsetAt(params.position);
1202
+ const node = parsed.nodeAt(offset);
1203
+ return await ((_a = handlers2[NodeType[node.type]]) == null ? void 0 : _a.call(handlers2, {
1204
+ document: doc,
1205
+ params,
1206
+ parsed,
1207
+ offset,
1208
+ node,
1209
+ code: doc.getText(),
1210
+ ...getCompilerInfo(doc)
1211
+ }));
1212
+ };
1213
+
1102
1214
  // src/service/marko/definition/OpenTagName.ts
1103
1215
  var import_path4 = __toESM(require("path"));
1104
1216
  var import_vscode_uri4 = require("vscode-uri");
@@ -1128,20 +1240,8 @@ function escape(val) {
1128
1240
  return String(val).replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
1129
1241
  }
1130
1242
 
1131
- // src/utils/utils.ts
1132
- var import_fs = __toESM(require("fs"));
1133
- var import_vscode_uri3 = require("vscode-uri");
1134
- var import_vscode_languageserver8 = require("vscode-languageserver");
1135
- var import_vscode_languageserver_textdocument = require("vscode-languageserver-textdocument");
1136
- var START_OF_FILE = import_vscode_languageserver8.Range.create(import_vscode_languageserver8.Position.create(0, 0), import_vscode_languageserver8.Position.create(0, 0));
1137
- function createTextDocument(filename) {
1138
- const uri = import_vscode_uri3.URI.file(filename).toString();
1139
- const content = import_fs.default.readFileSync(filename, "utf-8");
1140
- return import_vscode_languageserver_textdocument.TextDocument.create(uri, "plaintext", 0, content);
1141
- }
1142
-
1143
1243
  // src/service/marko/definition/OpenTagName.ts
1144
- function OpenTagName2({
1244
+ function OpenTagName3({
1145
1245
  lookup,
1146
1246
  parsed,
1147
1247
  node
@@ -1166,13 +1266,23 @@ function OpenTagName2({
1166
1266
  }
1167
1267
  if (/\/marko(?:-tag)?\.json$/.test(tagEntryFile)) {
1168
1268
  const tagDefDoc = createTextDocument(tagEntryFile);
1169
- const match = RegExpBuilder`/"(?:<${tag.nameText}>|${tag.nameText})"\s*:\s*[^\r\n,]+/g`.exec(tagDefDoc.getText());
1269
+ const match = RegExpBuilder`/"(?:<${tag.nameText}>|${tag.nameText})"\s*:\s*[^\r\n,]+/g`.exec(
1270
+ tagDefDoc.getText()
1271
+ );
1170
1272
  if (match && match.index) {
1171
- range = import_vscode_languageserver9.Range.create(tagDefDoc.positionAt(match.index), tagDefDoc.positionAt(match.index + match[0].length));
1273
+ range = import_vscode_languageserver9.Range.create(
1274
+ tagDefDoc.positionAt(match.index),
1275
+ tagDefDoc.positionAt(match.index + match[0].length)
1276
+ );
1172
1277
  }
1173
1278
  }
1174
1279
  return [
1175
- import_vscode_languageserver9.LocationLink.create(import_vscode_uri4.URI.file(tagEntryFile).toString(), range, range, parsed.locationAt(node))
1280
+ import_vscode_languageserver9.LocationLink.create(
1281
+ import_vscode_uri4.URI.file(tagEntryFile).toString(),
1282
+ range,
1283
+ range,
1284
+ parsed.locationAt(node)
1285
+ )
1176
1286
  ];
1177
1287
  }
1178
1288
 
@@ -1200,19 +1310,29 @@ function AttrName2({
1200
1310
  }
1201
1311
  if (/\/marko(?:-tag)?\.json$/.test(attrEntryFile)) {
1202
1312
  const tagDefDoc = createTextDocument(attrEntryFile);
1203
- const match = RegExpBuilder`/"@${attrName}"\s*:\s*[^\r\n,]+/g`.exec(tagDefDoc.getText());
1313
+ const match = RegExpBuilder`/"@${attrName}"\s*:\s*[^\r\n,]+/g`.exec(
1314
+ tagDefDoc.getText()
1315
+ );
1204
1316
  if (match && match.index) {
1205
- range = import_vscode_languageserver10.Range.create(tagDefDoc.positionAt(match.index), tagDefDoc.positionAt(match.index + match[0].length));
1317
+ range = import_vscode_languageserver10.Range.create(
1318
+ tagDefDoc.positionAt(match.index),
1319
+ tagDefDoc.positionAt(match.index + match[0].length)
1320
+ );
1206
1321
  }
1207
1322
  }
1208
1323
  return [
1209
- import_vscode_languageserver10.LocationLink.create(import_vscode_uri5.URI.file(attrEntryFile).toString(), range, range, parsed.locationAt(node))
1324
+ import_vscode_languageserver10.LocationLink.create(
1325
+ import_vscode_uri5.URI.file(attrEntryFile).toString(),
1326
+ range,
1327
+ range,
1328
+ parsed.locationAt(node)
1329
+ )
1210
1330
  ];
1211
1331
  }
1212
1332
 
1213
1333
  // src/service/marko/definition/index.ts
1214
- var handlers2 = {
1215
- OpenTagName: OpenTagName2,
1334
+ var handlers3 = {
1335
+ OpenTagName: OpenTagName3,
1216
1336
  AttrName: AttrName2
1217
1337
  };
1218
1338
  var findDefinition = async (doc, params) => {
@@ -1220,7 +1340,7 @@ var findDefinition = async (doc, params) => {
1220
1340
  const parsed = parse2(doc);
1221
1341
  const offset = doc.offsetAt(params.position);
1222
1342
  const node = parsed.nodeAt(offset);
1223
- return await ((_a = handlers2[NodeType[node.type]]) == null ? void 0 : _a.call(handlers2, {
1343
+ return await ((_a = handlers3[NodeType[node.type]]) == null ? void 0 : _a.call(handlers3, {
1224
1344
  document: doc,
1225
1345
  params,
1226
1346
  parsed,
@@ -1231,10 +1351,20 @@ var findDefinition = async (doc, params) => {
1231
1351
  })) || [];
1232
1352
  };
1233
1353
 
1234
- // src/service/marko/document-links/extract.ts
1354
+ // src/service/marko/document-links.ts
1235
1355
  var import_vscode_languageserver11 = require("vscode-languageserver");
1236
1356
  var import_vscode_uri6 = require("vscode-uri");
1237
1357
  var importTagReg2 = /(['"])<((?:[^\1\\>]+|\\.)*)>?\1/g;
1358
+ var cache = /* @__PURE__ */ new WeakMap();
1359
+ var findDocumentLinks = async (doc) => {
1360
+ const parsed = parse2(doc);
1361
+ let result = cache.get(parsed);
1362
+ if (!result) {
1363
+ result = extractDocumentLinks(doc, parsed, getCompilerInfo(doc).lookup);
1364
+ cache.set(parsed, result);
1365
+ }
1366
+ return result;
1367
+ };
1238
1368
  function extractDocumentLinks(doc, parsed, lookup) {
1239
1369
  if (import_vscode_uri6.URI.parse(doc.uri).scheme === "untitled") {
1240
1370
  return [];
@@ -1245,14 +1375,29 @@ function extractDocumentLinks(doc, parsed, lookup) {
1245
1375
  const read = (range) => code.slice(range.start, range.end);
1246
1376
  const visit = (node) => {
1247
1377
  switch (node.type) {
1378
+ case 14 /* AttrTag */:
1379
+ if (node.body) {
1380
+ for (const child of node.body) {
1381
+ visit(child);
1382
+ }
1383
+ }
1384
+ break;
1248
1385
  case 1 /* Tag */:
1249
1386
  if (node.attrs && node.nameText) {
1250
1387
  for (const attr of node.attrs) {
1251
1388
  if (isDocumentLinkAttr(doc, node, attr)) {
1252
- links.push(import_vscode_languageserver11.DocumentLink.create({
1253
- start: parsed.positionAt(attr.value.value.start),
1254
- end: parsed.positionAt(attr.value.value.end)
1255
- }, resolveUrl(read(attr.value.value).slice(1, -1), doc.uri)));
1389
+ const resolved = resolveUrl(
1390
+ read(attr.value.value).slice(1, -1),
1391
+ doc.uri
1392
+ );
1393
+ if (resolved) {
1394
+ links.push(
1395
+ import_vscode_languageserver11.DocumentLink.create(
1396
+ parsed.locationAt(attr.value.value),
1397
+ resolveUrl(read(attr.value.value).slice(1, -1), doc.uri)
1398
+ )
1399
+ );
1400
+ }
1256
1401
  }
1257
1402
  }
1258
1403
  }
@@ -1274,10 +1419,15 @@ function extractDocumentLinks(doc, parsed, lookup) {
1274
1419
  const tagDef = lookup.getTag(tagName);
1275
1420
  const fileForTag = tagDef && (tagDef.template || tagDef.renderer);
1276
1421
  if (fileForTag) {
1277
- links.push(import_vscode_languageserver11.DocumentLink.create({
1278
- start: parsed.positionAt(item.start + match.index),
1279
- end: parsed.positionAt(item.start + match.index + length)
1280
- }, fileForTag));
1422
+ links.push(
1423
+ import_vscode_languageserver11.DocumentLink.create(
1424
+ parsed.locationAt({
1425
+ start: item.start + match.index,
1426
+ end: item.start + match.index + length
1427
+ }),
1428
+ fileForTag
1429
+ )
1430
+ );
1281
1431
  }
1282
1432
  }
1283
1433
  }
@@ -1288,26 +1438,60 @@ function extractDocumentLinks(doc, parsed, lookup) {
1288
1438
  return links;
1289
1439
  }
1290
1440
 
1291
- // src/service/marko/document-links/index.ts
1292
- var cache = /* @__PURE__ */ new WeakMap();
1293
- var findDocumentLinks = async (doc) => {
1441
+ // src/service/marko/document-symbols.ts
1442
+ var import_vscode_uri7 = require("vscode-uri");
1443
+ var import_vscode_languageserver12 = require("vscode-languageserver");
1444
+ var cache2 = /* @__PURE__ */ new WeakMap();
1445
+ var findDocumentSymbols = async (doc) => {
1294
1446
  const parsed = parse2(doc);
1295
- let result = cache.get(parsed);
1447
+ let result = cache2.get(parsed);
1296
1448
  if (!result) {
1297
- result = extractDocumentLinks(doc, parsed, getCompilerInfo(doc).lookup);
1298
- cache.set(parsed, result);
1449
+ result = extractDocumentSymbols(doc, parsed, getCompilerInfo(doc).lookup);
1450
+ cache2.set(parsed, result);
1299
1451
  }
1300
1452
  return result;
1301
1453
  };
1454
+ function extractDocumentSymbols(doc, parsed, lookup) {
1455
+ if (import_vscode_uri7.URI.parse(doc.uri).scheme === "untitled") {
1456
+ return [];
1457
+ }
1458
+ const symbols = [];
1459
+ const { program } = parsed;
1460
+ const visit = (node) => {
1461
+ var _a, _b;
1462
+ switch (node.type) {
1463
+ case 1 /* Tag */:
1464
+ case 14 /* AttrTag */:
1465
+ symbols.push(
1466
+ import_vscode_languageserver12.SymbolInformation.create(
1467
+ (node.type === 14 /* AttrTag */ ? (_a = node.nameText) == null ? void 0 : _a.slice(node.nameText.indexOf("@")) : node.nameText) || "<${...}>",
1468
+ node.nameText && ((_b = lookup.getTag(node.nameText)) == null ? void 0 : _b.html) && import_vscode_languageserver12.SymbolKind.Property || import_vscode_languageserver12.SymbolKind.Class,
1469
+ parsed.locationAt(node),
1470
+ doc.uri
1471
+ )
1472
+ );
1473
+ if (node.body) {
1474
+ for (const child of node.body) {
1475
+ visit(child);
1476
+ }
1477
+ }
1478
+ break;
1479
+ }
1480
+ };
1481
+ for (const item of program.body) {
1482
+ visit(item);
1483
+ }
1484
+ return symbols;
1485
+ }
1302
1486
 
1303
1487
  // src/service/marko/format.ts
1304
- var import_vscode_languageserver12 = require("vscode-languageserver");
1305
- var import_vscode_uri7 = require("vscode-uri");
1488
+ var import_vscode_languageserver13 = require("vscode-languageserver");
1489
+ var import_vscode_uri8 = require("vscode-uri");
1306
1490
  var prettier = __toESM(require("prettier"));
1307
1491
  var markoPrettier = __toESM(require("prettier-plugin-marko"));
1308
1492
  var format2 = async (doc, params, cancel) => {
1309
1493
  try {
1310
- const { fsPath, scheme } = import_vscode_uri7.URI.parse(doc.uri);
1494
+ const { fsPath, scheme } = import_vscode_uri8.URI.parse(doc.uri);
1311
1495
  const text = doc.getText();
1312
1496
  const options = {
1313
1497
  parser: "marko",
@@ -1322,7 +1506,10 @@ var format2 = async (doc, params, cancel) => {
1322
1506
  if (cancel.isCancellationRequested)
1323
1507
  return;
1324
1508
  return [
1325
- import_vscode_languageserver12.TextEdit.replace(import_vscode_languageserver12.Range.create(doc.positionAt(0), doc.positionAt(text.length)), prettier.format(text, options))
1509
+ import_vscode_languageserver13.TextEdit.replace(
1510
+ import_vscode_languageserver13.Range.create(doc.positionAt(0), doc.positionAt(text.length)),
1511
+ prettier.format(text, options)
1512
+ )
1326
1513
  ];
1327
1514
  } catch (e) {
1328
1515
  displayError(e);
@@ -1333,13 +1520,15 @@ var format2 = async (doc, params, cancel) => {
1333
1520
  var marko_default = {
1334
1521
  doComplete,
1335
1522
  doValidate,
1523
+ doHover,
1336
1524
  findDefinition,
1337
1525
  findDocumentLinks,
1526
+ findDocumentSymbols,
1338
1527
  format: format2
1339
1528
  };
1340
1529
 
1341
1530
  // src/service/stylesheet/index.ts
1342
- var import_vscode_languageserver13 = require("vscode-languageserver");
1531
+ var import_vscode_languageserver14 = require("vscode-languageserver");
1343
1532
  var import_vscode_css_languageservice2 = require("vscode-css-languageservice");
1344
1533
  var import_vscode_languageserver_textdocument2 = require("vscode-languageserver-textdocument");
1345
1534
 
@@ -1445,6 +1634,13 @@ function extractStyleSheets(code, program, lookup) {
1445
1634
  const visit = (node) => {
1446
1635
  var _a, _b;
1447
1636
  switch (node.type) {
1637
+ case 14 /* AttrTag */:
1638
+ if (node.body) {
1639
+ for (const child of node.body) {
1640
+ visit(child);
1641
+ }
1642
+ }
1643
+ break;
1448
1644
  case 1 /* Tag */:
1449
1645
  if (node.nameText === "style" && node.concise && node.attrs) {
1450
1646
  const block = node.attrs.at(-1);
@@ -1501,7 +1697,7 @@ function extractStyleSheets(code, program, lookup) {
1501
1697
  }
1502
1698
 
1503
1699
  // src/service/stylesheet/index.ts
1504
- var cache2 = /* @__PURE__ */ new WeakMap();
1700
+ var cache3 = /* @__PURE__ */ new WeakMap();
1505
1701
  var services = {
1506
1702
  css: import_vscode_css_languageservice2.getCSSLanguageService,
1507
1703
  less: import_vscode_css_languageservice2.getLESSLanguageService,
@@ -1521,12 +1717,21 @@ var StyleSheetService = {
1521
1717
  if (generatedOffset === void 0)
1522
1718
  continue;
1523
1719
  const { service: service2, virtualDoc } = info;
1524
- const result = await service2.doComplete2(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed, { resolveReference: resolveUrl });
1720
+ const result = await service2.doComplete2(
1721
+ virtualDoc,
1722
+ virtualDoc.positionAt(generatedOffset),
1723
+ info.parsed,
1724
+ { resolveReference: resolveUrl }
1725
+ );
1525
1726
  if (result.itemDefaults) {
1526
1727
  const { editRange } = result.itemDefaults;
1527
1728
  if (editRange) {
1528
1729
  if ("start" in editRange) {
1529
- result.itemDefaults.editRange = getSourceRange(doc, info, editRange);
1730
+ result.itemDefaults.editRange = getSourceRange(
1731
+ doc,
1732
+ info,
1733
+ editRange
1734
+ );
1530
1735
  } else {
1531
1736
  editRange.insert = getSourceRange(doc, info, editRange.insert);
1532
1737
  editRange.replace = getSourceRange(doc, info, editRange.replace);
@@ -1538,12 +1743,16 @@ var StyleSheetService = {
1538
1743
  item.textEdit = getSourceInsertReplaceEdit(doc, info, item.textEdit);
1539
1744
  }
1540
1745
  if (item.additionalTextEdits) {
1541
- item.additionalTextEdits = getSourceEdits(doc, info, item.additionalTextEdits);
1746
+ item.additionalTextEdits = getSourceEdits(
1747
+ doc,
1748
+ info,
1749
+ item.additionalTextEdits
1750
+ );
1542
1751
  }
1543
1752
  }
1544
1753
  return result;
1545
1754
  }
1546
- return import_vscode_languageserver13.CompletionList.create([], true);
1755
+ return import_vscode_languageserver14.CompletionList.create([], true);
1547
1756
  },
1548
1757
  findDefinition(doc, params) {
1549
1758
  const infoByExt = getStyleSheetInfo(doc);
@@ -1554,7 +1763,11 @@ var StyleSheetService = {
1554
1763
  if (generatedOffset === void 0)
1555
1764
  continue;
1556
1765
  const { service: service2, virtualDoc } = info;
1557
- const result = service2.findDefinition(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed);
1766
+ const result = service2.findDefinition(
1767
+ virtualDoc,
1768
+ virtualDoc.positionAt(generatedOffset),
1769
+ info.parsed
1770
+ );
1558
1771
  if (result) {
1559
1772
  const range = getSourceRange(doc, info, result.range);
1560
1773
  if (range) {
@@ -1577,7 +1790,11 @@ var StyleSheetService = {
1577
1790
  continue;
1578
1791
  const { service: service2, virtualDoc } = info;
1579
1792
  const result = [];
1580
- for (const location of service2.findReferences(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed)) {
1793
+ for (const location of service2.findReferences(
1794
+ virtualDoc,
1795
+ virtualDoc.positionAt(generatedOffset),
1796
+ info.parsed
1797
+ )) {
1581
1798
  const range = getSourceRange(doc, info, location.range);
1582
1799
  if (range) {
1583
1800
  result.push({
@@ -1589,13 +1806,46 @@ var StyleSheetService = {
1589
1806
  return result.length ? result : void 0;
1590
1807
  }
1591
1808
  },
1809
+ findDocumentSymbols(doc) {
1810
+ const infoByExt = getStyleSheetInfo(doc);
1811
+ const result = [];
1812
+ for (const ext in infoByExt) {
1813
+ const info = infoByExt[ext];
1814
+ const { service: service2, virtualDoc } = info;
1815
+ for (const symbol of service2.findDocumentSymbols(
1816
+ virtualDoc,
1817
+ info.parsed
1818
+ )) {
1819
+ if (symbol.location.uri === doc.uri) {
1820
+ const range = getSourceRange(doc, info, symbol.location.range);
1821
+ if (range) {
1822
+ result.push({
1823
+ kind: symbol.kind,
1824
+ name: symbol.name,
1825
+ tags: symbol.tags,
1826
+ deprecated: symbol.deprecated,
1827
+ containerName: symbol.containerName,
1828
+ location: { uri: doc.uri, range }
1829
+ });
1830
+ }
1831
+ } else {
1832
+ result.push(symbol);
1833
+ }
1834
+ }
1835
+ }
1836
+ return result.length ? result : void 0;
1837
+ },
1592
1838
  async findDocumentLinks(doc) {
1593
1839
  const infoByExt = getStyleSheetInfo(doc);
1594
1840
  const result = [];
1595
1841
  for (const ext in infoByExt) {
1596
1842
  const info = infoByExt[ext];
1597
1843
  const { service: service2, virtualDoc } = info;
1598
- for (const link of await service2.findDocumentLinks2(virtualDoc, info.parsed, { resolveReference: resolveUrl })) {
1844
+ for (const link of await service2.findDocumentLinks2(
1845
+ virtualDoc,
1846
+ info.parsed,
1847
+ { resolveReference: resolveUrl }
1848
+ )) {
1599
1849
  const range = getSourceRange(doc, info, link.range);
1600
1850
  if (range) {
1601
1851
  result.push({
@@ -1619,7 +1869,11 @@ var StyleSheetService = {
1619
1869
  continue;
1620
1870
  const { service: service2, virtualDoc } = info;
1621
1871
  const result = [];
1622
- for (const highlight of service2.findDocumentHighlights(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed)) {
1872
+ for (const highlight of service2.findDocumentHighlights(
1873
+ virtualDoc,
1874
+ virtualDoc.positionAt(generatedOffset),
1875
+ info.parsed
1876
+ )) {
1623
1877
  const range = getSourceRange(doc, info, highlight.range);
1624
1878
  if (range) {
1625
1879
  result.push({
@@ -1637,7 +1891,10 @@ var StyleSheetService = {
1637
1891
  for (const ext in infoByExt) {
1638
1892
  const info = infoByExt[ext];
1639
1893
  const { service: service2, virtualDoc } = info;
1640
- for (const colorInfo of service2.findDocumentColors(virtualDoc, info.parsed)) {
1894
+ for (const colorInfo of service2.findDocumentColors(
1895
+ virtualDoc,
1896
+ info.parsed
1897
+ )) {
1641
1898
  const range = getSourceRange(doc, info, colorInfo.range);
1642
1899
  if (range) {
1643
1900
  result.push({
@@ -1657,12 +1914,22 @@ var StyleSheetService = {
1657
1914
  const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
1658
1915
  if (generatedOffsetStart === void 0)
1659
1916
  continue;
1660
- const generatedOffsetEnd = info.generatedOffsetAt(doc.offsetAt(params.range.end));
1917
+ const generatedOffsetEnd = info.generatedOffsetAt(
1918
+ doc.offsetAt(params.range.end)
1919
+ );
1661
1920
  if (generatedOffsetEnd === void 0)
1662
1921
  continue;
1663
1922
  const { service: service2, virtualDoc } = info;
1664
1923
  const result = [];
1665
- for (const colorPresentation of service2.getColorPresentations(virtualDoc, info.parsed, params.color, import_vscode_languageserver13.Range.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)))) {
1924
+ for (const colorPresentation of service2.getColorPresentations(
1925
+ virtualDoc,
1926
+ info.parsed,
1927
+ params.color,
1928
+ import_vscode_languageserver14.Range.create(
1929
+ virtualDoc.positionAt(generatedOffsetStart),
1930
+ virtualDoc.positionAt(generatedOffsetEnd)
1931
+ )
1932
+ )) {
1666
1933
  const textEdit = colorPresentation.textEdit && getSourceEdit(doc, info, colorPresentation.textEdit);
1667
1934
  const additionalTextEdits = colorPresentation.additionalTextEdits && getSourceEdits(doc, info, colorPresentation.additionalTextEdits);
1668
1935
  if (textEdit || additionalTextEdits) {
@@ -1685,7 +1952,11 @@ var StyleSheetService = {
1685
1952
  if (generatedOffset === void 0)
1686
1953
  continue;
1687
1954
  const { service: service2, virtualDoc } = info;
1688
- const result = service2.doHover(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed);
1955
+ const result = service2.doHover(
1956
+ virtualDoc,
1957
+ virtualDoc.positionAt(generatedOffset),
1958
+ info.parsed
1959
+ );
1689
1960
  if (result) {
1690
1961
  if (result.range) {
1691
1962
  const range = getSourceRange(doc, info, result.range);
@@ -1710,7 +1981,12 @@ var StyleSheetService = {
1710
1981
  if (generatedOffset === void 0)
1711
1982
  continue;
1712
1983
  const { service: service2, virtualDoc } = info;
1713
- const result = service2.doRename(virtualDoc, virtualDoc.positionAt(generatedOffset), params.newName, info.parsed);
1984
+ const result = service2.doRename(
1985
+ virtualDoc,
1986
+ virtualDoc.positionAt(generatedOffset),
1987
+ params.newName,
1988
+ info.parsed
1989
+ );
1714
1990
  if (result.changes) {
1715
1991
  for (const uri in result.changes) {
1716
1992
  if (uri === doc.uri) {
@@ -1720,7 +1996,7 @@ var StyleSheetService = {
1720
1996
  }
1721
1997
  if (result.documentChanges) {
1722
1998
  for (const change of result.documentChanges) {
1723
- if (import_vscode_languageserver13.TextDocumentEdit.is(change)) {
1999
+ if (import_vscode_languageserver14.TextDocumentEdit.is(change)) {
1724
2000
  if (change.textDocument.uri === doc.uri) {
1725
2001
  change.edits = getSourceEdits(doc, info, change.edits) || [];
1726
2002
  }
@@ -1739,11 +2015,21 @@ var StyleSheetService = {
1739
2015
  const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
1740
2016
  if (generatedOffsetStart === void 0)
1741
2017
  continue;
1742
- const generatedOffsetEnd = info.generatedOffsetAt(doc.offsetAt(params.range.end));
2018
+ const generatedOffsetEnd = info.generatedOffsetAt(
2019
+ doc.offsetAt(params.range.end)
2020
+ );
1743
2021
  if (generatedOffsetEnd === void 0)
1744
2022
  continue;
1745
2023
  const { service: service2, virtualDoc } = info;
1746
- const result = service2.doCodeActions(virtualDoc, import_vscode_languageserver13.Range.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)), params.context, info.parsed);
2024
+ const result = service2.doCodeActions(
2025
+ virtualDoc,
2026
+ import_vscode_languageserver14.Range.create(
2027
+ virtualDoc.positionAt(generatedOffsetStart),
2028
+ virtualDoc.positionAt(generatedOffsetEnd)
2029
+ ),
2030
+ params.context,
2031
+ info.parsed
2032
+ );
1747
2033
  for (const command of result) {
1748
2034
  const edits = (_a = command.arguments) == null ? void 0 : _a[2];
1749
2035
  if (edits && Array.isArray(edits) && isTextEdit(edits[0])) {
@@ -1758,7 +2044,10 @@ var StyleSheetService = {
1758
2044
  const result = [];
1759
2045
  for (const ext in infoByExt) {
1760
2046
  const info = infoByExt[ext];
1761
- for (const diag of info.service.doValidation(info.virtualDoc, info.parsed)) {
2047
+ for (const diag of info.service.doValidation(
2048
+ info.virtualDoc,
2049
+ info.parsed
2050
+ )) {
1762
2051
  const range = getSourceRange(doc, info, diag.range);
1763
2052
  if (range) {
1764
2053
  diag.range = range;
@@ -1828,9 +2117,13 @@ function getSourceRange(doc, info, range) {
1828
2117
  function getStyleSheetInfo(doc) {
1829
2118
  var _a;
1830
2119
  const parsed = parse2(doc);
1831
- let cached = cache2.get(parsed);
2120
+ let cached = cache3.get(parsed);
1832
2121
  if (!cached) {
1833
- const results = extractStyleSheets(doc.getText(), parsed.program, getCompilerInfo(doc).lookup);
2122
+ const results = extractStyleSheets(
2123
+ doc.getText(),
2124
+ parsed.program,
2125
+ getCompilerInfo(doc).lookup
2126
+ );
1834
2127
  cached = {};
1835
2128
  for (const ext in results) {
1836
2129
  const service2 = (_a = services[ext]) == null ? void 0 : _a.call(services, {
@@ -1840,7 +2133,12 @@ function getStyleSheetInfo(doc) {
1840
2133
  if (!service2)
1841
2134
  continue;
1842
2135
  const { generated, sourceOffsetAt, generatedOffsetAt } = results[ext];
1843
- const virtualDoc = import_vscode_languageserver_textdocument2.TextDocument.create(doc.uri, "css", doc.version, generated);
2136
+ const virtualDoc = import_vscode_languageserver_textdocument2.TextDocument.create(
2137
+ doc.uri,
2138
+ "css",
2139
+ doc.version,
2140
+ generated
2141
+ );
1844
2142
  cached[ext] = {
1845
2143
  service: service2,
1846
2144
  virtualDoc,
@@ -1849,7 +2147,7 @@ function getStyleSheetInfo(doc) {
1849
2147
  parsed: service2.parseStylesheet(virtualDoc)
1850
2148
  };
1851
2149
  }
1852
- cache2.set(parsed, cached);
2150
+ cache3.set(parsed, cached);
1853
2151
  }
1854
2152
  return cached;
1855
2153
  }
@@ -1870,10 +2168,12 @@ var service = {
1870
2168
  let items;
1871
2169
  let isIncomplete = false;
1872
2170
  try {
1873
- for (const pending of plugins.map((plugin) => {
1874
- var _a;
1875
- return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
1876
- })) {
2171
+ for (const pending of plugins.map(
2172
+ (plugin) => {
2173
+ var _a;
2174
+ return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2175
+ }
2176
+ )) {
1877
2177
  const cur = await pending;
1878
2178
  if (cancel.isCancellationRequested)
1879
2179
  return;
@@ -1893,16 +2193,18 @@ var service = {
1893
2193
  displayError(err);
1894
2194
  }
1895
2195
  if (items) {
1896
- return import_vscode_languageserver14.CompletionList.create(items, isIncomplete);
2196
+ return import_vscode_languageserver15.CompletionList.create(items, isIncomplete);
1897
2197
  }
1898
2198
  },
1899
2199
  async findDefinition(doc, params, cancel) {
1900
2200
  let result;
1901
2201
  try {
1902
- for (const pending of plugins.map((plugin) => {
1903
- var _a;
1904
- return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
1905
- })) {
2202
+ for (const pending of plugins.map(
2203
+ (plugin) => {
2204
+ var _a;
2205
+ return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2206
+ }
2207
+ )) {
1906
2208
  const cur = await pending;
1907
2209
  if (cancel.isCancellationRequested)
1908
2210
  return;
@@ -1917,10 +2219,32 @@ var service = {
1917
2219
  async findReferences(doc, params, cancel) {
1918
2220
  let result;
1919
2221
  try {
1920
- for (const pending of plugins.map((plugin) => {
1921
- var _a;
1922
- return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
1923
- })) {
2222
+ for (const pending of plugins.map(
2223
+ (plugin) => {
2224
+ var _a;
2225
+ return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2226
+ }
2227
+ )) {
2228
+ const cur = await pending;
2229
+ if (cancel.isCancellationRequested)
2230
+ return;
2231
+ if (cur)
2232
+ result = result ? result.concat(cur) : cur;
2233
+ }
2234
+ } catch (err) {
2235
+ displayError(err);
2236
+ }
2237
+ return result;
2238
+ },
2239
+ async findDocumentSymbols(doc, params, cancel) {
2240
+ let result;
2241
+ try {
2242
+ for (const pending of plugins.map(
2243
+ (plugin) => {
2244
+ var _a;
2245
+ return (_a = plugin.findDocumentSymbols) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2246
+ }
2247
+ )) {
1924
2248
  const cur = await pending;
1925
2249
  if (cancel.isCancellationRequested)
1926
2250
  return;
@@ -1935,10 +2259,12 @@ var service = {
1935
2259
  async findDocumentLinks(doc, params, cancel) {
1936
2260
  let result;
1937
2261
  try {
1938
- for (const pending of plugins.map((plugin) => {
1939
- var _a;
1940
- return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
1941
- })) {
2262
+ for (const pending of plugins.map(
2263
+ (plugin) => {
2264
+ var _a;
2265
+ return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2266
+ }
2267
+ )) {
1942
2268
  const cur = await pending;
1943
2269
  if (cancel.isCancellationRequested)
1944
2270
  return;
@@ -1953,10 +2279,12 @@ var service = {
1953
2279
  async findDocumentHighlights(doc, params, cancel) {
1954
2280
  let result;
1955
2281
  try {
1956
- for (const pending of plugins.map((plugin) => {
1957
- var _a;
1958
- return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
1959
- })) {
2282
+ for (const pending of plugins.map(
2283
+ (plugin) => {
2284
+ var _a;
2285
+ return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2286
+ }
2287
+ )) {
1960
2288
  const cur = await pending;
1961
2289
  if (cancel.isCancellationRequested)
1962
2290
  return;
@@ -1971,10 +2299,12 @@ var service = {
1971
2299
  async findDocumentColors(doc, params, cancel) {
1972
2300
  let result;
1973
2301
  try {
1974
- for (const pending of plugins.map((plugin) => {
1975
- var _a;
1976
- return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
1977
- })) {
2302
+ for (const pending of plugins.map(
2303
+ (plugin) => {
2304
+ var _a;
2305
+ return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2306
+ }
2307
+ )) {
1978
2308
  const cur = await pending;
1979
2309
  if (cancel.isCancellationRequested)
1980
2310
  return;
@@ -1989,10 +2319,12 @@ var service = {
1989
2319
  async getColorPresentations(doc, params, cancel) {
1990
2320
  let result;
1991
2321
  try {
1992
- for (const pending of plugins.map((plugin) => {
1993
- var _a;
1994
- return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
1995
- })) {
2322
+ for (const pending of plugins.map(
2323
+ (plugin) => {
2324
+ var _a;
2325
+ return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2326
+ }
2327
+ )) {
1996
2328
  const cur = await pending;
1997
2329
  if (cancel.isCancellationRequested)
1998
2330
  return;
@@ -2023,10 +2355,12 @@ var service = {
2023
2355
  let changeAnnotations;
2024
2356
  let documentChanges;
2025
2357
  try {
2026
- for (const pending of plugins.map((plugin) => {
2027
- var _a;
2028
- return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2029
- })) {
2358
+ for (const pending of plugins.map(
2359
+ (plugin) => {
2360
+ var _a;
2361
+ return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2362
+ }
2363
+ )) {
2030
2364
  const cur = await pending;
2031
2365
  if (cancel.isCancellationRequested)
2032
2366
  return;
@@ -2066,10 +2400,12 @@ var service = {
2066
2400
  async doCodeActions(doc, params, cancel) {
2067
2401
  let result;
2068
2402
  try {
2069
- for (const pending of plugins.map((plugin) => {
2070
- var _a;
2071
- return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2072
- })) {
2403
+ for (const pending of plugins.map(
2404
+ (plugin) => {
2405
+ var _a;
2406
+ return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2407
+ }
2408
+ )) {
2073
2409
  const cur = await pending;
2074
2410
  if (cancel.isCancellationRequested)
2075
2411
  return;
@@ -2132,6 +2468,7 @@ connection2.onInitialize(async (params) => {
2132
2468
  documentLinkProvider: { resolveProvider: false },
2133
2469
  colorProvider: true,
2134
2470
  documentHighlightProvider: true,
2471
+ documentSymbolProvider: true,
2135
2472
  completionProvider: {
2136
2473
  triggerCharacters: [
2137
2474
  ".",
@@ -2166,37 +2503,88 @@ documents.onDidChangeContent(({ document }) => {
2166
2503
  clearCompilerCache(document);
2167
2504
  });
2168
2505
  connection2.onCompletion(async (params, cancel) => {
2169
- return await service.doComplete(documents.get(params.textDocument.uri), params, cancel) || null;
2506
+ return await service.doComplete(
2507
+ documents.get(params.textDocument.uri),
2508
+ params,
2509
+ cancel
2510
+ ) || null;
2170
2511
  });
2171
2512
  connection2.onDefinition(async (params, cancel) => {
2172
- return await service.findDefinition(documents.get(params.textDocument.uri), params, cancel) || null;
2513
+ return await service.findDefinition(
2514
+ documents.get(params.textDocument.uri),
2515
+ params,
2516
+ cancel
2517
+ ) || null;
2173
2518
  });
2174
2519
  connection2.onReferences(async (params, cancel) => {
2175
- return await service.findReferences(documents.get(params.textDocument.uri), params, cancel) || null;
2520
+ return await service.findReferences(
2521
+ documents.get(params.textDocument.uri),
2522
+ params,
2523
+ cancel
2524
+ ) || null;
2176
2525
  });
2177
2526
  connection2.onDocumentLinks(async (params, cancel) => {
2178
- return await service.findDocumentLinks(documents.get(params.textDocument.uri), params, cancel) || null;
2527
+ return await service.findDocumentLinks(
2528
+ documents.get(params.textDocument.uri),
2529
+ params,
2530
+ cancel
2531
+ ) || null;
2532
+ });
2533
+ connection2.onDocumentSymbol(async (params, cancel) => {
2534
+ return await service.findDocumentSymbols(
2535
+ documents.get(params.textDocument.uri),
2536
+ params,
2537
+ cancel
2538
+ ) || null;
2179
2539
  });
2180
2540
  connection2.onDocumentHighlight(async (params, cancel) => {
2181
- return await service.findDocumentHighlights(documents.get(params.textDocument.uri), params, cancel) || null;
2541
+ return await service.findDocumentHighlights(
2542
+ documents.get(params.textDocument.uri),
2543
+ params,
2544
+ cancel
2545
+ ) || null;
2182
2546
  });
2183
2547
  connection2.onDocumentColor(async (params, cancel) => {
2184
- return await service.findDocumentColors(documents.get(params.textDocument.uri), params, cancel) || null;
2548
+ return await service.findDocumentColors(
2549
+ documents.get(params.textDocument.uri),
2550
+ params,
2551
+ cancel
2552
+ ) || null;
2185
2553
  });
2186
2554
  connection2.onColorPresentation(async (params, cancel) => {
2187
- return await service.getColorPresentations(documents.get(params.textDocument.uri), params, cancel) || null;
2555
+ return await service.getColorPresentations(
2556
+ documents.get(params.textDocument.uri),
2557
+ params,
2558
+ cancel
2559
+ ) || null;
2188
2560
  });
2189
2561
  connection2.onHover(async (params, cancel) => {
2190
- return await service.doHover(documents.get(params.textDocument.uri), params, cancel) || null;
2562
+ return await service.doHover(
2563
+ documents.get(params.textDocument.uri),
2564
+ params,
2565
+ cancel
2566
+ ) || null;
2191
2567
  });
2192
2568
  connection2.onRenameRequest(async (params, cancel) => {
2193
- return await service.doRename(documents.get(params.textDocument.uri), params, cancel) || null;
2569
+ return await service.doRename(
2570
+ documents.get(params.textDocument.uri),
2571
+ params,
2572
+ cancel
2573
+ ) || null;
2194
2574
  });
2195
2575
  connection2.onCodeAction(async (params, cancel) => {
2196
- return await service.doCodeActions(documents.get(params.textDocument.uri), params, cancel) || null;
2576
+ return await service.doCodeActions(
2577
+ documents.get(params.textDocument.uri),
2578
+ params,
2579
+ cancel
2580
+ ) || null;
2197
2581
  });
2198
2582
  connection2.onDocumentFormatting(async (params, cancel) => {
2199
- return await service.format(documents.get(params.textDocument.uri), params, cancel) || null;
2583
+ return await service.format(
2584
+ documents.get(params.textDocument.uri),
2585
+ params,
2586
+ cancel
2587
+ ) || null;
2200
2588
  });
2201
2589
  function validateDocs() {
2202
2590
  queueDiagnostic();
@@ -2208,15 +2596,17 @@ function validateDocs() {
2208
2596
  function queueDiagnostic() {
2209
2597
  clearTimeout(diagnosticTimeout);
2210
2598
  const id = diagnosticTimeout = setTimeout(async () => {
2211
- const results = await Promise.all(documents.all().map(async (doc) => {
2212
- if (!pendingDiags.delete(doc))
2213
- return;
2214
- const prevDiag = prevDiags.get(doc) || [];
2215
- const nextDiag = await service.doValidate(doc) || [];
2216
- if ((0, import_util2.isDeepStrictEqual)(prevDiag, nextDiag))
2217
- return;
2218
- return [doc, nextDiag];
2219
- }));
2599
+ const results = await Promise.all(
2600
+ documents.all().map(async (doc) => {
2601
+ if (!pendingDiags.delete(doc))
2602
+ return;
2603
+ const prevDiag = prevDiags.get(doc) || [];
2604
+ const nextDiag = await service.doValidate(doc) || [];
2605
+ if ((0, import_util2.isDeepStrictEqual)(prevDiag, nextDiag))
2606
+ return;
2607
+ return [doc, nextDiag];
2608
+ })
2609
+ );
2220
2610
  if (id === diagnosticTimeout) {
2221
2611
  for (const result of results) {
2222
2612
  if (result) {