Chromium Code Reviews

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

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

Powered by Google App Engine