Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: pkg/analyzer/lib/src/generated/testing/ast_factory.dart

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

Powered by Google App Engine
This is Rietveld 408576698