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