@mirascript/monaco 0.1.40 → 0.1.42

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/lsp/index.js CHANGED
@@ -1,10 +1,14 @@
1
1
  import {
2
2
  KEYWORDS,
3
+ REG_BIN,
4
+ REG_HEX,
3
5
  REG_IDENTIFIER_FULL,
6
+ REG_NUMBER,
7
+ REG_OCT,
4
8
  REG_ORDINAL_FULL,
5
9
  RESERVED_KEYWORDS,
6
10
  isKeyword
7
- } from "../chunk-SFU27XXU.js";
11
+ } from "../chunk-QENEDDTR.js";
8
12
  import {
9
13
  Emitter,
10
14
  MarkerSeverity,
@@ -29,6 +33,16 @@ function wordAt(model, position) {
29
33
  const range = new Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn);
30
34
  return { word: word.word, range };
31
35
  }
36
+ function rangeAt(...args) {
37
+ if (args.length === 1 || args[1] == null) {
38
+ const { lineNumber, startColumn, endColumn } = args[0];
39
+ return new Range(lineNumber, startColumn, lineNumber, endColumn);
40
+ } else {
41
+ const { lineNumber } = args[0];
42
+ const { startColumn, endColumn } = args[1];
43
+ return new Range(lineNumber, startColumn, lineNumber, endColumn);
44
+ }
45
+ }
32
46
 
33
47
  // src/lsp/compile-result.ts
34
48
  import {
@@ -516,6 +530,72 @@ ${value}
516
530
  ${CODEBLOCK_FENCE}
517
531
  `;
518
532
  }
533
+ function serializeIntegerImpl(num, base, prefix, sep) {
534
+ let str = Math.abs(num).toString(base);
535
+ if (base > 10) str = str.toUpperCase();
536
+ const sepSize = Math.abs(sep);
537
+ if (sep !== 0 && str.length > sepSize) {
538
+ const seg = [];
539
+ if (sep > 0) {
540
+ while (str.length > sepSize) {
541
+ seg.unshift(str.slice(-sepSize));
542
+ str = str.slice(0, -sepSize);
543
+ }
544
+ if (str.length > 0) {
545
+ seg.unshift(str);
546
+ }
547
+ } else {
548
+ while (str.length > sepSize) {
549
+ seg.push(str.slice(0, sepSize));
550
+ str = str.slice(sepSize);
551
+ }
552
+ if (str.length > 0) {
553
+ seg.push(str);
554
+ }
555
+ }
556
+ str = seg.join("_");
557
+ }
558
+ return (num < 0 ? "-" : "") + prefix + str;
559
+ }
560
+ function serializeInteger(num, base, sep = true) {
561
+ const prefix = base === 2 ? "0b" : base === 8 ? "0o" : "0x";
562
+ const sepSize = sep ? base === 2 ? 8 : base === 8 ? 6 : 4 : 0;
563
+ return serializeIntegerImpl(num, base, prefix, sepSize);
564
+ }
565
+ function serializeNumber(num) {
566
+ if (!Number.isFinite(num)) {
567
+ return serialize(num);
568
+ }
569
+ const str = String(num);
570
+ const dot = str.indexOf(".");
571
+ const exp = str.indexOf("e");
572
+ let intPart;
573
+ let fracPart;
574
+ let expPart;
575
+ if (dot >= 0) {
576
+ intPart = str.slice(0, dot);
577
+ if (exp >= 0) {
578
+ fracPart = str.slice(dot + 1, exp);
579
+ expPart = str.slice(exp);
580
+ } else {
581
+ fracPart = str.slice(dot + 1);
582
+ expPart = "";
583
+ }
584
+ } else {
585
+ if (exp >= 0) {
586
+ intPart = str.slice(0, exp);
587
+ fracPart = "";
588
+ expPart = str.slice(exp);
589
+ } else {
590
+ intPart = str;
591
+ fracPart = "";
592
+ expPart = "";
593
+ }
594
+ }
595
+ if (intPart.length > 5) intPart = serializeIntegerImpl(Number(intPart), 10, "", 3);
596
+ if (fracPart.length > 5) fracPart = serializeIntegerImpl(Number(fracPart), 10, "", -3);
597
+ return intPart + (fracPart ? "." + fracPart : "") + expPart;
598
+ }
519
599
  function serializeForDisplayInner(value, maxWidth) {
520
600
  if (maxWidth < 10) maxWidth = 10;
521
601
  if (typeof value === "string") {
@@ -524,6 +604,9 @@ function serializeForDisplayInner(value, maxWidth) {
524
604
  }
525
605
  return `${serializeString(value.slice(0, maxWidth))}..`;
526
606
  }
607
+ if (typeof value === "number") {
608
+ return serializeNumber(value);
609
+ }
527
610
  if (isVmPrimitive(value)) {
528
611
  return serialize(value);
529
612
  }
@@ -1181,7 +1264,7 @@ function createCodeAction(result, context, model, marker) {
1181
1264
  if (current === uppercase || !Object.is(context.getOrUndefined(current), context.getOrUndefined(uppercase))) {
1182
1265
  return void 0;
1183
1266
  }
1184
- action.title = "Convert to uppercase constant";
1267
+ action.title = "转换为大写常量";
1185
1268
  action.kind = "quickfix";
1186
1269
  action.edit = edits({
1187
1270
  range,
@@ -1212,7 +1295,7 @@ function createCodeAction(result, context, model, marker) {
1212
1295
  if (prefix === "$") {
1213
1296
  fixed = `(${fixed})`;
1214
1297
  }
1215
- action.title = "Convert record literal to parentheses";
1298
+ action.title = `转换为使用圆括号的记录字面量`;
1216
1299
  action.kind = "quickfix";
1217
1300
  action.edit = edits({
1218
1301
  range,
@@ -1237,7 +1320,7 @@ function createCodeAction(result, context, model, marker) {
1237
1320
  if (!fixed) {
1238
1321
  return void 0;
1239
1322
  }
1240
- action.title = `Convert to '${fixed}' operator`;
1323
+ action.title = `转换为 '${fixed}' 运算符`;
1241
1324
  action.kind = "quickfix";
1242
1325
  action.edit = edits({
1243
1326
  range: range0,
@@ -1255,7 +1338,7 @@ function createCodeAction(result, context, model, marker) {
1255
1338
  if (fixed === current) {
1256
1339
  return void 0;
1257
1340
  }
1258
- action.title = "Remove unnecessary parentheses";
1341
+ action.title = "移除不必要的括号";
1259
1342
  action.kind = "quickfix";
1260
1343
  action.edit = edits({
1261
1344
  range,
@@ -1299,7 +1382,7 @@ function createCodeAction(result, context, model, marker) {
1299
1382
  return `{ ${expr} }`;
1300
1383
  };
1301
1384
  const fixed = `if ${cond} ${wrapIfNeeded(thenExpr, false)} else ${wrapIfNeeded(elseExpr, true)}`;
1302
- action.title = "Convert to if expression";
1385
+ action.title = "转换为 if 表达式";
1303
1386
  action.kind = "quickfix";
1304
1387
  action.edit = edits({
1305
1388
  range,
@@ -1328,14 +1411,34 @@ var CodeActionProvider = class extends Provider {
1328
1411
  dispose: () => void 0
1329
1412
  };
1330
1413
  }
1414
+ };
1415
+
1416
+ // src/lsp/providers/code-lens-provider.ts
1417
+ import { DiagnosticCode as DiagnosticCode5 } from "@mirascript/constants";
1418
+ var CodeLensProvider = class extends Provider {
1331
1419
  /** @inheritdoc */
1332
- resolveCodeAction(codeAction, token) {
1333
- return codeAction;
1420
+ async provideCodeLenses(model, token) {
1421
+ const result = await this.getCompileResult(model);
1422
+ if (!result) return void 0;
1423
+ const lenses = [];
1424
+ for (const { definition, references } of result.groupedTags(model).locals) {
1425
+ if (definition.code === DiagnosticCode5.LocalFunction) {
1426
+ lenses.push({
1427
+ range: definition.range,
1428
+ command: {
1429
+ id: "editor.action.findReferences",
1430
+ title: `${references.length} 个引用`,
1431
+ arguments: [model.uri, Range.getStartPosition(definition.range)]
1432
+ }
1433
+ });
1434
+ }
1435
+ }
1436
+ return { lenses };
1334
1437
  }
1335
1438
  };
1336
1439
 
1337
1440
  // src/lsp/providers/color-provider.ts
1338
- import { DiagnosticCode as DiagnosticCode5 } from "@mirascript/constants";
1441
+ import { DiagnosticCode as DiagnosticCode6 } from "@mirascript/constants";
1339
1442
  var REG_COLOR_STR = /^(@*)(['"`])(#(?:[0-9a-f]{6}|[0-9a-f]{3}|[0-9a-f]{8}|[0-9a-f]{4}))\2\1$/iu;
1340
1443
  var { parseInt } = Number;
1341
1444
  function parseColorString(text) {
@@ -1398,7 +1501,7 @@ var ColorProvider = class extends Provider {
1398
1501
  if (!compiled) return void 0;
1399
1502
  const info = [];
1400
1503
  for (const { range, code } of compiled.groupedTags(model).ranges) {
1401
- if (code !== DiagnosticCode5.String) continue;
1504
+ if (code !== DiagnosticCode6.String) continue;
1402
1505
  if (range.startLineNumber !== range.endLineNumber) {
1403
1506
  continue;
1404
1507
  }
@@ -1436,7 +1539,7 @@ import {
1436
1539
  isVmWrapper as isVmWrapper2,
1437
1540
  serialize as serialize2
1438
1541
  } from "@mirascript/mirascript";
1439
- import { DiagnosticCode as DiagnosticCode6 } from "@mirascript/mirascript/subtle";
1542
+ import { DiagnosticCode as DiagnosticCode7 } from "@mirascript/mirascript/subtle";
1440
1543
  import { KEYWORDS as HELP_KEYWORDS } from "@mirascript/help";
1441
1544
  var DESC_GLOBAL = "(global)";
1442
1545
  var DESC_LOCAL = "(local)";
@@ -1673,7 +1776,7 @@ var CompletionItemProvider = class extends Provider {
1673
1776
  const locals = /* @__PURE__ */ new Set();
1674
1777
  while (scope) {
1675
1778
  for (const { definition, fn } of scope.locals) {
1676
- const name = definition.code === DiagnosticCode6.ParameterIt ? "it" : model.getValueInRange(definition.range);
1779
+ const name = definition.code === DiagnosticCode7.ParameterIt ? "it" : model.getValueInRange(definition.range);
1677
1780
  if (char && !name.toLowerCase().includes(char)) continue;
1678
1781
  if (locals.has(name)) continue;
1679
1782
  locals.add(name);
@@ -1768,7 +1871,7 @@ var CompletionItemProvider = class extends Provider {
1768
1871
  if (def.ref == null) {
1769
1872
  const suggestions2 = [];
1770
1873
  if (word && compiled.tags.some(
1771
- (t) => strictContainsPosition(t.range, position) && t.code === DiagnosticCode6.MatchExpression
1874
+ (t) => strictContainsPosition(t.range, position) && t.code === DiagnosticCode7.MatchExpression
1772
1875
  )) {
1773
1876
  suggestions2.push(
1774
1877
  kwSuggestion("case", this.toCompletionItemRanges(position, word.range)),
@@ -1912,7 +2015,7 @@ var DefinitionReferenceProvider = class extends Provider {
1912
2015
  };
1913
2016
 
1914
2017
  // src/lsp/providers/document-highlight-provider.ts
1915
- import { DiagnosticCode as DiagnosticCode7 } from "@mirascript/mirascript/subtle";
2018
+ import { DiagnosticCode as DiagnosticCode8 } from "@mirascript/mirascript/subtle";
1916
2019
  var DocumentHighlightProvider = class extends Provider {
1917
2020
  /** @inheritdoc */
1918
2021
  async provideDocumentHighlights(model, position, token) {
@@ -1932,7 +2035,7 @@ var DocumentHighlightProvider = class extends Provider {
1932
2035
  const links = def.references.map((u) => {
1933
2036
  const { code, range } = u;
1934
2037
  let kind = languages.DocumentHighlightKind.Read;
1935
- if (code === DiagnosticCode7.WriteLocal || code === DiagnosticCode7.ReadWriteLocal || code === DiagnosticCode7.RedeclareLocal) {
2038
+ if (code === DiagnosticCode8.WriteLocal || code === DiagnosticCode8.ReadWriteLocal || code === DiagnosticCode8.RedeclareLocal) {
1936
2039
  kind = languages.DocumentHighlightKind.Write;
1937
2040
  }
1938
2041
  return {
@@ -1962,7 +2065,7 @@ var DocumentHighlightProvider = class extends Provider {
1962
2065
  };
1963
2066
 
1964
2067
  // src/lsp/providers/document-symbol-provider.ts
1965
- import { DiagnosticCode as DiagnosticCode8 } from "@mirascript/constants";
2068
+ import { DiagnosticCode as DiagnosticCode9 } from "@mirascript/constants";
1966
2069
  var DocumentSymbolProvider = class extends Provider {
1967
2070
  /** 构建树 */
1968
2071
  handleScope(model, scope) {
@@ -1975,13 +2078,13 @@ var DocumentSymbolProvider = class extends Provider {
1975
2078
  let children = [];
1976
2079
  let allRange = range;
1977
2080
  switch (definition.code) {
1978
- case DiagnosticCode8.ParameterIt:
2081
+ case DiagnosticCode9.ParameterIt:
1979
2082
  if (definition.references.length === 0) {
1980
2083
  continue;
1981
2084
  }
1982
2085
  name = `it`;
1983
2086
  break;
1984
- case DiagnosticCode8.LocalFunction: {
2087
+ case DiagnosticCode9.LocalFunction: {
1985
2088
  kind = languages.SymbolKind.Function;
1986
2089
  const funcScope = scope.children.find((s) => Range.compareRangesUsingStarts(s.range, range) > 0);
1987
2090
  if (funcScope) {
@@ -2067,7 +2170,9 @@ var FormatterProvider = class extends Provider {
2067
2170
  };
2068
2171
 
2069
2172
  // src/lsp/providers/hover-provider.ts
2070
- import { DiagnosticCode as DiagnosticCode9 } from "@mirascript/constants";
2173
+ import { DiagnosticCode as DiagnosticCode10 } from "@mirascript/constants";
2174
+ import { convert } from "@mirascript/mirascript/subtle";
2175
+ import { KEYWORDS as HELP_KEYWORDS2, OPERATORS as HELP_OPERATORS } from "@mirascript/help";
2071
2176
 
2072
2177
  // src/lsp/monaco-private.js
2073
2178
  function fromStandardTokenType(tokenType) {
@@ -2107,8 +2212,14 @@ function tokenAt(model, position) {
2107
2212
  }
2108
2213
 
2109
2214
  // src/lsp/providers/hover-provider.ts
2110
- import { KEYWORDS as HELP_KEYWORDS2, OPERATORS as HELP_OPERATORS } from "@mirascript/help";
2111
2215
  var OPERATOR_TOKENS_DESC = Object.keys(HELP_OPERATORS).sort((a, b) => b.length - a.length);
2216
+ var REG_NUMBER_ALL_FULL = new RegExp(
2217
+ `^(?:${REG_BIN.source}|${REG_OCT.source}|${REG_HEX.source}|${REG_NUMBER.source})$`,
2218
+ REG_NUMBER.flags
2219
+ );
2220
+ var BIN_MAX = 2 ** 32 - 1;
2221
+ var OCT_MAX = 8 ** 18 - 1;
2222
+ var HEX_MAX = 16 ** 16 - 1;
2112
2223
  function operatorAt(lineContent, column) {
2113
2224
  const index = Math.max(0, column - 1);
2114
2225
  for (const token of OPERATOR_TOKENS_DESC) {
@@ -2150,59 +2261,59 @@ var HoverProvider = class extends Provider {
2150
2261
  let content;
2151
2262
  const tag = def.definition;
2152
2263
  switch (tag.code) {
2153
- case DiagnosticCode9.ParameterSubPatternImmutable:
2264
+ case DiagnosticCode10.ParameterSubPatternImmutable:
2154
2265
  content = {
2155
2266
  value: codeblock(`\0(parameter pattern) ${model.getValueInRange(tag.range)}`)
2156
2267
  };
2157
2268
  break;
2158
- case DiagnosticCode9.ParameterSubPatternMutable:
2269
+ case DiagnosticCode10.ParameterSubPatternMutable:
2159
2270
  content = {
2160
2271
  value: codeblock(`\0(parameter pattern) mut ${model.getValueInRange(tag.range)}`)
2161
2272
  };
2162
2273
  break;
2163
- case DiagnosticCode9.ParameterImmutable:
2274
+ case DiagnosticCode10.ParameterImmutable:
2164
2275
  content = {
2165
2276
  value: codeblock(`\0(parameter) ${model.getValueInRange(tag.range)}`)
2166
2277
  };
2167
2278
  break;
2168
- case DiagnosticCode9.ParameterMutable:
2279
+ case DiagnosticCode10.ParameterMutable:
2169
2280
  content = {
2170
2281
  value: codeblock(`\0(parameter) mut ${model.getValueInRange(tag.range)}`)
2171
2282
  };
2172
2283
  break;
2173
- case DiagnosticCode9.ParameterIt:
2284
+ case DiagnosticCode10.ParameterIt:
2174
2285
  content = {
2175
2286
  value: codeblock(`\0(parameter) it`)
2176
2287
  };
2177
2288
  break;
2178
- case DiagnosticCode9.ParameterImmutableRest:
2289
+ case DiagnosticCode10.ParameterImmutableRest:
2179
2290
  content = {
2180
2291
  value: codeblock(`\0(parameter) ..${model.getValueInRange(tag.range)}`)
2181
2292
  };
2182
2293
  break;
2183
- case DiagnosticCode9.ParameterMutableRest:
2294
+ case DiagnosticCode10.ParameterMutableRest:
2184
2295
  content = {
2185
2296
  value: codeblock(`\0(parameter) ..mut ${model.getValueInRange(tag.range)}`)
2186
2297
  };
2187
2298
  break;
2188
- case DiagnosticCode9.LocalFunction: {
2299
+ case DiagnosticCode10.LocalFunction: {
2189
2300
  const params = paramsList(model, def.fn);
2190
2301
  content = {
2191
2302
  value: codeblock(`\0fn ${model.getValueInRange(tag.range)}${params}`)
2192
2303
  };
2193
2304
  break;
2194
2305
  }
2195
- case DiagnosticCode9.LocalImmutable:
2306
+ case DiagnosticCode10.LocalImmutable:
2196
2307
  content = {
2197
2308
  value: codeblock(`\0let ${model.getValueInRange(tag.range)}`)
2198
2309
  };
2199
2310
  break;
2200
- case DiagnosticCode9.LocalConst:
2311
+ case DiagnosticCode10.LocalConst:
2201
2312
  content = {
2202
2313
  value: codeblock(`\0const ${model.getValueInRange(tag.range)}`)
2203
2314
  };
2204
2315
  break;
2205
- case DiagnosticCode9.LocalMutable:
2316
+ case DiagnosticCode10.LocalMutable:
2206
2317
  content = {
2207
2318
  value: codeblock(`\0let mut ${model.getValueInRange(tag.range)}`)
2208
2319
  };
@@ -2244,29 +2355,54 @@ var HoverProvider = class extends Provider {
2244
2355
  if (token?.type && token.type !== "other") {
2245
2356
  return void 0;
2246
2357
  }
2247
- if (token?.text && (token.text in HELP_KEYWORDS2 || token.text in HELP_OPERATORS)) {
2248
- const doc = HELP_KEYWORDS2[token.text] ?? HELP_OPERATORS[token.text];
2249
- return {
2250
- contents: [{ value: doc }],
2251
- range: {
2252
- startLineNumber: position.lineNumber,
2253
- endLineNumber: position.lineNumber,
2254
- startColumn: token.startColumn,
2255
- endColumn: token.endColumn
2358
+ if (token?.text) {
2359
+ if (token.text in HELP_KEYWORDS2) {
2360
+ const doc = HELP_KEYWORDS2[token.text];
2361
+ return {
2362
+ contents: [{ value: doc }],
2363
+ range: rangeAt(position, token)
2364
+ };
2365
+ }
2366
+ if (token.text in HELP_OPERATORS) {
2367
+ const doc = HELP_OPERATORS[token.text];
2368
+ return {
2369
+ contents: [{ value: doc }],
2370
+ range: rangeAt(position, token)
2371
+ };
2372
+ }
2373
+ if (REG_NUMBER_ALL_FULL.test(token.text)) {
2374
+ const num = convert.toNumber(token.text.replaceAll("_", ""), null);
2375
+ if (num == null) return void 0;
2376
+ const contents = [];
2377
+ if (Number.isInteger(num)) {
2378
+ const abs = Math.abs(num);
2379
+ if (abs <= BIN_MAX) {
2380
+ contents.push("\0(bin) " + serializeInteger(num, 2));
2381
+ }
2382
+ if (abs <= OCT_MAX) {
2383
+ contents.push("\0(oct) " + serializeInteger(num, 8));
2384
+ }
2385
+ if (abs <= HEX_MAX) {
2386
+ contents.push("\0(hex) " + serializeInteger(num, 16));
2387
+ }
2256
2388
  }
2257
- };
2389
+ if (contents.length) {
2390
+ contents.unshift(`\0(dec) ` + serializeNumber(num));
2391
+ } else {
2392
+ contents.push(`\0(number) ` + serializeNumber(num));
2393
+ }
2394
+ return {
2395
+ contents: [{ value: codeblock(contents.join("\n")) }],
2396
+ range: rangeAt(position, token)
2397
+ };
2398
+ }
2258
2399
  }
2259
2400
  const word = model.getWordAtPosition(position);
2260
2401
  if (word?.word && word.word in HELP_KEYWORDS2) {
2261
2402
  const doc = HELP_KEYWORDS2[word.word];
2262
2403
  return {
2263
2404
  contents: [{ value: doc }],
2264
- range: {
2265
- startLineNumber: position.lineNumber,
2266
- endLineNumber: position.lineNumber,
2267
- startColumn: word.startColumn,
2268
- endColumn: word.endColumn
2269
- }
2405
+ range: rangeAt(position, word)
2270
2406
  };
2271
2407
  }
2272
2408
  const lineContent = model.getLineContent(position.lineNumber);
@@ -2275,12 +2411,7 @@ var HoverProvider = class extends Provider {
2275
2411
  const doc = HELP_OPERATORS[hit.token];
2276
2412
  return {
2277
2413
  contents: [{ value: doc }],
2278
- range: {
2279
- startLineNumber: position.lineNumber,
2280
- endLineNumber: position.lineNumber,
2281
- startColumn: hit.range.startColumn,
2282
- endColumn: hit.range.endColumn
2283
- }
2414
+ range: rangeAt(position, hit.range)
2284
2415
  };
2285
2416
  }
2286
2417
  return void 0;
@@ -2299,7 +2430,7 @@ var HoverProvider = class extends Provider {
2299
2430
  };
2300
2431
 
2301
2432
  // src/lsp/providers/inlay-hints-provider.ts
2302
- import { DiagnosticCode as DiagnosticCode10 } from "@mirascript/constants";
2433
+ import { DiagnosticCode as DiagnosticCode11 } from "@mirascript/constants";
2303
2434
  var InlayHintsProvider = class extends Provider {
2304
2435
  /** @inheritdoc */
2305
2436
  get onDidChangeInlayHints() {
@@ -2324,7 +2455,7 @@ var InlayHintsProvider = class extends Provider {
2324
2455
  let paddingRight = false;
2325
2456
  const edits = [];
2326
2457
  switch (tag.code) {
2327
- case DiagnosticCode10.ParameterIt: {
2458
+ case DiagnosticCode11.ParameterIt: {
2328
2459
  if (!tag.references.length) {
2329
2460
  continue;
2330
2461
  }
@@ -2341,18 +2472,18 @@ var InlayHintsProvider = class extends Provider {
2341
2472
  });
2342
2473
  break;
2343
2474
  }
2344
- case DiagnosticCode10.UnnamedRecordField0:
2345
- case DiagnosticCode10.UnnamedRecordField1:
2346
- case DiagnosticCode10.UnnamedRecordField2:
2347
- case DiagnosticCode10.UnnamedRecordField3:
2348
- case DiagnosticCode10.UnnamedRecordField4:
2349
- case DiagnosticCode10.UnnamedRecordField5:
2350
- case DiagnosticCode10.UnnamedRecordField6:
2351
- case DiagnosticCode10.UnnamedRecordField7:
2352
- case DiagnosticCode10.UnnamedRecordField8:
2353
- case DiagnosticCode10.UnnamedRecordField9:
2354
- case DiagnosticCode10.UnnamedRecordFieldN: {
2355
- const index = tag.code - DiagnosticCode10.UnnamedRecordField0;
2475
+ case DiagnosticCode11.UnnamedRecordField0:
2476
+ case DiagnosticCode11.UnnamedRecordField1:
2477
+ case DiagnosticCode11.UnnamedRecordField2:
2478
+ case DiagnosticCode11.UnnamedRecordField3:
2479
+ case DiagnosticCode11.UnnamedRecordField4:
2480
+ case DiagnosticCode11.UnnamedRecordField5:
2481
+ case DiagnosticCode11.UnnamedRecordField6:
2482
+ case DiagnosticCode11.UnnamedRecordField7:
2483
+ case DiagnosticCode11.UnnamedRecordField8:
2484
+ case DiagnosticCode11.UnnamedRecordField9:
2485
+ case DiagnosticCode11.UnnamedRecordFieldN: {
2486
+ const index = tag.code - DiagnosticCode11.UnnamedRecordField0;
2356
2487
  if (index > 9) break;
2357
2488
  lineNumber = tag.range.startLineNumber;
2358
2489
  column = tag.range.startColumn;
@@ -2363,9 +2494,9 @@ var InlayHintsProvider = class extends Provider {
2363
2494
  paddingRight = true;
2364
2495
  break;
2365
2496
  }
2366
- case DiagnosticCode10.OmitNamedRecordField: {
2497
+ case DiagnosticCode11.OmitNamedRecordField: {
2367
2498
  const ref = tag.references[0];
2368
- if (ref?.code !== DiagnosticCode10.OmitNamedRecordFieldName) continue;
2499
+ if (ref?.code !== DiagnosticCode11.OmitNamedRecordFieldName) continue;
2369
2500
  lineNumber = tag.range.startLineNumber;
2370
2501
  column = tag.range.startColumn;
2371
2502
  label = model.getValueInRange(ref.range);
@@ -2431,7 +2562,7 @@ var RangeProvider = class extends Provider {
2431
2562
  };
2432
2563
 
2433
2564
  // src/lsp/providers/rename-provider.ts
2434
- import { DiagnosticCode as DiagnosticCode11 } from "@mirascript/constants";
2565
+ import { DiagnosticCode as DiagnosticCode12 } from "@mirascript/constants";
2435
2566
  var RenameProvider = class extends Provider {
2436
2567
  /** 重命名推断字段 */
2437
2568
  provideRenameEditsOmitNameFields(model, compiled, edits, ref, oldName) {
@@ -2482,7 +2613,7 @@ var RenameProvider = class extends Provider {
2482
2613
  versionId: compiled.version,
2483
2614
  textEdit: {
2484
2615
  range: d.def.definition.range,
2485
- text: d.def.definition.code === DiagnosticCode11.ParameterIt ? `(${newName})` : newName
2616
+ text: d.def.definition.code === DiagnosticCode12.ParameterIt ? `(${newName})` : newName
2486
2617
  }
2487
2618
  });
2488
2619
  oldName = model.getValueInRange(d.def.definition.range);
@@ -2548,7 +2679,7 @@ var RenameProvider = class extends Provider {
2548
2679
 
2549
2680
  // src/lsp/providers/semantic-tokens-provider.ts
2550
2681
  import { isVmFunction as isVmFunction2, isVmModule as isVmModule3 } from "@mirascript/mirascript";
2551
- import { DiagnosticCode as DiagnosticCode12 } from "@mirascript/constants";
2682
+ import { DiagnosticCode as DiagnosticCode13 } from "@mirascript/constants";
2552
2683
  var TOKEN_TYPES = {
2553
2684
  [0 /* VARIABLE */]: "variable.other.constant",
2554
2685
  [1 /* VARIABLE_MUTABLE */]: "variable",
@@ -2583,7 +2714,7 @@ var DocumentSemanticTokensProvider = class extends Provider {
2583
2714
  let tokenType = -1;
2584
2715
  let onlyReferences = false;
2585
2716
  switch (code) {
2586
- case DiagnosticCode12.GlobalVariable: {
2717
+ case DiagnosticCode13.GlobalVariable: {
2587
2718
  const id = model.getValueInRange(range);
2588
2719
  if (id.startsWith("@")) {
2589
2720
  tokenType = 2 /* CONSTANT */;
@@ -2599,44 +2730,46 @@ var DocumentSemanticTokensProvider = class extends Provider {
2599
2730
  }
2600
2731
  break;
2601
2732
  }
2602
- case DiagnosticCode12.LocalFunction: {
2733
+ case DiagnosticCode13.LocalFunction: {
2603
2734
  tokenType = 4 /* FUNCTION */;
2604
2735
  break;
2605
2736
  }
2606
- case DiagnosticCode12.ParameterMutable:
2607
- case DiagnosticCode12.ParameterSubPatternMutable:
2608
- case DiagnosticCode12.ParameterMutableRest: {
2737
+ case DiagnosticCode13.ParameterMutable:
2738
+ case DiagnosticCode13.ParameterSubPatternMutable:
2739
+ case DiagnosticCode13.ParameterMutableRest: {
2609
2740
  tokenType = 9 /* PARAM_MUTABLE */;
2610
2741
  break;
2611
2742
  }
2612
- case DiagnosticCode12.LocalMutable: {
2743
+ case DiagnosticCode13.LocalMutable: {
2613
2744
  tokenType = 1 /* VARIABLE_MUTABLE */;
2614
2745
  break;
2615
2746
  }
2616
- case DiagnosticCode12.ParameterIt: {
2747
+ case DiagnosticCode13.ParameterIt: {
2617
2748
  tokenType = 8 /* PARAM */;
2618
2749
  onlyReferences = true;
2619
2750
  break;
2620
2751
  }
2621
- case DiagnosticCode12.ParameterImmutable:
2622
- case DiagnosticCode12.ParameterSubPatternImmutable:
2623
- case DiagnosticCode12.ParameterImmutableRest: {
2752
+ case DiagnosticCode13.ParameterImmutable:
2753
+ case DiagnosticCode13.ParameterSubPatternImmutable:
2754
+ case DiagnosticCode13.ParameterImmutableRest: {
2624
2755
  tokenType = 8 /* PARAM */;
2625
2756
  break;
2626
2757
  }
2627
- case DiagnosticCode12.LocalImmutable: {
2758
+ case DiagnosticCode13.LocalImmutable: {
2628
2759
  tokenType = 0 /* VARIABLE */;
2629
2760
  break;
2630
2761
  }
2631
- case DiagnosticCode12.LocalConst: {
2762
+ case DiagnosticCode13.LocalConst: {
2632
2763
  tokenType = 2 /* CONSTANT */;
2633
2764
  break;
2634
2765
  }
2635
- case DiagnosticCode12.RecordFieldIdName: {
2766
+ // case DiagnosticCode.RecordFieldStringName:
2767
+ case DiagnosticCode13.RecordFieldOrdinalName:
2768
+ case DiagnosticCode13.RecordFieldIdName: {
2636
2769
  tokenType = 6 /* PROPERTY */;
2637
2770
  break;
2638
2771
  }
2639
- case DiagnosticCode12.ForExpression: {
2772
+ case DiagnosticCode13.ForExpression: {
2640
2773
  tokenType = 7 /* KEYWORD_CONTROL */;
2641
2774
  onlyReferences = true;
2642
2775
  break;
@@ -2695,7 +2828,7 @@ var DocumentSemanticTokensProvider = class extends Provider {
2695
2828
  };
2696
2829
 
2697
2830
  // src/lsp/providers/signature-help-provider.ts
2698
- import { DiagnosticCode as DiagnosticCode13 } from "@mirascript/constants";
2831
+ import { DiagnosticCode as DiagnosticCode14 } from "@mirascript/constants";
2699
2832
  import { getVmFunctionInfo as getVmFunctionInfo3 } from "@mirascript/mirascript";
2700
2833
  var SignatureHelpProvider = class extends Provider {
2701
2834
  constructor() {
@@ -2710,14 +2843,14 @@ var SignatureHelpProvider = class extends Provider {
2710
2843
  const compiled = await this.getCompileResult(model);
2711
2844
  if (!compiled) return void 0;
2712
2845
  const invokes = compiled.groupedTags(model).ranges.filter((r) => {
2713
- if (r.code !== DiagnosticCode13.FunctionCall && r.code !== DiagnosticCode13.ExtensionCall) {
2846
+ if (r.code !== DiagnosticCode14.FunctionCall && r.code !== DiagnosticCode14.ExtensionCall) {
2714
2847
  return false;
2715
2848
  }
2716
2849
  if (!strictContainsPosition(r.range, position)) {
2717
2850
  return false;
2718
2851
  }
2719
- const argStart = r.references.find((ref) => ref.code === DiagnosticCode13.ArgumentStart);
2720
- const argEnd = r.references.find((ref) => ref.code === DiagnosticCode13.ArgumentEnd);
2852
+ const argStart = r.references.find((ref) => ref.code === DiagnosticCode14.ArgumentStart);
2853
+ const argEnd = r.references.find((ref) => ref.code === DiagnosticCode14.ArgumentEnd);
2721
2854
  if (!argStart || !argEnd) {
2722
2855
  return false;
2723
2856
  }
@@ -2729,7 +2862,7 @@ var SignatureHelpProvider = class extends Provider {
2729
2862
  if (!invokes.length) return void 0;
2730
2863
  invokes.sort((a, b) => Range.strictContainsRange(a.range, b.range) ? 1 : -1);
2731
2864
  const invoke = invokes[0];
2732
- const callableRef = invoke.references.find((ref) => ref.code === DiagnosticCode13.Callable);
2865
+ const callableRef = invoke.references.find((ref) => ref.code === DiagnosticCode14.Callable);
2733
2866
  if (!callableRef) return void 0;
2734
2867
  const callableInfo = compiled.accessAt(model, Range.getEndPosition(callableRef.range));
2735
2868
  if (!callableInfo) return void 0;
@@ -2753,7 +2886,7 @@ var SignatureHelpProvider = class extends Provider {
2753
2886
  label: "",
2754
2887
  parameters: []
2755
2888
  };
2756
- if (invoke.code === DiagnosticCode13.ExtensionCall) {
2889
+ if (invoke.code === DiagnosticCode14.ExtensionCall) {
2757
2890
  const thisArg = sig.params[0];
2758
2891
  if (thisArg && !thisArg[0].startsWith("..")) {
2759
2892
  sig.params.shift();
@@ -2782,8 +2915,8 @@ var SignatureHelpProvider = class extends Provider {
2782
2915
  signature.label += ")" + sig.returns;
2783
2916
  let pos = 0;
2784
2917
  for (const ref of invoke.references) {
2785
- if (ref.code === DiagnosticCode13.ArgumentSpread) pos = Number.NaN;
2786
- if (ref.code !== DiagnosticCode13.ArgumentComma || Range.isEmpty(ref.range)) continue;
2918
+ if (ref.code === DiagnosticCode14.ArgumentSpread) pos = Number.NaN;
2919
+ if (ref.code !== DiagnosticCode14.ArgumentComma || Range.isEmpty(ref.range)) continue;
2787
2920
  if (Position.isBeforeOrEqual(Range.getEndPosition(ref.range), position) && !sig.params[pos]?.[0].startsWith("..")) {
2788
2921
  pos++;
2789
2922
  }
@@ -2805,6 +2938,7 @@ async function registerLSP(contextProvider2) {
2805
2938
  const { loadModule } = await import("@mirascript/bindings/wasm");
2806
2939
  await loadModule();
2807
2940
  const codeActionProvider = new CodeActionProvider();
2941
+ const codeLensProvider = new CodeLensProvider();
2808
2942
  const colorProvider = new ColorProvider();
2809
2943
  const completionItemProvider = new CompletionItemProvider();
2810
2944
  const definitionReferenceProvider = new DefinitionReferenceProvider();
@@ -2820,6 +2954,7 @@ async function registerLSP(contextProvider2) {
2820
2954
  const language = ["mirascript", "mirascript-template"];
2821
2955
  return [
2822
2956
  languages.registerCodeActionProvider(language, codeActionProvider),
2957
+ languages.registerCodeLensProvider(language, codeLensProvider),
2823
2958
  languages.registerColorProvider(language, colorProvider),
2824
2959
  languages.registerDefinitionProvider(language, definitionReferenceProvider),
2825
2960
  languages.registerReferenceProvider(language, definitionReferenceProvider),
@@ -2840,6 +2975,7 @@ async function registerLSP(contextProvider2) {
2840
2975
  }
2841
2976
  export {
2842
2977
  CodeActionProvider,
2978
+ CodeLensProvider,
2843
2979
  ColorProvider,
2844
2980
  CompletionItemProvider,
2845
2981
  DefinitionReferenceProvider,