skir 0.0.3 → 0.0.6
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/casing.d.ts.map +1 -1
- package/dist/casing.js +4 -1
- package/dist/casing.js.map +1 -1
- package/dist/casing.test.js +35 -1
- package/dist/casing.test.js.map +1 -1
- package/dist/compatibility_checker.test.js +2 -2
- package/dist/compiler.js +23 -42
- package/dist/compiler.js.map +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -10
- package/dist/config.js.map +1 -1
- package/dist/config_parser.d.ts +25 -0
- package/dist/config_parser.d.ts.map +1 -0
- package/dist/config_parser.js +125 -0
- package/dist/config_parser.js.map +1 -0
- package/dist/config_parser.test.d.ts +2 -0
- package/dist/config_parser.test.d.ts.map +1 -0
- package/dist/config_parser.test.js +386 -0
- package/dist/config_parser.test.js.map +1 -0
- package/dist/doc_comment_parser.d.ts +3 -2
- package/dist/doc_comment_parser.d.ts.map +1 -1
- package/dist/doc_comment_parser.js +67 -52
- package/dist/doc_comment_parser.js.map +1 -1
- package/dist/doc_comment_parser.test.js +86 -154
- package/dist/doc_comment_parser.test.js.map +1 -1
- package/dist/error_renderer.d.ts +4 -0
- package/dist/error_renderer.d.ts.map +1 -1
- package/dist/error_renderer.js +21 -0
- package/dist/error_renderer.js.map +1 -1
- package/dist/module_set.d.ts.map +1 -1
- package/dist/module_set.js +29 -12
- package/dist/module_set.js.map +1 -1
- package/dist/module_set.test.js +318 -173
- package/dist/module_set.test.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +10 -10
- package/dist/parser.js.map +1 -1
- package/dist/project_initializer.js +9 -1
- package/dist/project_initializer.js.map +1 -1
- package/dist/tokenizer.d.ts +7 -1
- package/dist/tokenizer.d.ts.map +1 -1
- package/dist/tokenizer.js +12 -0
- package/dist/tokenizer.js.map +1 -1
- package/package.json +10 -5
- package/src/casing.ts +6 -1
- package/src/compiler.ts +26 -40
- package/src/config.ts +10 -15
- package/src/config_parser.ts +169 -0
- package/src/doc_comment_parser.ts +76 -52
- package/src/error_renderer.ts +34 -0
- package/src/module_set.ts +31 -15
- package/src/parser.ts +16 -10
- package/src/project_initializer.ts +9 -1
- package/src/tokenizer.ts +20 -2
- package/dist/language_server.d.ts +0 -15
- package/dist/language_server.d.ts.map +0 -1
- package/dist/language_server.js +0 -248
- package/dist/language_server.js.map +0 -1
- package/src/language_server.ts +0 -301
package/dist/module_set.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect } from "buckwheat";
|
|
2
|
-
import { describe, it } from "
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
3
|
import { ModuleSet } from "./module_set.js";
|
|
4
4
|
class FakeFileReader {
|
|
5
5
|
constructor() {
|
|
@@ -1346,27 +1346,39 @@ describe("module set", () => {
|
|
|
1346
1346
|
`);
|
|
1347
1347
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1348
1348
|
const actual = moduleSet.parseAndResolve("module");
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1349
|
+
expect(actual).toMatch({
|
|
1350
|
+
result: {
|
|
1351
|
+
nameToDeclaration: {
|
|
1352
|
+
Foo: {
|
|
1353
|
+
name: { text: "Foo" },
|
|
1354
|
+
doc: {
|
|
1355
|
+
pieces: [
|
|
1356
|
+
{ kind: "text", text: "Hello " },
|
|
1357
|
+
{
|
|
1358
|
+
kind: "reference",
|
|
1359
|
+
nameParts: [
|
|
1360
|
+
{
|
|
1361
|
+
token: { text: "Bar" },
|
|
1362
|
+
declaration: { kind: "record", name: { text: "Bar" } },
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
token: { text: "OK" },
|
|
1366
|
+
declaration: { kind: "field", name: { text: "OK" } },
|
|
1367
|
+
},
|
|
1368
|
+
],
|
|
1369
|
+
referee: {
|
|
1370
|
+
kind: "field",
|
|
1371
|
+
field: { name: { text: "OK" } },
|
|
1372
|
+
record: { name: { text: "Bar" } },
|
|
1373
|
+
},
|
|
1374
|
+
},
|
|
1375
|
+
],
|
|
1364
1376
|
},
|
|
1365
|
-
|
|
1377
|
+
},
|
|
1366
1378
|
},
|
|
1367
1379
|
},
|
|
1380
|
+
errors: [],
|
|
1368
1381
|
});
|
|
1369
|
-
expect(actual.errors).toMatch([]);
|
|
1370
1382
|
});
|
|
1371
1383
|
it("resolves reference to sibling field", () => {
|
|
1372
1384
|
const fakeFileReader = new FakeFileReader();
|
|
@@ -1393,7 +1405,15 @@ describe("module set", () => {
|
|
|
1393
1405
|
{ kind: "text", text: "Must be different from " },
|
|
1394
1406
|
{
|
|
1395
1407
|
kind: "reference",
|
|
1396
|
-
|
|
1408
|
+
nameParts: [
|
|
1409
|
+
{
|
|
1410
|
+
token: { text: "x" },
|
|
1411
|
+
declaration: {
|
|
1412
|
+
kind: "field",
|
|
1413
|
+
name: { text: "x" },
|
|
1414
|
+
},
|
|
1415
|
+
},
|
|
1416
|
+
],
|
|
1397
1417
|
referee: {
|
|
1398
1418
|
kind: "field",
|
|
1399
1419
|
field: { name: { text: "x" } },
|
|
@@ -1423,24 +1443,32 @@ describe("module set", () => {
|
|
|
1423
1443
|
`);
|
|
1424
1444
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1425
1445
|
const actual = moduleSet.parseAndResolve("module");
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1446
|
+
expect(actual).toMatch({
|
|
1447
|
+
result: {
|
|
1448
|
+
nameToDeclaration: {
|
|
1449
|
+
Foo: {
|
|
1450
|
+
name: { text: "Foo" },
|
|
1451
|
+
doc: {
|
|
1452
|
+
pieces: [
|
|
1453
|
+
{ kind: "text", text: "See " },
|
|
1454
|
+
{
|
|
1455
|
+
kind: "reference",
|
|
1456
|
+
nameParts: [
|
|
1457
|
+
{
|
|
1458
|
+
token: { text: "Bar" },
|
|
1459
|
+
declaration: { kind: "record", name: { text: "Bar" } },
|
|
1460
|
+
},
|
|
1461
|
+
],
|
|
1462
|
+
referee: { kind: "record", name: { text: "Bar" } },
|
|
1463
|
+
},
|
|
1464
|
+
{ kind: "text", text: " for details" },
|
|
1465
|
+
],
|
|
1437
1466
|
},
|
|
1438
|
-
|
|
1439
|
-
],
|
|
1467
|
+
},
|
|
1440
1468
|
},
|
|
1441
1469
|
},
|
|
1470
|
+
errors: [],
|
|
1442
1471
|
});
|
|
1443
|
-
expect(actual.errors).toMatch([]);
|
|
1444
1472
|
});
|
|
1445
1473
|
it("resolves reference to nested record", () => {
|
|
1446
1474
|
const fakeFileReader = new FakeFileReader();
|
|
@@ -1456,23 +1484,41 @@ describe("module set", () => {
|
|
|
1456
1484
|
`);
|
|
1457
1485
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1458
1486
|
const actual = moduleSet.parseAndResolve("module");
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1487
|
+
expect(actual).toMatch({
|
|
1488
|
+
result: {
|
|
1489
|
+
nameToDeclaration: {
|
|
1490
|
+
Foo: {
|
|
1491
|
+
name: { text: "Foo" },
|
|
1492
|
+
doc: {
|
|
1493
|
+
pieces: [
|
|
1494
|
+
{ kind: "text", text: "Uses " },
|
|
1495
|
+
{
|
|
1496
|
+
kind: "reference",
|
|
1497
|
+
nameParts: [
|
|
1498
|
+
{
|
|
1499
|
+
token: { text: "Outer" },
|
|
1500
|
+
declaration: {
|
|
1501
|
+
kind: "record",
|
|
1502
|
+
name: { text: "Outer" },
|
|
1503
|
+
},
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
token: { text: "Inner" },
|
|
1507
|
+
declaration: {
|
|
1508
|
+
kind: "record",
|
|
1509
|
+
name: { text: "Inner" },
|
|
1510
|
+
},
|
|
1511
|
+
},
|
|
1512
|
+
],
|
|
1513
|
+
referee: { kind: "record", name: { text: "Inner" } },
|
|
1514
|
+
},
|
|
1515
|
+
],
|
|
1470
1516
|
},
|
|
1471
|
-
|
|
1517
|
+
},
|
|
1472
1518
|
},
|
|
1473
1519
|
},
|
|
1520
|
+
errors: [],
|
|
1474
1521
|
});
|
|
1475
|
-
expect(actual.errors).toMatch([]);
|
|
1476
1522
|
});
|
|
1477
1523
|
it("resolves absolute reference", () => {
|
|
1478
1524
|
const fakeFileReader = new FakeFileReader();
|
|
@@ -1487,35 +1533,46 @@ describe("module set", () => {
|
|
|
1487
1533
|
`);
|
|
1488
1534
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1489
1535
|
const actual = moduleSet.parseAndResolve("module");
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1536
|
+
expect(actual).toMatch({
|
|
1537
|
+
result: {
|
|
1538
|
+
nameToDeclaration: {
|
|
1539
|
+
Outer: {
|
|
1540
|
+
name: { text: "Outer" },
|
|
1541
|
+
nestedRecords: [
|
|
1542
|
+
{
|
|
1543
|
+
name: { text: "Inner" },
|
|
1544
|
+
doc: {
|
|
1545
|
+
pieces: [
|
|
1546
|
+
{ kind: "text", text: "Reference to " },
|
|
1547
|
+
{
|
|
1548
|
+
kind: "reference",
|
|
1549
|
+
absolute: true,
|
|
1550
|
+
nameParts: [
|
|
1551
|
+
{
|
|
1552
|
+
token: { text: "Bar" },
|
|
1553
|
+
declaration: {
|
|
1554
|
+
kind: "record",
|
|
1555
|
+
name: { text: "Bar", colNumber: 17 },
|
|
1556
|
+
},
|
|
1557
|
+
},
|
|
1558
|
+
],
|
|
1559
|
+
referee: {
|
|
1560
|
+
kind: "record",
|
|
1561
|
+
name: { text: "Bar", colNumber: 17 },
|
|
1562
|
+
},
|
|
1563
|
+
},
|
|
1564
|
+
],
|
|
1508
1565
|
},
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1566
|
+
},
|
|
1567
|
+
{
|
|
1568
|
+
name: { text: "Bar", colNumber: 19 },
|
|
1569
|
+
},
|
|
1570
|
+
],
|
|
1514
1571
|
},
|
|
1515
|
-
|
|
1572
|
+
},
|
|
1516
1573
|
},
|
|
1574
|
+
errors: [],
|
|
1517
1575
|
});
|
|
1518
|
-
expect(actual.errors).toMatch([]);
|
|
1519
1576
|
});
|
|
1520
1577
|
it("resolves reference to method", () => {
|
|
1521
1578
|
const fakeFileReader = new FakeFileReader();
|
|
@@ -1538,7 +1595,15 @@ describe("module set", () => {
|
|
|
1538
1595
|
{ kind: "text", text: "Calls " },
|
|
1539
1596
|
{
|
|
1540
1597
|
kind: "reference",
|
|
1541
|
-
|
|
1598
|
+
nameParts: [
|
|
1599
|
+
{
|
|
1600
|
+
token: { text: "GetData" },
|
|
1601
|
+
declaration: {
|
|
1602
|
+
kind: "method",
|
|
1603
|
+
name: { text: "GetData" },
|
|
1604
|
+
},
|
|
1605
|
+
},
|
|
1606
|
+
],
|
|
1542
1607
|
referee: { kind: "method", name: { text: "GetData" } },
|
|
1543
1608
|
},
|
|
1544
1609
|
],
|
|
@@ -1573,7 +1638,15 @@ describe("module set", () => {
|
|
|
1573
1638
|
{ kind: "text", text: "Default is " },
|
|
1574
1639
|
{
|
|
1575
1640
|
kind: "reference",
|
|
1576
|
-
|
|
1641
|
+
nameParts: [
|
|
1642
|
+
{
|
|
1643
|
+
token: { text: "DEFAULT_VALUE" },
|
|
1644
|
+
declaration: {
|
|
1645
|
+
kind: "constant",
|
|
1646
|
+
name: { text: "DEFAULT_VALUE" },
|
|
1647
|
+
},
|
|
1648
|
+
},
|
|
1649
|
+
],
|
|
1577
1650
|
referee: {
|
|
1578
1651
|
kind: "constant",
|
|
1579
1652
|
name: { text: "DEFAULT_VALUE" },
|
|
@@ -1600,33 +1673,44 @@ describe("module set", () => {
|
|
|
1600
1673
|
`);
|
|
1601
1674
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1602
1675
|
const actual = moduleSet.parseAndResolve("module");
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1676
|
+
expect(actual).toMatch({
|
|
1677
|
+
result: {
|
|
1678
|
+
nameToDeclaration: {
|
|
1679
|
+
Foo: {
|
|
1680
|
+
name: { text: "Foo" },
|
|
1681
|
+
fields: [
|
|
1682
|
+
{
|
|
1683
|
+
name: { text: "bar" },
|
|
1684
|
+
doc: {
|
|
1685
|
+
pieces: [
|
|
1686
|
+
{ kind: "text", text: "Uses " },
|
|
1687
|
+
{
|
|
1688
|
+
kind: "reference",
|
|
1689
|
+
nameParts: [
|
|
1690
|
+
{
|
|
1691
|
+
token: { text: "OK" },
|
|
1692
|
+
declaration: {
|
|
1693
|
+
kind: "field",
|
|
1694
|
+
name: { text: "OK" },
|
|
1695
|
+
},
|
|
1696
|
+
},
|
|
1697
|
+
],
|
|
1698
|
+
referee: {
|
|
1699
|
+
kind: "field",
|
|
1700
|
+
field: { name: { text: "OK" } },
|
|
1701
|
+
record: { name: { text: "Bar" } },
|
|
1702
|
+
},
|
|
1703
|
+
},
|
|
1704
|
+
{ kind: "text", text: " from the Bar enum" },
|
|
1705
|
+
],
|
|
1621
1706
|
},
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
},
|
|
1707
|
+
},
|
|
1708
|
+
],
|
|
1625
1709
|
},
|
|
1626
|
-
|
|
1710
|
+
},
|
|
1627
1711
|
},
|
|
1712
|
+
errors: [],
|
|
1628
1713
|
});
|
|
1629
|
-
expect(actual.errors).toMatch([]);
|
|
1630
1714
|
});
|
|
1631
1715
|
it("resolves reference from method request type scope", () => {
|
|
1632
1716
|
const fakeFileReader = new FakeFileReader();
|
|
@@ -1652,7 +1736,12 @@ describe("module set", () => {
|
|
|
1652
1736
|
{ kind: "text", text: "Input " },
|
|
1653
1737
|
{
|
|
1654
1738
|
kind: "reference",
|
|
1655
|
-
|
|
1739
|
+
nameParts: [
|
|
1740
|
+
{
|
|
1741
|
+
token: { text: "x" },
|
|
1742
|
+
declaration: { kind: "field", name: { text: "x" } },
|
|
1743
|
+
},
|
|
1744
|
+
],
|
|
1656
1745
|
referee: {
|
|
1657
1746
|
kind: "field",
|
|
1658
1747
|
field: { name: { text: "x" } },
|
|
@@ -1688,7 +1777,12 @@ describe("module set", () => {
|
|
|
1688
1777
|
{ kind: "text", text: "Default status is " },
|
|
1689
1778
|
{
|
|
1690
1779
|
kind: "reference",
|
|
1691
|
-
|
|
1780
|
+
nameParts: [
|
|
1781
|
+
{
|
|
1782
|
+
token: { text: "OK" },
|
|
1783
|
+
declaration: { kind: "field", name: { text: "OK" } },
|
|
1784
|
+
},
|
|
1785
|
+
],
|
|
1692
1786
|
referee: {
|
|
1693
1787
|
kind: "field",
|
|
1694
1788
|
field: { name: { text: "OK" } },
|
|
@@ -1714,29 +1808,42 @@ describe("module set", () => {
|
|
|
1714
1808
|
`);
|
|
1715
1809
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1716
1810
|
const actual = moduleSet.parseAndResolve("module");
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1811
|
+
expect(actual).toMatch({
|
|
1812
|
+
result: {
|
|
1813
|
+
nameToDeclaration: {
|
|
1814
|
+
Baz: {
|
|
1815
|
+
name: { text: "Baz" },
|
|
1816
|
+
doc: {
|
|
1817
|
+
pieces: [
|
|
1818
|
+
{ kind: "text", text: "Compare " },
|
|
1819
|
+
{
|
|
1820
|
+
kind: "reference",
|
|
1821
|
+
nameParts: [
|
|
1822
|
+
{
|
|
1823
|
+
token: { text: "Foo" },
|
|
1824
|
+
declaration: { kind: "record", name: { text: "Foo" } },
|
|
1825
|
+
},
|
|
1826
|
+
],
|
|
1827
|
+
referee: { kind: "record", name: { text: "Foo" } },
|
|
1828
|
+
},
|
|
1829
|
+
{ kind: "text", text: " and " },
|
|
1830
|
+
{
|
|
1831
|
+
kind: "reference",
|
|
1832
|
+
nameParts: [
|
|
1833
|
+
{
|
|
1834
|
+
token: { text: "Bar" },
|
|
1835
|
+
declaration: { kind: "record", name: { text: "Bar" } },
|
|
1836
|
+
},
|
|
1837
|
+
],
|
|
1838
|
+
referee: { kind: "record", name: { text: "Bar" } },
|
|
1839
|
+
},
|
|
1840
|
+
],
|
|
1734
1841
|
},
|
|
1735
|
-
|
|
1842
|
+
},
|
|
1736
1843
|
},
|
|
1737
1844
|
},
|
|
1845
|
+
errors: [],
|
|
1738
1846
|
});
|
|
1739
|
-
expect(actual.errors).toMatch([]);
|
|
1740
1847
|
});
|
|
1741
1848
|
it("resolves reference through import alias", () => {
|
|
1742
1849
|
const fakeFileReader = new FakeFileReader();
|
|
@@ -1751,23 +1858,38 @@ describe("module set", () => {
|
|
|
1751
1858
|
`);
|
|
1752
1859
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1753
1860
|
const actual = moduleSet.parseAndResolve("module");
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1861
|
+
expect(actual).toMatch({
|
|
1862
|
+
result: {
|
|
1863
|
+
nameToDeclaration: {
|
|
1864
|
+
Bar: {
|
|
1865
|
+
name: { text: "Bar" },
|
|
1866
|
+
doc: {
|
|
1867
|
+
pieces: [
|
|
1868
|
+
{ kind: "text", text: "Uses " },
|
|
1869
|
+
{
|
|
1870
|
+
kind: "reference",
|
|
1871
|
+
nameParts: [
|
|
1872
|
+
{
|
|
1873
|
+
token: { text: "other" },
|
|
1874
|
+
declaration: {
|
|
1875
|
+
kind: "import-alias",
|
|
1876
|
+
name: { text: "other" },
|
|
1877
|
+
},
|
|
1878
|
+
},
|
|
1879
|
+
{
|
|
1880
|
+
token: { text: "Foo" },
|
|
1881
|
+
declaration: { kind: "record", name: { text: "Foo" } },
|
|
1882
|
+
},
|
|
1883
|
+
],
|
|
1884
|
+
referee: { kind: "record", name: { text: "Foo" } },
|
|
1885
|
+
},
|
|
1886
|
+
],
|
|
1765
1887
|
},
|
|
1766
|
-
|
|
1888
|
+
},
|
|
1767
1889
|
},
|
|
1768
1890
|
},
|
|
1891
|
+
errors: [{ message: "Unused import alias" }],
|
|
1769
1892
|
});
|
|
1770
|
-
expect(actual.errors).toMatch([{ message: "Unused import alias" }]);
|
|
1771
1893
|
});
|
|
1772
1894
|
it("resolves reference through import", () => {
|
|
1773
1895
|
const fakeFileReader = new FakeFileReader();
|
|
@@ -1782,23 +1904,38 @@ describe("module set", () => {
|
|
|
1782
1904
|
`);
|
|
1783
1905
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1784
1906
|
const actual = moduleSet.parseAndResolve("module");
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1907
|
+
expect(actual).toMatch({
|
|
1908
|
+
result: {
|
|
1909
|
+
nameToDeclaration: {
|
|
1910
|
+
Bar: {
|
|
1911
|
+
name: { text: "Bar" },
|
|
1912
|
+
doc: {
|
|
1913
|
+
pieces: [
|
|
1914
|
+
{ kind: "text", text: "Uses " },
|
|
1915
|
+
{
|
|
1916
|
+
kind: "reference",
|
|
1917
|
+
nameParts: [
|
|
1918
|
+
{
|
|
1919
|
+
token: { text: "other" },
|
|
1920
|
+
declaration: {
|
|
1921
|
+
kind: "import-alias",
|
|
1922
|
+
name: { text: "other" },
|
|
1923
|
+
},
|
|
1924
|
+
},
|
|
1925
|
+
{
|
|
1926
|
+
token: { text: "Foo" },
|
|
1927
|
+
declaration: { kind: "record", name: { text: "Foo" } },
|
|
1928
|
+
},
|
|
1929
|
+
],
|
|
1930
|
+
referee: { kind: "record", name: { text: "Foo" } },
|
|
1931
|
+
},
|
|
1932
|
+
],
|
|
1796
1933
|
},
|
|
1797
|
-
|
|
1934
|
+
},
|
|
1798
1935
|
},
|
|
1799
1936
|
},
|
|
1937
|
+
errors: [{ message: "Unused import alias" }],
|
|
1800
1938
|
});
|
|
1801
|
-
expect(actual.errors).toMatch([{ message: "Unused import alias" }]);
|
|
1802
1939
|
});
|
|
1803
1940
|
it("reports error for unresolved reference", () => {
|
|
1804
1941
|
const fakeFileReader = new FakeFileReader();
|
|
@@ -1853,42 +1990,50 @@ describe("module set", () => {
|
|
|
1853
1990
|
`);
|
|
1854
1991
|
const moduleSet = ModuleSet.create(fakeFileReader, "path/to/root");
|
|
1855
1992
|
const actual = moduleSet.parseAndResolve("module");
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
{
|
|
1863
|
-
name: { text: "Inner" },
|
|
1864
|
-
fields: [
|
|
1993
|
+
expect(actual).toMatch({
|
|
1994
|
+
result: {
|
|
1995
|
+
nameToDeclaration: {
|
|
1996
|
+
Outer: {
|
|
1997
|
+
name: { text: "Outer" },
|
|
1998
|
+
nestedRecords: [
|
|
1865
1999
|
{
|
|
1866
|
-
name: { text: "
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
{
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
2000
|
+
name: { text: "Inner" },
|
|
2001
|
+
fields: [
|
|
2002
|
+
{
|
|
2003
|
+
name: { text: "x" },
|
|
2004
|
+
doc: {
|
|
2005
|
+
pieces: [
|
|
2006
|
+
{ kind: "text", text: "Reference to " },
|
|
2007
|
+
{
|
|
2008
|
+
kind: "reference",
|
|
2009
|
+
nameParts: [
|
|
2010
|
+
{
|
|
2011
|
+
token: { text: "Foo" },
|
|
2012
|
+
declaration: {
|
|
2013
|
+
kind: "record",
|
|
2014
|
+
name: { text: "Foo" },
|
|
2015
|
+
},
|
|
2016
|
+
},
|
|
2017
|
+
],
|
|
2018
|
+
// Should resolve to Outer.Foo, not the top-level Foo
|
|
2019
|
+
referee: {
|
|
2020
|
+
kind: "record",
|
|
2021
|
+
name: { text: "Foo" },
|
|
2022
|
+
},
|
|
2023
|
+
},
|
|
2024
|
+
{ kind: "text", text: " (nested)" },
|
|
2025
|
+
],
|
|
1878
2026
|
},
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
2027
|
+
},
|
|
2028
|
+
],
|
|
2029
|
+
},
|
|
2030
|
+
{
|
|
2031
|
+
name: { text: "Foo" },
|
|
1882
2032
|
},
|
|
1883
2033
|
],
|
|
1884
2034
|
},
|
|
1885
|
-
|
|
1886
|
-
name: { text: "Foo" },
|
|
1887
|
-
},
|
|
1888
|
-
],
|
|
2035
|
+
},
|
|
1889
2036
|
},
|
|
1890
|
-
});
|
|
1891
|
-
expect(actual).toMatch({
|
|
1892
2037
|
errors: [],
|
|
1893
2038
|
});
|
|
1894
2039
|
});
|