@typespec/compiler 0.67.0-dev.11 → 0.67.0-dev.12
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/manifest.js +2 -2
- package/dist/src/core/binder.d.ts.map +1 -1
- package/dist/src/core/binder.js +17 -130
- package/dist/src/core/binder.js.map +1 -1
- package/dist/src/core/checker.d.ts +3 -8
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +30 -674
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/decorator-utils.d.ts.map +1 -1
- package/dist/src/core/decorator-utils.js +1 -3
- package/dist/src/core/decorator-utils.js.map +1 -1
- package/dist/src/core/diagnostics.d.ts +0 -6
- package/dist/src/core/diagnostics.d.ts.map +1 -1
- package/dist/src/core/diagnostics.js +2 -11
- package/dist/src/core/diagnostics.js.map +1 -1
- package/dist/src/core/inspector/symbol.d.ts.map +1 -1
- package/dist/src/core/inspector/symbol.js +9 -11
- package/dist/src/core/inspector/symbol.js.map +1 -1
- package/dist/src/core/messages.d.ts +20 -40
- package/dist/src/core/messages.d.ts.map +1 -1
- package/dist/src/core/messages.js +6 -10
- package/dist/src/core/messages.js.map +1 -1
- package/dist/src/core/name-resolver.d.ts.map +1 -1
- package/dist/src/core/name-resolver.js +12 -23
- package/dist/src/core/name-resolver.js.map +1 -1
- package/dist/src/core/parser.d.ts.map +1 -1
- package/dist/src/core/parser.js +0 -642
- package/dist/src/core/parser.js.map +1 -1
- package/dist/src/core/program.d.ts +1 -10
- package/dist/src/core/program.d.ts.map +1 -1
- package/dist/src/core/program.js +2 -7
- package/dist/src/core/program.js.map +1 -1
- package/dist/src/core/semantic-walker.d.ts.map +1 -1
- package/dist/src/core/semantic-walker.js +0 -9
- package/dist/src/core/semantic-walker.js.map +1 -1
- package/dist/src/core/state-accessors.d.ts +53 -12
- package/dist/src/core/state-accessors.d.ts.map +1 -1
- package/dist/src/core/state-accessors.js +75 -48
- package/dist/src/core/state-accessors.js.map +1 -1
- package/dist/src/core/type-relation-checker.d.ts.map +1 -1
- package/dist/src/core/type-relation-checker.js +3 -6
- package/dist/src/core/type-relation-checker.js.map +1 -1
- package/dist/src/core/type-utils.js +2 -2
- package/dist/src/core/type-utils.js.map +1 -1
- package/dist/src/core/types.d.ts +41 -274
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js +24 -55
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/core/visibility/lifecycle.d.ts.map +1 -1
- package/dist/src/core/visibility/lifecycle.js +2 -11
- package/dist/src/core/visibility/lifecycle.js.map +1 -1
- package/dist/src/experimental/freeze-graph.d.ts.map +1 -1
- package/dist/src/experimental/freeze-graph.js +0 -3
- package/dist/src/experimental/freeze-graph.js.map +1 -1
- package/dist/src/experimental/mutators.d.ts +2 -2
- package/dist/src/experimental/mutators.d.ts.map +1 -1
- package/dist/src/experimental/mutators.js +0 -6
- package/dist/src/experimental/mutators.js.map +1 -1
- package/dist/src/experimental/typekit/kits/type.js +0 -3
- package/dist/src/experimental/typekit/kits/type.js.map +1 -1
- package/dist/src/formatter/print/needs-parens.d.ts.map +1 -1
- package/dist/src/formatter/print/needs-parens.js +0 -4
- package/dist/src/formatter/print/needs-parens.js.map +1 -1
- package/dist/src/formatter/print/printer.d.ts +4 -12
- package/dist/src/formatter/print/printer.d.ts.map +1 -1
- package/dist/src/formatter/print/printer.js +0 -187
- package/dist/src/formatter/print/printer.js.map +1 -1
- package/dist/src/index.d.ts +3 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/decorators.d.ts +3 -3
- package/dist/src/lib/decorators.d.ts.map +1 -1
- package/dist/src/lib/decorators.js +14 -29
- package/dist/src/lib/decorators.js.map +1 -1
- package/dist/src/lib/examples.js +1 -5
- package/dist/src/lib/examples.js.map +1 -1
- package/dist/src/lib/tsp-index.d.ts.map +1 -1
- package/dist/src/lib/tsp-index.js +0 -1
- package/dist/src/lib/tsp-index.js.map +1 -1
- package/dist/src/server/classify.d.ts.map +1 -1
- package/dist/src/server/classify.js +0 -26
- package/dist/src/server/classify.js.map +1 -1
- package/dist/src/server/completion.js +1 -1
- package/dist/src/server/completion.js.map +1 -1
- package/dist/src/server/tmlanguage.d.ts.map +1 -1
- package/dist/src/server/tmlanguage.js +0 -125
- package/dist/src/server/tmlanguage.js.map +1 -1
- package/dist/src/server/type-signature.js +0 -11
- package/dist/src/server/type-signature.js.map +1 -1
- package/dist/typespec.tmLanguage +0 -342
- package/package.json +1 -1
- package/dist/src/core/helpers/projected-names-utils.d.ts +0 -20
- package/dist/src/core/helpers/projected-names-utils.d.ts.map +0 -1
- package/dist/src/core/helpers/projected-names-utils.js +0 -42
- package/dist/src/core/helpers/projected-names-utils.js.map +0 -1
- package/dist/src/core/projected-program.d.ts +0 -3
- package/dist/src/core/projected-program.d.ts.map +0 -1
- package/dist/src/core/projected-program.js +0 -4
- package/dist/src/core/projected-program.js.map +0 -1
- package/dist/src/core/projection-members.d.ts +0 -8
- package/dist/src/core/projection-members.d.ts.map +0 -1
- package/dist/src/core/projection-members.js +0 -382
- package/dist/src/core/projection-members.js.map +0 -1
- package/dist/src/core/projector.d.ts +0 -26
- package/dist/src/core/projector.d.ts.map +0 -1
- package/dist/src/core/projector.js +0 -572
- package/dist/src/core/projector.js.map +0 -1
package/dist/src/core/parser.js
CHANGED
|
@@ -122,18 +122,6 @@ var ListKind;
|
|
|
122
122
|
close: Token.CloseParen,
|
|
123
123
|
invalidAnnotationTarget: "expression",
|
|
124
124
|
};
|
|
125
|
-
ListKind.ProjectionExpression = {
|
|
126
|
-
...ExpresionsBase,
|
|
127
|
-
allowEmpty: true,
|
|
128
|
-
open: Token.OpenParen,
|
|
129
|
-
close: Token.CloseParen,
|
|
130
|
-
};
|
|
131
|
-
ListKind.ProjectionParameter = {
|
|
132
|
-
...ExpresionsBase,
|
|
133
|
-
allowEmpty: true,
|
|
134
|
-
open: Token.OpenParen,
|
|
135
|
-
close: Token.CloseParen,
|
|
136
|
-
};
|
|
137
125
|
})(ListKind || (ListKind = {}));
|
|
138
126
|
export function parse(code, options = {}) {
|
|
139
127
|
const parser = createParser(code, options);
|
|
@@ -266,10 +254,6 @@ function createParser(code, options = {}) {
|
|
|
266
254
|
reportInvalidDecorators(decorators, "using statement");
|
|
267
255
|
item = parseUsingStatement(pos);
|
|
268
256
|
break;
|
|
269
|
-
case Token.ProjectionKeyword:
|
|
270
|
-
reportInvalidDecorators(decorators, "projection statement");
|
|
271
|
-
item = parseProjectionStatement(pos);
|
|
272
|
-
break;
|
|
273
257
|
case Token.Semicolon:
|
|
274
258
|
reportInvalidDecorators(decorators, "empty statement");
|
|
275
259
|
item = parseEmptyStatement(pos);
|
|
@@ -370,10 +354,6 @@ function createParser(code, options = {}) {
|
|
|
370
354
|
case Token.DecKeyword:
|
|
371
355
|
item = parseDeclaration(pos);
|
|
372
356
|
break;
|
|
373
|
-
case Token.ProjectionKeyword:
|
|
374
|
-
reportInvalidDecorators(decorators, "project statement");
|
|
375
|
-
item = parseProjectionStatement(pos);
|
|
376
|
-
break;
|
|
377
357
|
case Token.EndOfFile:
|
|
378
358
|
parseExpected(Token.CloseBrace);
|
|
379
359
|
return stmts;
|
|
@@ -1619,570 +1599,6 @@ function createParser(code, options = {}) {
|
|
|
1619
1599
|
}
|
|
1620
1600
|
return flags;
|
|
1621
1601
|
}
|
|
1622
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
1623
|
-
function parseProjectionStatement(pos) {
|
|
1624
|
-
parseExpected(Token.ProjectionKeyword);
|
|
1625
|
-
const selector = parseProjectionSelector();
|
|
1626
|
-
parseExpected(Token.Hash);
|
|
1627
|
-
const id = parseIdentifier();
|
|
1628
|
-
parseExpected(Token.OpenBrace);
|
|
1629
|
-
const projectionMap = new Map();
|
|
1630
|
-
const projections = [];
|
|
1631
|
-
while (token() === Token.Identifier) {
|
|
1632
|
-
const projection = parseProjection();
|
|
1633
|
-
if (projection.direction !== "<error>") {
|
|
1634
|
-
if (projectionMap.has(projection.direction)) {
|
|
1635
|
-
error({ code: "duplicate-symbol", target: projection, format: { name: "projection" } });
|
|
1636
|
-
}
|
|
1637
|
-
else {
|
|
1638
|
-
projectionMap.set(projection.direction, projection);
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
// NOTE: Don't drop projections with error in direction definition from the AST.
|
|
1642
|
-
projections.push(projection);
|
|
1643
|
-
}
|
|
1644
|
-
parseExpected(Token.CloseBrace);
|
|
1645
|
-
return {
|
|
1646
|
-
kind: SyntaxKind.ProjectionStatement,
|
|
1647
|
-
selector,
|
|
1648
|
-
projections,
|
|
1649
|
-
preTo: projectionMap.get("pre_to"),
|
|
1650
|
-
preFrom: projectionMap.get("pre_from"),
|
|
1651
|
-
from: projectionMap.get("from"),
|
|
1652
|
-
to: projectionMap.get("to"),
|
|
1653
|
-
id,
|
|
1654
|
-
...finishNode(pos),
|
|
1655
|
-
};
|
|
1656
|
-
}
|
|
1657
|
-
function parseProjection() {
|
|
1658
|
-
const pos = tokenPos();
|
|
1659
|
-
let directionId = parseIdentifier({ message: "projectionDirection" });
|
|
1660
|
-
let direction;
|
|
1661
|
-
const modifierIds = [];
|
|
1662
|
-
let isPre = false;
|
|
1663
|
-
if (directionId.sv === "pre") {
|
|
1664
|
-
isPre = true;
|
|
1665
|
-
modifierIds.push(directionId);
|
|
1666
|
-
directionId = parseIdentifier({ message: "projectionDirection" });
|
|
1667
|
-
}
|
|
1668
|
-
if (directionId.sv !== "to" && directionId.sv !== "from") {
|
|
1669
|
-
error({ code: "token-expected", messageId: "projectionDirection" });
|
|
1670
|
-
direction = "<error>";
|
|
1671
|
-
}
|
|
1672
|
-
else if (isPre) {
|
|
1673
|
-
direction = directionId.sv === "to" ? "pre_to" : "pre_from";
|
|
1674
|
-
}
|
|
1675
|
-
else {
|
|
1676
|
-
direction = directionId.sv;
|
|
1677
|
-
}
|
|
1678
|
-
let parameters;
|
|
1679
|
-
if (token() === Token.OpenParen) {
|
|
1680
|
-
parameters = parseList(ListKind.ProjectionParameter, parseProjectionParameter).items;
|
|
1681
|
-
}
|
|
1682
|
-
else {
|
|
1683
|
-
parameters = [];
|
|
1684
|
-
}
|
|
1685
|
-
parseExpected(Token.OpenBrace);
|
|
1686
|
-
const body = parseProjectionStatementList();
|
|
1687
|
-
parseExpected(Token.CloseBrace);
|
|
1688
|
-
return {
|
|
1689
|
-
kind: SyntaxKind.Projection,
|
|
1690
|
-
body,
|
|
1691
|
-
direction,
|
|
1692
|
-
directionId,
|
|
1693
|
-
modifierIds,
|
|
1694
|
-
parameters,
|
|
1695
|
-
...finishNode(pos),
|
|
1696
|
-
};
|
|
1697
|
-
}
|
|
1698
|
-
function parseProjectionParameter() {
|
|
1699
|
-
const pos = tokenPos();
|
|
1700
|
-
const id = parseIdentifier();
|
|
1701
|
-
return {
|
|
1702
|
-
kind: SyntaxKind.ProjectionParameterDeclaration,
|
|
1703
|
-
id,
|
|
1704
|
-
...finishNode(pos),
|
|
1705
|
-
};
|
|
1706
|
-
}
|
|
1707
|
-
function parseProjectionStatementList() {
|
|
1708
|
-
const stmts = [];
|
|
1709
|
-
while (token() !== Token.CloseBrace) {
|
|
1710
|
-
const startPos = tokenPos();
|
|
1711
|
-
if (token() === Token.EndOfFile) {
|
|
1712
|
-
error({ code: "token-expected", messageId: "default", format: { token: "}" } });
|
|
1713
|
-
break;
|
|
1714
|
-
}
|
|
1715
|
-
const expr = parseProjectionExpressionStatement();
|
|
1716
|
-
stmts.push(expr);
|
|
1717
|
-
if (tokenPos() === startPos) {
|
|
1718
|
-
// we didn't manage to parse anything, so break out
|
|
1719
|
-
// and we'll report errors elsewhere.
|
|
1720
|
-
break;
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
return stmts;
|
|
1724
|
-
}
|
|
1725
|
-
function parseProjectionExpressionStatement() {
|
|
1726
|
-
const pos = tokenPos();
|
|
1727
|
-
const expr = parseProjectionExpression();
|
|
1728
|
-
parseExpected(Token.Semicolon);
|
|
1729
|
-
return {
|
|
1730
|
-
kind: SyntaxKind.ProjectionExpressionStatement,
|
|
1731
|
-
expr,
|
|
1732
|
-
...finishNode(pos),
|
|
1733
|
-
};
|
|
1734
|
-
}
|
|
1735
|
-
function parseProjectionExpression() {
|
|
1736
|
-
return parseProjectionReturnExpressionOrHigher();
|
|
1737
|
-
}
|
|
1738
|
-
function parseProjectionReturnExpressionOrHigher() {
|
|
1739
|
-
if (token() === Token.ReturnKeyword) {
|
|
1740
|
-
const pos = tokenPos();
|
|
1741
|
-
parseExpected(Token.ReturnKeyword);
|
|
1742
|
-
return {
|
|
1743
|
-
kind: SyntaxKind.Return,
|
|
1744
|
-
value: parseProjectionExpression(),
|
|
1745
|
-
...finishNode(pos),
|
|
1746
|
-
};
|
|
1747
|
-
}
|
|
1748
|
-
return parseProjectionLogicalOrExpressionOrHigher();
|
|
1749
|
-
}
|
|
1750
|
-
function parseProjectionLogicalOrExpressionOrHigher() {
|
|
1751
|
-
let expr = parseProjectionLogicalAndExpressionOrHigher();
|
|
1752
|
-
while (token() !== Token.EndOfFile) {
|
|
1753
|
-
const pos = expr.pos;
|
|
1754
|
-
if (parseOptional(Token.BarBar)) {
|
|
1755
|
-
expr = {
|
|
1756
|
-
kind: SyntaxKind.ProjectionLogicalExpression,
|
|
1757
|
-
op: "||",
|
|
1758
|
-
left: expr,
|
|
1759
|
-
right: parseProjectionLogicalAndExpressionOrHigher(),
|
|
1760
|
-
...finishNode(pos),
|
|
1761
|
-
};
|
|
1762
|
-
}
|
|
1763
|
-
else {
|
|
1764
|
-
break;
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
return expr;
|
|
1768
|
-
}
|
|
1769
|
-
function parseProjectionLogicalAndExpressionOrHigher() {
|
|
1770
|
-
let expr = parseProjectionEqualityExpressionOrHigher();
|
|
1771
|
-
while (token() !== Token.EndOfFile) {
|
|
1772
|
-
const pos = expr.pos;
|
|
1773
|
-
if (parseOptional(Token.AmpsersandAmpersand)) {
|
|
1774
|
-
expr = {
|
|
1775
|
-
kind: SyntaxKind.ProjectionLogicalExpression,
|
|
1776
|
-
op: "&&",
|
|
1777
|
-
left: expr,
|
|
1778
|
-
right: parseProjectionEqualityExpressionOrHigher(),
|
|
1779
|
-
...finishNode(pos),
|
|
1780
|
-
};
|
|
1781
|
-
}
|
|
1782
|
-
else {
|
|
1783
|
-
break;
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
return expr;
|
|
1787
|
-
}
|
|
1788
|
-
function parseProjectionEqualityExpressionOrHigher() {
|
|
1789
|
-
let expr = parseProjectionRelationalExpressionOrHigher();
|
|
1790
|
-
while (token() !== Token.EndOfFile) {
|
|
1791
|
-
const pos = expr.pos;
|
|
1792
|
-
const tok = token();
|
|
1793
|
-
if (tok === Token.EqualsEquals || tok === Token.ExclamationEquals) {
|
|
1794
|
-
const op = tokenValue();
|
|
1795
|
-
nextToken();
|
|
1796
|
-
expr = {
|
|
1797
|
-
kind: SyntaxKind.ProjectionEqualityExpression,
|
|
1798
|
-
op,
|
|
1799
|
-
left: expr,
|
|
1800
|
-
right: parseProjectionRelationalExpressionOrHigher(),
|
|
1801
|
-
...finishNode(pos),
|
|
1802
|
-
};
|
|
1803
|
-
}
|
|
1804
|
-
else {
|
|
1805
|
-
break;
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
return expr;
|
|
1809
|
-
}
|
|
1810
|
-
function parseProjectionRelationalExpressionOrHigher() {
|
|
1811
|
-
let expr = parseProjectionAdditiveExpressionOrHigher();
|
|
1812
|
-
while (token() !== Token.EndOfFile) {
|
|
1813
|
-
const pos = expr.pos;
|
|
1814
|
-
const tok = token();
|
|
1815
|
-
if (tok === Token.LessThan ||
|
|
1816
|
-
tok === Token.LessThanEquals ||
|
|
1817
|
-
tok === Token.GreaterThan ||
|
|
1818
|
-
tok === Token.GreaterThanEquals) {
|
|
1819
|
-
const op = tokenValue();
|
|
1820
|
-
nextToken();
|
|
1821
|
-
expr = {
|
|
1822
|
-
kind: SyntaxKind.ProjectionRelationalExpression,
|
|
1823
|
-
op,
|
|
1824
|
-
left: expr,
|
|
1825
|
-
right: parseProjectionAdditiveExpressionOrHigher(),
|
|
1826
|
-
...finishNode(pos),
|
|
1827
|
-
};
|
|
1828
|
-
}
|
|
1829
|
-
else {
|
|
1830
|
-
break;
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
return expr;
|
|
1834
|
-
}
|
|
1835
|
-
function parseProjectionAdditiveExpressionOrHigher() {
|
|
1836
|
-
let expr = parseProjectionMultiplicativeExpressionOrHigher();
|
|
1837
|
-
while (token() !== Token.EndOfFile) {
|
|
1838
|
-
const pos = expr.pos;
|
|
1839
|
-
const tok = token();
|
|
1840
|
-
if (tok === Token.Plus || tok === Token.Hyphen) {
|
|
1841
|
-
const op = tokenValue();
|
|
1842
|
-
nextToken();
|
|
1843
|
-
expr = {
|
|
1844
|
-
kind: SyntaxKind.ProjectionArithmeticExpression,
|
|
1845
|
-
op,
|
|
1846
|
-
left: expr,
|
|
1847
|
-
right: parseProjectionMultiplicativeExpressionOrHigher(),
|
|
1848
|
-
...finishNode(pos),
|
|
1849
|
-
};
|
|
1850
|
-
}
|
|
1851
|
-
else {
|
|
1852
|
-
break;
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
return expr;
|
|
1856
|
-
}
|
|
1857
|
-
function parseProjectionMultiplicativeExpressionOrHigher() {
|
|
1858
|
-
let expr = parseProjectionUnaryExpressionOrHigher();
|
|
1859
|
-
while (token() !== Token.EndOfFile) {
|
|
1860
|
-
const pos = expr.pos;
|
|
1861
|
-
const tok = token();
|
|
1862
|
-
if (tok === Token.ForwardSlash || tok === Token.Star) {
|
|
1863
|
-
const op = tokenValue();
|
|
1864
|
-
nextToken();
|
|
1865
|
-
expr = {
|
|
1866
|
-
kind: SyntaxKind.ProjectionArithmeticExpression,
|
|
1867
|
-
op,
|
|
1868
|
-
left: expr,
|
|
1869
|
-
right: parseProjectionUnaryExpressionOrHigher(),
|
|
1870
|
-
...finishNode(pos),
|
|
1871
|
-
};
|
|
1872
|
-
}
|
|
1873
|
-
else {
|
|
1874
|
-
break;
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
return expr;
|
|
1878
|
-
}
|
|
1879
|
-
function parseProjectionUnaryExpressionOrHigher() {
|
|
1880
|
-
if (token() === Token.Exclamation) {
|
|
1881
|
-
const pos = tokenPos();
|
|
1882
|
-
nextToken();
|
|
1883
|
-
return {
|
|
1884
|
-
kind: SyntaxKind.ProjectionUnaryExpression,
|
|
1885
|
-
op: "!",
|
|
1886
|
-
target: parseProjectionUnaryExpressionOrHigher(),
|
|
1887
|
-
...finishNode(pos),
|
|
1888
|
-
};
|
|
1889
|
-
}
|
|
1890
|
-
return parseProjectionCallExpressionOrHigher();
|
|
1891
|
-
}
|
|
1892
|
-
function parseProjectionCallExpressionOrHigher() {
|
|
1893
|
-
let expr = parseProjectionDecoratorReferenceExpressionOrHigher();
|
|
1894
|
-
while (token() !== Token.EndOfFile) {
|
|
1895
|
-
const pos = expr.pos;
|
|
1896
|
-
expr = parseProjectionMemberExpressionRest(expr, pos);
|
|
1897
|
-
if (token() === Token.OpenParen) {
|
|
1898
|
-
expr = {
|
|
1899
|
-
kind: SyntaxKind.ProjectionCallExpression,
|
|
1900
|
-
callKind: "method",
|
|
1901
|
-
target: expr,
|
|
1902
|
-
arguments: parseList(ListKind.CallArguments, parseProjectionExpression).items,
|
|
1903
|
-
...finishNode(pos),
|
|
1904
|
-
};
|
|
1905
|
-
}
|
|
1906
|
-
else {
|
|
1907
|
-
break;
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
return expr;
|
|
1911
|
-
}
|
|
1912
|
-
function parseProjectionDecoratorReferenceExpressionOrHigher() {
|
|
1913
|
-
if (token() === Token.At) {
|
|
1914
|
-
const pos = tokenPos();
|
|
1915
|
-
nextToken();
|
|
1916
|
-
return {
|
|
1917
|
-
kind: SyntaxKind.ProjectionDecoratorReferenceExpression,
|
|
1918
|
-
target: parseIdentifierOrMemberExpression(undefined, true),
|
|
1919
|
-
...finishNode(pos),
|
|
1920
|
-
};
|
|
1921
|
-
}
|
|
1922
|
-
return parseProjectionMemberExpressionOrHigher();
|
|
1923
|
-
}
|
|
1924
|
-
function parseProjectionMemberExpressionOrHigher() {
|
|
1925
|
-
const pos = tokenPos();
|
|
1926
|
-
let expr = parseProjectionPrimaryExpression();
|
|
1927
|
-
expr = parseProjectionMemberExpressionRest(expr, pos);
|
|
1928
|
-
return expr;
|
|
1929
|
-
}
|
|
1930
|
-
function parseProjectionMemberExpressionRest(expr, pos) {
|
|
1931
|
-
while (token() !== Token.EndOfFile) {
|
|
1932
|
-
if (parseOptional(Token.Dot)) {
|
|
1933
|
-
expr = {
|
|
1934
|
-
kind: SyntaxKind.ProjectionMemberExpression,
|
|
1935
|
-
base: expr,
|
|
1936
|
-
id: parseIdentifier(),
|
|
1937
|
-
selector: ".",
|
|
1938
|
-
...finishNode(pos),
|
|
1939
|
-
};
|
|
1940
|
-
}
|
|
1941
|
-
else if (parseOptional(Token.ColonColon)) {
|
|
1942
|
-
expr = {
|
|
1943
|
-
kind: SyntaxKind.ProjectionMemberExpression,
|
|
1944
|
-
base: expr,
|
|
1945
|
-
id: parseIdentifier(),
|
|
1946
|
-
selector: "::",
|
|
1947
|
-
...finishNode(pos),
|
|
1948
|
-
};
|
|
1949
|
-
}
|
|
1950
|
-
else {
|
|
1951
|
-
break;
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
return expr;
|
|
1955
|
-
}
|
|
1956
|
-
function parseProjectionPrimaryExpression() {
|
|
1957
|
-
switch (token()) {
|
|
1958
|
-
case Token.IfKeyword:
|
|
1959
|
-
return parseProjectionIfExpression();
|
|
1960
|
-
case Token.NumericLiteral:
|
|
1961
|
-
return parseNumericLiteral();
|
|
1962
|
-
case Token.StringLiteral:
|
|
1963
|
-
return parseStringLiteral();
|
|
1964
|
-
case Token.TrueKeyword:
|
|
1965
|
-
case Token.FalseKeyword:
|
|
1966
|
-
return parseBooleanLiteral();
|
|
1967
|
-
case Token.OpenBracket:
|
|
1968
|
-
return parseProjectionTupleExpression();
|
|
1969
|
-
case Token.OpenBrace:
|
|
1970
|
-
return parseProjectionModelExpression();
|
|
1971
|
-
case Token.OpenParen:
|
|
1972
|
-
return parseProjectionLambdaOrParenthesizedExpression();
|
|
1973
|
-
case Token.VoidKeyword:
|
|
1974
|
-
return parseVoidKeyword();
|
|
1975
|
-
case Token.NeverKeyword:
|
|
1976
|
-
return parseNeverKeyword();
|
|
1977
|
-
case Token.UnknownKeyword:
|
|
1978
|
-
return parseUnknownKeyword();
|
|
1979
|
-
default:
|
|
1980
|
-
return parseIdentifier({ message: "expression" });
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
function parseProjectionLambdaOrParenthesizedExpression() {
|
|
1984
|
-
const pos = tokenPos();
|
|
1985
|
-
const exprs = parseList(ListKind.ProjectionExpression, parseProjectionExpression).items;
|
|
1986
|
-
if (token() === Token.EqualsGreaterThan) {
|
|
1987
|
-
// unpack the exprs (which should be just identifiers) into a param list
|
|
1988
|
-
const params = [];
|
|
1989
|
-
for (const expr of exprs) {
|
|
1990
|
-
if (expr.kind === SyntaxKind.Identifier) {
|
|
1991
|
-
params.push(withSymbol({
|
|
1992
|
-
kind: SyntaxKind.ProjectionLambdaParameterDeclaration,
|
|
1993
|
-
id: expr,
|
|
1994
|
-
pos: expr.pos,
|
|
1995
|
-
end: expr.end,
|
|
1996
|
-
flags: 0 /* NodeFlags.None */,
|
|
1997
|
-
}));
|
|
1998
|
-
}
|
|
1999
|
-
else {
|
|
2000
|
-
error({ code: "token-expected", messageId: "identifier", target: expr });
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
return parseProjectionLambdaExpressionRest(pos, params);
|
|
2004
|
-
}
|
|
2005
|
-
else {
|
|
2006
|
-
if (exprs.length === 0) {
|
|
2007
|
-
error({
|
|
2008
|
-
code: "token-expected",
|
|
2009
|
-
messageId: "expression",
|
|
2010
|
-
});
|
|
2011
|
-
}
|
|
2012
|
-
// verify we only have one entry
|
|
2013
|
-
for (let i = 1; i < exprs.length; i++) {
|
|
2014
|
-
error({
|
|
2015
|
-
code: "token-expected",
|
|
2016
|
-
messageId: "unexpected",
|
|
2017
|
-
format: { token: "expression" },
|
|
2018
|
-
target: exprs[i],
|
|
2019
|
-
});
|
|
2020
|
-
}
|
|
2021
|
-
return exprs[0];
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
function parseProjectionLambdaExpressionRest(pos, parameters) {
|
|
2025
|
-
parseExpected(Token.EqualsGreaterThan);
|
|
2026
|
-
const body = parseProjectionBlockExpression();
|
|
2027
|
-
return {
|
|
2028
|
-
kind: SyntaxKind.ProjectionLambdaExpression,
|
|
2029
|
-
parameters,
|
|
2030
|
-
body,
|
|
2031
|
-
...finishNode(pos),
|
|
2032
|
-
};
|
|
2033
|
-
}
|
|
2034
|
-
function parseProjectionModelExpression() {
|
|
2035
|
-
const pos = tokenPos();
|
|
2036
|
-
const { items: properties } = parseList(ListKind.ModelProperties, parseProjectionModelPropertyOrSpread);
|
|
2037
|
-
return {
|
|
2038
|
-
kind: SyntaxKind.ProjectionModelExpression,
|
|
2039
|
-
properties,
|
|
2040
|
-
...finishNode(pos),
|
|
2041
|
-
};
|
|
2042
|
-
}
|
|
2043
|
-
function parseProjectionModelPropertyOrSpread(pos, decorators) {
|
|
2044
|
-
return token() === Token.Ellipsis
|
|
2045
|
-
? parseProjectionModelSpreadProperty(pos, decorators)
|
|
2046
|
-
: parseProjectionModelProperty(pos, decorators);
|
|
2047
|
-
}
|
|
2048
|
-
function parseProjectionModelSpreadProperty(pos, decorators) {
|
|
2049
|
-
parseExpected(Token.Ellipsis);
|
|
2050
|
-
reportInvalidDecorators(decorators, "spread property");
|
|
2051
|
-
const target = parseProjectionExpression();
|
|
2052
|
-
return {
|
|
2053
|
-
kind: SyntaxKind.ProjectionModelSpreadProperty,
|
|
2054
|
-
target,
|
|
2055
|
-
...finishNode(pos),
|
|
2056
|
-
};
|
|
2057
|
-
}
|
|
2058
|
-
function parseProjectionModelProperty(pos, decorators) {
|
|
2059
|
-
const id = parseIdentifier({ message: "property", allowStringLiteral: true });
|
|
2060
|
-
const optional = parseOptional(Token.Question);
|
|
2061
|
-
parseExpected(Token.Colon);
|
|
2062
|
-
const value = parseProjectionExpression();
|
|
2063
|
-
const hasDefault = parseOptional(Token.Equals);
|
|
2064
|
-
const defaultValue = hasDefault ? parseProjectionExpression() : undefined;
|
|
2065
|
-
return {
|
|
2066
|
-
kind: SyntaxKind.ProjectionModelProperty,
|
|
2067
|
-
id,
|
|
2068
|
-
decorators,
|
|
2069
|
-
value,
|
|
2070
|
-
optional,
|
|
2071
|
-
default: defaultValue,
|
|
2072
|
-
...finishNode(pos),
|
|
2073
|
-
};
|
|
2074
|
-
}
|
|
2075
|
-
function parseProjectionIfExpression() {
|
|
2076
|
-
const pos = tokenPos();
|
|
2077
|
-
parseExpected(Token.IfKeyword);
|
|
2078
|
-
const test = parseProjectionExpression();
|
|
2079
|
-
const consequent = parseProjectionBlockExpression();
|
|
2080
|
-
let alternate = undefined;
|
|
2081
|
-
if (parseOptional(Token.ElseKeyword)) {
|
|
2082
|
-
if (token() === Token.IfKeyword) {
|
|
2083
|
-
alternate = parseProjectionIfExpression();
|
|
2084
|
-
}
|
|
2085
|
-
else {
|
|
2086
|
-
alternate = parseProjectionBlockExpression();
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
return {
|
|
2090
|
-
kind: SyntaxKind.ProjectionIfExpression,
|
|
2091
|
-
test,
|
|
2092
|
-
consequent,
|
|
2093
|
-
alternate,
|
|
2094
|
-
...finishNode(pos),
|
|
2095
|
-
};
|
|
2096
|
-
}
|
|
2097
|
-
function parseProjectionBlockExpression() {
|
|
2098
|
-
const pos = tokenPos();
|
|
2099
|
-
parseExpected(Token.OpenBrace);
|
|
2100
|
-
const statements = parseProjectionStatementList();
|
|
2101
|
-
parseExpected(Token.CloseBrace);
|
|
2102
|
-
return {
|
|
2103
|
-
kind: SyntaxKind.ProjectionBlockExpression,
|
|
2104
|
-
statements,
|
|
2105
|
-
...finishNode(pos),
|
|
2106
|
-
};
|
|
2107
|
-
}
|
|
2108
|
-
function parseProjectionTupleExpression() {
|
|
2109
|
-
const pos = tokenPos();
|
|
2110
|
-
const { items: values } = parseList(ListKind.Tuple, parseProjectionExpression);
|
|
2111
|
-
return {
|
|
2112
|
-
kind: SyntaxKind.ProjectionTupleExpression,
|
|
2113
|
-
values,
|
|
2114
|
-
...finishNode(pos),
|
|
2115
|
-
};
|
|
2116
|
-
}
|
|
2117
|
-
function parseProjectionSelector() {
|
|
2118
|
-
const pos = tokenPos();
|
|
2119
|
-
const selectorTok = expectTokenIsOneOf(Token.Identifier, Token.ModelKeyword, Token.OpKeyword, Token.InterfaceKeyword, Token.UnionKeyword, Token.EnumKeyword, Token.ScalarKeyword);
|
|
2120
|
-
switch (selectorTok) {
|
|
2121
|
-
case Token.Identifier:
|
|
2122
|
-
const id = parseIdentifierOrMemberExpression(undefined, true);
|
|
2123
|
-
if (id.kind === SyntaxKind.Identifier) {
|
|
2124
|
-
switch (id.sv) {
|
|
2125
|
-
case "modelproperty":
|
|
2126
|
-
return {
|
|
2127
|
-
kind: SyntaxKind.ProjectionModelPropertySelector,
|
|
2128
|
-
...finishNode(pos),
|
|
2129
|
-
};
|
|
2130
|
-
case "unionvariant":
|
|
2131
|
-
return {
|
|
2132
|
-
kind: SyntaxKind.ProjectionUnionVariantSelector,
|
|
2133
|
-
...finishNode(pos),
|
|
2134
|
-
};
|
|
2135
|
-
case "enummember":
|
|
2136
|
-
return {
|
|
2137
|
-
kind: SyntaxKind.ProjectionEnumMemberSelector,
|
|
2138
|
-
...finishNode(pos),
|
|
2139
|
-
};
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
return id;
|
|
2143
|
-
case Token.ModelKeyword:
|
|
2144
|
-
nextToken();
|
|
2145
|
-
return {
|
|
2146
|
-
kind: SyntaxKind.ProjectionModelSelector,
|
|
2147
|
-
...finishNode(pos),
|
|
2148
|
-
};
|
|
2149
|
-
case Token.OpKeyword:
|
|
2150
|
-
nextToken();
|
|
2151
|
-
return {
|
|
2152
|
-
kind: SyntaxKind.ProjectionOperationSelector,
|
|
2153
|
-
...finishNode(pos),
|
|
2154
|
-
};
|
|
2155
|
-
case Token.InterfaceKeyword:
|
|
2156
|
-
nextToken();
|
|
2157
|
-
return {
|
|
2158
|
-
kind: SyntaxKind.ProjectionInterfaceSelector,
|
|
2159
|
-
...finishNode(pos),
|
|
2160
|
-
};
|
|
2161
|
-
case Token.UnionKeyword:
|
|
2162
|
-
nextToken();
|
|
2163
|
-
return {
|
|
2164
|
-
kind: SyntaxKind.ProjectionUnionSelector,
|
|
2165
|
-
...finishNode(pos),
|
|
2166
|
-
};
|
|
2167
|
-
case Token.EnumKeyword:
|
|
2168
|
-
nextToken();
|
|
2169
|
-
return {
|
|
2170
|
-
kind: SyntaxKind.ProjectionEnumSelector,
|
|
2171
|
-
...finishNode(pos),
|
|
2172
|
-
};
|
|
2173
|
-
case Token.ScalarKeyword:
|
|
2174
|
-
nextToken();
|
|
2175
|
-
return {
|
|
2176
|
-
kind: SyntaxKind.ProjectionScalarSelector,
|
|
2177
|
-
...finishNode(pos),
|
|
2178
|
-
};
|
|
2179
|
-
default:
|
|
2180
|
-
// recovery: return a missing identifier to use as the selector
|
|
2181
|
-
// we don't need to emit a diagnostic here as the `expectTokenOneOf` above
|
|
2182
|
-
// will have done so.
|
|
2183
|
-
return createMissingIdentifier();
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
1602
|
function parseRange(mode, range, callback) {
|
|
2187
1603
|
const savedMode = currentMode;
|
|
2188
1604
|
const result = scanner.scanRange(range, () => {
|
|
@@ -2925,58 +2341,12 @@ export function visitChildren(node, cb) {
|
|
|
2925
2341
|
return visitEach(cb, node.values);
|
|
2926
2342
|
case SyntaxKind.UnionExpression:
|
|
2927
2343
|
return visitEach(cb, node.options);
|
|
2928
|
-
case SyntaxKind.Projection:
|
|
2929
|
-
return (visitNode(cb, node.directionId) ||
|
|
2930
|
-
visitEach(cb, node.modifierIds) ||
|
|
2931
|
-
visitEach(cb, node.parameters) ||
|
|
2932
|
-
visitEach(cb, node.body));
|
|
2933
|
-
case SyntaxKind.ProjectionExpressionStatement:
|
|
2934
|
-
return visitNode(cb, node.expr);
|
|
2935
|
-
case SyntaxKind.ProjectionCallExpression:
|
|
2936
|
-
return visitNode(cb, node.target) || visitEach(cb, node.arguments);
|
|
2937
|
-
case SyntaxKind.ProjectionMemberExpression:
|
|
2938
|
-
return visitNode(cb, node.base) || visitNode(cb, node.id);
|
|
2939
|
-
// binops
|
|
2940
|
-
case SyntaxKind.ProjectionLogicalExpression:
|
|
2941
|
-
case SyntaxKind.ProjectionRelationalExpression:
|
|
2942
|
-
case SyntaxKind.ProjectionArithmeticExpression:
|
|
2943
|
-
case SyntaxKind.ProjectionEqualityExpression:
|
|
2944
|
-
return visitNode(cb, node.left) || visitNode(cb, node.right);
|
|
2945
|
-
case SyntaxKind.ProjectionUnaryExpression:
|
|
2946
|
-
return visitNode(cb, node.target);
|
|
2947
|
-
case SyntaxKind.ProjectionModelExpression:
|
|
2948
|
-
return visitEach(cb, node.properties);
|
|
2949
|
-
case SyntaxKind.ProjectionModelProperty:
|
|
2950
|
-
return (visitEach(cb, node.decorators) ||
|
|
2951
|
-
visitNode(cb, node.id) ||
|
|
2952
|
-
visitNode(cb, node.value) ||
|
|
2953
|
-
visitNode(cb, node.default));
|
|
2954
|
-
case SyntaxKind.ProjectionModelSpreadProperty:
|
|
2955
|
-
return visitNode(cb, node.target);
|
|
2956
|
-
case SyntaxKind.ProjectionTupleExpression:
|
|
2957
|
-
return visitEach(cb, node.values);
|
|
2958
|
-
case SyntaxKind.ProjectionBlockExpression:
|
|
2959
|
-
return visitEach(cb, node.statements);
|
|
2960
|
-
case SyntaxKind.ProjectionIfExpression:
|
|
2961
|
-
return (visitNode(cb, node.test) || visitNode(cb, node.consequent) || visitNode(cb, node.alternate));
|
|
2962
|
-
case SyntaxKind.ProjectionLambdaExpression:
|
|
2963
|
-
return visitEach(cb, node.parameters) || visitNode(cb, node.body);
|
|
2964
|
-
case SyntaxKind.ProjectionStatement:
|
|
2965
|
-
return (visitNode(cb, node.id) || visitNode(cb, node.selector) || visitEach(cb, node.projections));
|
|
2966
|
-
case SyntaxKind.ProjectionDecoratorReferenceExpression:
|
|
2967
|
-
return visitNode(cb, node.target);
|
|
2968
|
-
case SyntaxKind.Return:
|
|
2969
|
-
return visitNode(cb, node.value);
|
|
2970
2344
|
case SyntaxKind.InvalidStatement:
|
|
2971
2345
|
return visitEach(cb, node.decorators);
|
|
2972
2346
|
case SyntaxKind.TemplateParameterDeclaration:
|
|
2973
2347
|
return (visitNode(cb, node.id) || visitNode(cb, node.constraint) || visitNode(cb, node.default));
|
|
2974
2348
|
case SyntaxKind.TemplateArgument:
|
|
2975
2349
|
return (node.name && visitNode(cb, node.name)) || visitNode(cb, node.argument);
|
|
2976
|
-
case SyntaxKind.ProjectionLambdaParameterDeclaration:
|
|
2977
|
-
return visitNode(cb, node.id);
|
|
2978
|
-
case SyntaxKind.ProjectionParameterDeclaration:
|
|
2979
|
-
return visitNode(cb, node.id);
|
|
2980
2350
|
case SyntaxKind.Doc:
|
|
2981
2351
|
return visitEach(cb, node.content) || visitEach(cb, node.tags);
|
|
2982
2352
|
case SyntaxKind.DocParamTag:
|
|
@@ -3009,15 +2379,6 @@ export function visitChildren(node, cb) {
|
|
|
3009
2379
|
case SyntaxKind.BooleanLiteral:
|
|
3010
2380
|
case SyntaxKind.Identifier:
|
|
3011
2381
|
case SyntaxKind.EmptyStatement:
|
|
3012
|
-
case SyntaxKind.ProjectionModelSelector:
|
|
3013
|
-
case SyntaxKind.ProjectionModelPropertySelector:
|
|
3014
|
-
case SyntaxKind.ProjectionScalarSelector:
|
|
3015
|
-
case SyntaxKind.ProjectionUnionSelector:
|
|
3016
|
-
case SyntaxKind.ProjectionUnionVariantSelector:
|
|
3017
|
-
case SyntaxKind.ProjectionInterfaceSelector:
|
|
3018
|
-
case SyntaxKind.ProjectionOperationSelector:
|
|
3019
|
-
case SyntaxKind.ProjectionEnumSelector:
|
|
3020
|
-
case SyntaxKind.ProjectionEnumMemberSelector:
|
|
3021
2382
|
case SyntaxKind.VoidKeyword:
|
|
3022
2383
|
case SyntaxKind.NeverKeyword:
|
|
3023
2384
|
case SyntaxKind.ExternKeyword:
|
|
@@ -3193,9 +2554,6 @@ export function getIdentifierContext(id) {
|
|
|
3193
2554
|
case SyntaxKind.DecoratorExpression:
|
|
3194
2555
|
kind = IdentifierKind.Decorator;
|
|
3195
2556
|
break;
|
|
3196
|
-
case SyntaxKind.ProjectionCallExpression:
|
|
3197
|
-
kind = IdentifierKind.Function;
|
|
3198
|
-
break;
|
|
3199
2557
|
case SyntaxKind.UsingStatement:
|
|
3200
2558
|
kind = IdentifierKind.Using;
|
|
3201
2559
|
break;
|