@mirascript/monaco 0.1.41 → 0.1.43
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/basic/index.js +1 -1
- package/dist/basic/tokens-provider.d.ts.map +1 -1
- package/dist/{chunk-KZW3KCZF.js → chunk-QENEDDTR.js} +10 -12
- package/dist/chunk-QENEDDTR.js.map +6 -0
- package/dist/lsp/index.d.ts +2 -1
- package/dist/lsp/index.d.ts.map +1 -1
- package/dist/lsp/index.js +106 -79
- package/dist/lsp/index.js.map +3 -3
- package/dist/lsp/providers/code-action-provider.d.ts.map +1 -1
- package/dist/lsp/providers/code-lens-provider.d.ts +12 -0
- package/dist/lsp/providers/code-lens-provider.d.ts.map +1 -0
- package/dist/lsp/providers/hover-provider.d.ts.map +1 -1
- package/dist/lsp/providers/semantic-tokens-provider.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/basic/tokens-provider.ts +9 -12
- package/src/lsp/index.ts +4 -0
- package/src/lsp/providers/code-action-provider.ts +6 -8
- package/src/lsp/providers/code-lens-provider.ts +39 -0
- package/src/lsp/providers/hover-provider.ts +10 -8
- package/src/lsp/providers/semantic-tokens-provider.ts +2 -0
- package/dist/chunk-KZW3KCZF.js.map +0 -6
package/dist/lsp/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
REG_ORDINAL_FULL,
|
|
9
9
|
RESERVED_KEYWORDS,
|
|
10
10
|
isKeyword
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-QENEDDTR.js";
|
|
12
12
|
import {
|
|
13
13
|
Emitter,
|
|
14
14
|
MarkerSeverity,
|
|
@@ -1264,7 +1264,7 @@ function createCodeAction(result, context, model, marker) {
|
|
|
1264
1264
|
if (current === uppercase || !Object.is(context.getOrUndefined(current), context.getOrUndefined(uppercase))) {
|
|
1265
1265
|
return void 0;
|
|
1266
1266
|
}
|
|
1267
|
-
action.title = "
|
|
1267
|
+
action.title = "转换为大写常量";
|
|
1268
1268
|
action.kind = "quickfix";
|
|
1269
1269
|
action.edit = edits({
|
|
1270
1270
|
range,
|
|
@@ -1295,7 +1295,7 @@ function createCodeAction(result, context, model, marker) {
|
|
|
1295
1295
|
if (prefix === "$") {
|
|
1296
1296
|
fixed = `(${fixed})`;
|
|
1297
1297
|
}
|
|
1298
|
-
action.title =
|
|
1298
|
+
action.title = `转换为使用圆括号的记录字面量`;
|
|
1299
1299
|
action.kind = "quickfix";
|
|
1300
1300
|
action.edit = edits({
|
|
1301
1301
|
range,
|
|
@@ -1320,7 +1320,7 @@ function createCodeAction(result, context, model, marker) {
|
|
|
1320
1320
|
if (!fixed) {
|
|
1321
1321
|
return void 0;
|
|
1322
1322
|
}
|
|
1323
|
-
action.title =
|
|
1323
|
+
action.title = `转换为 '${fixed}' 运算符`;
|
|
1324
1324
|
action.kind = "quickfix";
|
|
1325
1325
|
action.edit = edits({
|
|
1326
1326
|
range: range0,
|
|
@@ -1338,7 +1338,7 @@ function createCodeAction(result, context, model, marker) {
|
|
|
1338
1338
|
if (fixed === current) {
|
|
1339
1339
|
return void 0;
|
|
1340
1340
|
}
|
|
1341
|
-
action.title = "
|
|
1341
|
+
action.title = "移除不必要的括号";
|
|
1342
1342
|
action.kind = "quickfix";
|
|
1343
1343
|
action.edit = edits({
|
|
1344
1344
|
range,
|
|
@@ -1382,7 +1382,7 @@ function createCodeAction(result, context, model, marker) {
|
|
|
1382
1382
|
return `{ ${expr} }`;
|
|
1383
1383
|
};
|
|
1384
1384
|
const fixed = `if ${cond} ${wrapIfNeeded(thenExpr, false)} else ${wrapIfNeeded(elseExpr, true)}`;
|
|
1385
|
-
action.title = "
|
|
1385
|
+
action.title = "转换为 if 表达式";
|
|
1386
1386
|
action.kind = "quickfix";
|
|
1387
1387
|
action.edit = edits({
|
|
1388
1388
|
range,
|
|
@@ -1411,14 +1411,34 @@ var CodeActionProvider = class extends Provider {
|
|
|
1411
1411
|
dispose: () => void 0
|
|
1412
1412
|
};
|
|
1413
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 {
|
|
1414
1419
|
/** @inheritdoc */
|
|
1415
|
-
|
|
1416
|
-
|
|
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 };
|
|
1417
1437
|
}
|
|
1418
1438
|
};
|
|
1419
1439
|
|
|
1420
1440
|
// src/lsp/providers/color-provider.ts
|
|
1421
|
-
import { DiagnosticCode as
|
|
1441
|
+
import { DiagnosticCode as DiagnosticCode6 } from "@mirascript/constants";
|
|
1422
1442
|
var REG_COLOR_STR = /^(@*)(['"`])(#(?:[0-9a-f]{6}|[0-9a-f]{3}|[0-9a-f]{8}|[0-9a-f]{4}))\2\1$/iu;
|
|
1423
1443
|
var { parseInt } = Number;
|
|
1424
1444
|
function parseColorString(text) {
|
|
@@ -1481,7 +1501,7 @@ var ColorProvider = class extends Provider {
|
|
|
1481
1501
|
if (!compiled) return void 0;
|
|
1482
1502
|
const info = [];
|
|
1483
1503
|
for (const { range, code } of compiled.groupedTags(model).ranges) {
|
|
1484
|
-
if (code !==
|
|
1504
|
+
if (code !== DiagnosticCode6.String) continue;
|
|
1485
1505
|
if (range.startLineNumber !== range.endLineNumber) {
|
|
1486
1506
|
continue;
|
|
1487
1507
|
}
|
|
@@ -1519,7 +1539,7 @@ import {
|
|
|
1519
1539
|
isVmWrapper as isVmWrapper2,
|
|
1520
1540
|
serialize as serialize2
|
|
1521
1541
|
} from "@mirascript/mirascript";
|
|
1522
|
-
import { DiagnosticCode as
|
|
1542
|
+
import { DiagnosticCode as DiagnosticCode7 } from "@mirascript/mirascript/subtle";
|
|
1523
1543
|
import { KEYWORDS as HELP_KEYWORDS } from "@mirascript/help";
|
|
1524
1544
|
var DESC_GLOBAL = "(global)";
|
|
1525
1545
|
var DESC_LOCAL = "(local)";
|
|
@@ -1756,7 +1776,7 @@ var CompletionItemProvider = class extends Provider {
|
|
|
1756
1776
|
const locals = /* @__PURE__ */ new Set();
|
|
1757
1777
|
while (scope) {
|
|
1758
1778
|
for (const { definition, fn } of scope.locals) {
|
|
1759
|
-
const name = definition.code ===
|
|
1779
|
+
const name = definition.code === DiagnosticCode7.ParameterIt ? "it" : model.getValueInRange(definition.range);
|
|
1760
1780
|
if (char && !name.toLowerCase().includes(char)) continue;
|
|
1761
1781
|
if (locals.has(name)) continue;
|
|
1762
1782
|
locals.add(name);
|
|
@@ -1851,7 +1871,7 @@ var CompletionItemProvider = class extends Provider {
|
|
|
1851
1871
|
if (def.ref == null) {
|
|
1852
1872
|
const suggestions2 = [];
|
|
1853
1873
|
if (word && compiled.tags.some(
|
|
1854
|
-
(t) => strictContainsPosition(t.range, position) && t.code ===
|
|
1874
|
+
(t) => strictContainsPosition(t.range, position) && t.code === DiagnosticCode7.MatchExpression
|
|
1855
1875
|
)) {
|
|
1856
1876
|
suggestions2.push(
|
|
1857
1877
|
kwSuggestion("case", this.toCompletionItemRanges(position, word.range)),
|
|
@@ -1995,7 +2015,7 @@ var DefinitionReferenceProvider = class extends Provider {
|
|
|
1995
2015
|
};
|
|
1996
2016
|
|
|
1997
2017
|
// src/lsp/providers/document-highlight-provider.ts
|
|
1998
|
-
import { DiagnosticCode as
|
|
2018
|
+
import { DiagnosticCode as DiagnosticCode8 } from "@mirascript/mirascript/subtle";
|
|
1999
2019
|
var DocumentHighlightProvider = class extends Provider {
|
|
2000
2020
|
/** @inheritdoc */
|
|
2001
2021
|
async provideDocumentHighlights(model, position, token) {
|
|
@@ -2015,7 +2035,7 @@ var DocumentHighlightProvider = class extends Provider {
|
|
|
2015
2035
|
const links = def.references.map((u) => {
|
|
2016
2036
|
const { code, range } = u;
|
|
2017
2037
|
let kind = languages.DocumentHighlightKind.Read;
|
|
2018
|
-
if (code ===
|
|
2038
|
+
if (code === DiagnosticCode8.WriteLocal || code === DiagnosticCode8.ReadWriteLocal || code === DiagnosticCode8.RedeclareLocal) {
|
|
2019
2039
|
kind = languages.DocumentHighlightKind.Write;
|
|
2020
2040
|
}
|
|
2021
2041
|
return {
|
|
@@ -2045,7 +2065,7 @@ var DocumentHighlightProvider = class extends Provider {
|
|
|
2045
2065
|
};
|
|
2046
2066
|
|
|
2047
2067
|
// src/lsp/providers/document-symbol-provider.ts
|
|
2048
|
-
import { DiagnosticCode as
|
|
2068
|
+
import { DiagnosticCode as DiagnosticCode9 } from "@mirascript/constants";
|
|
2049
2069
|
var DocumentSymbolProvider = class extends Provider {
|
|
2050
2070
|
/** 构建树 */
|
|
2051
2071
|
handleScope(model, scope) {
|
|
@@ -2058,13 +2078,13 @@ var DocumentSymbolProvider = class extends Provider {
|
|
|
2058
2078
|
let children = [];
|
|
2059
2079
|
let allRange = range;
|
|
2060
2080
|
switch (definition.code) {
|
|
2061
|
-
case
|
|
2081
|
+
case DiagnosticCode9.ParameterIt:
|
|
2062
2082
|
if (definition.references.length === 0) {
|
|
2063
2083
|
continue;
|
|
2064
2084
|
}
|
|
2065
2085
|
name = `it`;
|
|
2066
2086
|
break;
|
|
2067
|
-
case
|
|
2087
|
+
case DiagnosticCode9.LocalFunction: {
|
|
2068
2088
|
kind = languages.SymbolKind.Function;
|
|
2069
2089
|
const funcScope = scope.children.find((s) => Range.compareRangesUsingStarts(s.range, range) > 0);
|
|
2070
2090
|
if (funcScope) {
|
|
@@ -2150,7 +2170,7 @@ var FormatterProvider = class extends Provider {
|
|
|
2150
2170
|
};
|
|
2151
2171
|
|
|
2152
2172
|
// src/lsp/providers/hover-provider.ts
|
|
2153
|
-
import { DiagnosticCode as
|
|
2173
|
+
import { DiagnosticCode as DiagnosticCode10 } from "@mirascript/constants";
|
|
2154
2174
|
import { convert } from "@mirascript/mirascript/subtle";
|
|
2155
2175
|
import { KEYWORDS as HELP_KEYWORDS2, OPERATORS as HELP_OPERATORS } from "@mirascript/help";
|
|
2156
2176
|
|
|
@@ -2241,59 +2261,59 @@ var HoverProvider = class extends Provider {
|
|
|
2241
2261
|
let content;
|
|
2242
2262
|
const tag = def.definition;
|
|
2243
2263
|
switch (tag.code) {
|
|
2244
|
-
case
|
|
2264
|
+
case DiagnosticCode10.ParameterSubPatternImmutable:
|
|
2245
2265
|
content = {
|
|
2246
2266
|
value: codeblock(`\0(parameter pattern) ${model.getValueInRange(tag.range)}`)
|
|
2247
2267
|
};
|
|
2248
2268
|
break;
|
|
2249
|
-
case
|
|
2269
|
+
case DiagnosticCode10.ParameterSubPatternMutable:
|
|
2250
2270
|
content = {
|
|
2251
2271
|
value: codeblock(`\0(parameter pattern) mut ${model.getValueInRange(tag.range)}`)
|
|
2252
2272
|
};
|
|
2253
2273
|
break;
|
|
2254
|
-
case
|
|
2274
|
+
case DiagnosticCode10.ParameterImmutable:
|
|
2255
2275
|
content = {
|
|
2256
2276
|
value: codeblock(`\0(parameter) ${model.getValueInRange(tag.range)}`)
|
|
2257
2277
|
};
|
|
2258
2278
|
break;
|
|
2259
|
-
case
|
|
2279
|
+
case DiagnosticCode10.ParameterMutable:
|
|
2260
2280
|
content = {
|
|
2261
2281
|
value: codeblock(`\0(parameter) mut ${model.getValueInRange(tag.range)}`)
|
|
2262
2282
|
};
|
|
2263
2283
|
break;
|
|
2264
|
-
case
|
|
2284
|
+
case DiagnosticCode10.ParameterIt:
|
|
2265
2285
|
content = {
|
|
2266
2286
|
value: codeblock(`\0(parameter) it`)
|
|
2267
2287
|
};
|
|
2268
2288
|
break;
|
|
2269
|
-
case
|
|
2289
|
+
case DiagnosticCode10.ParameterImmutableRest:
|
|
2270
2290
|
content = {
|
|
2271
2291
|
value: codeblock(`\0(parameter) ..${model.getValueInRange(tag.range)}`)
|
|
2272
2292
|
};
|
|
2273
2293
|
break;
|
|
2274
|
-
case
|
|
2294
|
+
case DiagnosticCode10.ParameterMutableRest:
|
|
2275
2295
|
content = {
|
|
2276
2296
|
value: codeblock(`\0(parameter) ..mut ${model.getValueInRange(tag.range)}`)
|
|
2277
2297
|
};
|
|
2278
2298
|
break;
|
|
2279
|
-
case
|
|
2299
|
+
case DiagnosticCode10.LocalFunction: {
|
|
2280
2300
|
const params = paramsList(model, def.fn);
|
|
2281
2301
|
content = {
|
|
2282
2302
|
value: codeblock(`\0fn ${model.getValueInRange(tag.range)}${params}`)
|
|
2283
2303
|
};
|
|
2284
2304
|
break;
|
|
2285
2305
|
}
|
|
2286
|
-
case
|
|
2306
|
+
case DiagnosticCode10.LocalImmutable:
|
|
2287
2307
|
content = {
|
|
2288
2308
|
value: codeblock(`\0let ${model.getValueInRange(tag.range)}`)
|
|
2289
2309
|
};
|
|
2290
2310
|
break;
|
|
2291
|
-
case
|
|
2311
|
+
case DiagnosticCode10.LocalConst:
|
|
2292
2312
|
content = {
|
|
2293
2313
|
value: codeblock(`\0const ${model.getValueInRange(tag.range)}`)
|
|
2294
2314
|
};
|
|
2295
2315
|
break;
|
|
2296
|
-
case
|
|
2316
|
+
case DiagnosticCode10.LocalMutable:
|
|
2297
2317
|
content = {
|
|
2298
2318
|
value: codeblock(`\0let mut ${model.getValueInRange(tag.range)}`)
|
|
2299
2319
|
};
|
|
@@ -2353,24 +2373,26 @@ var HoverProvider = class extends Provider {
|
|
|
2353
2373
|
if (REG_NUMBER_ALL_FULL.test(token.text)) {
|
|
2354
2374
|
const num = convert.toNumber(token.text.replaceAll("_", ""), null);
|
|
2355
2375
|
if (num == null) return void 0;
|
|
2356
|
-
const contents = [
|
|
2357
|
-
{ value: `数字字面量` },
|
|
2358
|
-
{ value: codeblock("val: " + serializeNumber(num)) }
|
|
2359
|
-
];
|
|
2376
|
+
const contents = [];
|
|
2360
2377
|
if (Number.isInteger(num)) {
|
|
2361
2378
|
const abs = Math.abs(num);
|
|
2362
2379
|
if (abs <= BIN_MAX) {
|
|
2363
|
-
contents.push(
|
|
2380
|
+
contents.push("\0(bin) " + serializeInteger(num, 2));
|
|
2364
2381
|
}
|
|
2365
2382
|
if (abs <= OCT_MAX) {
|
|
2366
|
-
contents.push(
|
|
2383
|
+
contents.push("\0(oct) " + serializeInteger(num, 8));
|
|
2367
2384
|
}
|
|
2368
2385
|
if (abs <= HEX_MAX) {
|
|
2369
|
-
contents.push(
|
|
2386
|
+
contents.push("\0(hex) " + serializeInteger(num, 16));
|
|
2370
2387
|
}
|
|
2371
2388
|
}
|
|
2389
|
+
if (contents.length) {
|
|
2390
|
+
contents.unshift(`\0(dec) ` + serializeNumber(num));
|
|
2391
|
+
} else {
|
|
2392
|
+
contents.push(`\0(number) ` + serializeNumber(num));
|
|
2393
|
+
}
|
|
2372
2394
|
return {
|
|
2373
|
-
contents,
|
|
2395
|
+
contents: [{ value: codeblock(contents.join("\n")) }],
|
|
2374
2396
|
range: rangeAt(position, token)
|
|
2375
2397
|
};
|
|
2376
2398
|
}
|
|
@@ -2408,7 +2430,7 @@ var HoverProvider = class extends Provider {
|
|
|
2408
2430
|
};
|
|
2409
2431
|
|
|
2410
2432
|
// src/lsp/providers/inlay-hints-provider.ts
|
|
2411
|
-
import { DiagnosticCode as
|
|
2433
|
+
import { DiagnosticCode as DiagnosticCode11 } from "@mirascript/constants";
|
|
2412
2434
|
var InlayHintsProvider = class extends Provider {
|
|
2413
2435
|
/** @inheritdoc */
|
|
2414
2436
|
get onDidChangeInlayHints() {
|
|
@@ -2433,7 +2455,7 @@ var InlayHintsProvider = class extends Provider {
|
|
|
2433
2455
|
let paddingRight = false;
|
|
2434
2456
|
const edits = [];
|
|
2435
2457
|
switch (tag.code) {
|
|
2436
|
-
case
|
|
2458
|
+
case DiagnosticCode11.ParameterIt: {
|
|
2437
2459
|
if (!tag.references.length) {
|
|
2438
2460
|
continue;
|
|
2439
2461
|
}
|
|
@@ -2450,18 +2472,18 @@ var InlayHintsProvider = class extends Provider {
|
|
|
2450
2472
|
});
|
|
2451
2473
|
break;
|
|
2452
2474
|
}
|
|
2453
|
-
case
|
|
2454
|
-
case
|
|
2455
|
-
case
|
|
2456
|
-
case
|
|
2457
|
-
case
|
|
2458
|
-
case
|
|
2459
|
-
case
|
|
2460
|
-
case
|
|
2461
|
-
case
|
|
2462
|
-
case
|
|
2463
|
-
case
|
|
2464
|
-
const index = tag.code -
|
|
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;
|
|
2465
2487
|
if (index > 9) break;
|
|
2466
2488
|
lineNumber = tag.range.startLineNumber;
|
|
2467
2489
|
column = tag.range.startColumn;
|
|
@@ -2472,9 +2494,9 @@ var InlayHintsProvider = class extends Provider {
|
|
|
2472
2494
|
paddingRight = true;
|
|
2473
2495
|
break;
|
|
2474
2496
|
}
|
|
2475
|
-
case
|
|
2497
|
+
case DiagnosticCode11.OmitNamedRecordField: {
|
|
2476
2498
|
const ref = tag.references[0];
|
|
2477
|
-
if (ref?.code !==
|
|
2499
|
+
if (ref?.code !== DiagnosticCode11.OmitNamedRecordFieldName) continue;
|
|
2478
2500
|
lineNumber = tag.range.startLineNumber;
|
|
2479
2501
|
column = tag.range.startColumn;
|
|
2480
2502
|
label = model.getValueInRange(ref.range);
|
|
@@ -2540,7 +2562,7 @@ var RangeProvider = class extends Provider {
|
|
|
2540
2562
|
};
|
|
2541
2563
|
|
|
2542
2564
|
// src/lsp/providers/rename-provider.ts
|
|
2543
|
-
import { DiagnosticCode as
|
|
2565
|
+
import { DiagnosticCode as DiagnosticCode12 } from "@mirascript/constants";
|
|
2544
2566
|
var RenameProvider = class extends Provider {
|
|
2545
2567
|
/** 重命名推断字段 */
|
|
2546
2568
|
provideRenameEditsOmitNameFields(model, compiled, edits, ref, oldName) {
|
|
@@ -2591,7 +2613,7 @@ var RenameProvider = class extends Provider {
|
|
|
2591
2613
|
versionId: compiled.version,
|
|
2592
2614
|
textEdit: {
|
|
2593
2615
|
range: d.def.definition.range,
|
|
2594
|
-
text: d.def.definition.code ===
|
|
2616
|
+
text: d.def.definition.code === DiagnosticCode12.ParameterIt ? `(${newName})` : newName
|
|
2595
2617
|
}
|
|
2596
2618
|
});
|
|
2597
2619
|
oldName = model.getValueInRange(d.def.definition.range);
|
|
@@ -2657,7 +2679,7 @@ var RenameProvider = class extends Provider {
|
|
|
2657
2679
|
|
|
2658
2680
|
// src/lsp/providers/semantic-tokens-provider.ts
|
|
2659
2681
|
import { isVmFunction as isVmFunction2, isVmModule as isVmModule3 } from "@mirascript/mirascript";
|
|
2660
|
-
import { DiagnosticCode as
|
|
2682
|
+
import { DiagnosticCode as DiagnosticCode13 } from "@mirascript/constants";
|
|
2661
2683
|
var TOKEN_TYPES = {
|
|
2662
2684
|
[0 /* VARIABLE */]: "variable.other.constant",
|
|
2663
2685
|
[1 /* VARIABLE_MUTABLE */]: "variable",
|
|
@@ -2692,7 +2714,7 @@ var DocumentSemanticTokensProvider = class extends Provider {
|
|
|
2692
2714
|
let tokenType = -1;
|
|
2693
2715
|
let onlyReferences = false;
|
|
2694
2716
|
switch (code) {
|
|
2695
|
-
case
|
|
2717
|
+
case DiagnosticCode13.GlobalVariable: {
|
|
2696
2718
|
const id = model.getValueInRange(range);
|
|
2697
2719
|
if (id.startsWith("@")) {
|
|
2698
2720
|
tokenType = 2 /* CONSTANT */;
|
|
@@ -2708,44 +2730,46 @@ var DocumentSemanticTokensProvider = class extends Provider {
|
|
|
2708
2730
|
}
|
|
2709
2731
|
break;
|
|
2710
2732
|
}
|
|
2711
|
-
case
|
|
2733
|
+
case DiagnosticCode13.LocalFunction: {
|
|
2712
2734
|
tokenType = 4 /* FUNCTION */;
|
|
2713
2735
|
break;
|
|
2714
2736
|
}
|
|
2715
|
-
case
|
|
2716
|
-
case
|
|
2717
|
-
case
|
|
2737
|
+
case DiagnosticCode13.ParameterMutable:
|
|
2738
|
+
case DiagnosticCode13.ParameterSubPatternMutable:
|
|
2739
|
+
case DiagnosticCode13.ParameterMutableRest: {
|
|
2718
2740
|
tokenType = 9 /* PARAM_MUTABLE */;
|
|
2719
2741
|
break;
|
|
2720
2742
|
}
|
|
2721
|
-
case
|
|
2743
|
+
case DiagnosticCode13.LocalMutable: {
|
|
2722
2744
|
tokenType = 1 /* VARIABLE_MUTABLE */;
|
|
2723
2745
|
break;
|
|
2724
2746
|
}
|
|
2725
|
-
case
|
|
2747
|
+
case DiagnosticCode13.ParameterIt: {
|
|
2726
2748
|
tokenType = 8 /* PARAM */;
|
|
2727
2749
|
onlyReferences = true;
|
|
2728
2750
|
break;
|
|
2729
2751
|
}
|
|
2730
|
-
case
|
|
2731
|
-
case
|
|
2732
|
-
case
|
|
2752
|
+
case DiagnosticCode13.ParameterImmutable:
|
|
2753
|
+
case DiagnosticCode13.ParameterSubPatternImmutable:
|
|
2754
|
+
case DiagnosticCode13.ParameterImmutableRest: {
|
|
2733
2755
|
tokenType = 8 /* PARAM */;
|
|
2734
2756
|
break;
|
|
2735
2757
|
}
|
|
2736
|
-
case
|
|
2758
|
+
case DiagnosticCode13.LocalImmutable: {
|
|
2737
2759
|
tokenType = 0 /* VARIABLE */;
|
|
2738
2760
|
break;
|
|
2739
2761
|
}
|
|
2740
|
-
case
|
|
2762
|
+
case DiagnosticCode13.LocalConst: {
|
|
2741
2763
|
tokenType = 2 /* CONSTANT */;
|
|
2742
2764
|
break;
|
|
2743
2765
|
}
|
|
2744
|
-
case
|
|
2766
|
+
// case DiagnosticCode.RecordFieldStringName:
|
|
2767
|
+
case DiagnosticCode13.RecordFieldOrdinalName:
|
|
2768
|
+
case DiagnosticCode13.RecordFieldIdName: {
|
|
2745
2769
|
tokenType = 6 /* PROPERTY */;
|
|
2746
2770
|
break;
|
|
2747
2771
|
}
|
|
2748
|
-
case
|
|
2772
|
+
case DiagnosticCode13.ForExpression: {
|
|
2749
2773
|
tokenType = 7 /* KEYWORD_CONTROL */;
|
|
2750
2774
|
onlyReferences = true;
|
|
2751
2775
|
break;
|
|
@@ -2804,7 +2828,7 @@ var DocumentSemanticTokensProvider = class extends Provider {
|
|
|
2804
2828
|
};
|
|
2805
2829
|
|
|
2806
2830
|
// src/lsp/providers/signature-help-provider.ts
|
|
2807
|
-
import { DiagnosticCode as
|
|
2831
|
+
import { DiagnosticCode as DiagnosticCode14 } from "@mirascript/constants";
|
|
2808
2832
|
import { getVmFunctionInfo as getVmFunctionInfo3 } from "@mirascript/mirascript";
|
|
2809
2833
|
var SignatureHelpProvider = class extends Provider {
|
|
2810
2834
|
constructor() {
|
|
@@ -2819,14 +2843,14 @@ var SignatureHelpProvider = class extends Provider {
|
|
|
2819
2843
|
const compiled = await this.getCompileResult(model);
|
|
2820
2844
|
if (!compiled) return void 0;
|
|
2821
2845
|
const invokes = compiled.groupedTags(model).ranges.filter((r) => {
|
|
2822
|
-
if (r.code !==
|
|
2846
|
+
if (r.code !== DiagnosticCode14.FunctionCall && r.code !== DiagnosticCode14.ExtensionCall) {
|
|
2823
2847
|
return false;
|
|
2824
2848
|
}
|
|
2825
2849
|
if (!strictContainsPosition(r.range, position)) {
|
|
2826
2850
|
return false;
|
|
2827
2851
|
}
|
|
2828
|
-
const argStart = r.references.find((ref) => ref.code ===
|
|
2829
|
-
const argEnd = r.references.find((ref) => ref.code ===
|
|
2852
|
+
const argStart = r.references.find((ref) => ref.code === DiagnosticCode14.ArgumentStart);
|
|
2853
|
+
const argEnd = r.references.find((ref) => ref.code === DiagnosticCode14.ArgumentEnd);
|
|
2830
2854
|
if (!argStart || !argEnd) {
|
|
2831
2855
|
return false;
|
|
2832
2856
|
}
|
|
@@ -2838,7 +2862,7 @@ var SignatureHelpProvider = class extends Provider {
|
|
|
2838
2862
|
if (!invokes.length) return void 0;
|
|
2839
2863
|
invokes.sort((a, b) => Range.strictContainsRange(a.range, b.range) ? 1 : -1);
|
|
2840
2864
|
const invoke = invokes[0];
|
|
2841
|
-
const callableRef = invoke.references.find((ref) => ref.code ===
|
|
2865
|
+
const callableRef = invoke.references.find((ref) => ref.code === DiagnosticCode14.Callable);
|
|
2842
2866
|
if (!callableRef) return void 0;
|
|
2843
2867
|
const callableInfo = compiled.accessAt(model, Range.getEndPosition(callableRef.range));
|
|
2844
2868
|
if (!callableInfo) return void 0;
|
|
@@ -2862,7 +2886,7 @@ var SignatureHelpProvider = class extends Provider {
|
|
|
2862
2886
|
label: "",
|
|
2863
2887
|
parameters: []
|
|
2864
2888
|
};
|
|
2865
|
-
if (invoke.code ===
|
|
2889
|
+
if (invoke.code === DiagnosticCode14.ExtensionCall) {
|
|
2866
2890
|
const thisArg = sig.params[0];
|
|
2867
2891
|
if (thisArg && !thisArg[0].startsWith("..")) {
|
|
2868
2892
|
sig.params.shift();
|
|
@@ -2891,8 +2915,8 @@ var SignatureHelpProvider = class extends Provider {
|
|
|
2891
2915
|
signature.label += ")" + sig.returns;
|
|
2892
2916
|
let pos = 0;
|
|
2893
2917
|
for (const ref of invoke.references) {
|
|
2894
|
-
if (ref.code ===
|
|
2895
|
-
if (ref.code !==
|
|
2918
|
+
if (ref.code === DiagnosticCode14.ArgumentSpread) pos = Number.NaN;
|
|
2919
|
+
if (ref.code !== DiagnosticCode14.ArgumentComma || Range.isEmpty(ref.range)) continue;
|
|
2896
2920
|
if (Position.isBeforeOrEqual(Range.getEndPosition(ref.range), position) && !sig.params[pos]?.[0].startsWith("..")) {
|
|
2897
2921
|
pos++;
|
|
2898
2922
|
}
|
|
@@ -2914,6 +2938,7 @@ async function registerLSP(contextProvider2) {
|
|
|
2914
2938
|
const { loadModule } = await import("@mirascript/bindings/wasm");
|
|
2915
2939
|
await loadModule();
|
|
2916
2940
|
const codeActionProvider = new CodeActionProvider();
|
|
2941
|
+
const codeLensProvider = new CodeLensProvider();
|
|
2917
2942
|
const colorProvider = new ColorProvider();
|
|
2918
2943
|
const completionItemProvider = new CompletionItemProvider();
|
|
2919
2944
|
const definitionReferenceProvider = new DefinitionReferenceProvider();
|
|
@@ -2929,6 +2954,7 @@ async function registerLSP(contextProvider2) {
|
|
|
2929
2954
|
const language = ["mirascript", "mirascript-template"];
|
|
2930
2955
|
return [
|
|
2931
2956
|
languages.registerCodeActionProvider(language, codeActionProvider),
|
|
2957
|
+
languages.registerCodeLensProvider(language, codeLensProvider),
|
|
2932
2958
|
languages.registerColorProvider(language, colorProvider),
|
|
2933
2959
|
languages.registerDefinitionProvider(language, definitionReferenceProvider),
|
|
2934
2960
|
languages.registerReferenceProvider(language, definitionReferenceProvider),
|
|
@@ -2949,6 +2975,7 @@ async function registerLSP(contextProvider2) {
|
|
|
2949
2975
|
}
|
|
2950
2976
|
export {
|
|
2951
2977
|
CodeActionProvider,
|
|
2978
|
+
CodeLensProvider,
|
|
2952
2979
|
ColorProvider,
|
|
2953
2980
|
CompletionItemProvider,
|
|
2954
2981
|
DefinitionReferenceProvider,
|