@mirascript/monaco 0.1.35 → 0.1.38

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
@@ -4,7 +4,7 @@ import {
4
4
  REG_ORDINAL_FULL,
5
5
  RESERVED_KEYWORDS,
6
6
  isKeyword
7
- } from "../chunk-HWHYHL3D.js";
7
+ } from "../chunk-22HCOXU4.js";
8
8
  import {
9
9
  Emitter,
10
10
  MarkerSeverity,
@@ -790,6 +790,21 @@ var makeMarkerData = (model, range, code, message, severity, tags) => {
790
790
  }
791
791
  return marker;
792
792
  };
793
+ function getDiagnosticCode(marker) {
794
+ if (!marker) return void 0;
795
+ const { code } = marker;
796
+ if (typeof code == "object") {
797
+ const codeName = code.value;
798
+ if (codeName in DiagnosticCode3) {
799
+ return DiagnosticCode3[codeName];
800
+ }
801
+ } else if (typeof code == "string") {
802
+ if (code in DiagnosticCode3) {
803
+ return DiagnosticCode3[code];
804
+ }
805
+ }
806
+ return void 0;
807
+ }
793
808
  var makeMarker = (model, diagnostic, severity) => {
794
809
  const { range, code } = diagnostic;
795
810
  let unnecessary = false;
@@ -1135,22 +1150,188 @@ var Provider = class _Provider {
1135
1150
  };
1136
1151
 
1137
1152
  // src/lsp/providers/code-action-provider.ts
1153
+ import { DiagnosticCode as DiagnosticCode4 } from "@mirascript/constants";
1154
+ function createCodeAction(result, context, model, marker) {
1155
+ const code = getDiagnosticCode(marker);
1156
+ if (!code) return void 0;
1157
+ const range = Range.lift(marker);
1158
+ const action = {
1159
+ title: "",
1160
+ diagnostics: [marker]
1161
+ };
1162
+ const edits = (...textEdits) => {
1163
+ const edits2 = [];
1164
+ for (const textEdit of textEdits) {
1165
+ if (textEdit == null) continue;
1166
+ edits2.push({
1167
+ resource: model.uri,
1168
+ versionId: result.version,
1169
+ textEdit
1170
+ });
1171
+ }
1172
+ return { edits: edits2 };
1173
+ };
1174
+ if (code === DiagnosticCode4.PreferUppercaseConstant) {
1175
+ const current = model.getValueInRange(range);
1176
+ const uppercase = current.toUpperCase();
1177
+ if (current === uppercase || !Object.is(context.getOrUndefined(current), context.getOrUndefined(uppercase))) {
1178
+ return void 0;
1179
+ }
1180
+ action.title = "Convert to uppercase constant";
1181
+ action.kind = "quickfix";
1182
+ action.edit = edits({
1183
+ range,
1184
+ text: uppercase
1185
+ });
1186
+ } else if (code === DiagnosticCode4.PreferParenthesesForRecordLiteral) {
1187
+ const current = model.getValueInRange(range);
1188
+ let fixed = current;
1189
+ if (current.startsWith("{ ")) {
1190
+ fixed = `(${fixed.slice(2)}`;
1191
+ } else if (current.startsWith("{")) {
1192
+ fixed = `(${fixed.slice(1)}`;
1193
+ }
1194
+ if (current.endsWith(" }")) {
1195
+ fixed = `${fixed.slice(0, -2)})`;
1196
+ } else if (current.endsWith("}")) {
1197
+ fixed = `${fixed.slice(0, -1)})`;
1198
+ }
1199
+ if (fixed === current) {
1200
+ return void 0;
1201
+ }
1202
+ const prefix = model.getValueInRange({
1203
+ startLineNumber: range.startLineNumber,
1204
+ startColumn: range.startColumn - 1,
1205
+ endLineNumber: range.startLineNumber,
1206
+ endColumn: range.startColumn
1207
+ });
1208
+ if (prefix === "$") {
1209
+ fixed = `(${fixed})`;
1210
+ }
1211
+ action.title = "Convert record literal to parentheses";
1212
+ action.kind = "quickfix";
1213
+ action.edit = edits({
1214
+ range,
1215
+ text: fixed
1216
+ });
1217
+ } else if (code === DiagnosticCode4.PreferLogicalOperatorAnd || code === DiagnosticCode4.PreferLogicalOperatorOr || code === DiagnosticCode4.PreferLogicalOperatorNot) {
1218
+ let range0 = range;
1219
+ const current = model.getValueInRange(range);
1220
+ let fixed;
1221
+ if (current === "and") {
1222
+ fixed = "&&";
1223
+ } else if (current === "or") {
1224
+ fixed = "||";
1225
+ } else if (current === "not") {
1226
+ const range1 = range.setEndPosition(range.endLineNumber, range.endColumn + 1);
1227
+ const current1 = model.getValueInRange(range1);
1228
+ if (current1.trim() === "not") {
1229
+ range0 = range1;
1230
+ }
1231
+ fixed = "!";
1232
+ }
1233
+ if (!fixed) {
1234
+ return void 0;
1235
+ }
1236
+ action.title = `Convert to '${fixed}' operator`;
1237
+ action.kind = "quickfix";
1238
+ action.edit = edits({
1239
+ range: range0,
1240
+ text: fixed
1241
+ });
1242
+ } else if (code === DiagnosticCode4.UnnecessaryParentheses) {
1243
+ const current = model.getValueInRange(range);
1244
+ let fixed = current;
1245
+ if (current.startsWith("(")) {
1246
+ fixed = fixed.slice(1);
1247
+ }
1248
+ if (current.endsWith(")")) {
1249
+ fixed = fixed.slice(0, -1);
1250
+ }
1251
+ if (fixed === current) {
1252
+ return void 0;
1253
+ }
1254
+ action.title = "Remove unnecessary parentheses";
1255
+ action.kind = "quickfix";
1256
+ action.edit = edits({
1257
+ range,
1258
+ text: fixed
1259
+ });
1260
+ } else if (code === DiagnosticCode4.PreferIfExpression) {
1261
+ const tag = result.tags.find(
1262
+ (tag2) => tag2.code === DiagnosticCode4.IfExpression && Range.equalsRange(tag2.range, range)
1263
+ );
1264
+ if (!tag) return void 0;
1265
+ const questionMark = tag.references.find((ref) => ref.code === DiagnosticCode4.KeywordIf);
1266
+ const colon = tag.references.find((ref) => ref.code === DiagnosticCode4.KeywordElse);
1267
+ if (!questionMark || !colon) return void 0;
1268
+ const condRange = Range.fromPositions(
1269
+ range.getStartPosition(),
1270
+ model.getPositionAt(model.getOffsetAt(Range.getStartPosition(questionMark.range)))
1271
+ );
1272
+ const thenRange = Range.fromPositions(
1273
+ model.getPositionAt(model.getOffsetAt(Range.getEndPosition(questionMark.range))),
1274
+ model.getPositionAt(model.getOffsetAt(Range.getStartPosition(colon.range)))
1275
+ );
1276
+ const elseRange = Range.fromPositions(
1277
+ model.getPositionAt(model.getOffsetAt(Range.getEndPosition(colon.range))),
1278
+ range.getEndPosition()
1279
+ );
1280
+ const cond = model.getValueInRange(condRange).trim();
1281
+ const thenExpr = model.getValueInRange(thenRange).trim();
1282
+ const elseExpr = model.getValueInRange(elseRange).trim();
1283
+ const wrapIfNeeded = (expr, elseBranch) => {
1284
+ if (elseBranch && expr.startsWith("if ") && expr.endsWith("}")) {
1285
+ return expr;
1286
+ }
1287
+ if (expr.startsWith("{") && expr.endsWith("}") && !expr.includes(":")) {
1288
+ return expr;
1289
+ }
1290
+ if (expr.includes("\n")) {
1291
+ return `{
1292
+ ${expr}
1293
+ }`;
1294
+ }
1295
+ return `{ ${expr} }`;
1296
+ };
1297
+ const fixed = `if ${cond} ${wrapIfNeeded(thenExpr, false)} else ${wrapIfNeeded(elseExpr, true)}`;
1298
+ action.title = "Convert to if expression";
1299
+ action.kind = "quickfix";
1300
+ action.edit = edits({
1301
+ range,
1302
+ text: fixed
1303
+ });
1304
+ }
1305
+ if (action.title) return action;
1306
+ return void 0;
1307
+ }
1138
1308
  var CodeActionProvider = class extends Provider {
1139
1309
  /** @inheritdoc */
1140
- provideCodeActions(model, range, context, token) {
1310
+ async provideCodeActions(model, range, { markers, only, trigger }, token) {
1311
+ const result = await this.getCompileResult(model);
1312
+ if (!result) return void 0;
1313
+ const context = await this.getContext(model);
1314
+ const actions = [];
1315
+ for (const marker of markers) {
1316
+ const action = createCodeAction(result, context, model, marker);
1317
+ if (action == null || (only && action.kind ? action.kind !== only : false)) {
1318
+ continue;
1319
+ }
1320
+ actions.push(action);
1321
+ }
1141
1322
  return {
1142
- actions: [],
1323
+ actions,
1143
1324
  dispose: () => void 0
1144
1325
  };
1145
1326
  }
1146
1327
  /** @inheritdoc */
1147
1328
  resolveCodeAction(codeAction, token) {
1148
- throw new Error("Method not implemented.");
1329
+ return codeAction;
1149
1330
  }
1150
1331
  };
1151
1332
 
1152
1333
  // src/lsp/providers/color-provider.ts
1153
- import { DiagnosticCode as DiagnosticCode4 } from "@mirascript/constants";
1334
+ import { DiagnosticCode as DiagnosticCode5 } from "@mirascript/constants";
1154
1335
  var REG_COLOR_STR = /^(@*)(['"`])(#(?:[0-9a-f]{6}|[0-9a-f]{3}|[0-9a-f]{8}|[0-9a-f]{4}))\2\1$/iu;
1155
1336
  var { parseInt } = Number;
1156
1337
  function parseColorString(text) {
@@ -1213,7 +1394,7 @@ var ColorProvider = class extends Provider {
1213
1394
  if (!compiled) return void 0;
1214
1395
  const info = [];
1215
1396
  for (const { range, code } of compiled.groupedTags(model).ranges) {
1216
- if (code !== DiagnosticCode4.String) continue;
1397
+ if (code !== DiagnosticCode5.String) continue;
1217
1398
  if (range.startLineNumber !== range.endLineNumber) {
1218
1399
  continue;
1219
1400
  }
@@ -1251,7 +1432,7 @@ import {
1251
1432
  isVmWrapper as isVmWrapper2,
1252
1433
  serialize as serialize2
1253
1434
  } from "@mirascript/mirascript";
1254
- import { DiagnosticCode as DiagnosticCode5 } from "@mirascript/mirascript/subtle";
1435
+ import { DiagnosticCode as DiagnosticCode6 } from "@mirascript/mirascript/subtle";
1255
1436
  var DESC_GLOBAL = "(global)";
1256
1437
  var DESC_LOCAL = "(local)";
1257
1438
  var DESC_FIELD = "(field)";
@@ -1489,7 +1670,7 @@ var CompletionItemProvider = class extends Provider {
1489
1670
  const locals = /* @__PURE__ */ new Set();
1490
1671
  while (scope) {
1491
1672
  for (const { definition, fn } of scope.locals) {
1492
- const name = definition.code === DiagnosticCode5.ParameterIt ? "it" : model.getValueInRange(definition.range);
1673
+ const name = definition.code === DiagnosticCode6.ParameterIt ? "it" : model.getValueInRange(definition.range);
1493
1674
  if (char && !name.toLowerCase().includes(char)) continue;
1494
1675
  if (locals.has(name)) continue;
1495
1676
  locals.add(name);
@@ -1584,7 +1765,7 @@ var CompletionItemProvider = class extends Provider {
1584
1765
  if (def.ref == null) {
1585
1766
  const suggestions2 = [];
1586
1767
  if (word && compiled.tags.some(
1587
- (t) => strictContainsPosition(t.range, position) && t.code === DiagnosticCode5.MatchExpression
1768
+ (t) => strictContainsPosition(t.range, position) && t.code === DiagnosticCode6.MatchExpression
1588
1769
  )) {
1589
1770
  suggestions2.push(
1590
1771
  kwSuggestion("case", this.toCompletionItemRanges(position, word.range)),
@@ -1728,7 +1909,7 @@ var DefinitionReferenceProvider = class extends Provider {
1728
1909
  };
1729
1910
 
1730
1911
  // src/lsp/providers/document-highlight-provider.ts
1731
- import { DiagnosticCode as DiagnosticCode6 } from "@mirascript/mirascript/subtle";
1912
+ import { DiagnosticCode as DiagnosticCode7 } from "@mirascript/mirascript/subtle";
1732
1913
  var DocumentHighlightProvider = class extends Provider {
1733
1914
  /** @inheritdoc */
1734
1915
  async provideDocumentHighlights(model, position, token) {
@@ -1748,7 +1929,7 @@ var DocumentHighlightProvider = class extends Provider {
1748
1929
  const links = def.references.map((u) => {
1749
1930
  const { code, range } = u;
1750
1931
  let kind = languages.DocumentHighlightKind.Read;
1751
- if (code === DiagnosticCode6.WriteLocal || code === DiagnosticCode6.ReadWriteLocal || code === DiagnosticCode6.RedeclareLocal) {
1932
+ if (code === DiagnosticCode7.WriteLocal || code === DiagnosticCode7.ReadWriteLocal || code === DiagnosticCode7.RedeclareLocal) {
1752
1933
  kind = languages.DocumentHighlightKind.Write;
1753
1934
  }
1754
1935
  return {
@@ -1778,7 +1959,7 @@ var DocumentHighlightProvider = class extends Provider {
1778
1959
  };
1779
1960
 
1780
1961
  // src/lsp/providers/document-symbol-provider.ts
1781
- import { DiagnosticCode as DiagnosticCode7 } from "@mirascript/constants";
1962
+ import { DiagnosticCode as DiagnosticCode8 } from "@mirascript/constants";
1782
1963
  var DocumentSymbolProvider = class extends Provider {
1783
1964
  /** 构建树 */
1784
1965
  handleScope(model, scope) {
@@ -1791,13 +1972,13 @@ var DocumentSymbolProvider = class extends Provider {
1791
1972
  let children = [];
1792
1973
  let allRange = range;
1793
1974
  switch (definition.code) {
1794
- case DiagnosticCode7.ParameterIt:
1975
+ case DiagnosticCode8.ParameterIt:
1795
1976
  if (definition.references.length === 0) {
1796
1977
  continue;
1797
1978
  }
1798
1979
  name = `it`;
1799
1980
  break;
1800
- case DiagnosticCode7.LocalFunction: {
1981
+ case DiagnosticCode8.LocalFunction: {
1801
1982
  kind = languages.SymbolKind.Function;
1802
1983
  const funcScope = scope.children.find((s) => Range.compareRangesUsingStarts(s.range, range) > 0);
1803
1984
  if (funcScope) {
@@ -1883,7 +2064,7 @@ var FormatterProvider = class extends Provider {
1883
2064
  };
1884
2065
 
1885
2066
  // src/lsp/providers/hover-provider.ts
1886
- import { DiagnosticCode as DiagnosticCode8 } from "@mirascript/constants";
2067
+ import { DiagnosticCode as DiagnosticCode9 } from "@mirascript/constants";
1887
2068
  var HoverProvider = class extends Provider {
1888
2069
  /** 变量提示 */
1889
2070
  async provideVariableHover(model, { def, ref }) {
@@ -1902,59 +2083,59 @@ var HoverProvider = class extends Provider {
1902
2083
  let content;
1903
2084
  const tag = def.definition;
1904
2085
  switch (tag.code) {
1905
- case DiagnosticCode8.ParameterSubPatternImmutable:
2086
+ case DiagnosticCode9.ParameterSubPatternImmutable:
1906
2087
  content = {
1907
2088
  value: codeblock(`\0(parameter pattern) ${model.getValueInRange(tag.range)}`)
1908
2089
  };
1909
2090
  break;
1910
- case DiagnosticCode8.ParameterSubPatternMutable:
2091
+ case DiagnosticCode9.ParameterSubPatternMutable:
1911
2092
  content = {
1912
2093
  value: codeblock(`\0(parameter pattern) mut ${model.getValueInRange(tag.range)}`)
1913
2094
  };
1914
2095
  break;
1915
- case DiagnosticCode8.ParameterImmutable:
2096
+ case DiagnosticCode9.ParameterImmutable:
1916
2097
  content = {
1917
2098
  value: codeblock(`\0(parameter) ${model.getValueInRange(tag.range)}`)
1918
2099
  };
1919
2100
  break;
1920
- case DiagnosticCode8.ParameterMutable:
2101
+ case DiagnosticCode9.ParameterMutable:
1921
2102
  content = {
1922
2103
  value: codeblock(`\0(parameter) mut ${model.getValueInRange(tag.range)}`)
1923
2104
  };
1924
2105
  break;
1925
- case DiagnosticCode8.ParameterIt:
2106
+ case DiagnosticCode9.ParameterIt:
1926
2107
  content = {
1927
2108
  value: codeblock(`\0(parameter) it`)
1928
2109
  };
1929
2110
  break;
1930
- case DiagnosticCode8.ParameterImmutableRest:
2111
+ case DiagnosticCode9.ParameterImmutableRest:
1931
2112
  content = {
1932
2113
  value: codeblock(`\0(parameter) ..${model.getValueInRange(tag.range)}`)
1933
2114
  };
1934
2115
  break;
1935
- case DiagnosticCode8.ParameterMutableRest:
2116
+ case DiagnosticCode9.ParameterMutableRest:
1936
2117
  content = {
1937
2118
  value: codeblock(`\0(parameter) ..mut ${model.getValueInRange(tag.range)}`)
1938
2119
  };
1939
2120
  break;
1940
- case DiagnosticCode8.LocalFunction: {
2121
+ case DiagnosticCode9.LocalFunction: {
1941
2122
  const params = paramsList(model, def.fn);
1942
2123
  content = {
1943
2124
  value: codeblock(`\0fn ${model.getValueInRange(tag.range)}${params}`)
1944
2125
  };
1945
2126
  break;
1946
2127
  }
1947
- case DiagnosticCode8.LocalImmutable:
2128
+ case DiagnosticCode9.LocalImmutable:
1948
2129
  content = {
1949
2130
  value: codeblock(`\0let ${model.getValueInRange(tag.range)}`)
1950
2131
  };
1951
2132
  break;
1952
- case DiagnosticCode8.LocalConst:
2133
+ case DiagnosticCode9.LocalConst:
1953
2134
  content = {
1954
2135
  value: codeblock(`\0const ${model.getValueInRange(tag.range)}`)
1955
2136
  };
1956
2137
  break;
1957
- case DiagnosticCode8.LocalMutable:
2138
+ case DiagnosticCode9.LocalMutable:
1958
2139
  content = {
1959
2140
  value: codeblock(`\0let mut ${model.getValueInRange(tag.range)}`)
1960
2141
  };
@@ -2003,7 +2184,7 @@ var HoverProvider = class extends Provider {
2003
2184
  };
2004
2185
 
2005
2186
  // src/lsp/providers/inlay-hints-provider.ts
2006
- import { DiagnosticCode as DiagnosticCode9 } from "@mirascript/constants";
2187
+ import { DiagnosticCode as DiagnosticCode10 } from "@mirascript/constants";
2007
2188
  var InlayHintsProvider = class extends Provider {
2008
2189
  /** @inheritdoc */
2009
2190
  get onDidChangeInlayHints() {
@@ -2028,7 +2209,7 @@ var InlayHintsProvider = class extends Provider {
2028
2209
  let paddingRight = false;
2029
2210
  const edits = [];
2030
2211
  switch (tag.code) {
2031
- case DiagnosticCode9.ParameterIt: {
2212
+ case DiagnosticCode10.ParameterIt: {
2032
2213
  if (!tag.references.length) {
2033
2214
  continue;
2034
2215
  }
@@ -2045,18 +2226,18 @@ var InlayHintsProvider = class extends Provider {
2045
2226
  });
2046
2227
  break;
2047
2228
  }
2048
- case DiagnosticCode9.UnnamedRecordField0:
2049
- case DiagnosticCode9.UnnamedRecordField1:
2050
- case DiagnosticCode9.UnnamedRecordField2:
2051
- case DiagnosticCode9.UnnamedRecordField3:
2052
- case DiagnosticCode9.UnnamedRecordField4:
2053
- case DiagnosticCode9.UnnamedRecordField5:
2054
- case DiagnosticCode9.UnnamedRecordField6:
2055
- case DiagnosticCode9.UnnamedRecordField7:
2056
- case DiagnosticCode9.UnnamedRecordField8:
2057
- case DiagnosticCode9.UnnamedRecordField9:
2058
- case DiagnosticCode9.UnnamedRecordFieldN: {
2059
- const index = tag.code - DiagnosticCode9.UnnamedRecordField0;
2229
+ case DiagnosticCode10.UnnamedRecordField0:
2230
+ case DiagnosticCode10.UnnamedRecordField1:
2231
+ case DiagnosticCode10.UnnamedRecordField2:
2232
+ case DiagnosticCode10.UnnamedRecordField3:
2233
+ case DiagnosticCode10.UnnamedRecordField4:
2234
+ case DiagnosticCode10.UnnamedRecordField5:
2235
+ case DiagnosticCode10.UnnamedRecordField6:
2236
+ case DiagnosticCode10.UnnamedRecordField7:
2237
+ case DiagnosticCode10.UnnamedRecordField8:
2238
+ case DiagnosticCode10.UnnamedRecordField9:
2239
+ case DiagnosticCode10.UnnamedRecordFieldN: {
2240
+ const index = tag.code - DiagnosticCode10.UnnamedRecordField0;
2060
2241
  if (index > 9) break;
2061
2242
  lineNumber = tag.range.startLineNumber;
2062
2243
  column = tag.range.startColumn;
@@ -2067,9 +2248,9 @@ var InlayHintsProvider = class extends Provider {
2067
2248
  paddingRight = true;
2068
2249
  break;
2069
2250
  }
2070
- case DiagnosticCode9.OmitNamedRecordField: {
2251
+ case DiagnosticCode10.OmitNamedRecordField: {
2071
2252
  const ref = tag.references[0];
2072
- if (ref?.code !== DiagnosticCode9.OmitNamedRecordFieldName) continue;
2253
+ if (ref?.code !== DiagnosticCode10.OmitNamedRecordFieldName) continue;
2073
2254
  lineNumber = tag.range.startLineNumber;
2074
2255
  column = tag.range.startColumn;
2075
2256
  label = model.getValueInRange(ref.range);
@@ -2135,7 +2316,7 @@ var RangeProvider = class extends Provider {
2135
2316
  };
2136
2317
 
2137
2318
  // src/lsp/providers/rename-provider.ts
2138
- import { DiagnosticCode as DiagnosticCode10 } from "@mirascript/constants";
2319
+ import { DiagnosticCode as DiagnosticCode11 } from "@mirascript/constants";
2139
2320
  var RenameProvider = class extends Provider {
2140
2321
  /** 重命名推断字段 */
2141
2322
  provideRenameEditsOmitNameFields(model, compiled, edits, ref, oldName) {
@@ -2186,7 +2367,7 @@ var RenameProvider = class extends Provider {
2186
2367
  versionId: compiled.version,
2187
2368
  textEdit: {
2188
2369
  range: d.def.definition.range,
2189
- text: d.def.definition.code === DiagnosticCode10.ParameterIt ? `(${newName})` : newName
2370
+ text: d.def.definition.code === DiagnosticCode11.ParameterIt ? `(${newName})` : newName
2190
2371
  }
2191
2372
  });
2192
2373
  oldName = model.getValueInRange(d.def.definition.range);
@@ -2252,7 +2433,7 @@ var RenameProvider = class extends Provider {
2252
2433
 
2253
2434
  // src/lsp/providers/semantic-tokens-provider.ts
2254
2435
  import { isVmFunction as isVmFunction2, isVmModule as isVmModule3 } from "@mirascript/mirascript";
2255
- import { DiagnosticCode as DiagnosticCode11 } from "@mirascript/constants";
2436
+ import { DiagnosticCode as DiagnosticCode12 } from "@mirascript/constants";
2256
2437
  var TOKEN_TYPES = {
2257
2438
  [0 /* VARIABLE */]: "variable.other.constant",
2258
2439
  [1 /* VARIABLE_MUTABLE */]: "variable",
@@ -2287,7 +2468,7 @@ var DocumentSemanticTokensProvider = class extends Provider {
2287
2468
  let tokenType = -1;
2288
2469
  let onlyReferences = false;
2289
2470
  switch (code) {
2290
- case DiagnosticCode11.GlobalVariable: {
2471
+ case DiagnosticCode12.GlobalVariable: {
2291
2472
  const id = model.getValueInRange(range);
2292
2473
  if (id.startsWith("@")) {
2293
2474
  tokenType = 2 /* CONSTANT */;
@@ -2303,44 +2484,44 @@ var DocumentSemanticTokensProvider = class extends Provider {
2303
2484
  }
2304
2485
  break;
2305
2486
  }
2306
- case DiagnosticCode11.LocalFunction: {
2487
+ case DiagnosticCode12.LocalFunction: {
2307
2488
  tokenType = 4 /* FUNCTION */;
2308
2489
  break;
2309
2490
  }
2310
- case DiagnosticCode11.ParameterMutable:
2311
- case DiagnosticCode11.ParameterSubPatternMutable:
2312
- case DiagnosticCode11.ParameterMutableRest: {
2491
+ case DiagnosticCode12.ParameterMutable:
2492
+ case DiagnosticCode12.ParameterSubPatternMutable:
2493
+ case DiagnosticCode12.ParameterMutableRest: {
2313
2494
  tokenType = 9 /* PARAM_MUTABLE */;
2314
2495
  break;
2315
2496
  }
2316
- case DiagnosticCode11.LocalMutable: {
2497
+ case DiagnosticCode12.LocalMutable: {
2317
2498
  tokenType = 1 /* VARIABLE_MUTABLE */;
2318
2499
  break;
2319
2500
  }
2320
- case DiagnosticCode11.ParameterIt: {
2501
+ case DiagnosticCode12.ParameterIt: {
2321
2502
  tokenType = 8 /* PARAM */;
2322
2503
  onlyReferences = true;
2323
2504
  break;
2324
2505
  }
2325
- case DiagnosticCode11.ParameterImmutable:
2326
- case DiagnosticCode11.ParameterSubPatternImmutable:
2327
- case DiagnosticCode11.ParameterImmutableRest: {
2506
+ case DiagnosticCode12.ParameterImmutable:
2507
+ case DiagnosticCode12.ParameterSubPatternImmutable:
2508
+ case DiagnosticCode12.ParameterImmutableRest: {
2328
2509
  tokenType = 8 /* PARAM */;
2329
2510
  break;
2330
2511
  }
2331
- case DiagnosticCode11.LocalImmutable: {
2512
+ case DiagnosticCode12.LocalImmutable: {
2332
2513
  tokenType = 0 /* VARIABLE */;
2333
2514
  break;
2334
2515
  }
2335
- case DiagnosticCode11.LocalConst: {
2516
+ case DiagnosticCode12.LocalConst: {
2336
2517
  tokenType = 2 /* CONSTANT */;
2337
2518
  break;
2338
2519
  }
2339
- case DiagnosticCode11.RecordFieldIdName: {
2520
+ case DiagnosticCode12.RecordFieldIdName: {
2340
2521
  tokenType = 6 /* PROPERTY */;
2341
2522
  break;
2342
2523
  }
2343
- case DiagnosticCode11.ForExpression: {
2524
+ case DiagnosticCode12.ForExpression: {
2344
2525
  tokenType = 7 /* KEYWORD_CONTROL */;
2345
2526
  onlyReferences = true;
2346
2527
  break;
@@ -2399,7 +2580,7 @@ var DocumentSemanticTokensProvider = class extends Provider {
2399
2580
  };
2400
2581
 
2401
2582
  // src/lsp/providers/signature-help-provider.ts
2402
- import { DiagnosticCode as DiagnosticCode12 } from "@mirascript/constants";
2583
+ import { DiagnosticCode as DiagnosticCode13 } from "@mirascript/constants";
2403
2584
  import { getVmFunctionInfo as getVmFunctionInfo3 } from "@mirascript/mirascript";
2404
2585
  var SignatureHelpProvider = class extends Provider {
2405
2586
  constructor() {
@@ -2414,14 +2595,14 @@ var SignatureHelpProvider = class extends Provider {
2414
2595
  const compiled = await this.getCompileResult(model);
2415
2596
  if (!compiled) return void 0;
2416
2597
  const invokes = compiled.groupedTags(model).ranges.filter((r) => {
2417
- if (r.code !== DiagnosticCode12.FunctionCall && r.code !== DiagnosticCode12.ExtensionCall) {
2598
+ if (r.code !== DiagnosticCode13.FunctionCall && r.code !== DiagnosticCode13.ExtensionCall) {
2418
2599
  return false;
2419
2600
  }
2420
2601
  if (!strictContainsPosition(r.range, position)) {
2421
2602
  return false;
2422
2603
  }
2423
- const argStart = r.references.find((ref) => ref.code === DiagnosticCode12.ArgumentStart);
2424
- const argEnd = r.references.find((ref) => ref.code === DiagnosticCode12.ArgumentEnd);
2604
+ const argStart = r.references.find((ref) => ref.code === DiagnosticCode13.ArgumentStart);
2605
+ const argEnd = r.references.find((ref) => ref.code === DiagnosticCode13.ArgumentEnd);
2425
2606
  if (!argStart || !argEnd) {
2426
2607
  return false;
2427
2608
  }
@@ -2433,7 +2614,7 @@ var SignatureHelpProvider = class extends Provider {
2433
2614
  if (!invokes.length) return void 0;
2434
2615
  invokes.sort((a, b) => Range.strictContainsRange(a.range, b.range) ? 1 : -1);
2435
2616
  const invoke = invokes[0];
2436
- const callableRef = invoke.references.find((ref) => ref.code === DiagnosticCode12.Callable);
2617
+ const callableRef = invoke.references.find((ref) => ref.code === DiagnosticCode13.Callable);
2437
2618
  if (!callableRef) return void 0;
2438
2619
  const callableInfo = compiled.accessAt(model, Range.getEndPosition(callableRef.range));
2439
2620
  if (!callableInfo) return void 0;
@@ -2457,7 +2638,7 @@ var SignatureHelpProvider = class extends Provider {
2457
2638
  label: "",
2458
2639
  parameters: []
2459
2640
  };
2460
- if (invoke.code === DiagnosticCode12.ExtensionCall) {
2641
+ if (invoke.code === DiagnosticCode13.ExtensionCall) {
2461
2642
  const thisArg = sig.params[0];
2462
2643
  if (thisArg && !thisArg[0].startsWith("..")) {
2463
2644
  sig.params.shift();
@@ -2486,8 +2667,8 @@ var SignatureHelpProvider = class extends Provider {
2486
2667
  signature.label += ")" + sig.returns;
2487
2668
  let pos = 0;
2488
2669
  for (const ref of invoke.references) {
2489
- if (ref.code === DiagnosticCode12.ArgumentSpread) pos = Number.NaN;
2490
- if (ref.code !== DiagnosticCode12.ArgumentComma || Range.isEmpty(ref.range)) continue;
2670
+ if (ref.code === DiagnosticCode13.ArgumentSpread) pos = Number.NaN;
2671
+ if (ref.code !== DiagnosticCode13.ArgumentComma || Range.isEmpty(ref.range)) continue;
2491
2672
  if (Position.isBeforeOrEqual(Range.getEndPosition(ref.range), position) && !sig.params[pos]?.[0].startsWith("..")) {
2492
2673
  pos++;
2493
2674
  }