@marko/language-server 0.12.13 → 0.12.16

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
@@ -276,12 +276,14 @@ function parse(source) {
276
276
  }
277
277
  }
278
278
  program.body.length = i + 1;
279
- program.static.push(curParent = {
280
- type: 20 /* Statement */,
281
- parent: program,
282
- start: range.start,
283
- end: UNFINISHED
284
- });
279
+ program.static.push(
280
+ curParent = {
281
+ type: 20 /* Statement */,
282
+ parent: program,
283
+ start: range.start,
284
+ end: UNFINISHED
285
+ }
286
+ );
285
287
  return curBodyType = TagType.statement;
286
288
  }
287
289
  default:
@@ -408,15 +410,18 @@ function parse(source) {
408
410
  start: range.start,
409
411
  end: range.end
410
412
  };
411
- pushAttr(parent, curAttr = name.parent = {
412
- type: 8 /* AttrNamed */,
413
+ pushAttr(
413
414
  parent,
414
- name,
415
- value: void 0,
416
- args: void 0,
417
- start: range.start,
418
- end: range.end
419
- });
415
+ curAttr = name.parent = {
416
+ type: 8 /* AttrNamed */,
417
+ parent,
418
+ name,
419
+ value: void 0,
420
+ args: void 0,
421
+ start: range.start,
422
+ end: range.end
423
+ }
424
+ );
420
425
  },
421
426
  onAttrArgs(range) {
422
427
  curAttr.args = {
@@ -576,7 +581,11 @@ function loadCompilerInfo(dir) {
576
581
  let compiler = builtinCompiler;
577
582
  if (pkg && /^5\./.test(pkg.version)) {
578
583
  try {
579
- let checkTranslator = [].concat(Object.keys(pkg.dependencies), Object.keys(pkg.peerDependencies), Object.keys(pkg.devDependencies)).find((name) => /^marko$|^(@\/marko\/|marko-)translator-/.test(name));
584
+ let checkTranslator = [].concat(
585
+ Object.keys(pkg.dependencies),
586
+ Object.keys(pkg.peerDependencies),
587
+ Object.keys(pkg.devDependencies)
588
+ ).find((name) => /^marko$|^(@\/marko\/|marko-)translator-/.test(name));
580
589
  if (checkTranslator === "marko" || !checkTranslator) {
581
590
  checkTranslator = __require(resolveFrom(dir, "@marko/compiler/config")).translator;
582
591
  }
@@ -665,10 +674,13 @@ ${closingTagStr}`
665
674
  label: closingTagStr,
666
675
  kind: CompletionItemKind.Class,
667
676
  insertTextFormat: InsertTextFormat.Snippet,
668
- textEdit: TextEdit.replace(parsed.locationAt({
669
- start,
670
- end
671
- }), closingTagStr)
677
+ textEdit: TextEdit.replace(
678
+ parsed.locationAt({
679
+ start,
680
+ end
681
+ }),
682
+ closingTagStr
683
+ )
672
684
  }
673
685
  ];
674
686
  }
@@ -695,7 +707,9 @@ function getTagNameCompletion({
695
707
  let label = tag.isNestedTag ? `@${tag.name}` : tag.name;
696
708
  const fileForTag = tag.template || tag.renderer || tag.filePath;
697
709
  const fileURIForTag = URI2.file(fileForTag).toString();
698
- const nodeModuleMatch = /\/node_modules\/((?:@[^/]+\/)?[^/]+)/.exec(fileForTag);
710
+ const nodeModuleMatch = /\/node_modules\/((?:@[^/]+\/)?[^/]+)/.exec(
711
+ fileForTag
712
+ );
699
713
  const nodeModuleName = nodeModuleMatch && nodeModuleMatch[1];
700
714
  const isCoreTag = /^@?marko[/-]/.test(tag.taglibId) || nodeModuleName === "marko";
701
715
  const documentation = {
@@ -758,12 +772,14 @@ function OpenTagName({
758
772
  for (const key in nestedTags) {
759
773
  if (key !== "*") {
760
774
  const tag2 = nestedTags[key];
761
- result.push(getTagNameCompletion({
762
- tag: tag2,
763
- range,
764
- importer,
765
- showAutoComplete: true
766
- }));
775
+ result.push(
776
+ getTagNameCompletion({
777
+ tag: tag2,
778
+ range,
779
+ importer,
780
+ showAutoComplete: true
781
+ })
782
+ );
767
783
  }
768
784
  }
769
785
  }
@@ -771,12 +787,14 @@ function OpenTagName({
771
787
  const skipStatements = !(tag.concise && tag.parent.type === 0 /* Program */);
772
788
  for (const tag2 of lookup.getTagsSorted()) {
773
789
  if (!(tag2.name === "*" || tag2.isNestedTag || skipStatements && ((_a = tag2.parseOptions) == null ? void 0 : _a.statement) || tag2.name[0] === "_" && /^@?marko[/-]|[\\/]node_modules[\\/]/.test(tag2.filePath))) {
774
- result.push(getTagNameCompletion({
775
- tag: tag2,
776
- range,
777
- importer,
778
- showAutoComplete: true
779
- }));
790
+ result.push(
791
+ getTagNameCompletion({
792
+ tag: tag2,
793
+ range,
794
+ importer,
795
+ showAutoComplete: true
796
+ })
797
+ );
780
798
  }
781
799
  }
782
800
  }
@@ -820,10 +838,12 @@ function AttrName({
820
838
  }
821
839
  }
822
840
  const completions = [];
823
- const attrNameLoc = parsed.locationAt(hasModifier ? {
824
- start: node.start,
825
- end: node.start + name.length
826
- } : node);
841
+ const attrNameLoc = parsed.locationAt(
842
+ hasModifier ? {
843
+ start: node.start,
844
+ end: node.start + name.length
845
+ } : node
846
+ );
827
847
  const tagName = node.parent.parent.nameText || "";
828
848
  const tagDef = tagName && lookup.getTag(tagName);
829
849
  const nestedTagAttrs = {};
@@ -961,7 +981,11 @@ async function readDirectory(uri) {
961
981
  try {
962
982
  const entries = await fs.readdir(fileURLToPath(uri));
963
983
  const base = uri.at(-1) === "/" ? uri : `${uri}/`;
964
- return (await Promise.all(entries.map(async (entry) => [entry, (await stat(new URL(entry, base).toString())).type]))).filter(([, type]) => type !== FileType.Unknown);
984
+ return (await Promise.all(
985
+ entries.map(
986
+ async (entry) => [entry, (await stat(new URL(entry, base).toString())).type]
987
+ )
988
+ )).filter(([, type]) => type !== FileType.Unknown);
965
989
  } catch {
966
990
  return [];
967
991
  }
@@ -1005,22 +1029,27 @@ async function AttrValue({
1005
1029
  if (uri) {
1006
1030
  const result = [];
1007
1031
  const curFile = req === "." ? path3.basename(document.uri) : void 0;
1008
- const replaceRange = Range2.create(document.positionAt(start + segmentStart + 1), document.positionAt(start + rawValue.length));
1032
+ const replaceRange = Range2.create(
1033
+ document.positionAt(start + segmentStart + 1),
1034
+ document.positionAt(start + rawValue.length)
1035
+ );
1009
1036
  for (const [entry, type] of await file_system_default.readDirectory(uri)) {
1010
1037
  if (entry[0] !== "." && entry !== curFile) {
1011
- result.push(type === FileType.Directory ? {
1012
- label: `${entry}/`,
1013
- kind: CompletionItemKind4.Folder,
1014
- textEdit: TextEdit4.replace(replaceRange, `${entry}/`),
1015
- command: {
1016
- title: "Suggest",
1017
- command: "editor.action.triggerSuggest"
1038
+ result.push(
1039
+ type === FileType.Directory ? {
1040
+ label: `${entry}/`,
1041
+ kind: CompletionItemKind4.Folder,
1042
+ textEdit: TextEdit4.replace(replaceRange, `${entry}/`),
1043
+ command: {
1044
+ title: "Suggest",
1045
+ command: "editor.action.triggerSuggest"
1046
+ }
1047
+ } : {
1048
+ label: entry,
1049
+ kind: CompletionItemKind4.File,
1050
+ textEdit: TextEdit4.replace(replaceRange, entry)
1018
1051
  }
1019
- } : {
1020
- label: entry,
1021
- kind: CompletionItemKind4.File,
1022
- textEdit: TextEdit4.replace(replaceRange, entry)
1023
- });
1052
+ );
1024
1053
  }
1025
1054
  }
1026
1055
  return result;
@@ -1080,20 +1109,23 @@ var doComplete = async (doc, params) => {
1080
1109
  const parsed = parse2(doc);
1081
1110
  const offset = doc.offsetAt(params.position);
1082
1111
  const node = parsed.nodeAt(offset);
1083
- return CompletionList.create(await ((_a = handlers[NodeType[node.type]]) == null ? void 0 : _a.call(handlers, {
1084
- document: doc,
1085
- params,
1086
- parsed,
1087
- offset,
1088
- node,
1089
- code: doc.getText(),
1090
- ...getCompilerInfo(doc)
1091
- })) || [], true);
1112
+ return CompletionList.create(
1113
+ await ((_a = handlers[NodeType[node.type]]) == null ? void 0 : _a.call(handlers, {
1114
+ document: doc,
1115
+ params,
1116
+ parsed,
1117
+ offset,
1118
+ node,
1119
+ code: doc.getText(),
1120
+ ...getCompilerInfo(doc)
1121
+ })) || [],
1122
+ true
1123
+ );
1092
1124
  };
1093
1125
 
1094
1126
  // src/service/marko/validate.ts
1095
- import { Diagnostic, DiagnosticSeverity, Range as Range3 } from "vscode-languageserver";
1096
- var markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
1127
+ import { DiagnosticSeverity } from "vscode-languageserver";
1128
+ var markoErrorRegExp = /^(.+?)\.marko(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
1097
1129
  var doValidate = (doc) => {
1098
1130
  const fsPath = getDocFile(doc);
1099
1131
  const diagnostics = [];
@@ -1104,15 +1136,33 @@ var doValidate = (doc) => {
1104
1136
  translator,
1105
1137
  code: false,
1106
1138
  output: "source",
1107
- sourceMaps: false
1139
+ sourceMaps: false,
1140
+ babelConfig: {
1141
+ caller: {
1142
+ name: "@marko/language-server",
1143
+ supportsStaticESM: true,
1144
+ supportsDynamicImport: true,
1145
+ supportsTopLevelAwait: true,
1146
+ supportsExportNamespaceFrom: true
1147
+ }
1148
+ }
1108
1149
  });
1109
1150
  } catch (e) {
1110
1151
  let match;
1111
1152
  while (match = markoErrorRegExp.exec(e.message)) {
1112
- const [, fileName, rawLine, rawCol, msg] = match;
1113
- const line = (parseInt(rawLine, 10) || 1) - 1;
1114
- const col = (parseInt(rawCol, 10) || 1) - 1;
1115
- diagnostics.push(Diagnostic.create(Range3.create(line, col, line, col), msg, DiagnosticSeverity.Error, void 0, fileName));
1153
+ const [, , rawLine, rawCol, message] = match;
1154
+ const pos = {
1155
+ line: (parseInt(rawLine, 10) || 1) - 1,
1156
+ character: (parseInt(rawCol, 10) || 1) - 1
1157
+ };
1158
+ diagnostics.push({
1159
+ range: { start: pos, end: pos },
1160
+ source: "marko",
1161
+ code: void 0,
1162
+ tags: void 0,
1163
+ severity: DiagnosticSeverity.Error,
1164
+ message
1165
+ });
1116
1166
  }
1117
1167
  }
1118
1168
  return diagnostics;
@@ -1121,9 +1171,12 @@ var doValidate = (doc) => {
1121
1171
  // src/utils/utils.ts
1122
1172
  import fs2 from "fs";
1123
1173
  import { URI as URI3 } from "vscode-uri";
1124
- import { Position, Range as Range4 } from "vscode-languageserver";
1174
+ import { Position, Range as Range3 } from "vscode-languageserver";
1125
1175
  import { TextDocument } from "vscode-languageserver-textdocument";
1126
- var START_OF_FILE = Range4.create(Position.create(0, 0), Position.create(0, 0));
1176
+ var START_OF_FILE = Range3.create(
1177
+ Position.create(0, 0),
1178
+ Position.create(0, 0)
1179
+ );
1127
1180
  function createTextDocument(filename) {
1128
1181
  const uri = URI3.file(filename).toString();
1129
1182
  const content = fs2.readFileSync(filename, "utf-8");
@@ -1177,7 +1230,7 @@ var doHover = async (doc, params) => {
1177
1230
  // src/service/marko/definition/OpenTagName.ts
1178
1231
  import path4 from "path";
1179
1232
  import { URI as URI4 } from "vscode-uri";
1180
- import { Range as Range5, LocationLink } from "vscode-languageserver";
1233
+ import { Range as Range4, LocationLink } from "vscode-languageserver";
1181
1234
 
1182
1235
  // src/utils/regexp-builder.ts
1183
1236
  function RegExpBuilder(strings, ...expressions) {
@@ -1229,19 +1282,29 @@ function OpenTagName3({
1229
1282
  }
1230
1283
  if (/\/marko(?:-tag)?\.json$/.test(tagEntryFile)) {
1231
1284
  const tagDefDoc = createTextDocument(tagEntryFile);
1232
- const match = RegExpBuilder`/"(?:<${tag.nameText}>|${tag.nameText})"\s*:\s*[^\r\n,]+/g`.exec(tagDefDoc.getText());
1285
+ const match = RegExpBuilder`/"(?:<${tag.nameText}>|${tag.nameText})"\s*:\s*[^\r\n,]+/g`.exec(
1286
+ tagDefDoc.getText()
1287
+ );
1233
1288
  if (match && match.index) {
1234
- range = Range5.create(tagDefDoc.positionAt(match.index), tagDefDoc.positionAt(match.index + match[0].length));
1289
+ range = Range4.create(
1290
+ tagDefDoc.positionAt(match.index),
1291
+ tagDefDoc.positionAt(match.index + match[0].length)
1292
+ );
1235
1293
  }
1236
1294
  }
1237
1295
  return [
1238
- LocationLink.create(URI4.file(tagEntryFile).toString(), range, range, parsed.locationAt(node))
1296
+ LocationLink.create(
1297
+ URI4.file(tagEntryFile).toString(),
1298
+ range,
1299
+ range,
1300
+ parsed.locationAt(node)
1301
+ )
1239
1302
  ];
1240
1303
  }
1241
1304
 
1242
1305
  // src/service/marko/definition/AttrName.ts
1243
1306
  import { URI as URI5 } from "vscode-uri";
1244
- import { Range as Range6, LocationLink as LocationLink2 } from "vscode-languageserver";
1307
+ import { Range as Range5, LocationLink as LocationLink2 } from "vscode-languageserver";
1245
1308
  function AttrName2({
1246
1309
  lookup,
1247
1310
  parsed,
@@ -1263,13 +1326,23 @@ function AttrName2({
1263
1326
  }
1264
1327
  if (/\/marko(?:-tag)?\.json$/.test(attrEntryFile)) {
1265
1328
  const tagDefDoc = createTextDocument(attrEntryFile);
1266
- const match = RegExpBuilder`/"@${attrName}"\s*:\s*[^\r\n,]+/g`.exec(tagDefDoc.getText());
1329
+ const match = RegExpBuilder`/"@${attrName}"\s*:\s*[^\r\n,]+/g`.exec(
1330
+ tagDefDoc.getText()
1331
+ );
1267
1332
  if (match && match.index) {
1268
- range = Range6.create(tagDefDoc.positionAt(match.index), tagDefDoc.positionAt(match.index + match[0].length));
1333
+ range = Range5.create(
1334
+ tagDefDoc.positionAt(match.index),
1335
+ tagDefDoc.positionAt(match.index + match[0].length)
1336
+ );
1269
1337
  }
1270
1338
  }
1271
1339
  return [
1272
- LocationLink2.create(URI5.file(attrEntryFile).toString(), range, range, parsed.locationAt(node))
1340
+ LocationLink2.create(
1341
+ URI5.file(attrEntryFile).toString(),
1342
+ range,
1343
+ range,
1344
+ parsed.locationAt(node)
1345
+ )
1273
1346
  ];
1274
1347
  }
1275
1348
 
@@ -1294,10 +1367,20 @@ var findDefinition = async (doc, params) => {
1294
1367
  })) || [];
1295
1368
  };
1296
1369
 
1297
- // src/service/marko/document-links/extract.ts
1370
+ // src/service/marko/document-links.ts
1298
1371
  import { DocumentLink } from "vscode-languageserver";
1299
1372
  import { URI as URI6 } from "vscode-uri";
1300
1373
  var importTagReg2 = /(['"])<((?:[^\1\\>]+|\\.)*)>?\1/g;
1374
+ var cache = /* @__PURE__ */ new WeakMap();
1375
+ var findDocumentLinks = async (doc) => {
1376
+ const parsed = parse2(doc);
1377
+ let result = cache.get(parsed);
1378
+ if (!result) {
1379
+ result = extractDocumentLinks(doc, parsed, getCompilerInfo(doc).lookup);
1380
+ cache.set(parsed, result);
1381
+ }
1382
+ return result;
1383
+ };
1301
1384
  function extractDocumentLinks(doc, parsed, lookup) {
1302
1385
  if (URI6.parse(doc.uri).scheme === "untitled") {
1303
1386
  return [];
@@ -1319,7 +1402,18 @@ function extractDocumentLinks(doc, parsed, lookup) {
1319
1402
  if (node.attrs && node.nameText) {
1320
1403
  for (const attr of node.attrs) {
1321
1404
  if (isDocumentLinkAttr(doc, node, attr)) {
1322
- links.push(DocumentLink.create(parsed.locationAt(attr.value.value), resolveUrl(read(attr.value.value).slice(1, -1), doc.uri)));
1405
+ const resolved = resolveUrl(
1406
+ read(attr.value.value).slice(1, -1),
1407
+ doc.uri
1408
+ );
1409
+ if (resolved) {
1410
+ links.push(
1411
+ DocumentLink.create(
1412
+ parsed.locationAt(attr.value.value),
1413
+ resolveUrl(read(attr.value.value).slice(1, -1), doc.uri)
1414
+ )
1415
+ );
1416
+ }
1323
1417
  }
1324
1418
  }
1325
1419
  }
@@ -1341,10 +1435,15 @@ function extractDocumentLinks(doc, parsed, lookup) {
1341
1435
  const tagDef = lookup.getTag(tagName);
1342
1436
  const fileForTag = tagDef && (tagDef.template || tagDef.renderer);
1343
1437
  if (fileForTag) {
1344
- links.push(DocumentLink.create(parsed.locationAt({
1345
- start: item.start + match.index,
1346
- end: item.start + match.index + length
1347
- }), fileForTag));
1438
+ links.push(
1439
+ DocumentLink.create(
1440
+ parsed.locationAt({
1441
+ start: item.start + match.index,
1442
+ end: item.start + match.index + length
1443
+ }),
1444
+ fileForTag
1445
+ )
1446
+ );
1348
1447
  }
1349
1448
  }
1350
1449
  }
@@ -1355,21 +1454,19 @@ function extractDocumentLinks(doc, parsed, lookup) {
1355
1454
  return links;
1356
1455
  }
1357
1456
 
1358
- // src/service/marko/document-links/index.ts
1359
- var cache = /* @__PURE__ */ new WeakMap();
1360
- var findDocumentLinks = async (doc) => {
1457
+ // src/service/marko/document-symbols.ts
1458
+ import { URI as URI7 } from "vscode-uri";
1459
+ import { SymbolInformation, SymbolKind } from "vscode-languageserver";
1460
+ var cache2 = /* @__PURE__ */ new WeakMap();
1461
+ var findDocumentSymbols = async (doc) => {
1361
1462
  const parsed = parse2(doc);
1362
- let result = cache.get(parsed);
1463
+ let result = cache2.get(parsed);
1363
1464
  if (!result) {
1364
- result = extractDocumentLinks(doc, parsed, getCompilerInfo(doc).lookup);
1365
- cache.set(parsed, result);
1465
+ result = extractDocumentSymbols(doc, parsed, getCompilerInfo(doc).lookup);
1466
+ cache2.set(parsed, result);
1366
1467
  }
1367
1468
  return result;
1368
1469
  };
1369
-
1370
- // src/service/marko/document-symbols/extract.ts
1371
- import { URI as URI7 } from "vscode-uri";
1372
- import { SymbolInformation, SymbolKind } from "vscode-languageserver";
1373
1470
  function extractDocumentSymbols(doc, parsed, lookup) {
1374
1471
  if (URI7.parse(doc.uri).scheme === "untitled") {
1375
1472
  return [];
@@ -1381,7 +1478,14 @@ function extractDocumentSymbols(doc, parsed, lookup) {
1381
1478
  switch (node.type) {
1382
1479
  case 1 /* Tag */:
1383
1480
  case 14 /* AttrTag */:
1384
- symbols.push(SymbolInformation.create((node.type === 14 /* AttrTag */ ? (_a = node.nameText) == null ? void 0 : _a.slice(node.nameText.indexOf("@")) : node.nameText) || "<${...}>", node.nameText && ((_b = lookup.getTag(node.nameText)) == null ? void 0 : _b.html) && SymbolKind.Property || SymbolKind.Class, parsed.locationAt(node), doc.uri));
1481
+ symbols.push(
1482
+ SymbolInformation.create(
1483
+ (node.type === 14 /* AttrTag */ ? (_a = node.nameText) == null ? void 0 : _a.slice(node.nameText.indexOf("@")) : node.nameText) || "<${...}>",
1484
+ node.nameText && ((_b = lookup.getTag(node.nameText)) == null ? void 0 : _b.html) && SymbolKind.Property || SymbolKind.Class,
1485
+ parsed.locationAt(node),
1486
+ doc.uri
1487
+ )
1488
+ );
1385
1489
  if (node.body) {
1386
1490
  for (const child of node.body) {
1387
1491
  visit(child);
@@ -1396,20 +1500,8 @@ function extractDocumentSymbols(doc, parsed, lookup) {
1396
1500
  return symbols;
1397
1501
  }
1398
1502
 
1399
- // src/service/marko/document-symbols/index.ts
1400
- var cache2 = /* @__PURE__ */ new WeakMap();
1401
- var findDocumentSymbols = async (doc) => {
1402
- const parsed = parse2(doc);
1403
- let result = cache2.get(parsed);
1404
- if (!result) {
1405
- result = extractDocumentSymbols(doc, parsed, getCompilerInfo(doc).lookup);
1406
- cache2.set(parsed, result);
1407
- }
1408
- return result;
1409
- };
1410
-
1411
1503
  // src/service/marko/format.ts
1412
- import { Range as Range7, TextEdit as TextEdit6 } from "vscode-languageserver";
1504
+ import { Range as Range6, TextEdit as TextEdit6 } from "vscode-languageserver";
1413
1505
  import { URI as URI8 } from "vscode-uri";
1414
1506
  import * as prettier from "prettier";
1415
1507
  import * as markoPrettier from "prettier-plugin-marko";
@@ -1430,7 +1522,10 @@ var format2 = async (doc, params, cancel) => {
1430
1522
  if (cancel.isCancellationRequested)
1431
1523
  return;
1432
1524
  return [
1433
- TextEdit6.replace(Range7.create(doc.positionAt(0), doc.positionAt(text.length)), prettier.format(text, options))
1525
+ TextEdit6.replace(
1526
+ Range6.create(doc.positionAt(0), doc.positionAt(text.length)),
1527
+ prettier.format(text, options)
1528
+ )
1434
1529
  ];
1435
1530
  } catch (e) {
1436
1531
  displayError(e);
@@ -1451,7 +1546,7 @@ var marko_default = {
1451
1546
  // src/service/stylesheet/index.ts
1452
1547
  import {
1453
1548
  CompletionList as CompletionList2,
1454
- Range as Range9,
1549
+ Range as Range8,
1455
1550
  TextDocumentEdit
1456
1551
  } from "vscode-languageserver";
1457
1552
  import {
@@ -1646,12 +1741,21 @@ var StyleSheetService = {
1646
1741
  if (generatedOffset === void 0)
1647
1742
  continue;
1648
1743
  const { service: service2, virtualDoc } = info;
1649
- const result = await service2.doComplete2(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed, { resolveReference: resolveUrl });
1744
+ const result = await service2.doComplete2(
1745
+ virtualDoc,
1746
+ virtualDoc.positionAt(generatedOffset),
1747
+ info.parsed,
1748
+ { resolveReference: resolveUrl }
1749
+ );
1650
1750
  if (result.itemDefaults) {
1651
1751
  const { editRange } = result.itemDefaults;
1652
1752
  if (editRange) {
1653
1753
  if ("start" in editRange) {
1654
- result.itemDefaults.editRange = getSourceRange(doc, info, editRange);
1754
+ result.itemDefaults.editRange = getSourceRange(
1755
+ doc,
1756
+ info,
1757
+ editRange
1758
+ );
1655
1759
  } else {
1656
1760
  editRange.insert = getSourceRange(doc, info, editRange.insert);
1657
1761
  editRange.replace = getSourceRange(doc, info, editRange.replace);
@@ -1663,7 +1767,11 @@ var StyleSheetService = {
1663
1767
  item.textEdit = getSourceInsertReplaceEdit(doc, info, item.textEdit);
1664
1768
  }
1665
1769
  if (item.additionalTextEdits) {
1666
- item.additionalTextEdits = getSourceEdits(doc, info, item.additionalTextEdits);
1770
+ item.additionalTextEdits = getSourceEdits(
1771
+ doc,
1772
+ info,
1773
+ item.additionalTextEdits
1774
+ );
1667
1775
  }
1668
1776
  }
1669
1777
  return result;
@@ -1679,7 +1787,11 @@ var StyleSheetService = {
1679
1787
  if (generatedOffset === void 0)
1680
1788
  continue;
1681
1789
  const { service: service2, virtualDoc } = info;
1682
- const result = service2.findDefinition(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed);
1790
+ const result = service2.findDefinition(
1791
+ virtualDoc,
1792
+ virtualDoc.positionAt(generatedOffset),
1793
+ info.parsed
1794
+ );
1683
1795
  if (result) {
1684
1796
  const range = getSourceRange(doc, info, result.range);
1685
1797
  if (range) {
@@ -1702,7 +1814,11 @@ var StyleSheetService = {
1702
1814
  continue;
1703
1815
  const { service: service2, virtualDoc } = info;
1704
1816
  const result = [];
1705
- for (const location of service2.findReferences(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed)) {
1817
+ for (const location of service2.findReferences(
1818
+ virtualDoc,
1819
+ virtualDoc.positionAt(generatedOffset),
1820
+ info.parsed
1821
+ )) {
1706
1822
  const range = getSourceRange(doc, info, location.range);
1707
1823
  if (range) {
1708
1824
  result.push({
@@ -1720,7 +1836,10 @@ var StyleSheetService = {
1720
1836
  for (const ext in infoByExt) {
1721
1837
  const info = infoByExt[ext];
1722
1838
  const { service: service2, virtualDoc } = info;
1723
- for (const symbol of service2.findDocumentSymbols(virtualDoc, info.parsed)) {
1839
+ for (const symbol of service2.findDocumentSymbols(
1840
+ virtualDoc,
1841
+ info.parsed
1842
+ )) {
1724
1843
  if (symbol.location.uri === doc.uri) {
1725
1844
  const range = getSourceRange(doc, info, symbol.location.range);
1726
1845
  if (range) {
@@ -1746,7 +1865,11 @@ var StyleSheetService = {
1746
1865
  for (const ext in infoByExt) {
1747
1866
  const info = infoByExt[ext];
1748
1867
  const { service: service2, virtualDoc } = info;
1749
- for (const link of await service2.findDocumentLinks2(virtualDoc, info.parsed, { resolveReference: resolveUrl })) {
1868
+ for (const link of await service2.findDocumentLinks2(
1869
+ virtualDoc,
1870
+ info.parsed,
1871
+ { resolveReference: resolveUrl }
1872
+ )) {
1750
1873
  const range = getSourceRange(doc, info, link.range);
1751
1874
  if (range) {
1752
1875
  result.push({
@@ -1770,7 +1893,11 @@ var StyleSheetService = {
1770
1893
  continue;
1771
1894
  const { service: service2, virtualDoc } = info;
1772
1895
  const result = [];
1773
- for (const highlight of service2.findDocumentHighlights(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed)) {
1896
+ for (const highlight of service2.findDocumentHighlights(
1897
+ virtualDoc,
1898
+ virtualDoc.positionAt(generatedOffset),
1899
+ info.parsed
1900
+ )) {
1774
1901
  const range = getSourceRange(doc, info, highlight.range);
1775
1902
  if (range) {
1776
1903
  result.push({
@@ -1788,7 +1915,10 @@ var StyleSheetService = {
1788
1915
  for (const ext in infoByExt) {
1789
1916
  const info = infoByExt[ext];
1790
1917
  const { service: service2, virtualDoc } = info;
1791
- for (const colorInfo of service2.findDocumentColors(virtualDoc, info.parsed)) {
1918
+ for (const colorInfo of service2.findDocumentColors(
1919
+ virtualDoc,
1920
+ info.parsed
1921
+ )) {
1792
1922
  const range = getSourceRange(doc, info, colorInfo.range);
1793
1923
  if (range) {
1794
1924
  result.push({
@@ -1808,12 +1938,22 @@ var StyleSheetService = {
1808
1938
  const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
1809
1939
  if (generatedOffsetStart === void 0)
1810
1940
  continue;
1811
- const generatedOffsetEnd = info.generatedOffsetAt(doc.offsetAt(params.range.end));
1941
+ const generatedOffsetEnd = info.generatedOffsetAt(
1942
+ doc.offsetAt(params.range.end)
1943
+ );
1812
1944
  if (generatedOffsetEnd === void 0)
1813
1945
  continue;
1814
1946
  const { service: service2, virtualDoc } = info;
1815
1947
  const result = [];
1816
- for (const colorPresentation of service2.getColorPresentations(virtualDoc, info.parsed, params.color, Range9.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)))) {
1948
+ for (const colorPresentation of service2.getColorPresentations(
1949
+ virtualDoc,
1950
+ info.parsed,
1951
+ params.color,
1952
+ Range8.create(
1953
+ virtualDoc.positionAt(generatedOffsetStart),
1954
+ virtualDoc.positionAt(generatedOffsetEnd)
1955
+ )
1956
+ )) {
1817
1957
  const textEdit = colorPresentation.textEdit && getSourceEdit(doc, info, colorPresentation.textEdit);
1818
1958
  const additionalTextEdits = colorPresentation.additionalTextEdits && getSourceEdits(doc, info, colorPresentation.additionalTextEdits);
1819
1959
  if (textEdit || additionalTextEdits) {
@@ -1836,7 +1976,11 @@ var StyleSheetService = {
1836
1976
  if (generatedOffset === void 0)
1837
1977
  continue;
1838
1978
  const { service: service2, virtualDoc } = info;
1839
- const result = service2.doHover(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed);
1979
+ const result = service2.doHover(
1980
+ virtualDoc,
1981
+ virtualDoc.positionAt(generatedOffset),
1982
+ info.parsed
1983
+ );
1840
1984
  if (result) {
1841
1985
  if (result.range) {
1842
1986
  const range = getSourceRange(doc, info, result.range);
@@ -1861,7 +2005,12 @@ var StyleSheetService = {
1861
2005
  if (generatedOffset === void 0)
1862
2006
  continue;
1863
2007
  const { service: service2, virtualDoc } = info;
1864
- const result = service2.doRename(virtualDoc, virtualDoc.positionAt(generatedOffset), params.newName, info.parsed);
2008
+ const result = service2.doRename(
2009
+ virtualDoc,
2010
+ virtualDoc.positionAt(generatedOffset),
2011
+ params.newName,
2012
+ info.parsed
2013
+ );
1865
2014
  if (result.changes) {
1866
2015
  for (const uri in result.changes) {
1867
2016
  if (uri === doc.uri) {
@@ -1890,11 +2039,21 @@ var StyleSheetService = {
1890
2039
  const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
1891
2040
  if (generatedOffsetStart === void 0)
1892
2041
  continue;
1893
- const generatedOffsetEnd = info.generatedOffsetAt(doc.offsetAt(params.range.end));
2042
+ const generatedOffsetEnd = info.generatedOffsetAt(
2043
+ doc.offsetAt(params.range.end)
2044
+ );
1894
2045
  if (generatedOffsetEnd === void 0)
1895
2046
  continue;
1896
2047
  const { service: service2, virtualDoc } = info;
1897
- const result = service2.doCodeActions(virtualDoc, Range9.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)), params.context, info.parsed);
2048
+ const result = service2.doCodeActions(
2049
+ virtualDoc,
2050
+ Range8.create(
2051
+ virtualDoc.positionAt(generatedOffsetStart),
2052
+ virtualDoc.positionAt(generatedOffsetEnd)
2053
+ ),
2054
+ params.context,
2055
+ info.parsed
2056
+ );
1898
2057
  for (const command of result) {
1899
2058
  const edits = (_a = command.arguments) == null ? void 0 : _a[2];
1900
2059
  if (edits && Array.isArray(edits) && isTextEdit(edits[0])) {
@@ -1909,7 +2068,10 @@ var StyleSheetService = {
1909
2068
  const result = [];
1910
2069
  for (const ext in infoByExt) {
1911
2070
  const info = infoByExt[ext];
1912
- for (const diag of info.service.doValidation(info.virtualDoc, info.parsed)) {
2071
+ for (const diag of info.service.doValidation(
2072
+ info.virtualDoc,
2073
+ info.parsed
2074
+ )) {
1913
2075
  const range = getSourceRange(doc, info, diag.range);
1914
2076
  if (range) {
1915
2077
  diag.range = range;
@@ -1981,7 +2143,11 @@ function getStyleSheetInfo(doc) {
1981
2143
  const parsed = parse2(doc);
1982
2144
  let cached = cache3.get(parsed);
1983
2145
  if (!cached) {
1984
- const results = extractStyleSheets(doc.getText(), parsed.program, getCompilerInfo(doc).lookup);
2146
+ const results = extractStyleSheets(
2147
+ doc.getText(),
2148
+ parsed.program,
2149
+ getCompilerInfo(doc).lookup
2150
+ );
1985
2151
  cached = {};
1986
2152
  for (const ext in results) {
1987
2153
  const service2 = (_a = services[ext]) == null ? void 0 : _a.call(services, {
@@ -1991,7 +2157,12 @@ function getStyleSheetInfo(doc) {
1991
2157
  if (!service2)
1992
2158
  continue;
1993
2159
  const { generated, sourceOffsetAt, generatedOffsetAt } = results[ext];
1994
- const virtualDoc = TextDocument2.create(doc.uri, "css", doc.version, generated);
2160
+ const virtualDoc = TextDocument2.create(
2161
+ doc.uri,
2162
+ "css",
2163
+ doc.version,
2164
+ generated
2165
+ );
1995
2166
  cached[ext] = {
1996
2167
  service: service2,
1997
2168
  virtualDoc,
@@ -2021,10 +2192,12 @@ var service = {
2021
2192
  let items;
2022
2193
  let isIncomplete = false;
2023
2194
  try {
2024
- for (const pending of plugins.map((plugin) => {
2025
- var _a;
2026
- return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2027
- })) {
2195
+ for (const pending of plugins.map(
2196
+ (plugin) => {
2197
+ var _a;
2198
+ return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2199
+ }
2200
+ )) {
2028
2201
  const cur = await pending;
2029
2202
  if (cancel.isCancellationRequested)
2030
2203
  return;
@@ -2050,10 +2223,12 @@ var service = {
2050
2223
  async findDefinition(doc, params, cancel) {
2051
2224
  let result;
2052
2225
  try {
2053
- for (const pending of plugins.map((plugin) => {
2054
- var _a;
2055
- return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2056
- })) {
2226
+ for (const pending of plugins.map(
2227
+ (plugin) => {
2228
+ var _a;
2229
+ return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2230
+ }
2231
+ )) {
2057
2232
  const cur = await pending;
2058
2233
  if (cancel.isCancellationRequested)
2059
2234
  return;
@@ -2068,10 +2243,12 @@ var service = {
2068
2243
  async findReferences(doc, params, cancel) {
2069
2244
  let result;
2070
2245
  try {
2071
- for (const pending of plugins.map((plugin) => {
2072
- var _a;
2073
- return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2074
- })) {
2246
+ for (const pending of plugins.map(
2247
+ (plugin) => {
2248
+ var _a;
2249
+ return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2250
+ }
2251
+ )) {
2075
2252
  const cur = await pending;
2076
2253
  if (cancel.isCancellationRequested)
2077
2254
  return;
@@ -2086,10 +2263,12 @@ var service = {
2086
2263
  async findDocumentSymbols(doc, params, cancel) {
2087
2264
  let result;
2088
2265
  try {
2089
- for (const pending of plugins.map((plugin) => {
2090
- var _a;
2091
- return (_a = plugin.findDocumentSymbols) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2092
- })) {
2266
+ for (const pending of plugins.map(
2267
+ (plugin) => {
2268
+ var _a;
2269
+ return (_a = plugin.findDocumentSymbols) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2270
+ }
2271
+ )) {
2093
2272
  const cur = await pending;
2094
2273
  if (cancel.isCancellationRequested)
2095
2274
  return;
@@ -2104,10 +2283,12 @@ var service = {
2104
2283
  async findDocumentLinks(doc, params, cancel) {
2105
2284
  let result;
2106
2285
  try {
2107
- for (const pending of plugins.map((plugin) => {
2108
- var _a;
2109
- return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2110
- })) {
2286
+ for (const pending of plugins.map(
2287
+ (plugin) => {
2288
+ var _a;
2289
+ return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2290
+ }
2291
+ )) {
2111
2292
  const cur = await pending;
2112
2293
  if (cancel.isCancellationRequested)
2113
2294
  return;
@@ -2122,10 +2303,12 @@ var service = {
2122
2303
  async findDocumentHighlights(doc, params, cancel) {
2123
2304
  let result;
2124
2305
  try {
2125
- for (const pending of plugins.map((plugin) => {
2126
- var _a;
2127
- return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2128
- })) {
2306
+ for (const pending of plugins.map(
2307
+ (plugin) => {
2308
+ var _a;
2309
+ return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2310
+ }
2311
+ )) {
2129
2312
  const cur = await pending;
2130
2313
  if (cancel.isCancellationRequested)
2131
2314
  return;
@@ -2140,10 +2323,12 @@ var service = {
2140
2323
  async findDocumentColors(doc, params, cancel) {
2141
2324
  let result;
2142
2325
  try {
2143
- for (const pending of plugins.map((plugin) => {
2144
- var _a;
2145
- return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2146
- })) {
2326
+ for (const pending of plugins.map(
2327
+ (plugin) => {
2328
+ var _a;
2329
+ return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2330
+ }
2331
+ )) {
2147
2332
  const cur = await pending;
2148
2333
  if (cancel.isCancellationRequested)
2149
2334
  return;
@@ -2158,10 +2343,12 @@ var service = {
2158
2343
  async getColorPresentations(doc, params, cancel) {
2159
2344
  let result;
2160
2345
  try {
2161
- for (const pending of plugins.map((plugin) => {
2162
- var _a;
2163
- return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2164
- })) {
2346
+ for (const pending of plugins.map(
2347
+ (plugin) => {
2348
+ var _a;
2349
+ return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2350
+ }
2351
+ )) {
2165
2352
  const cur = await pending;
2166
2353
  if (cancel.isCancellationRequested)
2167
2354
  return;
@@ -2192,10 +2379,12 @@ var service = {
2192
2379
  let changeAnnotations;
2193
2380
  let documentChanges;
2194
2381
  try {
2195
- for (const pending of plugins.map((plugin) => {
2196
- var _a;
2197
- return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2198
- })) {
2382
+ for (const pending of plugins.map(
2383
+ (plugin) => {
2384
+ var _a;
2385
+ return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2386
+ }
2387
+ )) {
2199
2388
  const cur = await pending;
2200
2389
  if (cancel.isCancellationRequested)
2201
2390
  return;
@@ -2235,10 +2424,12 @@ var service = {
2235
2424
  async doCodeActions(doc, params, cancel) {
2236
2425
  let result;
2237
2426
  try {
2238
- for (const pending of plugins.map((plugin) => {
2239
- var _a;
2240
- return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2241
- })) {
2427
+ for (const pending of plugins.map(
2428
+ (plugin) => {
2429
+ var _a;
2430
+ return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
2431
+ }
2432
+ )) {
2242
2433
  const cur = await pending;
2243
2434
  if (cancel.isCancellationRequested)
2244
2435
  return;
@@ -2336,40 +2527,88 @@ documents.onDidChangeContent(({ document }) => {
2336
2527
  clearCompilerCache(document);
2337
2528
  });
2338
2529
  connection2.onCompletion(async (params, cancel) => {
2339
- return await service.doComplete(documents.get(params.textDocument.uri), params, cancel) || null;
2530
+ return await service.doComplete(
2531
+ documents.get(params.textDocument.uri),
2532
+ params,
2533
+ cancel
2534
+ ) || null;
2340
2535
  });
2341
2536
  connection2.onDefinition(async (params, cancel) => {
2342
- return await service.findDefinition(documents.get(params.textDocument.uri), params, cancel) || null;
2537
+ return await service.findDefinition(
2538
+ documents.get(params.textDocument.uri),
2539
+ params,
2540
+ cancel
2541
+ ) || null;
2343
2542
  });
2344
2543
  connection2.onReferences(async (params, cancel) => {
2345
- return await service.findReferences(documents.get(params.textDocument.uri), params, cancel) || null;
2544
+ return await service.findReferences(
2545
+ documents.get(params.textDocument.uri),
2546
+ params,
2547
+ cancel
2548
+ ) || null;
2346
2549
  });
2347
2550
  connection2.onDocumentLinks(async (params, cancel) => {
2348
- return await service.findDocumentLinks(documents.get(params.textDocument.uri), params, cancel) || null;
2551
+ return await service.findDocumentLinks(
2552
+ documents.get(params.textDocument.uri),
2553
+ params,
2554
+ cancel
2555
+ ) || null;
2349
2556
  });
2350
2557
  connection2.onDocumentSymbol(async (params, cancel) => {
2351
- return await service.findDocumentSymbols(documents.get(params.textDocument.uri), params, cancel) || null;
2558
+ return await service.findDocumentSymbols(
2559
+ documents.get(params.textDocument.uri),
2560
+ params,
2561
+ cancel
2562
+ ) || null;
2352
2563
  });
2353
2564
  connection2.onDocumentHighlight(async (params, cancel) => {
2354
- return await service.findDocumentHighlights(documents.get(params.textDocument.uri), params, cancel) || null;
2565
+ return await service.findDocumentHighlights(
2566
+ documents.get(params.textDocument.uri),
2567
+ params,
2568
+ cancel
2569
+ ) || null;
2355
2570
  });
2356
2571
  connection2.onDocumentColor(async (params, cancel) => {
2357
- return await service.findDocumentColors(documents.get(params.textDocument.uri), params, cancel) || null;
2572
+ return await service.findDocumentColors(
2573
+ documents.get(params.textDocument.uri),
2574
+ params,
2575
+ cancel
2576
+ ) || null;
2358
2577
  });
2359
2578
  connection2.onColorPresentation(async (params, cancel) => {
2360
- return await service.getColorPresentations(documents.get(params.textDocument.uri), params, cancel) || null;
2579
+ return await service.getColorPresentations(
2580
+ documents.get(params.textDocument.uri),
2581
+ params,
2582
+ cancel
2583
+ ) || null;
2361
2584
  });
2362
2585
  connection2.onHover(async (params, cancel) => {
2363
- return await service.doHover(documents.get(params.textDocument.uri), params, cancel) || null;
2586
+ return await service.doHover(
2587
+ documents.get(params.textDocument.uri),
2588
+ params,
2589
+ cancel
2590
+ ) || null;
2364
2591
  });
2365
2592
  connection2.onRenameRequest(async (params, cancel) => {
2366
- return await service.doRename(documents.get(params.textDocument.uri), params, cancel) || null;
2593
+ return await service.doRename(
2594
+ documents.get(params.textDocument.uri),
2595
+ params,
2596
+ cancel
2597
+ ) || null;
2367
2598
  });
2368
2599
  connection2.onCodeAction(async (params, cancel) => {
2369
- return await service.doCodeActions(documents.get(params.textDocument.uri), params, cancel) || null;
2600
+ return await service.doCodeActions(
2601
+ documents.get(params.textDocument.uri),
2602
+ params,
2603
+ cancel
2604
+ ) || null;
2370
2605
  });
2371
2606
  connection2.onDocumentFormatting(async (params, cancel) => {
2372
- return await service.format(documents.get(params.textDocument.uri), params, cancel) || null;
2607
+ return await service.format(
2608
+ documents.get(params.textDocument.uri),
2609
+ params,
2610
+ cancel
2611
+ ) || null;
2373
2612
  });
2374
2613
  function validateDocs() {
2375
2614
  queueDiagnostic();
@@ -2381,15 +2620,17 @@ function validateDocs() {
2381
2620
  function queueDiagnostic() {
2382
2621
  clearTimeout(diagnosticTimeout);
2383
2622
  const id = diagnosticTimeout = setTimeout(async () => {
2384
- const results = await Promise.all(documents.all().map(async (doc) => {
2385
- if (!pendingDiags.delete(doc))
2386
- return;
2387
- const prevDiag = prevDiags.get(doc) || [];
2388
- const nextDiag = await service.doValidate(doc) || [];
2389
- if (isDeepStrictEqual(prevDiag, nextDiag))
2390
- return;
2391
- return [doc, nextDiag];
2392
- }));
2623
+ const results = await Promise.all(
2624
+ documents.all().map(async (doc) => {
2625
+ if (!pendingDiags.delete(doc))
2626
+ return;
2627
+ const prevDiag = prevDiags.get(doc) || [];
2628
+ const nextDiag = await service.doValidate(doc) || [];
2629
+ if (isDeepStrictEqual(prevDiag, nextDiag))
2630
+ return;
2631
+ return [doc, nextDiag];
2632
+ })
2633
+ );
2393
2634
  if (id === diagnosticTimeout) {
2394
2635
  for (const result of results) {
2395
2636
  if (result) {