OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.generated.testing.ast_test_factory; | 5 library analyzer.src.generated.testing.ast_test_factory; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | |
9 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/ast/ast.dart'; |
11 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 11 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
12 import 'package:analyzer/src/generated/utilities_dart.dart'; | 12 import 'package:analyzer/src/generated/utilities_dart.dart'; |
13 | 13 |
14 /** | 14 /** |
15 * The class `AstTestFactory` defines utility methods that can be used to create
AST nodes. The | 15 * The class `AstTestFactory` defines utility methods that can be used to create
AST nodes. The |
16 * nodes that are created are complete in the sense that all of the tokens that
would have been | 16 * nodes that are created are complete in the sense that all of the tokens that
would have been |
17 * associated with the nodes by a parser are also created, but the token stream
is not constructed. | 17 * associated with the nodes by a parser are also created, but the token stream
is not constructed. |
18 * None of the nodes are resolved. | 18 * None of the nodes are resolved. |
19 * | 19 * |
20 * The general pattern is for the name of the factory method to be the same as t
he name of the class | 20 * The general pattern is for the name of the factory method to be the same as t
he name of the class |
21 * of AST node being created. There are two notable exceptions. The first is for
methods creating | 21 * of AST node being created. There are two notable exceptions. The first is for
methods creating |
22 * nodes that are part of a cascade expression. These methods are all prefixed w
ith 'cascaded'. The | 22 * nodes that are part of a cascade expression. These methods are all prefixed w
ith 'cascaded'. The |
23 * second is places where a shorter name seemed unambiguous and easier to read,
such as using | 23 * second is places where a shorter name seemed unambiguous and easier to read,
such as using |
24 * 'identifier' rather than 'prefixedIdentifier', or 'integer' rather than 'inte
gerLiteral'. | 24 * 'identifier' rather than 'prefixedIdentifier', or 'integer' rather than 'inte
gerLiteral'. |
25 */ | 25 */ |
26 class AstTestFactory { | 26 class AstTestFactory { |
27 static AdjacentStrings adjacentStrings(List<StringLiteral> strings) => | 27 static AdjacentStrings adjacentStrings(List<StringLiteral> strings) => |
28 astFactory.adjacentStrings(strings); | 28 new AdjacentStrings(strings); |
29 | 29 |
30 static Annotation annotation(Identifier name) => astFactory.annotation( | 30 static Annotation annotation(Identifier name) => new Annotation( |
31 TokenFactory.tokenFromType(TokenType.AT), name, null, null, null); | 31 TokenFactory.tokenFromType(TokenType.AT), name, null, null, null); |
32 | 32 |
33 static Annotation annotation2(Identifier name, | 33 static Annotation annotation2(Identifier name, |
34 SimpleIdentifier constructorName, ArgumentList arguments) => | 34 SimpleIdentifier constructorName, ArgumentList arguments) => |
35 astFactory.annotation( | 35 new Annotation( |
36 TokenFactory.tokenFromType(TokenType.AT), | 36 TokenFactory.tokenFromType(TokenType.AT), |
37 name, | 37 name, |
38 constructorName == null | 38 constructorName == null |
39 ? null | 39 ? null |
40 : TokenFactory.tokenFromType(TokenType.PERIOD), | 40 : TokenFactory.tokenFromType(TokenType.PERIOD), |
41 constructorName, | 41 constructorName, |
42 arguments); | 42 arguments); |
43 | 43 |
44 static ArgumentList argumentList([List<Expression> arguments]) => | 44 static ArgumentList argumentList([List<Expression> arguments]) => |
45 astFactory.argumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 45 new ArgumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
46 arguments, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)); | 46 arguments, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)); |
47 | 47 |
48 static AsExpression asExpression(Expression expression, TypeName type) => | 48 static AsExpression asExpression(Expression expression, TypeName type) => |
49 astFactory.asExpression( | 49 new AsExpression( |
50 expression, TokenFactory.tokenFromKeyword(Keyword.AS), type); | 50 expression, TokenFactory.tokenFromKeyword(Keyword.AS), type); |
51 | 51 |
52 static AssertStatement assertStatement(Expression condition, | 52 static AssertStatement assertStatement(Expression condition, |
53 [Expression message]) => | 53 [Expression message]) => |
54 astFactory.assertStatement( | 54 new AssertStatement( |
55 TokenFactory.tokenFromKeyword(Keyword.ASSERT), | 55 TokenFactory.tokenFromKeyword(Keyword.ASSERT), |
56 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 56 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
57 condition, | 57 condition, |
58 message == null ? null : TokenFactory.tokenFromType(TokenType.COMMA), | 58 message == null ? null : TokenFactory.tokenFromType(TokenType.COMMA), |
59 message, | 59 message, |
60 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 60 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
61 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 61 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
62 | 62 |
63 static AssignmentExpression assignmentExpression(Expression leftHandSide, | 63 static AssignmentExpression assignmentExpression(Expression leftHandSide, |
64 TokenType operator, Expression rightHandSide) => | 64 TokenType operator, Expression rightHandSide) => |
65 astFactory.assignmentExpression( | 65 new AssignmentExpression( |
66 leftHandSide, TokenFactory.tokenFromType(operator), rightHandSide); | 66 leftHandSide, TokenFactory.tokenFromType(operator), rightHandSide); |
67 | 67 |
68 static BlockFunctionBody asyncBlockFunctionBody( | 68 static BlockFunctionBody asyncBlockFunctionBody( |
69 [List<Statement> statements]) => | 69 [List<Statement> statements]) => |
70 astFactory.blockFunctionBody( | 70 new BlockFunctionBody( |
71 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"), | 71 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"), |
72 null, | 72 null, |
73 block(statements)); | 73 block(statements)); |
74 | 74 |
75 static ExpressionFunctionBody asyncExpressionFunctionBody( | 75 static ExpressionFunctionBody asyncExpressionFunctionBody( |
76 Expression expression) => | 76 Expression expression) => |
77 astFactory.expressionFunctionBody( | 77 new ExpressionFunctionBody( |
78 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"), | 78 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"), |
79 TokenFactory.tokenFromType(TokenType.FUNCTION), | 79 TokenFactory.tokenFromType(TokenType.FUNCTION), |
80 expression, | 80 expression, |
81 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 81 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
82 | 82 |
83 static BlockFunctionBody asyncGeneratorBlockFunctionBody( | 83 static BlockFunctionBody asyncGeneratorBlockFunctionBody( |
84 [List<Statement> statements]) => | 84 [List<Statement> statements]) => |
85 astFactory.blockFunctionBody( | 85 new BlockFunctionBody( |
86 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"), | 86 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"), |
87 TokenFactory.tokenFromType(TokenType.STAR), | 87 TokenFactory.tokenFromType(TokenType.STAR), |
88 block(statements)); | 88 block(statements)); |
89 | 89 |
90 static AwaitExpression awaitExpression(Expression expression) => | 90 static AwaitExpression awaitExpression(Expression expression) => |
91 astFactory.awaitExpression( | 91 new AwaitExpression( |
92 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "await"), | 92 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "await"), |
93 expression); | 93 expression); |
94 | 94 |
95 static BinaryExpression binaryExpression(Expression leftOperand, | 95 static BinaryExpression binaryExpression(Expression leftOperand, |
96 TokenType operator, Expression rightOperand) => | 96 TokenType operator, Expression rightOperand) => |
97 astFactory.binaryExpression( | 97 new BinaryExpression( |
98 leftOperand, TokenFactory.tokenFromType(operator), rightOperand); | 98 leftOperand, TokenFactory.tokenFromType(operator), rightOperand); |
99 | 99 |
100 static Block block([List<Statement> statements]) => astFactory.block( | 100 static Block block([List<Statement> statements]) => new Block( |
101 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), | 101 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), |
102 statements, | 102 statements, |
103 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); | 103 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); |
104 | 104 |
105 static BlockFunctionBody blockFunctionBody(Block block) => | 105 static BlockFunctionBody blockFunctionBody(Block block) => |
106 astFactory.blockFunctionBody(null, null, block); | 106 new BlockFunctionBody(null, null, block); |
107 | 107 |
108 static BlockFunctionBody blockFunctionBody2([List<Statement> statements]) => | 108 static BlockFunctionBody blockFunctionBody2([List<Statement> statements]) => |
109 astFactory.blockFunctionBody(null, null, block(statements)); | 109 new BlockFunctionBody(null, null, block(statements)); |
110 | 110 |
111 static BooleanLiteral booleanLiteral(bool value) => astFactory.booleanLiteral( | 111 static BooleanLiteral booleanLiteral(bool value) => new BooleanLiteral( |
112 value | 112 value |
113 ? TokenFactory.tokenFromKeyword(Keyword.TRUE) | 113 ? TokenFactory.tokenFromKeyword(Keyword.TRUE) |
114 : TokenFactory.tokenFromKeyword(Keyword.FALSE), | 114 : TokenFactory.tokenFromKeyword(Keyword.FALSE), |
115 value); | 115 value); |
116 | 116 |
117 static BreakStatement breakStatement() => astFactory.breakStatement( | 117 static BreakStatement breakStatement() => new BreakStatement( |
118 TokenFactory.tokenFromKeyword(Keyword.BREAK), | 118 TokenFactory.tokenFromKeyword(Keyword.BREAK), |
119 null, | 119 null, |
120 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 120 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
121 | 121 |
122 static BreakStatement breakStatement2(String label) => | 122 static BreakStatement breakStatement2(String label) => new BreakStatement( |
123 astFactory.breakStatement(TokenFactory.tokenFromKeyword(Keyword.BREAK), | 123 TokenFactory.tokenFromKeyword(Keyword.BREAK), |
124 identifier3(label), TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 124 identifier3(label), |
| 125 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
125 | 126 |
126 static IndexExpression cascadedIndexExpression(Expression index) => | 127 static IndexExpression cascadedIndexExpression(Expression index) => |
127 astFactory.indexExpressionForCascade( | 128 new IndexExpression.forCascade( |
128 TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD), | 129 TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD), |
129 TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET), | 130 TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET), |
130 index, | 131 index, |
131 TokenFactory.tokenFromType(TokenType.CLOSE_SQUARE_BRACKET)); | 132 TokenFactory.tokenFromType(TokenType.CLOSE_SQUARE_BRACKET)); |
132 | 133 |
133 static MethodInvocation cascadedMethodInvocation(String methodName, | 134 static MethodInvocation cascadedMethodInvocation(String methodName, |
134 [List<Expression> arguments]) => | 135 [List<Expression> arguments]) => |
135 astFactory.methodInvocation( | 136 new MethodInvocation( |
136 null, | 137 null, |
137 TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD), | 138 TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD), |
138 identifier3(methodName), | 139 identifier3(methodName), |
139 null, | 140 null, |
140 argumentList(arguments)); | 141 argumentList(arguments)); |
141 | 142 |
142 static PropertyAccess cascadedPropertyAccess(String propertyName) => | 143 static PropertyAccess cascadedPropertyAccess(String propertyName) => |
143 astFactory.propertyAccess( | 144 new PropertyAccess( |
144 null, | 145 null, |
145 TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD), | 146 TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD), |
146 identifier3(propertyName)); | 147 identifier3(propertyName)); |
147 | 148 |
148 static CascadeExpression cascadeExpression(Expression target, | 149 static CascadeExpression cascadeExpression(Expression target, |
149 [List<Expression> cascadeSections]) => | 150 [List<Expression> cascadeSections]) => |
150 astFactory.cascadeExpression(target, cascadeSections); | 151 new CascadeExpression(target, cascadeSections); |
151 | 152 |
152 static CatchClause catchClause(String exceptionParameter, | 153 static CatchClause catchClause(String exceptionParameter, |
153 [List<Statement> statements]) => | 154 [List<Statement> statements]) => |
154 catchClause5(null, exceptionParameter, null, statements); | 155 catchClause5(null, exceptionParameter, null, statements); |
155 | 156 |
156 static CatchClause catchClause2( | 157 static CatchClause catchClause2( |
157 String exceptionParameter, String stackTraceParameter, | 158 String exceptionParameter, String stackTraceParameter, |
158 [List<Statement> statements]) => | 159 [List<Statement> statements]) => |
159 catchClause5(null, exceptionParameter, stackTraceParameter, statements); | 160 catchClause5(null, exceptionParameter, stackTraceParameter, statements); |
160 | 161 |
161 static CatchClause catchClause3(TypeName exceptionType, | 162 static CatchClause catchClause3(TypeName exceptionType, |
162 [List<Statement> statements]) => | 163 [List<Statement> statements]) => |
163 catchClause5(exceptionType, null, null, statements); | 164 catchClause5(exceptionType, null, null, statements); |
164 | 165 |
165 static CatchClause catchClause4( | 166 static CatchClause catchClause4( |
166 TypeName exceptionType, String exceptionParameter, | 167 TypeName exceptionType, String exceptionParameter, |
167 [List<Statement> statements]) => | 168 [List<Statement> statements]) => |
168 catchClause5(exceptionType, exceptionParameter, null, statements); | 169 catchClause5(exceptionType, exceptionParameter, null, statements); |
169 | 170 |
170 static CatchClause catchClause5(TypeName exceptionType, | 171 static CatchClause catchClause5(TypeName exceptionType, |
171 String exceptionParameter, String stackTraceParameter, | 172 String exceptionParameter, String stackTraceParameter, |
172 [List<Statement> statements]) => | 173 [List<Statement> statements]) => |
173 astFactory.catchClause( | 174 new CatchClause( |
174 exceptionType == null | 175 exceptionType == null |
175 ? null | 176 ? null |
176 : TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "on"), | 177 : TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "on"), |
177 exceptionType, | 178 exceptionType, |
178 exceptionParameter == null | 179 exceptionParameter == null |
179 ? null | 180 ? null |
180 : TokenFactory.tokenFromKeyword(Keyword.CATCH), | 181 : TokenFactory.tokenFromKeyword(Keyword.CATCH), |
181 exceptionParameter == null | 182 exceptionParameter == null |
182 ? null | 183 ? null |
183 : TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 184 : TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
184 exceptionParameter == null ? null : identifier3(exceptionParameter), | 185 exceptionParameter == null ? null : identifier3(exceptionParameter), |
185 stackTraceParameter == null | 186 stackTraceParameter == null |
186 ? null | 187 ? null |
187 : TokenFactory.tokenFromType(TokenType.COMMA), | 188 : TokenFactory.tokenFromType(TokenType.COMMA), |
188 stackTraceParameter == null ? null : identifier3(stackTraceParameter), | 189 stackTraceParameter == null ? null : identifier3(stackTraceParameter), |
189 exceptionParameter == null | 190 exceptionParameter == null |
190 ? null | 191 ? null |
191 : TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 192 : TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
192 block(statements)); | 193 block(statements)); |
193 | 194 |
194 static ClassDeclaration classDeclaration( | 195 static ClassDeclaration classDeclaration( |
195 Keyword abstractKeyword, | 196 Keyword abstractKeyword, |
196 String name, | 197 String name, |
197 TypeParameterList typeParameters, | 198 TypeParameterList typeParameters, |
198 ExtendsClause extendsClause, | 199 ExtendsClause extendsClause, |
199 WithClause withClause, | 200 WithClause withClause, |
200 ImplementsClause implementsClause, | 201 ImplementsClause implementsClause, |
201 [List<ClassMember> members]) => | 202 [List<ClassMember> members]) => |
202 astFactory.classDeclaration( | 203 new ClassDeclaration( |
203 null, | 204 null, |
204 null, | 205 null, |
205 abstractKeyword == null | 206 abstractKeyword == null |
206 ? null | 207 ? null |
207 : TokenFactory.tokenFromKeyword(abstractKeyword), | 208 : TokenFactory.tokenFromKeyword(abstractKeyword), |
208 TokenFactory.tokenFromKeyword(Keyword.CLASS), | 209 TokenFactory.tokenFromKeyword(Keyword.CLASS), |
209 identifier3(name), | 210 identifier3(name), |
210 typeParameters, | 211 typeParameters, |
211 extendsClause, | 212 extendsClause, |
212 withClause, | 213 withClause, |
213 implementsClause, | 214 implementsClause, |
214 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), | 215 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), |
215 members, | 216 members, |
216 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); | 217 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); |
217 | 218 |
218 static ClassTypeAlias classTypeAlias( | 219 static ClassTypeAlias classTypeAlias( |
219 String name, | 220 String name, |
220 TypeParameterList typeParameters, | 221 TypeParameterList typeParameters, |
221 Keyword abstractKeyword, | 222 Keyword abstractKeyword, |
222 TypeName superclass, | 223 TypeName superclass, |
223 WithClause withClause, | 224 WithClause withClause, |
224 ImplementsClause implementsClause) => | 225 ImplementsClause implementsClause) => |
225 astFactory.classTypeAlias( | 226 new ClassTypeAlias( |
226 null, | 227 null, |
227 null, | 228 null, |
228 TokenFactory.tokenFromKeyword(Keyword.CLASS), | 229 TokenFactory.tokenFromKeyword(Keyword.CLASS), |
229 identifier3(name), | 230 identifier3(name), |
230 typeParameters, | 231 typeParameters, |
231 TokenFactory.tokenFromType(TokenType.EQ), | 232 TokenFactory.tokenFromType(TokenType.EQ), |
232 abstractKeyword == null | 233 abstractKeyword == null |
233 ? null | 234 ? null |
234 : TokenFactory.tokenFromKeyword(abstractKeyword), | 235 : TokenFactory.tokenFromKeyword(abstractKeyword), |
235 superclass, | 236 superclass, |
(...skipping 23 matching lines...) Expand all Loading... |
259 compilationUnit8(scriptTag, null, declarations); | 260 compilationUnit8(scriptTag, null, declarations); |
260 | 261 |
261 static CompilationUnit compilationUnit7( | 262 static CompilationUnit compilationUnit7( |
262 String scriptTag, List<Directive> directives) => | 263 String scriptTag, List<Directive> directives) => |
263 compilationUnit8(scriptTag, directives, null); | 264 compilationUnit8(scriptTag, directives, null); |
264 | 265 |
265 static CompilationUnit compilationUnit8( | 266 static CompilationUnit compilationUnit8( |
266 String scriptTag, | 267 String scriptTag, |
267 List<Directive> directives, | 268 List<Directive> directives, |
268 List<CompilationUnitMember> declarations) => | 269 List<CompilationUnitMember> declarations) => |
269 astFactory.compilationUnit( | 270 new CompilationUnit( |
270 TokenFactory.tokenFromType(TokenType.EOF), | 271 TokenFactory.tokenFromType(TokenType.EOF), |
271 scriptTag == null ? null : AstTestFactory.scriptTag(scriptTag), | 272 scriptTag == null ? null : AstTestFactory.scriptTag(scriptTag), |
272 directives == null ? new List<Directive>() : directives, | 273 directives == null ? new List<Directive>() : directives, |
273 declarations == null | 274 declarations == null |
274 ? new List<CompilationUnitMember>() | 275 ? new List<CompilationUnitMember>() |
275 : declarations, | 276 : declarations, |
276 TokenFactory.tokenFromType(TokenType.EOF)); | 277 TokenFactory.tokenFromType(TokenType.EOF)); |
277 | 278 |
278 static ConditionalExpression conditionalExpression(Expression condition, | 279 static ConditionalExpression conditionalExpression(Expression condition, |
279 Expression thenExpression, Expression elseExpression) => | 280 Expression thenExpression, Expression elseExpression) => |
280 astFactory.conditionalExpression( | 281 new ConditionalExpression( |
281 condition, | 282 condition, |
282 TokenFactory.tokenFromType(TokenType.QUESTION), | 283 TokenFactory.tokenFromType(TokenType.QUESTION), |
283 thenExpression, | 284 thenExpression, |
284 TokenFactory.tokenFromType(TokenType.COLON), | 285 TokenFactory.tokenFromType(TokenType.COLON), |
285 elseExpression); | 286 elseExpression); |
286 | 287 |
287 static ConstructorDeclaration constructorDeclaration( | 288 static ConstructorDeclaration constructorDeclaration( |
288 Identifier returnType, | 289 Identifier returnType, |
289 String name, | 290 String name, |
290 FormalParameterList parameters, | 291 FormalParameterList parameters, |
291 List<ConstructorInitializer> initializers) => | 292 List<ConstructorInitializer> initializers) => |
292 astFactory.constructorDeclaration( | 293 new ConstructorDeclaration( |
293 null, | 294 null, |
294 null, | 295 null, |
295 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL), | 296 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL), |
296 null, | 297 null, |
297 null, | 298 null, |
298 returnType, | 299 returnType, |
299 name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD), | 300 name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD), |
300 name == null ? null : identifier3(name), | 301 name == null ? null : identifier3(name), |
301 parameters, | 302 parameters, |
302 initializers == null || initializers.isEmpty | 303 initializers == null || initializers.isEmpty |
303 ? null | 304 ? null |
304 : TokenFactory.tokenFromType(TokenType.PERIOD), | 305 : TokenFactory.tokenFromType(TokenType.PERIOD), |
305 initializers == null | 306 initializers == null |
306 ? new List<ConstructorInitializer>() | 307 ? new List<ConstructorInitializer>() |
307 : initializers, | 308 : initializers, |
308 null, | 309 null, |
309 emptyFunctionBody()); | 310 emptyFunctionBody()); |
310 | 311 |
311 static ConstructorDeclaration constructorDeclaration2( | 312 static ConstructorDeclaration constructorDeclaration2( |
312 Keyword constKeyword, | 313 Keyword constKeyword, |
313 Keyword factoryKeyword, | 314 Keyword factoryKeyword, |
314 Identifier returnType, | 315 Identifier returnType, |
315 String name, | 316 String name, |
316 FormalParameterList parameters, | 317 FormalParameterList parameters, |
317 List<ConstructorInitializer> initializers, | 318 List<ConstructorInitializer> initializers, |
318 FunctionBody body) => | 319 FunctionBody body) => |
319 astFactory.constructorDeclaration( | 320 new ConstructorDeclaration( |
320 null, | 321 null, |
321 null, | 322 null, |
322 null, | 323 null, |
323 constKeyword == null | 324 constKeyword == null |
324 ? null | 325 ? null |
325 : TokenFactory.tokenFromKeyword(constKeyword), | 326 : TokenFactory.tokenFromKeyword(constKeyword), |
326 factoryKeyword == null | 327 factoryKeyword == null |
327 ? null | 328 ? null |
328 : TokenFactory.tokenFromKeyword(factoryKeyword), | 329 : TokenFactory.tokenFromKeyword(factoryKeyword), |
329 returnType, | 330 returnType, |
330 name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD), | 331 name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD), |
331 name == null ? null : identifier3(name), | 332 name == null ? null : identifier3(name), |
332 parameters, | 333 parameters, |
333 initializers == null || initializers.isEmpty | 334 initializers == null || initializers.isEmpty |
334 ? null | 335 ? null |
335 : TokenFactory.tokenFromType(TokenType.PERIOD), | 336 : TokenFactory.tokenFromType(TokenType.PERIOD), |
336 initializers == null | 337 initializers == null |
337 ? new List<ConstructorInitializer>() | 338 ? new List<ConstructorInitializer>() |
338 : initializers, | 339 : initializers, |
339 null, | 340 null, |
340 body); | 341 body); |
341 | 342 |
342 static ConstructorFieldInitializer constructorFieldInitializer( | 343 static ConstructorFieldInitializer constructorFieldInitializer( |
343 bool prefixedWithThis, String fieldName, Expression expression) => | 344 bool prefixedWithThis, String fieldName, Expression expression) => |
344 astFactory.constructorFieldInitializer( | 345 new ConstructorFieldInitializer( |
345 prefixedWithThis ? TokenFactory.tokenFromKeyword(Keyword.THIS) : null, | 346 prefixedWithThis ? TokenFactory.tokenFromKeyword(Keyword.THIS) : null, |
346 prefixedWithThis | 347 prefixedWithThis |
347 ? TokenFactory.tokenFromType(TokenType.PERIOD) | 348 ? TokenFactory.tokenFromType(TokenType.PERIOD) |
348 : null, | 349 : null, |
349 identifier3(fieldName), | 350 identifier3(fieldName), |
350 TokenFactory.tokenFromType(TokenType.EQ), | 351 TokenFactory.tokenFromType(TokenType.EQ), |
351 expression); | 352 expression); |
352 | 353 |
353 static ConstructorName constructorName(TypeName type, String name) => | 354 static ConstructorName constructorName(TypeName type, String name) => |
354 astFactory.constructorName( | 355 new ConstructorName( |
355 type, | 356 type, |
356 name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD), | 357 name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD), |
357 name == null ? null : identifier3(name)); | 358 name == null ? null : identifier3(name)); |
358 | 359 |
359 static ContinueStatement continueStatement([String label]) => | 360 static ContinueStatement continueStatement([String label]) => |
360 astFactory.continueStatement( | 361 new ContinueStatement( |
361 TokenFactory.tokenFromKeyword(Keyword.CONTINUE), | 362 TokenFactory.tokenFromKeyword(Keyword.CONTINUE), |
362 label == null ? null : identifier3(label), | 363 label == null ? null : identifier3(label), |
363 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 364 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
364 | 365 |
365 static DeclaredIdentifier declaredIdentifier( | 366 static DeclaredIdentifier declaredIdentifier( |
366 Keyword keyword, String identifier) => | 367 Keyword keyword, String identifier) => |
367 declaredIdentifier2(keyword, null, identifier); | 368 declaredIdentifier2(keyword, null, identifier); |
368 | 369 |
369 static DeclaredIdentifier declaredIdentifier2( | 370 static DeclaredIdentifier declaredIdentifier2( |
370 Keyword keyword, TypeName type, String identifier) => | 371 Keyword keyword, TypeName type, String identifier) => |
371 astFactory.declaredIdentifier( | 372 new DeclaredIdentifier( |
372 null, | 373 null, |
373 null, | 374 null, |
374 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), | 375 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), |
375 type, | 376 type, |
376 identifier3(identifier)); | 377 identifier3(identifier)); |
377 | 378 |
378 static DeclaredIdentifier declaredIdentifier3(String identifier) => | 379 static DeclaredIdentifier declaredIdentifier3(String identifier) => |
379 declaredIdentifier2(Keyword.VAR, null, identifier); | 380 declaredIdentifier2(Keyword.VAR, null, identifier); |
380 | 381 |
381 static DeclaredIdentifier declaredIdentifier4( | 382 static DeclaredIdentifier declaredIdentifier4( |
382 TypeName type, String identifier) => | 383 TypeName type, String identifier) => |
383 declaredIdentifier2(null, type, identifier); | 384 declaredIdentifier2(null, type, identifier); |
384 | 385 |
385 static Comment documentationComment( | 386 static Comment documentationComment( |
386 List<Token> tokens, List<CommentReference> references) { | 387 List<Token> tokens, List<CommentReference> references) { |
387 return astFactory.documentationComment(tokens, references); | 388 return new Comment(tokens, CommentType.DOCUMENTATION, references); |
388 } | 389 } |
389 | 390 |
390 static DoStatement doStatement(Statement body, Expression condition) => | 391 static DoStatement doStatement(Statement body, Expression condition) => |
391 astFactory.doStatement( | 392 new DoStatement( |
392 TokenFactory.tokenFromKeyword(Keyword.DO), | 393 TokenFactory.tokenFromKeyword(Keyword.DO), |
393 body, | 394 body, |
394 TokenFactory.tokenFromKeyword(Keyword.WHILE), | 395 TokenFactory.tokenFromKeyword(Keyword.WHILE), |
395 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 396 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
396 condition, | 397 condition, |
397 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 398 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
398 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 399 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
399 | 400 |
400 static DoubleLiteral doubleLiteral(double value) => astFactory.doubleLiteral( | 401 static DoubleLiteral doubleLiteral(double value) => |
401 TokenFactory.tokenFromString(value.toString()), value); | 402 new DoubleLiteral(TokenFactory.tokenFromString(value.toString()), value); |
402 | 403 |
403 static EmptyFunctionBody emptyFunctionBody() => astFactory | 404 static EmptyFunctionBody emptyFunctionBody() => |
404 .emptyFunctionBody(TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 405 new EmptyFunctionBody(TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
405 | 406 |
406 static EmptyStatement emptyStatement() => astFactory | 407 static EmptyStatement emptyStatement() => |
407 .emptyStatement(TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 408 new EmptyStatement(TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
408 | 409 |
409 static EnumDeclaration enumDeclaration( | 410 static EnumDeclaration enumDeclaration( |
410 SimpleIdentifier name, List<EnumConstantDeclaration> constants) => | 411 SimpleIdentifier name, List<EnumConstantDeclaration> constants) => |
411 astFactory.enumDeclaration( | 412 new EnumDeclaration( |
412 null, | 413 null, |
413 null, | 414 null, |
414 TokenFactory.tokenFromKeyword(Keyword.ENUM), | 415 TokenFactory.tokenFromKeyword(Keyword.ENUM), |
415 name, | 416 name, |
416 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), | 417 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), |
417 constants, | 418 constants, |
418 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); | 419 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); |
419 | 420 |
420 static EnumDeclaration enumDeclaration2( | 421 static EnumDeclaration enumDeclaration2( |
421 String name, List<String> constantNames) { | 422 String name, List<String> constantNames) { |
422 int count = constantNames.length; | 423 int count = constantNames.length; |
423 List<EnumConstantDeclaration> constants = | 424 List<EnumConstantDeclaration> constants = |
424 new List<EnumConstantDeclaration>(count); | 425 new List<EnumConstantDeclaration>(count); |
425 for (int i = 0; i < count; i++) { | 426 for (int i = 0; i < count; i++) { |
426 constants[i] = astFactory.enumConstantDeclaration( | 427 constants[i] = new EnumConstantDeclaration( |
427 null, null, identifier3(constantNames[i])); | 428 null, null, identifier3(constantNames[i])); |
428 } | 429 } |
429 return enumDeclaration(identifier3(name), constants); | 430 return enumDeclaration(identifier3(name), constants); |
430 } | 431 } |
431 | 432 |
432 static ExportDirective exportDirective(List<Annotation> metadata, String uri, | 433 static ExportDirective exportDirective(List<Annotation> metadata, String uri, |
433 [List<Combinator> combinators]) => | 434 [List<Combinator> combinators]) => |
434 astFactory.exportDirective( | 435 new ExportDirective( |
435 null, | 436 null, |
436 metadata, | 437 metadata, |
437 TokenFactory.tokenFromKeyword(Keyword.EXPORT), | 438 TokenFactory.tokenFromKeyword(Keyword.EXPORT), |
438 string2(uri), | 439 string2(uri), |
439 null, | 440 null, |
440 combinators, | 441 combinators, |
441 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 442 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
442 | 443 |
443 static ExportDirective exportDirective2(String uri, | 444 static ExportDirective exportDirective2(String uri, |
444 [List<Combinator> combinators]) => | 445 [List<Combinator> combinators]) => |
445 exportDirective(null, uri, combinators); | 446 exportDirective(null, uri, combinators); |
446 | 447 |
447 static ExpressionFunctionBody expressionFunctionBody(Expression expression) => | 448 static ExpressionFunctionBody expressionFunctionBody(Expression expression) => |
448 astFactory.expressionFunctionBody( | 449 new ExpressionFunctionBody( |
449 null, | 450 null, |
450 TokenFactory.tokenFromType(TokenType.FUNCTION), | 451 TokenFactory.tokenFromType(TokenType.FUNCTION), |
451 expression, | 452 expression, |
452 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 453 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
453 | 454 |
454 static ExpressionStatement expressionStatement(Expression expression) => | 455 static ExpressionStatement expressionStatement(Expression expression) => |
455 astFactory.expressionStatement( | 456 new ExpressionStatement( |
456 expression, TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 457 expression, TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
457 | 458 |
458 static ExtendsClause extendsClause(TypeName type) => astFactory.extendsClause( | 459 static ExtendsClause extendsClause(TypeName type) => |
459 TokenFactory.tokenFromKeyword(Keyword.EXTENDS), type); | 460 new ExtendsClause(TokenFactory.tokenFromKeyword(Keyword.EXTENDS), type); |
460 | 461 |
461 static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword, | 462 static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword, |
462 TypeName type, List<VariableDeclaration> variables) => | 463 TypeName type, List<VariableDeclaration> variables) => |
463 astFactory.fieldDeclaration( | 464 new FieldDeclaration( |
464 null, | 465 null, |
465 null, | 466 null, |
466 isStatic ? TokenFactory.tokenFromKeyword(Keyword.STATIC) : null, | 467 isStatic ? TokenFactory.tokenFromKeyword(Keyword.STATIC) : null, |
467 variableDeclarationList(keyword, type, variables), | 468 variableDeclarationList(keyword, type, variables), |
468 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 469 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
469 | 470 |
470 static FieldDeclaration fieldDeclaration2(bool isStatic, Keyword keyword, | 471 static FieldDeclaration fieldDeclaration2(bool isStatic, Keyword keyword, |
471 List<VariableDeclaration> variables) => | 472 List<VariableDeclaration> variables) => |
472 fieldDeclaration(isStatic, keyword, null, variables); | 473 fieldDeclaration(isStatic, keyword, null, variables); |
473 | 474 |
474 static FieldFormalParameter fieldFormalParameter( | 475 static FieldFormalParameter fieldFormalParameter( |
475 Keyword keyword, TypeName type, String identifier, | 476 Keyword keyword, TypeName type, String identifier, |
476 [FormalParameterList parameterList]) => | 477 [FormalParameterList parameterList]) => |
477 astFactory.fieldFormalParameter( | 478 new FieldFormalParameter( |
478 null, | 479 null, |
479 null, | 480 null, |
480 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), | 481 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), |
481 type, | 482 type, |
482 TokenFactory.tokenFromKeyword(Keyword.THIS), | 483 TokenFactory.tokenFromKeyword(Keyword.THIS), |
483 TokenFactory.tokenFromType(TokenType.PERIOD), | 484 TokenFactory.tokenFromType(TokenType.PERIOD), |
484 identifier3(identifier), | 485 identifier3(identifier), |
485 null, | 486 null, |
486 parameterList); | 487 parameterList); |
487 | 488 |
488 static FieldFormalParameter fieldFormalParameter2(String identifier) => | 489 static FieldFormalParameter fieldFormalParameter2(String identifier) => |
489 fieldFormalParameter(null, null, identifier); | 490 fieldFormalParameter(null, null, identifier); |
490 | 491 |
491 static ForEachStatement forEachStatement(DeclaredIdentifier loopVariable, | 492 static ForEachStatement forEachStatement(DeclaredIdentifier loopVariable, |
492 Expression iterator, Statement body) => | 493 Expression iterator, Statement body) => |
493 astFactory.forEachStatementWithDeclaration( | 494 new ForEachStatement.withDeclaration( |
494 null, | 495 null, |
495 TokenFactory.tokenFromKeyword(Keyword.FOR), | 496 TokenFactory.tokenFromKeyword(Keyword.FOR), |
496 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 497 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
497 loopVariable, | 498 loopVariable, |
498 TokenFactory.tokenFromKeyword(Keyword.IN), | 499 TokenFactory.tokenFromKeyword(Keyword.IN), |
499 iterator, | 500 iterator, |
500 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 501 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
501 body); | 502 body); |
502 | 503 |
503 static ForEachStatement forEachStatement2( | 504 static ForEachStatement forEachStatement2( |
504 SimpleIdentifier identifier, Expression iterator, Statement body) => | 505 SimpleIdentifier identifier, Expression iterator, Statement body) => |
505 astFactory.forEachStatementWithReference( | 506 new ForEachStatement.withReference( |
506 null, | 507 null, |
507 TokenFactory.tokenFromKeyword(Keyword.FOR), | 508 TokenFactory.tokenFromKeyword(Keyword.FOR), |
508 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 509 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
509 identifier, | 510 identifier, |
510 TokenFactory.tokenFromKeyword(Keyword.IN), | 511 TokenFactory.tokenFromKeyword(Keyword.IN), |
511 iterator, | 512 iterator, |
512 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 513 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
513 body); | 514 body); |
514 | 515 |
515 static FormalParameterList formalParameterList( | 516 static FormalParameterList formalParameterList( |
516 [List<FormalParameter> parameters]) => | 517 [List<FormalParameter> parameters]) => |
517 astFactory.formalParameterList( | 518 new FormalParameterList( |
518 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 519 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
519 parameters, | 520 parameters, |
520 null, | 521 null, |
521 null, | 522 null, |
522 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)); | 523 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)); |
523 | 524 |
524 static ForStatement forStatement(Expression initialization, | 525 static ForStatement forStatement(Expression initialization, |
525 Expression condition, List<Expression> updaters, Statement body) => | 526 Expression condition, List<Expression> updaters, Statement body) => |
526 astFactory.forStatement( | 527 new ForStatement( |
527 TokenFactory.tokenFromKeyword(Keyword.FOR), | 528 TokenFactory.tokenFromKeyword(Keyword.FOR), |
528 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 529 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
529 null, | 530 null, |
530 initialization, | 531 initialization, |
531 TokenFactory.tokenFromType(TokenType.SEMICOLON), | 532 TokenFactory.tokenFromType(TokenType.SEMICOLON), |
532 condition, | 533 condition, |
533 TokenFactory.tokenFromType(TokenType.SEMICOLON), | 534 TokenFactory.tokenFromType(TokenType.SEMICOLON), |
534 updaters, | 535 updaters, |
535 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 536 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
536 body); | 537 body); |
537 | 538 |
538 static ForStatement forStatement2(VariableDeclarationList variableList, | 539 static ForStatement forStatement2(VariableDeclarationList variableList, |
539 Expression condition, List<Expression> updaters, Statement body) => | 540 Expression condition, List<Expression> updaters, Statement body) => |
540 astFactory.forStatement( | 541 new ForStatement( |
541 TokenFactory.tokenFromKeyword(Keyword.FOR), | 542 TokenFactory.tokenFromKeyword(Keyword.FOR), |
542 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 543 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
543 variableList, | 544 variableList, |
544 null, | 545 null, |
545 TokenFactory.tokenFromType(TokenType.SEMICOLON), | 546 TokenFactory.tokenFromType(TokenType.SEMICOLON), |
546 condition, | 547 condition, |
547 TokenFactory.tokenFromType(TokenType.SEMICOLON), | 548 TokenFactory.tokenFromType(TokenType.SEMICOLON), |
548 updaters, | 549 updaters, |
549 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 550 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
550 body); | 551 body); |
551 | 552 |
552 static FunctionDeclaration functionDeclaration(TypeName type, Keyword keyword, | 553 static FunctionDeclaration functionDeclaration(TypeName type, Keyword keyword, |
553 String name, FunctionExpression functionExpression) => | 554 String name, FunctionExpression functionExpression) => |
554 astFactory.functionDeclaration( | 555 new FunctionDeclaration( |
555 null, | 556 null, |
556 null, | 557 null, |
557 null, | 558 null, |
558 type, | 559 type, |
559 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), | 560 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), |
560 identifier3(name), | 561 identifier3(name), |
561 functionExpression); | 562 functionExpression); |
562 | 563 |
563 static FunctionDeclarationStatement functionDeclarationStatement( | 564 static FunctionDeclarationStatement functionDeclarationStatement( |
564 TypeName type, | 565 TypeName type, |
565 Keyword keyword, | 566 Keyword keyword, |
566 String name, | 567 String name, |
567 FunctionExpression functionExpression) => | 568 FunctionExpression functionExpression) => |
568 astFactory.functionDeclarationStatement( | 569 new FunctionDeclarationStatement( |
569 functionDeclaration(type, keyword, name, functionExpression)); | 570 functionDeclaration(type, keyword, name, functionExpression)); |
570 | 571 |
571 static FunctionExpression functionExpression() => astFactory | 572 static FunctionExpression functionExpression() => |
572 .functionExpression(null, formalParameterList(), blockFunctionBody2()); | 573 new FunctionExpression(null, formalParameterList(), blockFunctionBody2()); |
573 | 574 |
574 static FunctionExpression functionExpression2( | 575 static FunctionExpression functionExpression2( |
575 FormalParameterList parameters, FunctionBody body) => | 576 FormalParameterList parameters, FunctionBody body) => |
576 astFactory.functionExpression(null, parameters, body); | 577 new FunctionExpression(null, parameters, body); |
577 | 578 |
578 static FunctionExpression functionExpression3( | 579 static FunctionExpression functionExpression3( |
579 TypeParameterList typeParameters, | 580 TypeParameterList typeParameters, |
580 FormalParameterList parameters, | 581 FormalParameterList parameters, |
581 FunctionBody body) => | 582 FunctionBody body) => |
582 astFactory.functionExpression(typeParameters, parameters, body); | 583 new FunctionExpression(typeParameters, parameters, body); |
583 | 584 |
584 static FunctionExpressionInvocation functionExpressionInvocation( | 585 static FunctionExpressionInvocation functionExpressionInvocation( |
585 Expression function, | 586 Expression function, |
586 [List<Expression> arguments]) => | 587 [List<Expression> arguments]) => |
587 functionExpressionInvocation2(function, null, arguments); | 588 functionExpressionInvocation2(function, null, arguments); |
588 | 589 |
589 static FunctionExpressionInvocation functionExpressionInvocation2( | 590 static FunctionExpressionInvocation functionExpressionInvocation2( |
590 Expression function, | 591 Expression function, |
591 [TypeArgumentList typeArguments, | 592 [TypeArgumentList typeArguments, |
592 List<Expression> arguments]) => | 593 List<Expression> arguments]) => |
593 astFactory.functionExpressionInvocation( | 594 new FunctionExpressionInvocation( |
594 function, typeArguments, argumentList(arguments)); | 595 function, typeArguments, argumentList(arguments)); |
595 | 596 |
596 static FunctionTypedFormalParameter functionTypedFormalParameter( | 597 static FunctionTypedFormalParameter functionTypedFormalParameter( |
597 TypeName returnType, String identifier, | 598 TypeName returnType, String identifier, |
598 [List<FormalParameter> parameters]) => | 599 [List<FormalParameter> parameters]) => |
599 astFactory.functionTypedFormalParameter(null, null, returnType, | 600 new FunctionTypedFormalParameter(null, null, returnType, |
600 identifier3(identifier), null, formalParameterList(parameters)); | 601 identifier3(identifier), null, formalParameterList(parameters)); |
601 | 602 |
602 static HideCombinator hideCombinator(List<SimpleIdentifier> identifiers) => | 603 static HideCombinator hideCombinator(List<SimpleIdentifier> identifiers) => |
603 astFactory.hideCombinator( | 604 new HideCombinator(TokenFactory.tokenFromString("hide"), identifiers); |
604 TokenFactory.tokenFromString("hide"), identifiers); | |
605 | 605 |
606 static HideCombinator hideCombinator2(List<String> identifiers) => | 606 static HideCombinator hideCombinator2(List<String> identifiers) => |
607 astFactory.hideCombinator( | 607 new HideCombinator( |
608 TokenFactory.tokenFromString("hide"), identifierList(identifiers)); | 608 TokenFactory.tokenFromString("hide"), identifierList(identifiers)); |
609 | 609 |
610 static PrefixedIdentifier identifier( | 610 static PrefixedIdentifier identifier( |
611 SimpleIdentifier prefix, SimpleIdentifier identifier) => | 611 SimpleIdentifier prefix, SimpleIdentifier identifier) => |
612 astFactory.prefixedIdentifier( | 612 new PrefixedIdentifier( |
613 prefix, TokenFactory.tokenFromType(TokenType.PERIOD), identifier); | 613 prefix, TokenFactory.tokenFromType(TokenType.PERIOD), identifier); |
614 | 614 |
615 static SimpleIdentifier identifier3(String lexeme) => | 615 static SimpleIdentifier identifier3(String lexeme) => new SimpleIdentifier( |
616 astFactory.simpleIdentifier( | 616 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, lexeme)); |
617 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, lexeme)); | |
618 | 617 |
619 static PrefixedIdentifier identifier4( | 618 static PrefixedIdentifier identifier4( |
620 String prefix, SimpleIdentifier identifier) => | 619 String prefix, SimpleIdentifier identifier) => |
621 astFactory.prefixedIdentifier(identifier3(prefix), | 620 new PrefixedIdentifier(identifier3(prefix), |
622 TokenFactory.tokenFromType(TokenType.PERIOD), identifier); | 621 TokenFactory.tokenFromType(TokenType.PERIOD), identifier); |
623 | 622 |
624 static PrefixedIdentifier identifier5(String prefix, String identifier) => | 623 static PrefixedIdentifier identifier5(String prefix, String identifier) => |
625 astFactory.prefixedIdentifier( | 624 new PrefixedIdentifier( |
626 identifier3(prefix), | 625 identifier3(prefix), |
627 TokenFactory.tokenFromType(TokenType.PERIOD), | 626 TokenFactory.tokenFromType(TokenType.PERIOD), |
628 identifier3(identifier)); | 627 identifier3(identifier)); |
629 | 628 |
630 static List<SimpleIdentifier> identifierList(List<String> identifiers) { | 629 static List<SimpleIdentifier> identifierList(List<String> identifiers) { |
631 if (identifiers == null) { | 630 if (identifiers == null) { |
632 return null; | 631 return null; |
633 } | 632 } |
634 return identifiers | 633 return identifiers |
635 .map((String identifier) => identifier3(identifier)) | 634 .map((String identifier) => identifier3(identifier)) |
636 .toList(); | 635 .toList(); |
637 } | 636 } |
638 | 637 |
639 static IfStatement ifStatement( | 638 static IfStatement ifStatement( |
640 Expression condition, Statement thenStatement) => | 639 Expression condition, Statement thenStatement) => |
641 ifStatement2(condition, thenStatement, null); | 640 ifStatement2(condition, thenStatement, null); |
642 | 641 |
643 static IfStatement ifStatement2(Expression condition, Statement thenStatement, | 642 static IfStatement ifStatement2(Expression condition, Statement thenStatement, |
644 Statement elseStatement) => | 643 Statement elseStatement) => |
645 astFactory.ifStatement( | 644 new IfStatement( |
646 TokenFactory.tokenFromKeyword(Keyword.IF), | 645 TokenFactory.tokenFromKeyword(Keyword.IF), |
647 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 646 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
648 condition, | 647 condition, |
649 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 648 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
650 thenStatement, | 649 thenStatement, |
651 elseStatement == null | 650 elseStatement == null |
652 ? null | 651 ? null |
653 : TokenFactory.tokenFromKeyword(Keyword.ELSE), | 652 : TokenFactory.tokenFromKeyword(Keyword.ELSE), |
654 elseStatement); | 653 elseStatement); |
655 | 654 |
656 static ImplementsClause implementsClause(List<TypeName> types) => | 655 static ImplementsClause implementsClause(List<TypeName> types) => |
657 astFactory.implementsClause( | 656 new ImplementsClause( |
658 TokenFactory.tokenFromKeyword(Keyword.IMPLEMENTS), types); | 657 TokenFactory.tokenFromKeyword(Keyword.IMPLEMENTS), types); |
659 | 658 |
660 static ImportDirective importDirective( | 659 static ImportDirective importDirective( |
661 List<Annotation> metadata, String uri, bool isDeferred, String prefix, | 660 List<Annotation> metadata, String uri, bool isDeferred, String prefix, |
662 [List<Combinator> combinators]) => | 661 [List<Combinator> combinators]) => |
663 astFactory.importDirective( | 662 new ImportDirective( |
664 null, | 663 null, |
665 metadata, | 664 metadata, |
666 TokenFactory.tokenFromKeyword(Keyword.IMPORT), | 665 TokenFactory.tokenFromKeyword(Keyword.IMPORT), |
667 string2(uri), | 666 string2(uri), |
668 null, | 667 null, |
669 !isDeferred ? null : TokenFactory.tokenFromKeyword(Keyword.DEFERRED), | 668 !isDeferred ? null : TokenFactory.tokenFromKeyword(Keyword.DEFERRED), |
670 prefix == null ? null : TokenFactory.tokenFromKeyword(Keyword.AS), | 669 prefix == null ? null : TokenFactory.tokenFromKeyword(Keyword.AS), |
671 prefix == null ? null : identifier3(prefix), | 670 prefix == null ? null : identifier3(prefix), |
672 combinators, | 671 combinators, |
673 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 672 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
674 | 673 |
675 static ImportDirective importDirective2( | 674 static ImportDirective importDirective2( |
676 String uri, bool isDeferred, String prefix, | 675 String uri, bool isDeferred, String prefix, |
677 [List<Combinator> combinators]) => | 676 [List<Combinator> combinators]) => |
678 importDirective(null, uri, isDeferred, prefix, combinators); | 677 importDirective(null, uri, isDeferred, prefix, combinators); |
679 | 678 |
680 static ImportDirective importDirective3(String uri, String prefix, | 679 static ImportDirective importDirective3(String uri, String prefix, |
681 [List<Combinator> combinators]) => | 680 [List<Combinator> combinators]) => |
682 importDirective(null, uri, false, prefix, combinators); | 681 importDirective(null, uri, false, prefix, combinators); |
683 | 682 |
684 static IndexExpression indexExpression(Expression array, Expression index) => | 683 static IndexExpression indexExpression(Expression array, Expression index) => |
685 astFactory.indexExpressionForTarget( | 684 new IndexExpression.forTarget( |
686 array, | 685 array, |
687 TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET), | 686 TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET), |
688 index, | 687 index, |
689 TokenFactory.tokenFromType(TokenType.CLOSE_SQUARE_BRACKET)); | 688 TokenFactory.tokenFromType(TokenType.CLOSE_SQUARE_BRACKET)); |
690 | 689 |
691 static InstanceCreationExpression instanceCreationExpression( | 690 static InstanceCreationExpression instanceCreationExpression( |
692 Keyword keyword, ConstructorName name, | 691 Keyword keyword, ConstructorName name, |
693 [List<Expression> arguments]) => | 692 [List<Expression> arguments]) => |
694 astFactory.instanceCreationExpression( | 693 new InstanceCreationExpression( |
695 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), | 694 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), |
696 name, | 695 name, |
697 argumentList(arguments)); | 696 argumentList(arguments)); |
698 | 697 |
699 static InstanceCreationExpression instanceCreationExpression2( | 698 static InstanceCreationExpression instanceCreationExpression2( |
700 Keyword keyword, TypeName type, | 699 Keyword keyword, TypeName type, |
701 [List<Expression> arguments]) => | 700 [List<Expression> arguments]) => |
702 instanceCreationExpression3(keyword, type, null, arguments); | 701 instanceCreationExpression3(keyword, type, null, arguments); |
703 | 702 |
704 static InstanceCreationExpression instanceCreationExpression3( | 703 static InstanceCreationExpression instanceCreationExpression3( |
705 Keyword keyword, TypeName type, String identifier, | 704 Keyword keyword, TypeName type, String identifier, |
706 [List<Expression> arguments]) => | 705 [List<Expression> arguments]) => |
707 instanceCreationExpression( | 706 instanceCreationExpression( |
708 keyword, | 707 keyword, |
709 astFactory.constructorName( | 708 new ConstructorName( |
710 type, | 709 type, |
711 identifier == null | 710 identifier == null |
712 ? null | 711 ? null |
713 : TokenFactory.tokenFromType(TokenType.PERIOD), | 712 : TokenFactory.tokenFromType(TokenType.PERIOD), |
714 identifier == null ? null : identifier3(identifier)), | 713 identifier == null ? null : identifier3(identifier)), |
715 arguments); | 714 arguments); |
716 | 715 |
717 static IntegerLiteral integer(int value) => astFactory.integerLiteral( | 716 static IntegerLiteral integer(int value) => new IntegerLiteral( |
718 TokenFactory.tokenFromTypeAndString(TokenType.INT, value.toString()), | 717 TokenFactory.tokenFromTypeAndString(TokenType.INT, value.toString()), |
719 value); | 718 value); |
720 | 719 |
721 static InterpolationExpression interpolationExpression( | 720 static InterpolationExpression interpolationExpression( |
722 Expression expression) => | 721 Expression expression) => |
723 astFactory.interpolationExpression( | 722 new InterpolationExpression( |
724 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION), | 723 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION), |
725 expression, | 724 expression, |
726 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); | 725 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); |
727 | 726 |
728 static InterpolationExpression interpolationExpression2(String identifier) => | 727 static InterpolationExpression interpolationExpression2(String identifier) => |
729 astFactory.interpolationExpression( | 728 new InterpolationExpression( |
730 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_IDENTIFIER), | 729 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_IDENTIFIER), |
731 identifier3(identifier), | 730 identifier3(identifier), |
732 null); | 731 null); |
733 | 732 |
734 static InterpolationString interpolationString( | 733 static InterpolationString interpolationString( |
735 String contents, String value) => | 734 String contents, String value) => |
736 astFactory.interpolationString( | 735 new InterpolationString(TokenFactory.tokenFromString(contents), value); |
737 TokenFactory.tokenFromString(contents), value); | |
738 | 736 |
739 static IsExpression isExpression( | 737 static IsExpression isExpression( |
740 Expression expression, bool negated, TypeName type) => | 738 Expression expression, bool negated, TypeName type) => |
741 astFactory.isExpression( | 739 new IsExpression(expression, TokenFactory.tokenFromKeyword(Keyword.IS), |
742 expression, | 740 negated ? TokenFactory.tokenFromType(TokenType.BANG) : null, type); |
743 TokenFactory.tokenFromKeyword(Keyword.IS), | |
744 negated ? TokenFactory.tokenFromType(TokenType.BANG) : null, | |
745 type); | |
746 | 741 |
747 static Label label(SimpleIdentifier label) => | 742 static Label label(SimpleIdentifier label) => |
748 astFactory.label(label, TokenFactory.tokenFromType(TokenType.COLON)); | 743 new Label(label, TokenFactory.tokenFromType(TokenType.COLON)); |
749 | 744 |
750 static Label label2(String label) => AstTestFactory.label(identifier3(label)); | 745 static Label label2(String label) => AstTestFactory.label(identifier3(label)); |
751 | 746 |
752 static LabeledStatement labeledStatement( | 747 static LabeledStatement labeledStatement( |
753 List<Label> labels, Statement statement) => | 748 List<Label> labels, Statement statement) => |
754 astFactory.labeledStatement(labels, statement); | 749 new LabeledStatement(labels, statement); |
755 | 750 |
756 static LibraryDirective libraryDirective( | 751 static LibraryDirective libraryDirective( |
757 List<Annotation> metadata, LibraryIdentifier libraryName) => | 752 List<Annotation> metadata, LibraryIdentifier libraryName) => |
758 astFactory.libraryDirective( | 753 new LibraryDirective( |
759 null, | 754 null, |
760 metadata, | 755 metadata, |
761 TokenFactory.tokenFromKeyword(Keyword.LIBRARY), | 756 TokenFactory.tokenFromKeyword(Keyword.LIBRARY), |
762 libraryName, | 757 libraryName, |
763 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 758 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
764 | 759 |
765 static LibraryDirective libraryDirective2(String libraryName) => | 760 static LibraryDirective libraryDirective2(String libraryName) => |
766 libraryDirective( | 761 libraryDirective( |
767 new List<Annotation>(), libraryIdentifier2([libraryName])); | 762 new List<Annotation>(), libraryIdentifier2([libraryName])); |
768 | 763 |
769 static LibraryIdentifier libraryIdentifier( | 764 static LibraryIdentifier libraryIdentifier( |
770 List<SimpleIdentifier> components) => | 765 List<SimpleIdentifier> components) => |
771 astFactory.libraryIdentifier(components); | 766 new LibraryIdentifier(components); |
772 | 767 |
773 static LibraryIdentifier libraryIdentifier2(List<String> components) { | 768 static LibraryIdentifier libraryIdentifier2(List<String> components) { |
774 return astFactory.libraryIdentifier(identifierList(components)); | 769 return new LibraryIdentifier(identifierList(components)); |
775 } | 770 } |
776 | 771 |
777 static List list(List<Object> elements) { | 772 static List list(List<Object> elements) { |
778 return elements; | 773 return elements; |
779 } | 774 } |
780 | 775 |
781 static ListLiteral listLiteral([List<Expression> elements]) => | 776 static ListLiteral listLiteral([List<Expression> elements]) => |
782 listLiteral2(null, null, elements); | 777 listLiteral2(null, null, elements); |
783 | 778 |
784 static ListLiteral listLiteral2( | 779 static ListLiteral listLiteral2( |
785 Keyword keyword, TypeArgumentList typeArguments, | 780 Keyword keyword, TypeArgumentList typeArguments, |
786 [List<Expression> elements]) => | 781 [List<Expression> elements]) => |
787 astFactory.listLiteral( | 782 new ListLiteral( |
788 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), | 783 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), |
789 typeArguments, | 784 typeArguments, |
790 TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET), | 785 TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET), |
791 elements, | 786 elements, |
792 TokenFactory.tokenFromType(TokenType.CLOSE_SQUARE_BRACKET)); | 787 TokenFactory.tokenFromType(TokenType.CLOSE_SQUARE_BRACKET)); |
793 | 788 |
794 static MapLiteral mapLiteral(Keyword keyword, TypeArgumentList typeArguments, | 789 static MapLiteral mapLiteral(Keyword keyword, TypeArgumentList typeArguments, |
795 [List<MapLiteralEntry> entries]) => | 790 [List<MapLiteralEntry> entries]) => |
796 astFactory.mapLiteral( | 791 new MapLiteral( |
797 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), | 792 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), |
798 typeArguments, | 793 typeArguments, |
799 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), | 794 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), |
800 entries, | 795 entries, |
801 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); | 796 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); |
802 | 797 |
803 static MapLiteral mapLiteral2([List<MapLiteralEntry> entries]) => | 798 static MapLiteral mapLiteral2([List<MapLiteralEntry> entries]) => |
804 mapLiteral(null, null, entries); | 799 mapLiteral(null, null, entries); |
805 | 800 |
806 static MapLiteralEntry mapLiteralEntry(String key, Expression value) => | 801 static MapLiteralEntry mapLiteralEntry(String key, Expression value) => |
807 astFactory.mapLiteralEntry( | 802 new MapLiteralEntry( |
808 string2(key), TokenFactory.tokenFromType(TokenType.COLON), value); | 803 string2(key), TokenFactory.tokenFromType(TokenType.COLON), value); |
809 | 804 |
810 static MapLiteralEntry mapLiteralEntry2(Expression key, Expression value) => | 805 static MapLiteralEntry mapLiteralEntry2(Expression key, Expression value) => |
811 astFactory.mapLiteralEntry( | 806 new MapLiteralEntry( |
812 key, TokenFactory.tokenFromType(TokenType.COLON), value); | 807 key, TokenFactory.tokenFromType(TokenType.COLON), value); |
813 | 808 |
814 static MethodDeclaration methodDeclaration( | 809 static MethodDeclaration methodDeclaration( |
815 Keyword modifier, | 810 Keyword modifier, |
816 TypeName returnType, | 811 TypeName returnType, |
817 Keyword property, | 812 Keyword property, |
818 Keyword operator, | 813 Keyword operator, |
819 SimpleIdentifier name, | 814 SimpleIdentifier name, |
820 FormalParameterList parameters) => | 815 FormalParameterList parameters) => |
821 astFactory.methodDeclaration( | 816 new MethodDeclaration( |
822 null, | 817 null, |
823 null, | 818 null, |
824 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL), | 819 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL), |
825 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), | 820 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), |
826 returnType, | 821 returnType, |
827 property == null ? null : TokenFactory.tokenFromKeyword(property), | 822 property == null ? null : TokenFactory.tokenFromKeyword(property), |
828 operator == null ? null : TokenFactory.tokenFromKeyword(operator), | 823 operator == null ? null : TokenFactory.tokenFromKeyword(operator), |
829 name, | 824 name, |
830 null, | 825 null, |
831 parameters, | 826 parameters, |
832 emptyFunctionBody()); | 827 emptyFunctionBody()); |
833 | 828 |
834 static MethodDeclaration methodDeclaration2( | 829 static MethodDeclaration methodDeclaration2( |
835 Keyword modifier, | 830 Keyword modifier, |
836 TypeName returnType, | 831 TypeName returnType, |
837 Keyword property, | 832 Keyword property, |
838 Keyword operator, | 833 Keyword operator, |
839 SimpleIdentifier name, | 834 SimpleIdentifier name, |
840 FormalParameterList parameters, | 835 FormalParameterList parameters, |
841 FunctionBody body) => | 836 FunctionBody body) => |
842 astFactory.methodDeclaration( | 837 new MethodDeclaration( |
843 null, | 838 null, |
844 null, | 839 null, |
845 null, | 840 null, |
846 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), | 841 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), |
847 returnType, | 842 returnType, |
848 property == null ? null : TokenFactory.tokenFromKeyword(property), | 843 property == null ? null : TokenFactory.tokenFromKeyword(property), |
849 operator == null ? null : TokenFactory.tokenFromKeyword(operator), | 844 operator == null ? null : TokenFactory.tokenFromKeyword(operator), |
850 name, | 845 name, |
851 null, | 846 null, |
852 parameters, | 847 parameters, |
853 body); | 848 body); |
854 | 849 |
855 static MethodDeclaration methodDeclaration3( | 850 static MethodDeclaration methodDeclaration3( |
856 Keyword modifier, | 851 Keyword modifier, |
857 TypeName returnType, | 852 TypeName returnType, |
858 Keyword property, | 853 Keyword property, |
859 Keyword operator, | 854 Keyword operator, |
860 SimpleIdentifier name, | 855 SimpleIdentifier name, |
861 TypeParameterList typeParameters, | 856 TypeParameterList typeParameters, |
862 FormalParameterList parameters, | 857 FormalParameterList parameters, |
863 FunctionBody body) => | 858 FunctionBody body) => |
864 astFactory.methodDeclaration( | 859 new MethodDeclaration( |
865 null, | 860 null, |
866 null, | 861 null, |
867 null, | 862 null, |
868 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), | 863 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), |
869 returnType, | 864 returnType, |
870 property == null ? null : TokenFactory.tokenFromKeyword(property), | 865 property == null ? null : TokenFactory.tokenFromKeyword(property), |
871 operator == null ? null : TokenFactory.tokenFromKeyword(operator), | 866 operator == null ? null : TokenFactory.tokenFromKeyword(operator), |
872 name, | 867 name, |
873 typeParameters, | 868 typeParameters, |
874 parameters, | 869 parameters, |
875 body); | 870 body); |
876 | 871 |
877 static MethodDeclaration methodDeclaration4( | 872 static MethodDeclaration methodDeclaration4( |
878 {bool external: false, | 873 {bool external: false, |
879 Keyword modifier, | 874 Keyword modifier, |
880 TypeName returnType, | 875 TypeName returnType, |
881 Keyword property, | 876 Keyword property, |
882 bool operator: false, | 877 bool operator: false, |
883 String name, | 878 String name, |
884 FormalParameterList parameters, | 879 FormalParameterList parameters, |
885 FunctionBody body}) => | 880 FunctionBody body}) => |
886 astFactory.methodDeclaration( | 881 new MethodDeclaration( |
887 null, | 882 null, |
888 null, | 883 null, |
889 external ? TokenFactory.tokenFromKeyword(Keyword.EXTERNAL) : null, | 884 external ? TokenFactory.tokenFromKeyword(Keyword.EXTERNAL) : null, |
890 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), | 885 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), |
891 returnType, | 886 returnType, |
892 property == null ? null : TokenFactory.tokenFromKeyword(property), | 887 property == null ? null : TokenFactory.tokenFromKeyword(property), |
893 operator ? TokenFactory.tokenFromKeyword(Keyword.OPERATOR) : null, | 888 operator ? TokenFactory.tokenFromKeyword(Keyword.OPERATOR) : null, |
894 identifier3(name), | 889 identifier3(name), |
895 null, | 890 null, |
896 parameters, | 891 parameters, |
897 body); | 892 body); |
898 | 893 |
899 static MethodInvocation methodInvocation(Expression target, String methodName, | 894 static MethodInvocation methodInvocation(Expression target, String methodName, |
900 [List<Expression> arguments, | 895 [List<Expression> arguments, |
901 TokenType operator = TokenType.PERIOD]) => | 896 TokenType operator = TokenType.PERIOD]) => |
902 astFactory.methodInvocation( | 897 new MethodInvocation( |
903 target, | 898 target, |
904 target == null ? null : TokenFactory.tokenFromType(operator), | 899 target == null ? null : TokenFactory.tokenFromType(operator), |
905 identifier3(methodName), | 900 identifier3(methodName), |
906 null, | 901 null, |
907 argumentList(arguments)); | 902 argumentList(arguments)); |
908 | 903 |
909 static MethodInvocation methodInvocation2(String methodName, | 904 static MethodInvocation methodInvocation2(String methodName, |
910 [List<Expression> arguments]) => | 905 [List<Expression> arguments]) => |
911 methodInvocation(null, methodName, arguments); | 906 methodInvocation(null, methodName, arguments); |
912 | 907 |
913 static MethodInvocation methodInvocation3( | 908 static MethodInvocation methodInvocation3( |
914 Expression target, String methodName, TypeArgumentList typeArguments, | 909 Expression target, String methodName, TypeArgumentList typeArguments, |
915 [List<Expression> arguments, | 910 [List<Expression> arguments, |
916 TokenType operator = TokenType.PERIOD]) => | 911 TokenType operator = TokenType.PERIOD]) => |
917 astFactory.methodInvocation( | 912 new MethodInvocation( |
918 target, | 913 target, |
919 target == null ? null : TokenFactory.tokenFromType(operator), | 914 target == null ? null : TokenFactory.tokenFromType(operator), |
920 identifier3(methodName), | 915 identifier3(methodName), |
921 typeArguments, | 916 typeArguments, |
922 argumentList(arguments)); | 917 argumentList(arguments)); |
923 | 918 |
924 static NamedExpression namedExpression(Label label, Expression expression) => | 919 static NamedExpression namedExpression(Label label, Expression expression) => |
925 astFactory.namedExpression(label, expression); | 920 new NamedExpression(label, expression); |
926 | 921 |
927 static NamedExpression namedExpression2( | 922 static NamedExpression namedExpression2( |
928 String label, Expression expression) => | 923 String label, Expression expression) => |
929 namedExpression(label2(label), expression); | 924 namedExpression(label2(label), expression); |
930 | 925 |
931 static DefaultFormalParameter namedFormalParameter( | 926 static DefaultFormalParameter namedFormalParameter( |
932 NormalFormalParameter parameter, Expression expression) => | 927 NormalFormalParameter parameter, Expression expression) => |
933 astFactory.defaultFormalParameter( | 928 new DefaultFormalParameter( |
934 parameter, | 929 parameter, |
935 ParameterKind.NAMED, | 930 ParameterKind.NAMED, |
936 expression == null | 931 expression == null |
937 ? null | 932 ? null |
938 : TokenFactory.tokenFromType(TokenType.COLON), | 933 : TokenFactory.tokenFromType(TokenType.COLON), |
939 expression); | 934 expression); |
940 | 935 |
941 static NativeClause nativeClause(String nativeCode) => | 936 static NativeClause nativeClause(String nativeCode) => new NativeClause( |
942 astFactory.nativeClause( | 937 TokenFactory.tokenFromString("native"), string2(nativeCode)); |
943 TokenFactory.tokenFromString("native"), string2(nativeCode)); | |
944 | 938 |
945 static NativeFunctionBody nativeFunctionBody(String nativeMethodName) => | 939 static NativeFunctionBody nativeFunctionBody(String nativeMethodName) => |
946 astFactory.nativeFunctionBody( | 940 new NativeFunctionBody( |
947 TokenFactory.tokenFromString("native"), | 941 TokenFactory.tokenFromString("native"), |
948 string2(nativeMethodName), | 942 string2(nativeMethodName), |
949 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 943 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
950 | 944 |
951 static NullLiteral nullLiteral() => | 945 static NullLiteral nullLiteral() => |
952 astFactory.nullLiteral(TokenFactory.tokenFromKeyword(Keyword.NULL)); | 946 new NullLiteral(TokenFactory.tokenFromKeyword(Keyword.NULL)); |
953 | 947 |
954 static ParenthesizedExpression parenthesizedExpression( | 948 static ParenthesizedExpression parenthesizedExpression( |
955 Expression expression) => | 949 Expression expression) => |
956 astFactory.parenthesizedExpression( | 950 new ParenthesizedExpression( |
957 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 951 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
958 expression, | 952 expression, |
959 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)); | 953 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)); |
960 | 954 |
961 static PartDirective partDirective(List<Annotation> metadata, String url) => | 955 static PartDirective partDirective(List<Annotation> metadata, String url) => |
962 astFactory.partDirective( | 956 new PartDirective( |
963 null, | 957 null, |
964 metadata, | 958 metadata, |
965 TokenFactory.tokenFromKeyword(Keyword.PART), | 959 TokenFactory.tokenFromKeyword(Keyword.PART), |
966 string2(url), | 960 string2(url), |
967 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 961 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
968 | 962 |
969 static PartDirective partDirective2(String url) => | 963 static PartDirective partDirective2(String url) => |
970 partDirective(new List<Annotation>(), url); | 964 partDirective(new List<Annotation>(), url); |
971 | 965 |
972 static PartOfDirective partOfDirective(LibraryIdentifier libraryName) => | 966 static PartOfDirective partOfDirective(LibraryIdentifier libraryName) => |
973 partOfDirective2(new List<Annotation>(), libraryName); | 967 partOfDirective2(new List<Annotation>(), libraryName); |
974 | 968 |
975 static PartOfDirective partOfDirective2( | 969 static PartOfDirective partOfDirective2( |
976 List<Annotation> metadata, LibraryIdentifier libraryName) => | 970 List<Annotation> metadata, LibraryIdentifier libraryName) => |
977 astFactory.partOfDirective( | 971 new PartOfDirective( |
978 null, | 972 null, |
979 metadata, | 973 metadata, |
980 TokenFactory.tokenFromKeyword(Keyword.PART), | 974 TokenFactory.tokenFromKeyword(Keyword.PART), |
981 TokenFactory.tokenFromString("of"), | 975 TokenFactory.tokenFromString("of"), |
982 null, | 976 null, |
983 libraryName, | 977 libraryName, |
984 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 978 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
985 | 979 |
986 static DefaultFormalParameter positionalFormalParameter( | 980 static DefaultFormalParameter positionalFormalParameter( |
987 NormalFormalParameter parameter, Expression expression) => | 981 NormalFormalParameter parameter, Expression expression) => |
988 astFactory.defaultFormalParameter( | 982 new DefaultFormalParameter( |
989 parameter, | 983 parameter, |
990 ParameterKind.POSITIONAL, | 984 ParameterKind.POSITIONAL, |
991 expression == null ? null : TokenFactory.tokenFromType(TokenType.EQ), | 985 expression == null ? null : TokenFactory.tokenFromType(TokenType.EQ), |
992 expression); | 986 expression); |
993 | 987 |
994 static PostfixExpression postfixExpression( | 988 static PostfixExpression postfixExpression( |
995 Expression expression, TokenType operator) => | 989 Expression expression, TokenType operator) => |
996 astFactory.postfixExpression( | 990 new PostfixExpression(expression, TokenFactory.tokenFromType(operator)); |
997 expression, TokenFactory.tokenFromType(operator)); | |
998 | 991 |
999 static PrefixExpression prefixExpression( | 992 static PrefixExpression prefixExpression( |
1000 TokenType operator, Expression expression) => | 993 TokenType operator, Expression expression) => |
1001 astFactory.prefixExpression( | 994 new PrefixExpression(TokenFactory.tokenFromType(operator), expression); |
1002 TokenFactory.tokenFromType(operator), expression); | |
1003 | 995 |
1004 static PropertyAccess propertyAccess( | 996 static PropertyAccess propertyAccess( |
1005 Expression target, SimpleIdentifier propertyName) => | 997 Expression target, SimpleIdentifier propertyName) => |
1006 astFactory.propertyAccess( | 998 new PropertyAccess( |
1007 target, TokenFactory.tokenFromType(TokenType.PERIOD), propertyName); | 999 target, TokenFactory.tokenFromType(TokenType.PERIOD), propertyName); |
1008 | 1000 |
1009 static PropertyAccess propertyAccess2(Expression target, String propertyName, | 1001 static PropertyAccess propertyAccess2(Expression target, String propertyName, |
1010 [TokenType operator = TokenType.PERIOD]) => | 1002 [TokenType operator = TokenType.PERIOD]) => |
1011 astFactory.propertyAccess(target, TokenFactory.tokenFromType(operator), | 1003 new PropertyAccess(target, TokenFactory.tokenFromType(operator), |
1012 identifier3(propertyName)); | 1004 identifier3(propertyName)); |
1013 | 1005 |
1014 static RedirectingConstructorInvocation redirectingConstructorInvocation( | 1006 static RedirectingConstructorInvocation redirectingConstructorInvocation( |
1015 [List<Expression> arguments]) => | 1007 [List<Expression> arguments]) => |
1016 redirectingConstructorInvocation2(null, arguments); | 1008 redirectingConstructorInvocation2(null, arguments); |
1017 | 1009 |
1018 static RedirectingConstructorInvocation redirectingConstructorInvocation2( | 1010 static RedirectingConstructorInvocation redirectingConstructorInvocation2( |
1019 String constructorName, | 1011 String constructorName, |
1020 [List<Expression> arguments]) => | 1012 [List<Expression> arguments]) => |
1021 astFactory.redirectingConstructorInvocation( | 1013 new RedirectingConstructorInvocation( |
1022 TokenFactory.tokenFromKeyword(Keyword.THIS), | 1014 TokenFactory.tokenFromKeyword(Keyword.THIS), |
1023 constructorName == null | 1015 constructorName == null |
1024 ? null | 1016 ? null |
1025 : TokenFactory.tokenFromType(TokenType.PERIOD), | 1017 : TokenFactory.tokenFromType(TokenType.PERIOD), |
1026 constructorName == null ? null : identifier3(constructorName), | 1018 constructorName == null ? null : identifier3(constructorName), |
1027 argumentList(arguments)); | 1019 argumentList(arguments)); |
1028 | 1020 |
1029 static RethrowExpression rethrowExpression() => astFactory | 1021 static RethrowExpression rethrowExpression() => |
1030 .rethrowExpression(TokenFactory.tokenFromKeyword(Keyword.RETHROW)); | 1022 new RethrowExpression(TokenFactory.tokenFromKeyword(Keyword.RETHROW)); |
1031 | 1023 |
1032 static ReturnStatement returnStatement() => returnStatement2(null); | 1024 static ReturnStatement returnStatement() => returnStatement2(null); |
1033 | 1025 |
1034 static ReturnStatement returnStatement2(Expression expression) => | 1026 static ReturnStatement returnStatement2(Expression expression) => |
1035 astFactory.returnStatement(TokenFactory.tokenFromKeyword(Keyword.RETURN), | 1027 new ReturnStatement(TokenFactory.tokenFromKeyword(Keyword.RETURN), |
1036 expression, TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 1028 expression, TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
1037 | 1029 |
1038 static ScriptTag scriptTag(String scriptTag) => | 1030 static ScriptTag scriptTag(String scriptTag) => |
1039 astFactory.scriptTag(TokenFactory.tokenFromString(scriptTag)); | 1031 new ScriptTag(TokenFactory.tokenFromString(scriptTag)); |
1040 | 1032 |
1041 static ShowCombinator showCombinator(List<SimpleIdentifier> identifiers) => | 1033 static ShowCombinator showCombinator(List<SimpleIdentifier> identifiers) => |
1042 astFactory.showCombinator( | 1034 new ShowCombinator(TokenFactory.tokenFromString("show"), identifiers); |
1043 TokenFactory.tokenFromString("show"), identifiers); | |
1044 | 1035 |
1045 static ShowCombinator showCombinator2(List<String> identifiers) => | 1036 static ShowCombinator showCombinator2(List<String> identifiers) => |
1046 astFactory.showCombinator( | 1037 new ShowCombinator( |
1047 TokenFactory.tokenFromString("show"), identifierList(identifiers)); | 1038 TokenFactory.tokenFromString("show"), identifierList(identifiers)); |
1048 | 1039 |
1049 static SimpleFormalParameter simpleFormalParameter( | 1040 static SimpleFormalParameter simpleFormalParameter( |
1050 Keyword keyword, String parameterName) => | 1041 Keyword keyword, String parameterName) => |
1051 simpleFormalParameter2(keyword, null, parameterName); | 1042 simpleFormalParameter2(keyword, null, parameterName); |
1052 | 1043 |
1053 static SimpleFormalParameter simpleFormalParameter2( | 1044 static SimpleFormalParameter simpleFormalParameter2( |
1054 Keyword keyword, TypeName type, String parameterName) => | 1045 Keyword keyword, TypeName type, String parameterName) => |
1055 astFactory.simpleFormalParameter( | 1046 new SimpleFormalParameter( |
1056 null, | 1047 null, |
1057 null, | 1048 null, |
1058 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), | 1049 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), |
1059 type, | 1050 type, |
1060 identifier3(parameterName)); | 1051 identifier3(parameterName)); |
1061 | 1052 |
1062 static SimpleFormalParameter simpleFormalParameter3(String parameterName) => | 1053 static SimpleFormalParameter simpleFormalParameter3(String parameterName) => |
1063 simpleFormalParameter2(null, null, parameterName); | 1054 simpleFormalParameter2(null, null, parameterName); |
1064 | 1055 |
1065 static SimpleFormalParameter simpleFormalParameter4( | 1056 static SimpleFormalParameter simpleFormalParameter4( |
1066 TypeName type, String parameterName) => | 1057 TypeName type, String parameterName) => |
1067 simpleFormalParameter2(null, type, parameterName); | 1058 simpleFormalParameter2(null, type, parameterName); |
1068 | 1059 |
1069 static StringInterpolation string([List<InterpolationElement> elements]) => | 1060 static StringInterpolation string([List<InterpolationElement> elements]) => |
1070 astFactory.stringInterpolation(elements); | 1061 new StringInterpolation(elements); |
1071 | 1062 |
1072 static SimpleStringLiteral string2(String content) => astFactory | 1063 static SimpleStringLiteral string2(String content) => new SimpleStringLiteral( |
1073 .simpleStringLiteral(TokenFactory.tokenFromString("'$content'"), content); | 1064 TokenFactory.tokenFromString("'$content'"), content); |
1074 | 1065 |
1075 static SuperConstructorInvocation superConstructorInvocation( | 1066 static SuperConstructorInvocation superConstructorInvocation( |
1076 [List<Expression> arguments]) => | 1067 [List<Expression> arguments]) => |
1077 superConstructorInvocation2(null, arguments); | 1068 superConstructorInvocation2(null, arguments); |
1078 | 1069 |
1079 static SuperConstructorInvocation superConstructorInvocation2(String name, | 1070 static SuperConstructorInvocation superConstructorInvocation2(String name, |
1080 [List<Expression> arguments]) => | 1071 [List<Expression> arguments]) => |
1081 astFactory.superConstructorInvocation( | 1072 new SuperConstructorInvocation( |
1082 TokenFactory.tokenFromKeyword(Keyword.SUPER), | 1073 TokenFactory.tokenFromKeyword(Keyword.SUPER), |
1083 name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD), | 1074 name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD), |
1084 name == null ? null : identifier3(name), | 1075 name == null ? null : identifier3(name), |
1085 argumentList(arguments)); | 1076 argumentList(arguments)); |
1086 | 1077 |
1087 static SuperExpression superExpression() => | 1078 static SuperExpression superExpression() => |
1088 astFactory.superExpression(TokenFactory.tokenFromKeyword(Keyword.SUPER)); | 1079 new SuperExpression(TokenFactory.tokenFromKeyword(Keyword.SUPER)); |
1089 | 1080 |
1090 static SwitchCase switchCase( | 1081 static SwitchCase switchCase( |
1091 Expression expression, List<Statement> statements) => | 1082 Expression expression, List<Statement> statements) => |
1092 switchCase2(new List<Label>(), expression, statements); | 1083 switchCase2(new List<Label>(), expression, statements); |
1093 | 1084 |
1094 static SwitchCase switchCase2(List<Label> labels, Expression expression, | 1085 static SwitchCase switchCase2(List<Label> labels, Expression expression, |
1095 List<Statement> statements) => | 1086 List<Statement> statements) => |
1096 astFactory.switchCase(labels, TokenFactory.tokenFromKeyword(Keyword.CASE), | 1087 new SwitchCase(labels, TokenFactory.tokenFromKeyword(Keyword.CASE), |
1097 expression, TokenFactory.tokenFromType(TokenType.COLON), statements); | 1088 expression, TokenFactory.tokenFromType(TokenType.COLON), statements); |
1098 | 1089 |
1099 static SwitchDefault switchDefault( | 1090 static SwitchDefault switchDefault( |
1100 List<Label> labels, List<Statement> statements) => | 1091 List<Label> labels, List<Statement> statements) => |
1101 astFactory.switchDefault( | 1092 new SwitchDefault(labels, TokenFactory.tokenFromKeyword(Keyword.DEFAULT), |
1102 labels, | 1093 TokenFactory.tokenFromType(TokenType.COLON), statements); |
1103 TokenFactory.tokenFromKeyword(Keyword.DEFAULT), | |
1104 TokenFactory.tokenFromType(TokenType.COLON), | |
1105 statements); | |
1106 | 1094 |
1107 static SwitchDefault switchDefault2(List<Statement> statements) => | 1095 static SwitchDefault switchDefault2(List<Statement> statements) => |
1108 switchDefault(new List<Label>(), statements); | 1096 switchDefault(new List<Label>(), statements); |
1109 | 1097 |
1110 static SwitchStatement switchStatement( | 1098 static SwitchStatement switchStatement( |
1111 Expression expression, List<SwitchMember> members) => | 1099 Expression expression, List<SwitchMember> members) => |
1112 astFactory.switchStatement( | 1100 new SwitchStatement( |
1113 TokenFactory.tokenFromKeyword(Keyword.SWITCH), | 1101 TokenFactory.tokenFromKeyword(Keyword.SWITCH), |
1114 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 1102 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
1115 expression, | 1103 expression, |
1116 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 1104 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
1117 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), | 1105 TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), |
1118 members, | 1106 members, |
1119 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); | 1107 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); |
1120 | 1108 |
1121 static SymbolLiteral symbolLiteral(List<String> components) { | 1109 static SymbolLiteral symbolLiteral(List<String> components) { |
1122 List<Token> identifierList = new List<Token>(); | 1110 List<Token> identifierList = new List<Token>(); |
1123 for (String component in components) { | 1111 for (String component in components) { |
1124 identifierList.add( | 1112 identifierList.add( |
1125 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, component)); | 1113 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, component)); |
1126 } | 1114 } |
1127 return astFactory.symbolLiteral( | 1115 return new SymbolLiteral( |
1128 TokenFactory.tokenFromType(TokenType.HASH), identifierList); | 1116 TokenFactory.tokenFromType(TokenType.HASH), identifierList); |
1129 } | 1117 } |
1130 | 1118 |
1131 static BlockFunctionBody syncBlockFunctionBody( | 1119 static BlockFunctionBody syncBlockFunctionBody( |
1132 [List<Statement> statements]) => | 1120 [List<Statement> statements]) => |
1133 astFactory.blockFunctionBody( | 1121 new BlockFunctionBody( |
1134 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "sync"), | 1122 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "sync"), |
1135 null, | 1123 null, |
1136 block(statements)); | 1124 block(statements)); |
1137 | 1125 |
1138 static BlockFunctionBody syncGeneratorBlockFunctionBody( | 1126 static BlockFunctionBody syncGeneratorBlockFunctionBody( |
1139 [List<Statement> statements]) => | 1127 [List<Statement> statements]) => |
1140 astFactory.blockFunctionBody( | 1128 new BlockFunctionBody( |
1141 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "sync"), | 1129 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "sync"), |
1142 TokenFactory.tokenFromType(TokenType.STAR), | 1130 TokenFactory.tokenFromType(TokenType.STAR), |
1143 block(statements)); | 1131 block(statements)); |
1144 | 1132 |
1145 static ThisExpression thisExpression() => | 1133 static ThisExpression thisExpression() => |
1146 astFactory.thisExpression(TokenFactory.tokenFromKeyword(Keyword.THIS)); | 1134 new ThisExpression(TokenFactory.tokenFromKeyword(Keyword.THIS)); |
1147 | 1135 |
1148 static ThrowExpression throwExpression() => throwExpression2(null); | 1136 static ThrowExpression throwExpression() => throwExpression2(null); |
1149 | 1137 |
1150 static ThrowExpression throwExpression2(Expression expression) => | 1138 static ThrowExpression throwExpression2(Expression expression) => |
1151 astFactory.throwExpression( | 1139 new ThrowExpression( |
1152 TokenFactory.tokenFromKeyword(Keyword.THROW), expression); | 1140 TokenFactory.tokenFromKeyword(Keyword.THROW), expression); |
1153 | 1141 |
1154 static TopLevelVariableDeclaration topLevelVariableDeclaration( | 1142 static TopLevelVariableDeclaration topLevelVariableDeclaration( |
1155 Keyword keyword, | 1143 Keyword keyword, |
1156 TypeName type, | 1144 TypeName type, |
1157 List<VariableDeclaration> variables) => | 1145 List<VariableDeclaration> variables) => |
1158 astFactory.topLevelVariableDeclaration( | 1146 new TopLevelVariableDeclaration( |
1159 null, | 1147 null, |
1160 null, | 1148 null, |
1161 variableDeclarationList(keyword, type, variables), | 1149 variableDeclarationList(keyword, type, variables), |
1162 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 1150 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
1163 | 1151 |
1164 static TopLevelVariableDeclaration topLevelVariableDeclaration2( | 1152 static TopLevelVariableDeclaration topLevelVariableDeclaration2( |
1165 Keyword keyword, List<VariableDeclaration> variables) => | 1153 Keyword keyword, List<VariableDeclaration> variables) => |
1166 astFactory.topLevelVariableDeclaration( | 1154 new TopLevelVariableDeclaration( |
1167 null, | 1155 null, |
1168 null, | 1156 null, |
1169 variableDeclarationList(keyword, null, variables), | 1157 variableDeclarationList(keyword, null, variables), |
1170 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 1158 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
1171 | 1159 |
1172 static TryStatement tryStatement(Block body, Block finallyClause) => | 1160 static TryStatement tryStatement(Block body, Block finallyClause) => |
1173 tryStatement3(body, new List<CatchClause>(), finallyClause); | 1161 tryStatement3(body, new List<CatchClause>(), finallyClause); |
1174 | 1162 |
1175 static TryStatement tryStatement2( | 1163 static TryStatement tryStatement2( |
1176 Block body, List<CatchClause> catchClauses) => | 1164 Block body, List<CatchClause> catchClauses) => |
1177 tryStatement3(body, catchClauses, null); | 1165 tryStatement3(body, catchClauses, null); |
1178 | 1166 |
1179 static TryStatement tryStatement3( | 1167 static TryStatement tryStatement3( |
1180 Block body, List<CatchClause> catchClauses, Block finallyClause) => | 1168 Block body, List<CatchClause> catchClauses, Block finallyClause) => |
1181 astFactory.tryStatement( | 1169 new TryStatement( |
1182 TokenFactory.tokenFromKeyword(Keyword.TRY), | 1170 TokenFactory.tokenFromKeyword(Keyword.TRY), |
1183 body, | 1171 body, |
1184 catchClauses, | 1172 catchClauses, |
1185 finallyClause == null | 1173 finallyClause == null |
1186 ? null | 1174 ? null |
1187 : TokenFactory.tokenFromKeyword(Keyword.FINALLY), | 1175 : TokenFactory.tokenFromKeyword(Keyword.FINALLY), |
1188 finallyClause); | 1176 finallyClause); |
1189 | 1177 |
1190 static FunctionTypeAlias typeAlias(TypeName returnType, String name, | 1178 static FunctionTypeAlias typeAlias(TypeName returnType, String name, |
1191 TypeParameterList typeParameters, FormalParameterList parameters) => | 1179 TypeParameterList typeParameters, FormalParameterList parameters) => |
1192 astFactory.functionTypeAlias( | 1180 new FunctionTypeAlias( |
1193 null, | 1181 null, |
1194 null, | 1182 null, |
1195 TokenFactory.tokenFromKeyword(Keyword.TYPEDEF), | 1183 TokenFactory.tokenFromKeyword(Keyword.TYPEDEF), |
1196 returnType, | 1184 returnType, |
1197 identifier3(name), | 1185 identifier3(name), |
1198 typeParameters, | 1186 typeParameters, |
1199 parameters, | 1187 parameters, |
1200 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 1188 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
1201 | 1189 |
1202 static TypeArgumentList typeArgumentList(List<TypeName> typeNames) { | 1190 static TypeArgumentList typeArgumentList(List<TypeName> typeNames) { |
1203 if (typeNames == null || typeNames.length == 0) { | 1191 if (typeNames == null || typeNames.length == 0) { |
1204 return null; | 1192 return null; |
1205 } | 1193 } |
1206 return astFactory.typeArgumentList(TokenFactory.tokenFromType(TokenType.LT), | 1194 return new TypeArgumentList(TokenFactory.tokenFromType(TokenType.LT), |
1207 typeNames, TokenFactory.tokenFromType(TokenType.GT)); | 1195 typeNames, TokenFactory.tokenFromType(TokenType.GT)); |
1208 } | 1196 } |
1209 | 1197 |
1210 /** | 1198 /** |
1211 * Create a type name whose name has been resolved to the given [element] and | 1199 * Create a type name whose name has been resolved to the given [element] and |
1212 * whose type has been resolved to the type of the given element. | 1200 * whose type has been resolved to the type of the given element. |
1213 * | 1201 * |
1214 * <b>Note:</b> This method does not correctly handle class elements that have | 1202 * <b>Note:</b> This method does not correctly handle class elements that have |
1215 * type parameters. | 1203 * type parameters. |
1216 */ | 1204 */ |
1217 static TypeName typeName(ClassElement element, [List<TypeName> arguments]) { | 1205 static TypeName typeName(ClassElement element, [List<TypeName> arguments]) { |
1218 SimpleIdentifier name = identifier3(element.name); | 1206 SimpleIdentifier name = identifier3(element.name); |
1219 name.staticElement = element; | 1207 name.staticElement = element; |
1220 TypeName typeName = typeName3(name, arguments); | 1208 TypeName typeName = typeName3(name, arguments); |
1221 typeName.type = element.type; | 1209 typeName.type = element.type; |
1222 return typeName; | 1210 return typeName; |
1223 } | 1211 } |
1224 | 1212 |
1225 static TypeName typeName3(Identifier name, [List<TypeName> arguments]) => | 1213 static TypeName typeName3(Identifier name, [List<TypeName> arguments]) => |
1226 astFactory.typeName(name, typeArgumentList(arguments)); | 1214 new TypeName(name, typeArgumentList(arguments)); |
1227 | 1215 |
1228 static TypeName typeName4(String name, [List<TypeName> arguments]) => | 1216 static TypeName typeName4(String name, [List<TypeName> arguments]) => |
1229 astFactory.typeName(identifier3(name), typeArgumentList(arguments)); | 1217 new TypeName(identifier3(name), typeArgumentList(arguments)); |
1230 | 1218 |
1231 static TypeParameter typeParameter(String name) => | 1219 static TypeParameter typeParameter(String name) => |
1232 astFactory.typeParameter(null, null, identifier3(name), null, null); | 1220 new TypeParameter(null, null, identifier3(name), null, null); |
1233 | 1221 |
1234 static TypeParameter typeParameter2(String name, TypeName bound) => | 1222 static TypeParameter typeParameter2(String name, TypeName bound) => |
1235 astFactory.typeParameter(null, null, identifier3(name), | 1223 new TypeParameter(null, null, identifier3(name), |
1236 TokenFactory.tokenFromKeyword(Keyword.EXTENDS), bound); | 1224 TokenFactory.tokenFromKeyword(Keyword.EXTENDS), bound); |
1237 | 1225 |
1238 static TypeParameterList typeParameterList([List<String> typeNames]) { | 1226 static TypeParameterList typeParameterList([List<String> typeNames]) { |
1239 List<TypeParameter> typeParameters = null; | 1227 List<TypeParameter> typeParameters = null; |
1240 if (typeNames != null && !typeNames.isEmpty) { | 1228 if (typeNames != null && !typeNames.isEmpty) { |
1241 typeParameters = new List<TypeParameter>(); | 1229 typeParameters = new List<TypeParameter>(); |
1242 for (String typeName in typeNames) { | 1230 for (String typeName in typeNames) { |
1243 typeParameters.add(typeParameter(typeName)); | 1231 typeParameters.add(typeParameter(typeName)); |
1244 } | 1232 } |
1245 } | 1233 } |
1246 return astFactory.typeParameterList( | 1234 return new TypeParameterList(TokenFactory.tokenFromType(TokenType.LT), |
1247 TokenFactory.tokenFromType(TokenType.LT), | 1235 typeParameters, TokenFactory.tokenFromType(TokenType.GT)); |
1248 typeParameters, | |
1249 TokenFactory.tokenFromType(TokenType.GT)); | |
1250 } | 1236 } |
1251 | 1237 |
1252 static VariableDeclaration variableDeclaration(String name) => | 1238 static VariableDeclaration variableDeclaration(String name) => |
1253 astFactory.variableDeclaration(identifier3(name), null, null); | 1239 new VariableDeclaration(identifier3(name), null, null); |
1254 | 1240 |
1255 static VariableDeclaration variableDeclaration2( | 1241 static VariableDeclaration variableDeclaration2( |
1256 String name, Expression initializer) => | 1242 String name, Expression initializer) => |
1257 astFactory.variableDeclaration(identifier3(name), | 1243 new VariableDeclaration(identifier3(name), |
1258 TokenFactory.tokenFromType(TokenType.EQ), initializer); | 1244 TokenFactory.tokenFromType(TokenType.EQ), initializer); |
1259 | 1245 |
1260 static VariableDeclarationList variableDeclarationList(Keyword keyword, | 1246 static VariableDeclarationList variableDeclarationList(Keyword keyword, |
1261 TypeName type, List<VariableDeclaration> variables) => | 1247 TypeName type, List<VariableDeclaration> variables) => |
1262 astFactory.variableDeclarationList( | 1248 new VariableDeclarationList( |
1263 null, | 1249 null, |
1264 null, | 1250 null, |
1265 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), | 1251 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), |
1266 type, | 1252 type, |
1267 variables); | 1253 variables); |
1268 | 1254 |
1269 static VariableDeclarationList variableDeclarationList2( | 1255 static VariableDeclarationList variableDeclarationList2( |
1270 Keyword keyword, List<VariableDeclaration> variables) => | 1256 Keyword keyword, List<VariableDeclaration> variables) => |
1271 variableDeclarationList(keyword, null, variables); | 1257 variableDeclarationList(keyword, null, variables); |
1272 | 1258 |
1273 static VariableDeclarationStatement variableDeclarationStatement( | 1259 static VariableDeclarationStatement variableDeclarationStatement( |
1274 Keyword keyword, | 1260 Keyword keyword, |
1275 TypeName type, | 1261 TypeName type, |
1276 List<VariableDeclaration> variables) => | 1262 List<VariableDeclaration> variables) => |
1277 astFactory.variableDeclarationStatement( | 1263 new VariableDeclarationStatement( |
1278 variableDeclarationList(keyword, type, variables), | 1264 variableDeclarationList(keyword, type, variables), |
1279 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 1265 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
1280 | 1266 |
1281 static VariableDeclarationStatement variableDeclarationStatement2( | 1267 static VariableDeclarationStatement variableDeclarationStatement2( |
1282 Keyword keyword, List<VariableDeclaration> variables) => | 1268 Keyword keyword, List<VariableDeclaration> variables) => |
1283 variableDeclarationStatement(keyword, null, variables); | 1269 variableDeclarationStatement(keyword, null, variables); |
1284 | 1270 |
1285 static WhileStatement whileStatement(Expression condition, Statement body) => | 1271 static WhileStatement whileStatement(Expression condition, Statement body) => |
1286 astFactory.whileStatement( | 1272 new WhileStatement( |
1287 TokenFactory.tokenFromKeyword(Keyword.WHILE), | 1273 TokenFactory.tokenFromKeyword(Keyword.WHILE), |
1288 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 1274 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
1289 condition, | 1275 condition, |
1290 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 1276 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
1291 body); | 1277 body); |
1292 | 1278 |
1293 static WithClause withClause(List<TypeName> types) => | 1279 static WithClause withClause(List<TypeName> types) => |
1294 astFactory.withClause(TokenFactory.tokenFromKeyword(Keyword.WITH), types); | 1280 new WithClause(TokenFactory.tokenFromKeyword(Keyword.WITH), types); |
1295 | 1281 |
1296 static YieldStatement yieldEachStatement(Expression expression) => | 1282 static YieldStatement yieldEachStatement(Expression expression) => |
1297 astFactory.yieldStatement( | 1283 new YieldStatement( |
1298 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"), | 1284 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"), |
1299 TokenFactory.tokenFromType(TokenType.STAR), | 1285 TokenFactory.tokenFromType(TokenType.STAR), |
1300 expression, | 1286 expression, |
1301 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 1287 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
1302 | 1288 |
1303 static YieldStatement yieldStatement(Expression expression) => | 1289 static YieldStatement yieldStatement(Expression expression) => |
1304 astFactory.yieldStatement( | 1290 new YieldStatement( |
1305 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"), | 1291 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"), |
1306 null, | 1292 null, |
1307 expression, | 1293 expression, |
1308 TokenFactory.tokenFromType(TokenType.SEMICOLON)); | 1294 TokenFactory.tokenFromType(TokenType.SEMICOLON)); |
1309 } | 1295 } |
OLD | NEW |