Skip to content

Commit 27e0e84

Browse files
jensjohaCommit Queue
authored and
Commit Queue
committed
[parser] Allow parsing top-level getter called get that's async/async*/sync*
Change-Id: I07e9759cdf61e1b633bbc0e7cd961d80ecfedf8e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263129 Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 7aeda01 commit 27e0e84

11 files changed

+1158
-43
lines changed

pkg/_fe_analyzer_shared/lib/src/parser/identifier_context.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ abstract class IdentifierContext {
149149
/// Identifier is the name being declared by a top level function declaration.
150150
static const TopLevelDeclarationIdentifierContext
151151
topLevelFunctionDeclaration = const TopLevelDeclarationIdentifierContext(
152-
'topLevelFunctionDeclaration', const ['<', '(', '{', '=>']);
152+
'topLevelFunctionDeclaration',
153+
const ['<', '(', '{', '=>', 'async', 'sync']);
153154

154155
/// Identifier is the start of the name being declared by a method
155156
/// declaration.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dynamic get get => throw "hello";
2+
dynamic get get { throw "hello"; }
3+
dynamic get get async => throw "hello";
4+
dynamic get get async { throw "hello"; }
5+
dynamic get get async* => throw "hello";
6+
dynamic get get async* { throw "hello"; }
7+
dynamic get get sync* => throw "hello";
8+
dynamic get get sync* { throw "hello"; }
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
beginCompilationUnit(dynamic)
2+
beginMetadataStar(dynamic)
3+
endMetadataStar(0)
4+
beginTopLevelMember(dynamic)
5+
beginTopLevelMethod(, null, null)
6+
handleIdentifier(dynamic, typeReference)
7+
handleNoTypeArguments(get)
8+
handleType(dynamic, null)
9+
handleIdentifier(get, topLevelFunctionDeclaration)
10+
handleNoTypeVariables(=>)
11+
handleNoFormalParameters(=>, MemberKind.TopLevelMethod)
12+
handleAsyncModifier(null, null)
13+
beginLiteralString("hello")
14+
endLiteralString(0, ;)
15+
handleThrowExpression(throw, ;)
16+
handleExpressionFunctionBody(=>, ;)
17+
endTopLevelMethod(dynamic, get, ;)
18+
endTopLevelDeclaration(dynamic)
19+
beginMetadataStar(dynamic)
20+
endMetadataStar(0)
21+
beginTopLevelMember(dynamic)
22+
beginTopLevelMethod(;, null, null)
23+
handleIdentifier(dynamic, typeReference)
24+
handleNoTypeArguments(get)
25+
handleType(dynamic, null)
26+
handleIdentifier(get, topLevelFunctionDeclaration)
27+
handleNoTypeVariables({)
28+
handleNoFormalParameters({, MemberKind.TopLevelMethod)
29+
handleAsyncModifier(null, null)
30+
beginBlockFunctionBody({)
31+
beginLiteralString("hello")
32+
endLiteralString(0, ;)
33+
handleThrowExpression(throw, ;)
34+
handleExpressionStatement(;)
35+
endBlockFunctionBody(1, {, })
36+
endTopLevelMethod(dynamic, get, })
37+
endTopLevelDeclaration(dynamic)
38+
beginMetadataStar(dynamic)
39+
endMetadataStar(0)
40+
beginTopLevelMember(dynamic)
41+
beginTopLevelMethod(}, null, null)
42+
handleIdentifier(dynamic, typeReference)
43+
handleNoTypeArguments(get)
44+
handleType(dynamic, null)
45+
handleIdentifier(get, topLevelFunctionDeclaration)
46+
handleNoTypeVariables(async)
47+
handleNoFormalParameters(async, MemberKind.TopLevelMethod)
48+
handleAsyncModifier(async, null)
49+
beginLiteralString("hello")
50+
endLiteralString(0, ;)
51+
handleThrowExpression(throw, ;)
52+
handleExpressionFunctionBody(=>, ;)
53+
endTopLevelMethod(dynamic, get, ;)
54+
endTopLevelDeclaration(dynamic)
55+
beginMetadataStar(dynamic)
56+
endMetadataStar(0)
57+
beginTopLevelMember(dynamic)
58+
beginTopLevelMethod(;, null, null)
59+
handleIdentifier(dynamic, typeReference)
60+
handleNoTypeArguments(get)
61+
handleType(dynamic, null)
62+
handleIdentifier(get, topLevelFunctionDeclaration)
63+
handleNoTypeVariables(async)
64+
handleNoFormalParameters(async, MemberKind.TopLevelMethod)
65+
handleAsyncModifier(async, null)
66+
beginBlockFunctionBody({)
67+
beginLiteralString("hello")
68+
endLiteralString(0, ;)
69+
handleThrowExpression(throw, ;)
70+
handleExpressionStatement(;)
71+
endBlockFunctionBody(1, {, })
72+
endTopLevelMethod(dynamic, get, })
73+
endTopLevelDeclaration(dynamic)
74+
beginMetadataStar(dynamic)
75+
endMetadataStar(0)
76+
beginTopLevelMember(dynamic)
77+
beginTopLevelMethod(}, null, null)
78+
handleIdentifier(dynamic, typeReference)
79+
handleNoTypeArguments(get)
80+
handleType(dynamic, null)
81+
handleIdentifier(get, topLevelFunctionDeclaration)
82+
handleNoTypeVariables(async)
83+
handleNoFormalParameters(async, MemberKind.TopLevelMethod)
84+
handleAsyncModifier(async, *)
85+
beginLiteralString("hello")
86+
endLiteralString(0, ;)
87+
handleThrowExpression(throw, ;)
88+
handleExpressionFunctionBody(=>, ;)
89+
handleInvalidStatement(=>, GeneratorReturnsValue)
90+
endTopLevelMethod(dynamic, get, ;)
91+
endTopLevelDeclaration(dynamic)
92+
beginMetadataStar(dynamic)
93+
endMetadataStar(0)
94+
beginTopLevelMember(dynamic)
95+
beginTopLevelMethod(;, null, null)
96+
handleIdentifier(dynamic, typeReference)
97+
handleNoTypeArguments(get)
98+
handleType(dynamic, null)
99+
handleIdentifier(get, topLevelFunctionDeclaration)
100+
handleNoTypeVariables(async)
101+
handleNoFormalParameters(async, MemberKind.TopLevelMethod)
102+
handleAsyncModifier(async, *)
103+
beginBlockFunctionBody({)
104+
beginLiteralString("hello")
105+
endLiteralString(0, ;)
106+
handleThrowExpression(throw, ;)
107+
handleExpressionStatement(;)
108+
endBlockFunctionBody(1, {, })
109+
endTopLevelMethod(dynamic, get, })
110+
endTopLevelDeclaration(dynamic)
111+
beginMetadataStar(dynamic)
112+
endMetadataStar(0)
113+
beginTopLevelMember(dynamic)
114+
beginTopLevelMethod(}, null, null)
115+
handleIdentifier(dynamic, typeReference)
116+
handleNoTypeArguments(get)
117+
handleType(dynamic, null)
118+
handleIdentifier(get, topLevelFunctionDeclaration)
119+
handleNoTypeVariables(sync)
120+
handleNoFormalParameters(sync, MemberKind.TopLevelMethod)
121+
handleAsyncModifier(sync, *)
122+
beginLiteralString("hello")
123+
endLiteralString(0, ;)
124+
handleThrowExpression(throw, ;)
125+
handleExpressionFunctionBody(=>, ;)
126+
handleInvalidStatement(=>, GeneratorReturnsValue)
127+
endTopLevelMethod(dynamic, get, ;)
128+
endTopLevelDeclaration(dynamic)
129+
beginMetadataStar(dynamic)
130+
endMetadataStar(0)
131+
beginTopLevelMember(dynamic)
132+
beginTopLevelMethod(;, null, null)
133+
handleIdentifier(dynamic, typeReference)
134+
handleNoTypeArguments(get)
135+
handleType(dynamic, null)
136+
handleIdentifier(get, topLevelFunctionDeclaration)
137+
handleNoTypeVariables(sync)
138+
handleNoFormalParameters(sync, MemberKind.TopLevelMethod)
139+
handleAsyncModifier(sync, *)
140+
beginBlockFunctionBody({)
141+
beginLiteralString("hello")
142+
endLiteralString(0, ;)
143+
handleThrowExpression(throw, ;)
144+
handleExpressionStatement(;)
145+
endBlockFunctionBody(1, {, })
146+
endTopLevelMethod(dynamic, get, })
147+
endTopLevelDeclaration()
148+
endCompilationUnit(8, )

0 commit comments

Comments
 (0)