OLD | NEW |
---|---|
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library engine.parser; | 5 library engine.parser; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import "dart:math" as math; | 8 import "dart:math" as math; |
9 | 9 |
10 import 'ast.dart'; | 10 import 'ast.dart'; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 0, (Parser target) => target.parseTypeArgumentList()), | 82 0, (Parser target) => target.parseTypeArgumentList()), |
83 'parseTypeName_0': | 83 'parseTypeName_0': |
84 new MethodTrampoline(0, (Parser target) => target.parseTypeName()), | 84 new MethodTrampoline(0, (Parser target) => target.parseTypeName()), |
85 'parseTypeParameter_0': | 85 'parseTypeParameter_0': |
86 new MethodTrampoline(0, (Parser target) => target.parseTypeParameter()), | 86 new MethodTrampoline(0, (Parser target) => target.parseTypeParameter()), |
87 'parseTypeParameterList_0': new MethodTrampoline( | 87 'parseTypeParameterList_0': new MethodTrampoline( |
88 0, (Parser target) => target.parseTypeParameterList()), | 88 0, (Parser target) => target.parseTypeParameterList()), |
89 'parseWithClause_0': | 89 'parseWithClause_0': |
90 new MethodTrampoline(0, (Parser target) => target.parseWithClause()), | 90 new MethodTrampoline(0, (Parser target) => target.parseWithClause()), |
91 'advance_0': new MethodTrampoline(0, (Parser target) => target._advance()), | 91 'advance_0': new MethodTrampoline(0, (Parser target) => target._advance()), |
92 'appendScalarValue_5': new MethodTrampoline(5, (Parser target, arg0, arg1, | 92 'appendScalarValue_5': new MethodTrampoline( |
93 arg2, arg3, | 93 5, |
94 arg4) => target._appendScalarValue(arg0, arg1, arg2, arg3, arg4)), | 94 (Parser target, arg0, arg1, arg2, arg3, arg4) => |
95 'computeStringValue_3': new MethodTrampoline(3, (Parser target, arg0, arg1, | 95 target._appendScalarValue(arg0, arg1, arg2, arg3, arg4)), |
96 arg2) => target._computeStringValue(arg0, arg1, arg2)), | 96 'computeStringValue_3': new MethodTrampoline( |
97 3, | |
98 (Parser target, arg0, arg1, arg2) => | |
99 target._computeStringValue(arg0, arg1, arg2)), | |
97 'convertToFunctionDeclaration_1': new MethodTrampoline( | 100 'convertToFunctionDeclaration_1': new MethodTrampoline( |
98 1, (Parser target, arg0) => target._convertToFunctionDeclaration(arg0)), | 101 1, (Parser target, arg0) => target._convertToFunctionDeclaration(arg0)), |
99 'couldBeStartOfCompilationUnitMember_0': new MethodTrampoline( | 102 'couldBeStartOfCompilationUnitMember_0': new MethodTrampoline( |
100 0, (Parser target) => target._couldBeStartOfCompilationUnitMember()), | 103 0, (Parser target) => target._couldBeStartOfCompilationUnitMember()), |
101 'createSyntheticIdentifier_0': new MethodTrampoline( | 104 'createSyntheticIdentifier_0': new MethodTrampoline( |
102 0, (Parser target) => target._createSyntheticIdentifier()), | 105 0, (Parser target) => target._createSyntheticIdentifier()), |
103 'createSyntheticKeyword_1': new MethodTrampoline( | 106 'createSyntheticKeyword_1': new MethodTrampoline( |
104 1, (Parser target, arg0) => target._createSyntheticKeyword(arg0)), | 107 1, (Parser target, arg0) => target._createSyntheticKeyword(arg0)), |
105 'createSyntheticStringLiteral_0': new MethodTrampoline( | 108 'createSyntheticStringLiteral_0': new MethodTrampoline( |
106 0, (Parser target) => target._createSyntheticStringLiteral()), | 109 0, (Parser target) => target._createSyntheticStringLiteral()), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 'matchesString_1': new MethodTrampoline( | 155 'matchesString_1': new MethodTrampoline( |
153 1, (Parser target, arg0) => target._matchesString(arg0)), | 156 1, (Parser target, arg0) => target._matchesString(arg0)), |
154 'optional_1': | 157 'optional_1': |
155 new MethodTrampoline(1, (Parser target, arg0) => target._optional(arg0)), | 158 new MethodTrampoline(1, (Parser target, arg0) => target._optional(arg0)), |
156 'parseAdditiveExpression_0': new MethodTrampoline( | 159 'parseAdditiveExpression_0': new MethodTrampoline( |
157 0, (Parser target) => target._parseAdditiveExpression()), | 160 0, (Parser target) => target._parseAdditiveExpression()), |
158 'parseAssertStatement_0': new MethodTrampoline( | 161 'parseAssertStatement_0': new MethodTrampoline( |
159 0, (Parser target) => target._parseAssertStatement()), | 162 0, (Parser target) => target._parseAssertStatement()), |
160 'parseAssignableExpression_1': new MethodTrampoline( | 163 'parseAssignableExpression_1': new MethodTrampoline( |
161 1, (Parser target, arg0) => target._parseAssignableExpression(arg0)), | 164 1, (Parser target, arg0) => target._parseAssignableExpression(arg0)), |
162 'parseAssignableSelector_2': new MethodTrampoline(2, (Parser target, arg0, | 165 'parseAssignableSelector_2': new MethodTrampoline( |
163 arg1) => target._parseAssignableSelector(arg0, arg1)), | 166 2, |
167 (Parser target, arg0, arg1) => | |
168 target._parseAssignableSelector(arg0, arg1)), | |
164 'parseAwaitExpression_0': new MethodTrampoline( | 169 'parseAwaitExpression_0': new MethodTrampoline( |
165 0, (Parser target) => target._parseAwaitExpression()), | 170 0, (Parser target) => target._parseAwaitExpression()), |
166 'parseBitwiseAndExpression_0': new MethodTrampoline( | 171 'parseBitwiseAndExpression_0': new MethodTrampoline( |
167 0, (Parser target) => target._parseBitwiseAndExpression()), | 172 0, (Parser target) => target._parseBitwiseAndExpression()), |
168 'parseBitwiseXorExpression_0': new MethodTrampoline( | 173 'parseBitwiseXorExpression_0': new MethodTrampoline( |
169 0, (Parser target) => target._parseBitwiseXorExpression()), | 174 0, (Parser target) => target._parseBitwiseXorExpression()), |
170 'parseBreakStatement_0': | 175 'parseBreakStatement_0': |
171 new MethodTrampoline(0, (Parser target) => target._parseBreakStatement()), | 176 new MethodTrampoline(0, (Parser target) => target._parseBreakStatement()), |
172 'parseCascadeSection_0': | 177 'parseCascadeSection_0': |
173 new MethodTrampoline(0, (Parser target) => target._parseCascadeSection()), | 178 new MethodTrampoline(0, (Parser target) => target._parseCascadeSection()), |
174 'parseClassDeclaration_2': new MethodTrampoline(2, | 179 'parseClassDeclaration_2': new MethodTrampoline(2, |
175 (Parser target, arg0, arg1) => target._parseClassDeclaration(arg0, arg1)), | 180 (Parser target, arg0, arg1) => target._parseClassDeclaration(arg0, arg1)), |
176 'parseClassMembers_2': new MethodTrampoline( | 181 'parseClassMembers_2': new MethodTrampoline( |
177 2, (Parser target, arg0, arg1) => target._parseClassMembers(arg0, arg1)), | 182 2, (Parser target, arg0, arg1) => target._parseClassMembers(arg0, arg1)), |
178 'parseClassTypeAlias_3': new MethodTrampoline(3, (Parser target, arg0, arg1, | 183 'parseClassTypeAlias_3': new MethodTrampoline( |
179 arg2) => target._parseClassTypeAlias(arg0, arg1, arg2)), | 184 3, |
185 (Parser target, arg0, arg1, arg2) => | |
186 target._parseClassTypeAlias(arg0, arg1, arg2)), | |
180 'parseCombinator_0': | 187 'parseCombinator_0': |
181 new MethodTrampoline(0, (Parser target) => target.parseCombinator()), | 188 new MethodTrampoline(0, (Parser target) => target.parseCombinator()), |
182 'parseCombinators_0': | 189 'parseCombinators_0': |
183 new MethodTrampoline(0, (Parser target) => target._parseCombinators()), | 190 new MethodTrampoline(0, (Parser target) => target._parseCombinators()), |
184 'parseCommentAndMetadata_0': new MethodTrampoline( | 191 'parseCommentAndMetadata_0': new MethodTrampoline( |
185 0, (Parser target) => target._parseCommentAndMetadata()), | 192 0, (Parser target) => target._parseCommentAndMetadata()), |
186 'parseCommentReference_2': new MethodTrampoline(2, | 193 'parseCommentReference_2': new MethodTrampoline(2, |
187 (Parser target, arg0, arg1) => target._parseCommentReference(arg0, arg1)), | 194 (Parser target, arg0, arg1) => target._parseCommentReference(arg0, arg1)), |
188 'parseCommentReferences_1': new MethodTrampoline( | 195 'parseCommentReferences_1': new MethodTrampoline( |
189 1, (Parser target, arg0) => target._parseCommentReferences(arg0)), | 196 1, (Parser target, arg0) => target._parseCommentReferences(arg0)), |
190 'parseCompilationUnitMember_1': new MethodTrampoline( | 197 'parseCompilationUnitMember_1': new MethodTrampoline( |
191 1, (Parser target, arg0) => target._parseCompilationUnitMember(arg0)), | 198 1, (Parser target, arg0) => target._parseCompilationUnitMember(arg0)), |
192 'parseConstExpression_0': new MethodTrampoline( | 199 'parseConstExpression_0': new MethodTrampoline( |
193 0, (Parser target) => target._parseConstExpression()), | 200 0, (Parser target) => target._parseConstExpression()), |
194 'parseConstructor_8': new MethodTrampoline(8, (Parser target, arg0, arg1, | 201 'parseConstructor_8': new MethodTrampoline( |
195 arg2, arg3, arg4, arg5, arg6, arg7) => | 202 8, |
196 target._parseConstructor(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)), | 203 (Parser target, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) => target |
204 ._parseConstructor(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)), | |
197 'parseConstructorFieldInitializer_0': new MethodTrampoline( | 205 'parseConstructorFieldInitializer_0': new MethodTrampoline( |
198 0, (Parser target) => target._parseConstructorFieldInitializer()), | 206 0, (Parser target) => target._parseConstructorFieldInitializer()), |
199 'parseContinueStatement_0': new MethodTrampoline( | 207 'parseContinueStatement_0': new MethodTrampoline( |
200 0, (Parser target) => target._parseContinueStatement()), | 208 0, (Parser target) => target._parseContinueStatement()), |
201 'parseDirective_1': new MethodTrampoline( | 209 'parseDirective_1': new MethodTrampoline( |
202 1, (Parser target, arg0) => target._parseDirective(arg0)), | 210 1, (Parser target, arg0) => target._parseDirective(arg0)), |
203 'parseDirectives_0': | 211 'parseDirectives_0': |
204 new MethodTrampoline(0, (Parser target) => target._parseDirectives()), | 212 new MethodTrampoline(0, (Parser target) => target._parseDirectives()), |
205 'parseDocumentationComment_0': new MethodTrampoline( | 213 'parseDocumentationComment_0': new MethodTrampoline( |
206 0, (Parser target) => target._parseDocumentationComment()), | 214 0, (Parser target) => target._parseDocumentationComment()), |
(...skipping 10 matching lines...) Expand all Loading... | |
217 'parseExportDirective_1': new MethodTrampoline( | 225 'parseExportDirective_1': new MethodTrampoline( |
218 1, (Parser target, arg0) => target._parseExportDirective(arg0)), | 226 1, (Parser target, arg0) => target._parseExportDirective(arg0)), |
219 'parseExpressionList_0': | 227 'parseExpressionList_0': |
220 new MethodTrampoline(0, (Parser target) => target._parseExpressionList()), | 228 new MethodTrampoline(0, (Parser target) => target._parseExpressionList()), |
221 'parseFinalConstVarOrType_1': new MethodTrampoline( | 229 'parseFinalConstVarOrType_1': new MethodTrampoline( |
222 1, (Parser target, arg0) => target._parseFinalConstVarOrType(arg0)), | 230 1, (Parser target, arg0) => target._parseFinalConstVarOrType(arg0)), |
223 'parseFormalParameter_1': new MethodTrampoline( | 231 'parseFormalParameter_1': new MethodTrampoline( |
224 1, (Parser target, arg0) => target._parseFormalParameter(arg0)), | 232 1, (Parser target, arg0) => target._parseFormalParameter(arg0)), |
225 'parseForStatement_0': | 233 'parseForStatement_0': |
226 new MethodTrampoline(0, (Parser target) => target._parseForStatement()), | 234 new MethodTrampoline(0, (Parser target) => target._parseForStatement()), |
227 'parseFunctionBody_3': new MethodTrampoline(3, (Parser target, arg0, arg1, | 235 'parseFunctionBody_3': new MethodTrampoline( |
228 arg2) => target._parseFunctionBody(arg0, arg1, arg2)), | 236 3, |
229 'parseFunctionDeclaration_3': new MethodTrampoline(3, (Parser target, arg0, | 237 (Parser target, arg0, arg1, arg2) => |
230 arg1, arg2) => target._parseFunctionDeclaration(arg0, arg1, arg2)), | 238 target._parseFunctionBody(arg0, arg1, arg2)), |
239 'parseFunctionDeclaration_3': new MethodTrampoline( | |
240 3, | |
241 (Parser target, arg0, arg1, arg2) => | |
242 target._parseFunctionDeclaration(arg0, arg1, arg2)), | |
231 'parseFunctionDeclarationStatement_0': new MethodTrampoline( | 243 'parseFunctionDeclarationStatement_0': new MethodTrampoline( |
232 0, (Parser target) => target._parseFunctionDeclarationStatement()), | 244 0, (Parser target) => target._parseFunctionDeclarationStatement()), |
233 'parseFunctionDeclarationStatementAfterReturnType_2': new MethodTrampoline(2, | 245 'parseFunctionDeclarationStatementAfterReturnType_2': new MethodTrampoline( |
246 2, | |
234 (Parser target, arg0, arg1) => | 247 (Parser target, arg0, arg1) => |
235 target._parseFunctionDeclarationStatementAfterReturnType(arg0, arg1)), | 248 target._parseFunctionDeclarationStatementAfterReturnType(arg0, arg1)), |
236 'parseFunctionTypeAlias_2': new MethodTrampoline(2, (Parser target, arg0, | 249 'parseFunctionTypeAlias_2': new MethodTrampoline( |
237 arg1) => target._parseFunctionTypeAlias(arg0, arg1)), | 250 2, |
238 'parseGetter_4': new MethodTrampoline(4, (Parser target, arg0, arg1, arg2, | 251 (Parser target, arg0, arg1) => |
239 arg3) => target._parseGetter(arg0, arg1, arg2, arg3)), | 252 target._parseFunctionTypeAlias(arg0, arg1)), |
253 'parseGetter_4': new MethodTrampoline( | |
254 4, | |
255 (Parser target, arg0, arg1, arg2, arg3) => | |
256 target._parseGetter(arg0, arg1, arg2, arg3)), | |
240 'parseIdentifierList_0': | 257 'parseIdentifierList_0': |
241 new MethodTrampoline(0, (Parser target) => target._parseIdentifierList()), | 258 new MethodTrampoline(0, (Parser target) => target._parseIdentifierList()), |
242 'parseIfStatement_0': | 259 'parseIfStatement_0': |
243 new MethodTrampoline(0, (Parser target) => target._parseIfStatement()), | 260 new MethodTrampoline(0, (Parser target) => target._parseIfStatement()), |
244 'parseImportDirective_1': new MethodTrampoline( | 261 'parseImportDirective_1': new MethodTrampoline( |
245 1, (Parser target, arg0) => target._parseImportDirective(arg0)), | 262 1, (Parser target, arg0) => target._parseImportDirective(arg0)), |
246 'parseInitializedIdentifierList_4': new MethodTrampoline(4, | 263 'parseInitializedIdentifierList_4': new MethodTrampoline( |
264 4, | |
247 (Parser target, arg0, arg1, arg2, arg3) => | 265 (Parser target, arg0, arg1, arg2, arg3) => |
248 target._parseInitializedIdentifierList(arg0, arg1, arg2, arg3)), | 266 target._parseInitializedIdentifierList(arg0, arg1, arg2, arg3)), |
249 'parseInstanceCreationExpression_1': new MethodTrampoline(1, | 267 'parseInstanceCreationExpression_1': new MethodTrampoline(1, |
250 (Parser target, arg0) => target._parseInstanceCreationExpression(arg0)), | 268 (Parser target, arg0) => target._parseInstanceCreationExpression(arg0)), |
251 'parseLibraryDirective_1': new MethodTrampoline( | 269 'parseLibraryDirective_1': new MethodTrampoline( |
252 1, (Parser target, arg0) => target._parseLibraryDirective(arg0)), | 270 1, (Parser target, arg0) => target._parseLibraryDirective(arg0)), |
253 'parseLibraryName_2': new MethodTrampoline( | 271 'parseLibraryName_2': new MethodTrampoline( |
254 2, (Parser target, arg0, arg1) => target._parseLibraryName(arg0, arg1)), | 272 2, (Parser target, arg0, arg1) => target._parseLibraryName(arg0, arg1)), |
255 'parseListLiteral_2': new MethodTrampoline( | 273 'parseListLiteral_2': new MethodTrampoline( |
256 2, (Parser target, arg0, arg1) => target._parseListLiteral(arg0, arg1)), | 274 2, (Parser target, arg0, arg1) => target._parseListLiteral(arg0, arg1)), |
257 'parseListOrMapLiteral_1': new MethodTrampoline( | 275 'parseListOrMapLiteral_1': new MethodTrampoline( |
258 1, (Parser target, arg0) => target._parseListOrMapLiteral(arg0)), | 276 1, (Parser target, arg0) => target._parseListOrMapLiteral(arg0)), |
259 'parseLogicalAndExpression_0': new MethodTrampoline( | 277 'parseLogicalAndExpression_0': new MethodTrampoline( |
260 0, (Parser target) => target._parseLogicalAndExpression()), | 278 0, (Parser target) => target._parseLogicalAndExpression()), |
261 'parseMapLiteral_2': new MethodTrampoline( | 279 'parseMapLiteral_2': new MethodTrampoline( |
262 2, (Parser target, arg0, arg1) => target._parseMapLiteral(arg0, arg1)), | 280 2, (Parser target, arg0, arg1) => target._parseMapLiteral(arg0, arg1)), |
263 'parseMethodDeclarationAfterParameters_7': new MethodTrampoline(7, | 281 'parseMethodDeclarationAfterParameters_7': new MethodTrampoline( |
264 (Parser target, arg0, arg1, arg2, arg3, arg4, arg5, arg6) => target | 282 7, |
265 ._parseMethodDeclarationAfterParameters( | 283 (Parser target, arg0, arg1, arg2, arg3, arg4, arg5, arg6) => |
284 target._parseMethodDeclarationAfterParameters( | |
266 arg0, arg1, arg2, arg3, arg4, arg5, arg6)), | 285 arg0, arg1, arg2, arg3, arg4, arg5, arg6)), |
267 'parseMethodDeclarationAfterReturnType_4': new MethodTrampoline(4, | 286 'parseMethodDeclarationAfterReturnType_4': new MethodTrampoline( |
287 4, | |
268 (Parser target, arg0, arg1, arg2, arg3) => target | 288 (Parser target, arg0, arg1, arg2, arg3) => target |
269 ._parseMethodDeclarationAfterReturnType(arg0, arg1, arg2, arg3)), | 289 ._parseMethodDeclarationAfterReturnType(arg0, arg1, arg2, arg3)), |
270 'parseModifiers_0': | 290 'parseModifiers_0': |
271 new MethodTrampoline(0, (Parser target) => target._parseModifiers()), | 291 new MethodTrampoline(0, (Parser target) => target._parseModifiers()), |
272 'parseMultiplicativeExpression_0': new MethodTrampoline( | 292 'parseMultiplicativeExpression_0': new MethodTrampoline( |
273 0, (Parser target) => target._parseMultiplicativeExpression()), | 293 0, (Parser target) => target._parseMultiplicativeExpression()), |
274 'parseNativeClause_0': | 294 'parseNativeClause_0': |
275 new MethodTrampoline(0, (Parser target) => target._parseNativeClause()), | 295 new MethodTrampoline(0, (Parser target) => target._parseNativeClause()), |
276 'parseNewExpression_0': | 296 'parseNewExpression_0': |
277 new MethodTrampoline(0, (Parser target) => target._parseNewExpression()), | 297 new MethodTrampoline(0, (Parser target) => target._parseNewExpression()), |
278 'parseNonLabeledStatement_0': new MethodTrampoline( | 298 'parseNonLabeledStatement_0': new MethodTrampoline( |
279 0, (Parser target) => target._parseNonLabeledStatement()), | 299 0, (Parser target) => target._parseNonLabeledStatement()), |
280 'parseOperator_3': new MethodTrampoline(3, (Parser target, arg0, arg1, | 300 'parseOperator_3': new MethodTrampoline( |
281 arg2) => target._parseOperator(arg0, arg1, arg2)), | 301 3, |
302 (Parser target, arg0, arg1, arg2) => | |
303 target._parseOperator(arg0, arg1, arg2)), | |
282 'parseOptionalReturnType_0': new MethodTrampoline( | 304 'parseOptionalReturnType_0': new MethodTrampoline( |
283 0, (Parser target) => target._parseOptionalReturnType()), | 305 0, (Parser target) => target._parseOptionalReturnType()), |
284 'parsePartDirective_1': new MethodTrampoline( | 306 'parsePartDirective_1': new MethodTrampoline( |
285 1, (Parser target, arg0) => target._parsePartDirective(arg0)), | 307 1, (Parser target, arg0) => target._parsePartDirective(arg0)), |
286 'parsePostfixExpression_0': new MethodTrampoline( | 308 'parsePostfixExpression_0': new MethodTrampoline( |
287 0, (Parser target) => target._parsePostfixExpression()), | 309 0, (Parser target) => target._parsePostfixExpression()), |
288 'parsePrimaryExpression_0': new MethodTrampoline( | 310 'parsePrimaryExpression_0': new MethodTrampoline( |
289 0, (Parser target) => target._parsePrimaryExpression()), | 311 0, (Parser target) => target._parsePrimaryExpression()), |
290 'parseRedirectingConstructorInvocation_0': new MethodTrampoline( | 312 'parseRedirectingConstructorInvocation_0': new MethodTrampoline( |
291 0, (Parser target) => target._parseRedirectingConstructorInvocation()), | 313 0, (Parser target) => target._parseRedirectingConstructorInvocation()), |
292 'parseRelationalExpression_0': new MethodTrampoline( | 314 'parseRelationalExpression_0': new MethodTrampoline( |
293 0, (Parser target) => target._parseRelationalExpression()), | 315 0, (Parser target) => target._parseRelationalExpression()), |
294 'parseRethrowExpression_0': new MethodTrampoline( | 316 'parseRethrowExpression_0': new MethodTrampoline( |
295 0, (Parser target) => target._parseRethrowExpression()), | 317 0, (Parser target) => target._parseRethrowExpression()), |
296 'parseReturnStatement_0': new MethodTrampoline( | 318 'parseReturnStatement_0': new MethodTrampoline( |
297 0, (Parser target) => target._parseReturnStatement()), | 319 0, (Parser target) => target._parseReturnStatement()), |
298 'parseSetter_4': new MethodTrampoline(4, (Parser target, arg0, arg1, arg2, | 320 'parseSetter_4': new MethodTrampoline( |
299 arg3) => target._parseSetter(arg0, arg1, arg2, arg3)), | 321 4, |
322 (Parser target, arg0, arg1, arg2, arg3) => | |
323 target._parseSetter(arg0, arg1, arg2, arg3)), | |
300 'parseShiftExpression_0': new MethodTrampoline( | 324 'parseShiftExpression_0': new MethodTrampoline( |
301 0, (Parser target) => target._parseShiftExpression()), | 325 0, (Parser target) => target._parseShiftExpression()), |
302 'parseStatementList_0': | 326 'parseStatementList_0': |
303 new MethodTrampoline(0, (Parser target) => target._parseStatementList()), | 327 new MethodTrampoline(0, (Parser target) => target._parseStatementList()), |
304 'parseStringInterpolation_1': new MethodTrampoline( | 328 'parseStringInterpolation_1': new MethodTrampoline( |
305 1, (Parser target, arg0) => target._parseStringInterpolation(arg0)), | 329 1, (Parser target, arg0) => target._parseStringInterpolation(arg0)), |
306 'parseSuperConstructorInvocation_0': new MethodTrampoline( | 330 'parseSuperConstructorInvocation_0': new MethodTrampoline( |
307 0, (Parser target) => target._parseSuperConstructorInvocation()), | 331 0, (Parser target) => target._parseSuperConstructorInvocation()), |
308 'parseSwitchStatement_0': new MethodTrampoline( | 332 'parseSwitchStatement_0': new MethodTrampoline( |
309 0, (Parser target) => target._parseSwitchStatement()), | 333 0, (Parser target) => target._parseSwitchStatement()), |
310 'parseSymbolLiteral_0': | 334 'parseSymbolLiteral_0': |
311 new MethodTrampoline(0, (Parser target) => target._parseSymbolLiteral()), | 335 new MethodTrampoline(0, (Parser target) => target._parseSymbolLiteral()), |
312 'parseThrowExpression_0': new MethodTrampoline( | 336 'parseThrowExpression_0': new MethodTrampoline( |
313 0, (Parser target) => target._parseThrowExpression()), | 337 0, (Parser target) => target._parseThrowExpression()), |
314 'parseThrowExpressionWithoutCascade_0': new MethodTrampoline( | 338 'parseThrowExpressionWithoutCascade_0': new MethodTrampoline( |
315 0, (Parser target) => target._parseThrowExpressionWithoutCascade()), | 339 0, (Parser target) => target._parseThrowExpressionWithoutCascade()), |
316 'parseTryStatement_0': | 340 'parseTryStatement_0': |
317 new MethodTrampoline(0, (Parser target) => target._parseTryStatement()), | 341 new MethodTrampoline(0, (Parser target) => target._parseTryStatement()), |
318 'parseTypeAlias_1': new MethodTrampoline( | 342 'parseTypeAlias_1': new MethodTrampoline( |
319 1, (Parser target, arg0) => target._parseTypeAlias(arg0)), | 343 1, (Parser target, arg0) => target._parseTypeAlias(arg0)), |
320 'parseUnaryExpression_0': new MethodTrampoline( | 344 'parseUnaryExpression_0': new MethodTrampoline( |
321 0, (Parser target) => target._parseUnaryExpression()), | 345 0, (Parser target) => target._parseUnaryExpression()), |
322 'parseVariableDeclaration_0': new MethodTrampoline( | 346 'parseVariableDeclaration_0': new MethodTrampoline( |
323 0, (Parser target) => target._parseVariableDeclaration()), | 347 0, (Parser target) => target._parseVariableDeclaration()), |
324 'parseVariableDeclarationListAfterMetadata_1': new MethodTrampoline(1, | 348 'parseVariableDeclarationListAfterMetadata_1': new MethodTrampoline( |
349 1, | |
325 (Parser target, arg0) => | 350 (Parser target, arg0) => |
326 target._parseVariableDeclarationListAfterMetadata(arg0)), | 351 target._parseVariableDeclarationListAfterMetadata(arg0)), |
327 'parseVariableDeclarationListAfterType_3': new MethodTrampoline(3, | 352 'parseVariableDeclarationListAfterType_3': new MethodTrampoline( |
353 3, | |
328 (Parser target, arg0, arg1, arg2) => | 354 (Parser target, arg0, arg1, arg2) => |
329 target._parseVariableDeclarationListAfterType(arg0, arg1, arg2)), | 355 target._parseVariableDeclarationListAfterType(arg0, arg1, arg2)), |
330 'parseVariableDeclarationStatementAfterMetadata_1': new MethodTrampoline(1, | 356 'parseVariableDeclarationStatementAfterMetadata_1': new MethodTrampoline( |
357 1, | |
331 (Parser target, arg0) => | 358 (Parser target, arg0) => |
332 target._parseVariableDeclarationStatementAfterMetadata(arg0)), | 359 target._parseVariableDeclarationStatementAfterMetadata(arg0)), |
333 'parseVariableDeclarationStatementAfterType_3': new MethodTrampoline(3, | 360 'parseVariableDeclarationStatementAfterType_3': new MethodTrampoline( |
361 3, | |
334 (Parser target, arg0, arg1, arg2) => | 362 (Parser target, arg0, arg1, arg2) => |
335 target._parseVariableDeclarationStatementAfterType(arg0, arg1, arg2)), | 363 target._parseVariableDeclarationStatementAfterType(arg0, arg1, arg2)), |
336 'parseWhileStatement_0': | 364 'parseWhileStatement_0': |
337 new MethodTrampoline(0, (Parser target) => target._parseWhileStatement()), | 365 new MethodTrampoline(0, (Parser target) => target._parseWhileStatement()), |
338 'parseYieldStatement_0': | 366 'parseYieldStatement_0': |
339 new MethodTrampoline(0, (Parser target) => target._parseYieldStatement()), | 367 new MethodTrampoline(0, (Parser target) => target._parseYieldStatement()), |
340 'peek_0': new MethodTrampoline(0, (Parser target) => target._peek()), | 368 'peek_0': new MethodTrampoline(0, (Parser target) => target._peek()), |
341 'peekAt_1': | 369 'peekAt_1': |
342 new MethodTrampoline(1, (Parser target, arg0) => target._peekAt(arg0)), | 370 new MethodTrampoline(1, (Parser target, arg0) => target._peekAt(arg0)), |
343 'reportError_1': new MethodTrampoline( | 371 'reportError_1': new MethodTrampoline( |
344 1, (Parser target, arg0) => target._reportError(arg0)), | 372 1, (Parser target, arg0) => target._reportError(arg0)), |
345 'reportErrorForCurrentToken_2': new MethodTrampoline(2, (Parser target, arg0, | 373 'reportErrorForCurrentToken_2': new MethodTrampoline( |
346 arg1) => target._reportErrorForCurrentToken(arg0, arg1)), | 374 2, |
347 'reportErrorForNode_3': new MethodTrampoline(3, (Parser target, arg0, arg1, | 375 (Parser target, arg0, arg1) => |
348 arg2) => target._reportErrorForNode(arg0, arg1, arg2)), | 376 target._reportErrorForCurrentToken(arg0, arg1)), |
349 'reportErrorForToken_3': new MethodTrampoline(3, (Parser target, arg0, arg1, | 377 'reportErrorForNode_3': new MethodTrampoline( |
350 arg2) => target._reportErrorForToken(arg0, arg1, arg2)), | 378 3, |
379 (Parser target, arg0, arg1, arg2) => | |
380 target._reportErrorForNode(arg0, arg1, arg2)), | |
381 'reportErrorForToken_3': new MethodTrampoline( | |
382 3, | |
383 (Parser target, arg0, arg1, arg2) => | |
384 target._reportErrorForToken(arg0, arg1, arg2)), | |
351 'skipBlock_0': | 385 'skipBlock_0': |
352 new MethodTrampoline(0, (Parser target) => target._skipBlock()), | 386 new MethodTrampoline(0, (Parser target) => target._skipBlock()), |
353 'skipFinalConstVarOrType_1': new MethodTrampoline( | 387 'skipFinalConstVarOrType_1': new MethodTrampoline( |
354 1, (Parser target, arg0) => target._skipFinalConstVarOrType(arg0)), | 388 1, (Parser target, arg0) => target._skipFinalConstVarOrType(arg0)), |
355 'skipFormalParameterList_1': new MethodTrampoline( | 389 'skipFormalParameterList_1': new MethodTrampoline( |
356 1, (Parser target, arg0) => target._skipFormalParameterList(arg0)), | 390 1, (Parser target, arg0) => target._skipFormalParameterList(arg0)), |
357 'skipPastMatchingToken_1': new MethodTrampoline( | 391 'skipPastMatchingToken_1': new MethodTrampoline( |
358 1, (Parser target, arg0) => target._skipPastMatchingToken(arg0)), | 392 1, (Parser target, arg0) => target._skipPastMatchingToken(arg0)), |
359 'skipPrefixedIdentifier_1': new MethodTrampoline( | 393 'skipPrefixedIdentifier_1': new MethodTrampoline( |
360 1, (Parser target, arg0) => target._skipPrefixedIdentifier(arg0)), | 394 1, (Parser target, arg0) => target._skipPrefixedIdentifier(arg0)), |
(...skipping 12 matching lines...) Expand all Loading... | |
373 'skipTypeParameterList_1': new MethodTrampoline( | 407 'skipTypeParameterList_1': new MethodTrampoline( |
374 1, (Parser target, arg0) => target._skipTypeParameterList(arg0)), | 408 1, (Parser target, arg0) => target._skipTypeParameterList(arg0)), |
375 'tokenMatches_2': new MethodTrampoline( | 409 'tokenMatches_2': new MethodTrampoline( |
376 2, (Parser target, arg0, arg1) => target._tokenMatches(arg0, arg1)), | 410 2, (Parser target, arg0, arg1) => target._tokenMatches(arg0, arg1)), |
377 'tokenMatchesIdentifier_1': new MethodTrampoline( | 411 'tokenMatchesIdentifier_1': new MethodTrampoline( |
378 1, (Parser target, arg0) => target._tokenMatchesIdentifier(arg0)), | 412 1, (Parser target, arg0) => target._tokenMatchesIdentifier(arg0)), |
379 'tokenMatchesKeyword_2': new MethodTrampoline(2, | 413 'tokenMatchesKeyword_2': new MethodTrampoline(2, |
380 (Parser target, arg0, arg1) => target._tokenMatchesKeyword(arg0, arg1)), | 414 (Parser target, arg0, arg1) => target._tokenMatchesKeyword(arg0, arg1)), |
381 'tokenMatchesString_2': new MethodTrampoline( | 415 'tokenMatchesString_2': new MethodTrampoline( |
382 2, (Parser target, arg0, arg1) => target._tokenMatchesString(arg0, arg1)), | 416 2, (Parser target, arg0, arg1) => target._tokenMatchesString(arg0, arg1)), |
383 'translateCharacter_3': new MethodTrampoline(3, (Parser target, arg0, arg1, | 417 'translateCharacter_3': new MethodTrampoline( |
384 arg2) => target._translateCharacter(arg0, arg1, arg2)), | 418 3, |
419 (Parser target, arg0, arg1, arg2) => | |
420 target._translateCharacter(arg0, arg1, arg2)), | |
385 'unlockErrorListener_0': | 421 'unlockErrorListener_0': |
386 new MethodTrampoline(0, (Parser target) => target._unlockErrorListener()), | 422 new MethodTrampoline(0, (Parser target) => target._unlockErrorListener()), |
387 'validateFormalParameterList_1': new MethodTrampoline( | 423 'validateFormalParameterList_1': new MethodTrampoline( |
388 1, (Parser target, arg0) => target._validateFormalParameterList(arg0)), | 424 1, (Parser target, arg0) => target._validateFormalParameterList(arg0)), |
389 'validateModifiersForClass_1': new MethodTrampoline( | 425 'validateModifiersForClass_1': new MethodTrampoline( |
390 1, (Parser target, arg0) => target._validateModifiersForClass(arg0)), | 426 1, (Parser target, arg0) => target._validateModifiersForClass(arg0)), |
391 'validateModifiersForConstructor_1': new MethodTrampoline(1, | 427 'validateModifiersForConstructor_1': new MethodTrampoline(1, |
392 (Parser target, arg0) => target._validateModifiersForConstructor(arg0)), | 428 (Parser target, arg0) => target._validateModifiersForConstructor(arg0)), |
393 'validateModifiersForEnum_1': new MethodTrampoline( | 429 'validateModifiersForEnum_1': new MethodTrampoline( |
394 1, (Parser target, arg0) => target._validateModifiersForEnum(arg0)), | 430 1, (Parser target, arg0) => target._validateModifiersForEnum(arg0)), |
395 'validateModifiersForField_1': new MethodTrampoline( | 431 'validateModifiersForField_1': new MethodTrampoline( |
396 1, (Parser target, arg0) => target._validateModifiersForField(arg0)), | 432 1, (Parser target, arg0) => target._validateModifiersForField(arg0)), |
397 'validateModifiersForFunctionDeclarationStatement_1': new MethodTrampoline(1, | 433 'validateModifiersForFunctionDeclarationStatement_1': new MethodTrampoline( |
434 1, | |
398 (Parser target, arg0) => | 435 (Parser target, arg0) => |
399 target._validateModifiersForFunctionDeclarationStatement(arg0)), | 436 target._validateModifiersForFunctionDeclarationStatement(arg0)), |
400 'validateModifiersForGetterOrSetterOrMethod_1': new MethodTrampoline(1, | 437 'validateModifiersForGetterOrSetterOrMethod_1': new MethodTrampoline( |
438 1, | |
401 (Parser target, arg0) => | 439 (Parser target, arg0) => |
402 target._validateModifiersForGetterOrSetterOrMethod(arg0)), | 440 target._validateModifiersForGetterOrSetterOrMethod(arg0)), |
403 'validateModifiersForOperator_1': new MethodTrampoline( | 441 'validateModifiersForOperator_1': new MethodTrampoline( |
404 1, (Parser target, arg0) => target._validateModifiersForOperator(arg0)), | 442 1, (Parser target, arg0) => target._validateModifiersForOperator(arg0)), |
405 'validateModifiersForTopLevelDeclaration_1': new MethodTrampoline(1, | 443 'validateModifiersForTopLevelDeclaration_1': new MethodTrampoline( |
444 1, | |
406 (Parser target, arg0) => | 445 (Parser target, arg0) => |
407 target._validateModifiersForTopLevelDeclaration(arg0)), | 446 target._validateModifiersForTopLevelDeclaration(arg0)), |
408 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1, | 447 'validateModifiersForTopLevelFunction_1': new MethodTrampoline( |
448 1, | |
409 (Parser target, arg0) => | 449 (Parser target, arg0) => |
410 target._validateModifiersForTopLevelFunction(arg0)), | 450 target._validateModifiersForTopLevelFunction(arg0)), |
411 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1, | 451 'validateModifiersForTopLevelVariable_1': new MethodTrampoline( |
452 1, | |
412 (Parser target, arg0) => | 453 (Parser target, arg0) => |
413 target._validateModifiersForTopLevelVariable(arg0)), | 454 target._validateModifiersForTopLevelVariable(arg0)), |
414 'validateModifiersForTypedef_1': new MethodTrampoline( | 455 'validateModifiersForTypedef_1': new MethodTrampoline( |
415 1, (Parser target, arg0) => target._validateModifiersForTypedef(arg0)), | 456 1, (Parser target, arg0) => target._validateModifiersForTypedef(arg0)), |
416 }; | 457 }; |
417 | 458 |
418 Object invokeParserMethodImpl( | 459 Object invokeParserMethodImpl( |
419 Parser parser, String methodName, List<Object> objects, Token tokenStream) { | 460 Parser parser, String methodName, List<Object> objects, Token tokenStream) { |
420 parser.currentToken = tokenStream; | 461 parser.currentToken = tokenStream; |
421 MethodTrampoline method = | 462 MethodTrampoline method = |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1622 */ | 1663 */ |
1623 final TokenMap _tokenMap; | 1664 final TokenMap _tokenMap; |
1624 | 1665 |
1625 /** | 1666 /** |
1626 * The error listener that will be informed of any errors that are found | 1667 * The error listener that will be informed of any errors that are found |
1627 * during the parse. | 1668 * during the parse. |
1628 */ | 1669 */ |
1629 final AnalysisErrorListener _errorListener; | 1670 final AnalysisErrorListener _errorListener; |
1630 | 1671 |
1631 /** | 1672 /** |
1673 * A flag indicating whether the parser is to allow assertions with messages | |
1674 * (DEP 37). | |
1675 */ | |
1676 final bool enableAssertMessage; | |
1677 | |
1678 /** | |
1632 * The node in the AST structure that contains the revised content. | 1679 * The node in the AST structure that contains the revised content. |
1633 */ | 1680 */ |
1634 AstNode _updatedNode; | 1681 AstNode _updatedNode; |
1635 | 1682 |
1636 /** | 1683 /** |
1637 * Initialize a newly created incremental parser to parse a portion of the | 1684 * Initialize a newly created incremental parser to parse a portion of the |
1638 * content of the given [_source]. The [_tokenMap] is a map from old tokens to | 1685 * content of the given [_source]. The [_tokenMap] is a map from old tokens to |
1639 * new tokens that is used during the cloning process. The [_errorListener] | 1686 * new tokens that is used during the cloning process. The [_errorListener] |
1640 * will be informed of any errors that are found during the parse. | 1687 * will be informed of any errors that are found during the parse. |
1641 */ | 1688 */ |
1642 IncrementalParser(this._source, this._tokenMap, this._errorListener); | 1689 IncrementalParser(this._source, this._tokenMap, this._errorListener, |
1690 {this.enableAssertMessage: false}); | |
1643 | 1691 |
1644 /** | 1692 /** |
1645 * Return the node in the AST structure that contains the revised content. | 1693 * Return the node in the AST structure that contains the revised content. |
1646 */ | 1694 */ |
1647 AstNode get updatedNode => _updatedNode; | 1695 AstNode get updatedNode => _updatedNode; |
1648 | 1696 |
1649 /** | 1697 /** |
1650 * Given a range of tokens that were re-scanned, re-parse the minimum number | 1698 * Given a range of tokens that were re-scanned, re-parse the minimum number |
1651 * of tokens to produce a consistent AST structure. The range is represented | 1699 * of tokens to produce a consistent AST structure. The range is represented |
1652 * by the first and last tokens in the range. | 1700 * by the first and last tokens in the range. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1687 // Find the token at which parsing is to begin. | 1735 // Find the token at which parsing is to begin. |
1688 // | 1736 // |
1689 int originalOffset = oldNode.offset; | 1737 int originalOffset = oldNode.offset; |
1690 Token parseToken = _findTokenAt(firstToken, originalOffset); | 1738 Token parseToken = _findTokenAt(firstToken, originalOffset); |
1691 if (parseToken == null) { | 1739 if (parseToken == null) { |
1692 return null; | 1740 return null; |
1693 } | 1741 } |
1694 // | 1742 // |
1695 // Parse the appropriate AST structure starting at the appropriate place. | 1743 // Parse the appropriate AST structure starting at the appropriate place. |
1696 // | 1744 // |
1697 Parser parser = new Parser(_source, _errorListener); | 1745 Parser parser = new Parser(_source, _errorListener, |
1746 enableAssertMessage: enableAssertMessage); | |
1698 parser.currentToken = parseToken; | 1747 parser.currentToken = parseToken; |
1699 while (newNode == null) { | 1748 while (newNode == null) { |
1700 AstNode parent = oldNode.parent; | 1749 AstNode parent = oldNode.parent; |
1701 if (parent == null) { | 1750 if (parent == null) { |
1702 parseToken = _findFirstToken(parseToken); | 1751 parseToken = _findFirstToken(parseToken); |
1703 parser.currentToken = parseToken; | 1752 parser.currentToken = parseToken; |
1704 return parser.parseCompilationUnit2(); | 1753 return parser.parseCompilationUnit2(); |
1705 } | 1754 } |
1706 bool advanceToParent = false; | 1755 bool advanceToParent = false; |
1707 try { | 1756 try { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2037 * An [errorListener] lock, if more than `0`, then errors are not reported. | 2086 * An [errorListener] lock, if more than `0`, then errors are not reported. |
2038 */ | 2087 */ |
2039 int _errorListenerLock = 0; | 2088 int _errorListenerLock = 0; |
2040 | 2089 |
2041 /** | 2090 /** |
2042 * A flag indicating whether parser is to parse function bodies. | 2091 * A flag indicating whether parser is to parse function bodies. |
2043 */ | 2092 */ |
2044 bool _parseFunctionBodies = true; | 2093 bool _parseFunctionBodies = true; |
2045 | 2094 |
2046 /** | 2095 /** |
2096 * A flag indicating whether the parser is to allow assertions with messages | |
2097 * (DEP 37). | |
2098 */ | |
2099 final bool enableAssertMessage; | |
2100 | |
2101 /** | |
2047 * The next token to be parsed. | 2102 * The next token to be parsed. |
2048 */ | 2103 */ |
2049 Token _currentToken; | 2104 Token _currentToken; |
2050 | 2105 |
2051 /** | 2106 /** |
2052 * A flag indicating whether the parser is currently in a function body marked | 2107 * A flag indicating whether the parser is currently in a function body marked |
2053 * as being 'async'. | 2108 * as being 'async'. |
2054 */ | 2109 */ |
2055 bool _inAsync = false; | 2110 bool _inAsync = false; |
2056 | 2111 |
(...skipping 22 matching lines...) Expand all Loading... | |
2079 /** | 2134 /** |
2080 * A flag indicating whether the parser is to parse generic method syntax. | 2135 * A flag indicating whether the parser is to parse generic method syntax. |
2081 */ | 2136 */ |
2082 bool parseGenericMethods = false; | 2137 bool parseGenericMethods = false; |
2083 | 2138 |
2084 /** | 2139 /** |
2085 * Initialize a newly created parser to parse the content of the given | 2140 * Initialize a newly created parser to parse the content of the given |
2086 * [_source] and to report any errors that are found to the given | 2141 * [_source] and to report any errors that are found to the given |
2087 * [_errorListener]. | 2142 * [_errorListener]. |
2088 */ | 2143 */ |
2089 Parser(this._source, this._errorListener); | 2144 Parser(this._source, this._errorListener, {this.enableAssertMessage: false}); |
2090 | 2145 |
2091 void set currentToken(Token currentToken) { | 2146 void set currentToken(Token currentToken) { |
2092 this._currentToken = currentToken; | 2147 this._currentToken = currentToken; |
2093 } | 2148 } |
2094 | 2149 |
2095 /** | 2150 /** |
2096 * Return `true` if the current token is the first token of a return type that | 2151 * Return `true` if the current token is the first token of a return type that |
2097 * is followed by an identifier, possibly followed by a list of type | 2152 * is followed by an identifier, possibly followed by a list of type |
2098 * parameters, followed by a left-parenthesis. This is used by | 2153 * parameters, followed by a left-parenthesis. This is used by |
2099 * [_parseTypeAlias] to determine whether or not to parse a return type. | 2154 * [_parseTypeAlias] to determine whether or not to parse a return type. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2321 _tokenMatchesIdentifier(_peek())) { | 2376 _tokenMatchesIdentifier(_peek())) { |
2322 _validateModifiersForGetterOrSetterOrMethod(modifiers); | 2377 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
2323 return _parseSetter(commentAndMetadata, modifiers.externalKeyword, | 2378 return _parseSetter(commentAndMetadata, modifiers.externalKeyword, |
2324 modifiers.staticKeyword, returnType); | 2379 modifiers.staticKeyword, returnType); |
2325 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { | 2380 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
2326 _validateModifiersForOperator(modifiers); | 2381 _validateModifiersForOperator(modifiers); |
2327 return _parseOperator( | 2382 return _parseOperator( |
2328 commentAndMetadata, modifiers.externalKeyword, returnType); | 2383 commentAndMetadata, modifiers.externalKeyword, returnType); |
2329 } else if (_matchesIdentifier() && | 2384 } else if (_matchesIdentifier() && |
2330 _peek().matchesAny([ | 2385 _peek().matchesAny([ |
2331 TokenType.OPEN_PAREN, | 2386 TokenType.OPEN_PAREN, |
2332 TokenType.OPEN_CURLY_BRACKET, | 2387 TokenType.OPEN_CURLY_BRACKET, |
2333 TokenType.FUNCTION, | 2388 TokenType.FUNCTION, |
2334 TokenType.LT | 2389 TokenType.LT |
2335 ])) { | 2390 ])) { |
2336 _validateModifiersForGetterOrSetterOrMethod(modifiers); | 2391 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
2337 return _parseMethodDeclarationAfterReturnType(commentAndMetadata, | 2392 return _parseMethodDeclarationAfterReturnType(commentAndMetadata, |
2338 modifiers.externalKeyword, modifiers.staticKeyword, returnType); | 2393 modifiers.externalKeyword, modifiers.staticKeyword, returnType); |
2339 } else { | 2394 } else { |
2340 // | 2395 // |
2341 // We have found an error of some kind. Try to recover. | 2396 // We have found an error of some kind. Try to recover. |
2342 // | 2397 // |
2343 if (_matchesIdentifier()) { | 2398 if (_matchesIdentifier()) { |
2344 if (_peek().matchesAny( | 2399 if (_peek().matchesAny( |
2345 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { | 2400 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { |
2346 // | 2401 // |
2347 // We appear to have a variable declaration with a type of "void". | 2402 // We appear to have a variable declaration with a type of "void". |
2348 // | 2403 // |
2349 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); | 2404 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); |
2350 return _parseInitializedIdentifierList(commentAndMetadata, | 2405 return _parseInitializedIdentifierList( |
2351 modifiers.staticKeyword, _validateModifiersForField(modifiers), | 2406 commentAndMetadata, |
2407 modifiers.staticKeyword, | |
2408 _validateModifiersForField(modifiers), | |
2352 returnType); | 2409 returnType); |
2353 } | 2410 } |
2354 } | 2411 } |
2355 if (_isOperator(_currentToken)) { | 2412 if (_isOperator(_currentToken)) { |
2356 // | 2413 // |
2357 // We appear to have found an operator declaration without the | 2414 // We appear to have found an operator declaration without the |
2358 // 'operator' keyword. | 2415 // 'operator' keyword. |
2359 // | 2416 // |
2360 _validateModifiersForOperator(modifiers); | 2417 _validateModifiersForOperator(modifiers); |
2361 return _parseOperator( | 2418 return _parseOperator( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2419 keyword = modifiers.constKeyword; | 2476 keyword = modifiers.constKeyword; |
2420 } | 2477 } |
2421 if (keyword != null) { | 2478 if (keyword != null) { |
2422 // | 2479 // |
2423 // We appear to have found an incomplete field declaration. | 2480 // We appear to have found an incomplete field declaration. |
2424 // | 2481 // |
2425 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); | 2482 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); |
2426 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 2483 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
2427 variables.add( | 2484 variables.add( |
2428 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); | 2485 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); |
2429 return new FieldDeclaration(commentAndMetadata.comment, | 2486 return new FieldDeclaration( |
2430 commentAndMetadata.metadata, null, | 2487 commentAndMetadata.comment, |
2488 commentAndMetadata.metadata, | |
2489 null, | |
2431 new VariableDeclarationList(null, null, keyword, null, variables), | 2490 new VariableDeclarationList(null, null, keyword, null, variables), |
2432 _expectSemicolon()); | 2491 _expectSemicolon()); |
2433 } | 2492 } |
2434 _reportErrorForToken( | 2493 _reportErrorForToken( |
2435 ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken); | 2494 ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken); |
2436 if (commentAndMetadata.comment != null || | 2495 if (commentAndMetadata.comment != null || |
2437 !commentAndMetadata.metadata.isEmpty) { | 2496 !commentAndMetadata.metadata.isEmpty) { |
2438 // | 2497 // |
2439 // We appear to have found an incomplete declaration at the end of the | 2498 // We appear to have found an incomplete declaration at the end of the |
2440 // class. At this point it consists of a metadata, which we don't want | 2499 // class. At this point it consists of a metadata, which we don't want |
2441 // to loose, so we'll treat it as a method declaration with a missing | 2500 // to loose, so we'll treat it as a method declaration with a missing |
2442 // name, parameters and empty body. | 2501 // name, parameters and empty body. |
2443 // | 2502 // |
2444 return new MethodDeclaration(commentAndMetadata.comment, | 2503 return new MethodDeclaration( |
2445 commentAndMetadata.metadata, null, null, null, null, null, | 2504 commentAndMetadata.comment, |
2446 _createSyntheticIdentifier(), null, new FormalParameterList( | 2505 commentAndMetadata.metadata, |
2506 null, | |
2507 null, | |
2508 null, | |
2509 null, | |
2510 null, | |
2511 _createSyntheticIdentifier(), | |
2512 null, | |
2513 new FormalParameterList( | |
2447 null, new List<FormalParameter>(), null, null, null), | 2514 null, new List<FormalParameter>(), null, null, null), |
2448 new EmptyFunctionBody(_createSyntheticToken(TokenType.SEMICOLON))); | 2515 new EmptyFunctionBody(_createSyntheticToken(TokenType.SEMICOLON))); |
2449 } | 2516 } |
2450 return null; | 2517 return null; |
2451 } else if (_tokenMatches(_peek(), TokenType.PERIOD) && | 2518 } else if (_tokenMatches(_peek(), TokenType.PERIOD) && |
2452 _tokenMatchesIdentifier(_peekAt(2)) && | 2519 _tokenMatchesIdentifier(_peekAt(2)) && |
2453 _tokenMatches(_peekAt(3), TokenType.OPEN_PAREN)) { | 2520 _tokenMatches(_peekAt(3), TokenType.OPEN_PAREN)) { |
2454 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword, | 2521 return _parseConstructor( |
2455 _validateModifiersForConstructor(modifiers), modifiers.factoryKeyword, | 2522 commentAndMetadata, |
2456 parseSimpleIdentifier(), getAndAdvance(), parseSimpleIdentifier(), | 2523 modifiers.externalKeyword, |
2524 _validateModifiersForConstructor(modifiers), | |
2525 modifiers.factoryKeyword, | |
2526 parseSimpleIdentifier(), | |
2527 getAndAdvance(), | |
2528 parseSimpleIdentifier(), | |
2457 parseFormalParameterList()); | 2529 parseFormalParameterList()); |
2458 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { | 2530 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
2459 SimpleIdentifier methodName = parseSimpleIdentifier(); | 2531 SimpleIdentifier methodName = parseSimpleIdentifier(); |
2460 FormalParameterList parameters = parseFormalParameterList(); | 2532 FormalParameterList parameters = parseFormalParameterList(); |
2461 if (_matches(TokenType.COLON) || | 2533 if (_matches(TokenType.COLON) || |
2462 modifiers.factoryKeyword != null || | 2534 modifiers.factoryKeyword != null || |
2463 methodName.name == className) { | 2535 methodName.name == className) { |
2464 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword, | 2536 return _parseConstructor( |
2537 commentAndMetadata, | |
2538 modifiers.externalKeyword, | |
2465 _validateModifiersForConstructor(modifiers), | 2539 _validateModifiersForConstructor(modifiers), |
2466 modifiers.factoryKeyword, methodName, null, null, parameters); | 2540 modifiers.factoryKeyword, |
2541 methodName, | |
2542 null, | |
2543 null, | |
2544 parameters); | |
2467 } | 2545 } |
2468 _validateModifiersForGetterOrSetterOrMethod(modifiers); | 2546 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
2469 _validateFormalParameterList(parameters); | 2547 _validateFormalParameterList(parameters); |
2470 return _parseMethodDeclarationAfterParameters(commentAndMetadata, | 2548 return _parseMethodDeclarationAfterParameters( |
2471 modifiers.externalKeyword, modifiers.staticKeyword, null, methodName, | 2549 commentAndMetadata, |
2472 null, parameters); | 2550 modifiers.externalKeyword, |
2551 modifiers.staticKeyword, | |
2552 null, | |
2553 methodName, | |
2554 null, | |
2555 parameters); | |
2473 } else if (_peek() | 2556 } else if (_peek() |
2474 .matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { | 2557 .matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { |
2475 if (modifiers.constKeyword == null && | 2558 if (modifiers.constKeyword == null && |
2476 modifiers.finalKeyword == null && | 2559 modifiers.finalKeyword == null && |
2477 modifiers.varKeyword == null) { | 2560 modifiers.varKeyword == null) { |
2478 _reportErrorForCurrentToken( | 2561 _reportErrorForCurrentToken( |
2479 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE); | 2562 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE); |
2480 } | 2563 } |
2481 return _parseInitializedIdentifierList(commentAndMetadata, | 2564 return _parseInitializedIdentifierList(commentAndMetadata, |
2482 modifiers.staticKeyword, _validateModifiersForField(modifiers), null); | 2565 modifiers.staticKeyword, _validateModifiersForField(modifiers), null); |
(...skipping 24 matching lines...) Expand all Loading... | |
2507 _validateModifiersForOperator(modifiers); | 2590 _validateModifiersForOperator(modifiers); |
2508 return _parseOperator( | 2591 return _parseOperator( |
2509 commentAndMetadata, modifiers.externalKeyword, type); | 2592 commentAndMetadata, modifiers.externalKeyword, type); |
2510 } else if (!_matchesIdentifier()) { | 2593 } else if (!_matchesIdentifier()) { |
2511 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { | 2594 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
2512 // | 2595 // |
2513 // We appear to have found an incomplete declaration at the end of the | 2596 // We appear to have found an incomplete declaration at the end of the |
2514 // class. At this point it consists of a type name, so we'll treat it as | 2597 // class. At this point it consists of a type name, so we'll treat it as |
2515 // a field declaration with a missing field name and semicolon. | 2598 // a field declaration with a missing field name and semicolon. |
2516 // | 2599 // |
2517 return _parseInitializedIdentifierList(commentAndMetadata, | 2600 return _parseInitializedIdentifierList( |
2518 modifiers.staticKeyword, _validateModifiersForField(modifiers), | 2601 commentAndMetadata, |
2602 modifiers.staticKeyword, | |
2603 _validateModifiersForField(modifiers), | |
2519 type); | 2604 type); |
2520 } | 2605 } |
2521 if (_isOperator(_currentToken)) { | 2606 if (_isOperator(_currentToken)) { |
2522 // | 2607 // |
2523 // We appear to have found an operator declaration without the | 2608 // We appear to have found an operator declaration without the |
2524 // 'operator' keyword. | 2609 // 'operator' keyword. |
2525 // | 2610 // |
2526 _validateModifiersForOperator(modifiers); | 2611 _validateModifiersForOperator(modifiers); |
2527 return _parseOperator( | 2612 return _parseOperator( |
2528 commentAndMetadata, modifiers.externalKeyword, type); | 2613 commentAndMetadata, modifiers.externalKeyword, type); |
2529 } | 2614 } |
2530 // | 2615 // |
2531 // We appear to have found an incomplete declaration before another | 2616 // We appear to have found an incomplete declaration before another |
2532 // declaration. At this point it consists of a type name, so we'll treat | 2617 // declaration. At this point it consists of a type name, so we'll treat |
2533 // it as a field declaration with a missing field name and semicolon. | 2618 // it as a field declaration with a missing field name and semicolon. |
2534 // | 2619 // |
2535 _reportErrorForToken( | 2620 _reportErrorForToken( |
2536 ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken); | 2621 ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken); |
2537 try { | 2622 try { |
2538 _lockErrorListener(); | 2623 _lockErrorListener(); |
2539 return _parseInitializedIdentifierList(commentAndMetadata, | 2624 return _parseInitializedIdentifierList( |
2540 modifiers.staticKeyword, _validateModifiersForField(modifiers), | 2625 commentAndMetadata, |
2626 modifiers.staticKeyword, | |
2627 _validateModifiersForField(modifiers), | |
2541 type); | 2628 type); |
2542 } finally { | 2629 } finally { |
2543 _unlockErrorListener(); | 2630 _unlockErrorListener(); |
2544 } | 2631 } |
2545 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { | 2632 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
2546 SimpleIdentifier methodName = parseSimpleIdentifier(); | 2633 SimpleIdentifier methodName = parseSimpleIdentifier(); |
2547 FormalParameterList parameters = parseFormalParameterList(); | 2634 FormalParameterList parameters = parseFormalParameterList(); |
2548 if (methodName.name == className) { | 2635 if (methodName.name == className) { |
2549 _reportErrorForNode(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type); | 2636 _reportErrorForNode(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type); |
2550 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword, | 2637 return _parseConstructor( |
2638 commentAndMetadata, | |
2639 modifiers.externalKeyword, | |
2551 _validateModifiersForConstructor(modifiers), | 2640 _validateModifiersForConstructor(modifiers), |
2552 modifiers.factoryKeyword, methodName, null, null, parameters); | 2641 modifiers.factoryKeyword, |
2642 methodName, | |
2643 null, | |
2644 null, | |
2645 parameters); | |
2553 } | 2646 } |
2554 _validateModifiersForGetterOrSetterOrMethod(modifiers); | 2647 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
2555 _validateFormalParameterList(parameters); | 2648 _validateFormalParameterList(parameters); |
2556 return _parseMethodDeclarationAfterParameters(commentAndMetadata, | 2649 return _parseMethodDeclarationAfterParameters( |
2557 modifiers.externalKeyword, modifiers.staticKeyword, type, methodName, | 2650 commentAndMetadata, |
2558 null, parameters); | 2651 modifiers.externalKeyword, |
2652 modifiers.staticKeyword, | |
2653 type, | |
2654 methodName, | |
2655 null, | |
2656 parameters); | |
2559 } else if (parseGenericMethods && _tokenMatches(_peek(), TokenType.LT)) { | 2657 } else if (parseGenericMethods && _tokenMatches(_peek(), TokenType.LT)) { |
2560 return _parseMethodDeclarationAfterReturnType(commentAndMetadata, | 2658 return _parseMethodDeclarationAfterReturnType(commentAndMetadata, |
2561 modifiers.externalKeyword, modifiers.staticKeyword, type); | 2659 modifiers.externalKeyword, modifiers.staticKeyword, type); |
2562 } else if (_tokenMatches(_peek(), TokenType.OPEN_CURLY_BRACKET)) { | 2660 } else if (_tokenMatches(_peek(), TokenType.OPEN_CURLY_BRACKET)) { |
2563 // We have found "TypeName identifier {", and are guessing that this is a | 2661 // We have found "TypeName identifier {", and are guessing that this is a |
2564 // getter without the keyword 'get'. | 2662 // getter without the keyword 'get'. |
2565 _validateModifiersForGetterOrSetterOrMethod(modifiers); | 2663 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
2566 _reportErrorForCurrentToken(ParserErrorCode.MISSING_GET); | 2664 _reportErrorForCurrentToken(ParserErrorCode.MISSING_GET); |
2567 _currentToken = _injectToken( | 2665 _currentToken = _injectToken( |
2568 new Parser_SyntheticKeywordToken(Keyword.GET, _currentToken.offset)); | 2666 new Parser_SyntheticKeywordToken(Keyword.GET, _currentToken.offset)); |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3185 if (parseGenericMethods && _matches(TokenType.LT)) { | 3283 if (parseGenericMethods && _matches(TokenType.LT)) { |
3186 typeParameters = parseTypeParameterList(); | 3284 typeParameters = parseTypeParameterList(); |
3187 } | 3285 } |
3188 if (_matches(TokenType.OPEN_PAREN)) { | 3286 if (_matches(TokenType.OPEN_PAREN)) { |
3189 FormalParameterList parameters = parseFormalParameterList(); | 3287 FormalParameterList parameters = parseFormalParameterList(); |
3190 if (thisKeyword == null) { | 3288 if (thisKeyword == null) { |
3191 if (holder.keyword != null) { | 3289 if (holder.keyword != null) { |
3192 _reportErrorForToken( | 3290 _reportErrorForToken( |
3193 ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.keyword); | 3291 ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.keyword); |
3194 } | 3292 } |
3195 return new FunctionTypedFormalParameter(commentAndMetadata.comment, | 3293 return new FunctionTypedFormalParameter( |
3196 commentAndMetadata.metadata, holder.type, identifier, | 3294 commentAndMetadata.comment, |
3197 typeParameters, parameters); | 3295 commentAndMetadata.metadata, |
3296 holder.type, | |
3297 identifier, | |
3298 typeParameters, | |
3299 parameters); | |
3198 } else { | 3300 } else { |
3199 return new FieldFormalParameter(commentAndMetadata.comment, | 3301 return new FieldFormalParameter( |
3200 commentAndMetadata.metadata, holder.keyword, holder.type, | 3302 commentAndMetadata.comment, |
3201 thisKeyword, period, identifier, typeParameters, parameters); | 3303 commentAndMetadata.metadata, |
3304 holder.keyword, | |
3305 holder.type, | |
3306 thisKeyword, | |
3307 period, | |
3308 identifier, | |
3309 typeParameters, | |
3310 parameters); | |
3202 } | 3311 } |
3203 } else if (typeParameters != null) { | 3312 } else if (typeParameters != null) { |
3204 // TODO(brianwilkerson) Report an error. It looks like a function-typed | 3313 // TODO(brianwilkerson) Report an error. It looks like a function-typed |
3205 // parameter with no parameter list. | 3314 // parameter with no parameter list. |
3206 //_reportErrorForToken(ParserErrorCode.MISSING_PARAMETERS, typeParameters. endToken); | 3315 //_reportErrorForToken(ParserErrorCode.MISSING_PARAMETERS, typeParameters. endToken); |
3207 } | 3316 } |
3208 TypeName type = holder.type; | 3317 TypeName type = holder.type; |
3209 if (type != null) { | 3318 if (type != null) { |
3210 if (_tokenMatchesKeyword(type.name.beginToken, Keyword.VOID)) { | 3319 if (_tokenMatchesKeyword(type.name.beginToken, Keyword.VOID)) { |
3211 _reportErrorForToken( | 3320 _reportErrorForToken( |
3212 ParserErrorCode.VOID_PARAMETER, type.name.beginToken); | 3321 ParserErrorCode.VOID_PARAMETER, type.name.beginToken); |
3213 } else if (holder.keyword != null && | 3322 } else if (holder.keyword != null && |
3214 _tokenMatchesKeyword(holder.keyword, Keyword.VAR)) { | 3323 _tokenMatchesKeyword(holder.keyword, Keyword.VAR)) { |
3215 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.keyword); | 3324 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.keyword); |
3216 } | 3325 } |
3217 } | 3326 } |
3218 if (thisKeyword != null) { | 3327 if (thisKeyword != null) { |
3219 // TODO(brianwilkerson) If there are type parameters but no parameters, | 3328 // TODO(brianwilkerson) If there are type parameters but no parameters, |
3220 // should we create a synthetic empty parameter list here so we can | 3329 // should we create a synthetic empty parameter list here so we can |
3221 // capture the type parameters? | 3330 // capture the type parameters? |
3222 return new FieldFormalParameter(commentAndMetadata.comment, | 3331 return new FieldFormalParameter( |
3223 commentAndMetadata.metadata, holder.keyword, holder.type, thisKeyword, | 3332 commentAndMetadata.comment, |
3224 period, identifier, null, null); | 3333 commentAndMetadata.metadata, |
3334 holder.keyword, | |
3335 holder.type, | |
3336 thisKeyword, | |
3337 period, | |
3338 identifier, | |
3339 null, | |
3340 null); | |
3225 } | 3341 } |
3226 return new SimpleFormalParameter(commentAndMetadata.comment, | 3342 return new SimpleFormalParameter(commentAndMetadata.comment, |
3227 commentAndMetadata.metadata, holder.keyword, holder.type, identifier); | 3343 commentAndMetadata.metadata, holder.keyword, holder.type, identifier); |
3228 } | 3344 } |
3229 | 3345 |
3230 /** | 3346 /** |
3231 * Parse a prefixed identifier. Return the prefixed identifier that was | 3347 * Parse a prefixed identifier. Return the prefixed identifier that was |
3232 * parsed. | 3348 * parsed. |
3233 * | 3349 * |
3234 * prefixedIdentifier ::= | 3350 * prefixedIdentifier ::= |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3501 } | 3617 } |
3502 return buffer.toString(); | 3618 return buffer.toString(); |
3503 } | 3619 } |
3504 | 3620 |
3505 /** | 3621 /** |
3506 * Convert the given [method] declaration into the nearest valid top-level | 3622 * Convert the given [method] declaration into the nearest valid top-level |
3507 * function declaration (that is, the function declaration that most closely | 3623 * function declaration (that is, the function declaration that most closely |
3508 * captures the components of the given method declaration). | 3624 * captures the components of the given method declaration). |
3509 */ | 3625 */ |
3510 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => | 3626 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => |
3511 new FunctionDeclaration(method.documentationComment, method.metadata, | 3627 new FunctionDeclaration( |
3512 method.externalKeyword, method.returnType, method.propertyKeyword, | 3628 method.documentationComment, |
3513 method.name, new FunctionExpression( | 3629 method.metadata, |
3630 method.externalKeyword, | |
3631 method.returnType, | |
3632 method.propertyKeyword, | |
3633 method.name, | |
3634 new FunctionExpression( | |
3514 method.typeParameters, method.parameters, method.body)); | 3635 method.typeParameters, method.parameters, method.body)); |
3515 | 3636 |
3516 /** | 3637 /** |
3517 * Return `true` if the current token could be the start of a compilation unit | 3638 * Return `true` if the current token could be the start of a compilation unit |
3518 * member. This method is used for recovery purposes to decide when to stop | 3639 * member. This method is used for recovery purposes to decide when to stop |
3519 * skipping tokens after finding an error while parsing a compilation unit | 3640 * skipping tokens after finding an error while parsing a compilation unit |
3520 * member. | 3641 * member. |
3521 */ | 3642 */ |
3522 bool _couldBeStartOfCompilationUnitMember() { | 3643 bool _couldBeStartOfCompilationUnitMember() { |
3523 if ((_matchesKeyword(Keyword.IMPORT) || | 3644 if ((_matchesKeyword(Keyword.IMPORT) || |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4186 } else if (expression is CascadeExpression) { | 4307 } else if (expression is CascadeExpression) { |
4187 _reportErrorForNode( | 4308 _reportErrorForNode( |
4188 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression); | 4309 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression); |
4189 } else if (expression is ThrowExpression) { | 4310 } else if (expression is ThrowExpression) { |
4190 _reportErrorForNode( | 4311 _reportErrorForNode( |
4191 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression); | 4312 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression); |
4192 } else if (expression is RethrowExpression) { | 4313 } else if (expression is RethrowExpression) { |
4193 _reportErrorForNode( | 4314 _reportErrorForNode( |
4194 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression); | 4315 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression); |
4195 } | 4316 } |
4317 Token comma; | |
4318 Expression message; | |
4319 if (enableAssertMessage && _matches(TokenType.COMMA)) { | |
Brian Wilkerson
2015/09/02 15:49:16
An alternative would be to always parse the messag
Paul Berry
2015/09/02 17:20:03
I like this idea. I'll rework the CL.
| |
4320 comma = getAndAdvance(); | |
4321 message = parseExpression2(); | |
4322 } | |
4196 Token rightParen = _expect(TokenType.CLOSE_PAREN); | 4323 Token rightParen = _expect(TokenType.CLOSE_PAREN); |
4197 Token semicolon = _expect(TokenType.SEMICOLON); | 4324 Token semicolon = _expect(TokenType.SEMICOLON); |
4198 return new AssertStatement( | 4325 return new AssertStatement( |
4199 keyword, leftParen, expression, rightParen, semicolon); | 4326 keyword, leftParen, expression, rightParen, semicolon, |
4327 comma: comma, message: message); | |
4200 } | 4328 } |
4201 | 4329 |
4202 /** | 4330 /** |
4203 * Parse an assignable expression. The [primaryAllowed] is `true` if the | 4331 * Parse an assignable expression. The [primaryAllowed] is `true` if the |
4204 * expression is allowed to be a primary without any assignable selector. | 4332 * expression is allowed to be a primary without any assignable selector. |
4205 * Return the assignable expression that was parsed. | 4333 * Return the assignable expression that was parsed. |
4206 * | 4334 * |
4207 * assignableExpression ::= | 4335 * assignableExpression ::= |
4208 * primary (arguments* assignableSelector)+ | 4336 * primary (arguments* assignableSelector)+ |
4209 * | 'super' unconditionalAssignableSelector | 4337 * | 'super' unconditionalAssignableSelector |
4210 * | identifier | 4338 * | identifier |
4211 */ | 4339 */ |
4212 Expression _parseAssignableExpression(bool primaryAllowed) { | 4340 Expression _parseAssignableExpression(bool primaryAllowed) { |
4213 if (_matchesKeyword(Keyword.SUPER)) { | 4341 if (_matchesKeyword(Keyword.SUPER)) { |
4214 return _parseAssignableSelector( | 4342 return _parseAssignableSelector( |
4215 new SuperExpression(getAndAdvance()), false, allowConditional: false); | 4343 new SuperExpression(getAndAdvance()), false, |
4344 allowConditional: false); | |
4216 } | 4345 } |
4217 // | 4346 // |
4218 // A primary expression can start with an identifier. We resolve the | 4347 // A primary expression can start with an identifier. We resolve the |
4219 // ambiguity by determining whether the primary consists of anything other | 4348 // ambiguity by determining whether the primary consists of anything other |
4220 // than an identifier and/or is followed by an assignableSelector. | 4349 // than an identifier and/or is followed by an assignableSelector. |
4221 // | 4350 // |
4222 Expression expression = _parsePrimaryExpression(); | 4351 Expression expression = _parsePrimaryExpression(); |
4223 bool isOptional = primaryAllowed || expression is SimpleIdentifier; | 4352 bool isOptional = primaryAllowed || expression is SimpleIdentifier; |
4224 while (true) { | 4353 while (true) { |
4225 while (_isLikelyParameterList()) { | 4354 while (_isLikelyParameterList()) { |
4226 TypeArgumentList typeArguments = null; | 4355 TypeArgumentList typeArguments = null; |
4227 if (_matches(TokenType.LT)) { | 4356 if (_matches(TokenType.LT)) { |
4228 typeArguments = parseTypeArgumentList(); | 4357 typeArguments = parseTypeArgumentList(); |
4229 } | 4358 } |
4230 ArgumentList argumentList = parseArgumentList(); | 4359 ArgumentList argumentList = parseArgumentList(); |
4231 if (expression is SimpleIdentifier) { | 4360 if (expression is SimpleIdentifier) { |
4232 expression = new MethodInvocation(null, null, | 4361 expression = new MethodInvocation(null, null, |
4233 expression as SimpleIdentifier, typeArguments, argumentList); | 4362 expression as SimpleIdentifier, typeArguments, argumentList); |
4234 } else if (expression is PrefixedIdentifier) { | 4363 } else if (expression is PrefixedIdentifier) { |
4235 PrefixedIdentifier identifier = expression as PrefixedIdentifier; | 4364 PrefixedIdentifier identifier = expression as PrefixedIdentifier; |
4236 expression = new MethodInvocation(identifier.prefix, | 4365 expression = new MethodInvocation( |
4237 identifier.period, identifier.identifier, typeArguments, | 4366 identifier.prefix, |
4367 identifier.period, | |
4368 identifier.identifier, | |
4369 typeArguments, | |
4238 argumentList); | 4370 argumentList); |
4239 } else if (expression is PropertyAccess) { | 4371 } else if (expression is PropertyAccess) { |
4240 PropertyAccess access = expression as PropertyAccess; | 4372 PropertyAccess access = expression as PropertyAccess; |
4241 expression = new MethodInvocation(access.target, access.operator, | 4373 expression = new MethodInvocation(access.target, access.operator, |
4242 access.propertyName, typeArguments, argumentList); | 4374 access.propertyName, typeArguments, argumentList); |
4243 } else { | 4375 } else { |
4244 expression = new FunctionExpressionInvocation( | 4376 expression = new FunctionExpressionInvocation( |
4245 expression, typeArguments, argumentList); | 4377 expression, typeArguments, argumentList); |
4246 } | 4378 } |
4247 if (!primaryAllowed) { | 4379 if (!primaryAllowed) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4462 if (!identical(selector, expression)) { | 4594 if (!identical(selector, expression)) { |
4463 expression = selector; | 4595 expression = selector; |
4464 progress = true; | 4596 progress = true; |
4465 while (_isLikelyParameterList()) { | 4597 while (_isLikelyParameterList()) { |
4466 TypeArgumentList typeArguments = null; | 4598 TypeArgumentList typeArguments = null; |
4467 if (_matches(TokenType.LT)) { | 4599 if (_matches(TokenType.LT)) { |
4468 typeArguments = parseTypeArgumentList(); | 4600 typeArguments = parseTypeArgumentList(); |
4469 } | 4601 } |
4470 if (expression is PropertyAccess) { | 4602 if (expression is PropertyAccess) { |
4471 PropertyAccess propertyAccess = expression as PropertyAccess; | 4603 PropertyAccess propertyAccess = expression as PropertyAccess; |
4472 expression = new MethodInvocation(propertyAccess.target, | 4604 expression = new MethodInvocation( |
4473 propertyAccess.operator, propertyAccess.propertyName, | 4605 propertyAccess.target, |
4474 typeArguments, parseArgumentList()); | 4606 propertyAccess.operator, |
4607 propertyAccess.propertyName, | |
4608 typeArguments, | |
4609 parseArgumentList()); | |
4475 } else { | 4610 } else { |
4476 expression = new FunctionExpressionInvocation( | 4611 expression = new FunctionExpressionInvocation( |
4477 expression, typeArguments, parseArgumentList()); | 4612 expression, typeArguments, parseArgumentList()); |
4478 } | 4613 } |
4479 } | 4614 } |
4480 } | 4615 } |
4481 } | 4616 } |
4482 if (_currentToken.type.isAssignmentOperator) { | 4617 if (_currentToken.type.isAssignmentOperator) { |
4483 Token operator = getAndAdvance(); | 4618 Token operator = getAndAdvance(); |
4484 _ensureAssignable(expression); | 4619 _ensureAssignable(expression); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4593 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { | 4728 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
4594 leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); | 4729 leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); |
4595 members = _parseClassMembers(className, _getEndToken(leftBracket)); | 4730 members = _parseClassMembers(className, _getEndToken(leftBracket)); |
4596 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); | 4731 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); |
4597 } else { | 4732 } else { |
4598 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); | 4733 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); |
4599 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); | 4734 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); |
4600 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CLASS_BODY); | 4735 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CLASS_BODY); |
4601 } | 4736 } |
4602 ClassDeclaration classDeclaration = new ClassDeclaration( | 4737 ClassDeclaration classDeclaration = new ClassDeclaration( |
4603 commentAndMetadata.comment, commentAndMetadata.metadata, | 4738 commentAndMetadata.comment, |
4604 abstractKeyword, keyword, name, typeParameters, extendsClause, | 4739 commentAndMetadata.metadata, |
4605 withClause, implementsClause, leftBracket, members, rightBracket); | 4740 abstractKeyword, |
4741 keyword, | |
4742 name, | |
4743 typeParameters, | |
4744 extendsClause, | |
4745 withClause, | |
4746 implementsClause, | |
4747 leftBracket, | |
4748 members, | |
4749 rightBracket); | |
4606 classDeclaration.nativeClause = nativeClause; | 4750 classDeclaration.nativeClause = nativeClause; |
4607 return classDeclaration; | 4751 return classDeclaration; |
4608 } | 4752 } |
4609 | 4753 |
4610 /** | 4754 /** |
4611 * Parse a list of class members. The [className] is the name of the class | 4755 * Parse a list of class members. The [className] is the name of the class |
4612 * whose members are being parsed. The [closingBracket] is the closing bracket | 4756 * whose members are being parsed. The [closingBracket] is the closing bracket |
4613 * for the class, or `null` if the closing bracket is missing. Return the list | 4757 * for the class, or `null` if the closing bracket is missing. Return the list |
4614 * of class members that were parsed. | 4758 * of class members that were parsed. |
4615 * | 4759 * |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4685 ParserErrorCode.EXPECTED_TOKEN, [TokenType.SEMICOLON.lexeme]); | 4829 ParserErrorCode.EXPECTED_TOKEN, [TokenType.SEMICOLON.lexeme]); |
4686 Token leftBracket = getAndAdvance(); | 4830 Token leftBracket = getAndAdvance(); |
4687 _parseClassMembers(className.name, _getEndToken(leftBracket)); | 4831 _parseClassMembers(className.name, _getEndToken(leftBracket)); |
4688 _expect(TokenType.CLOSE_CURLY_BRACKET); | 4832 _expect(TokenType.CLOSE_CURLY_BRACKET); |
4689 } else { | 4833 } else { |
4690 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, | 4834 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, |
4691 _currentToken.previous, [TokenType.SEMICOLON.lexeme]); | 4835 _currentToken.previous, [TokenType.SEMICOLON.lexeme]); |
4692 } | 4836 } |
4693 semicolon = _createSyntheticToken(TokenType.SEMICOLON); | 4837 semicolon = _createSyntheticToken(TokenType.SEMICOLON); |
4694 } | 4838 } |
4695 return new ClassTypeAlias(commentAndMetadata.comment, | 4839 return new ClassTypeAlias( |
4696 commentAndMetadata.metadata, classKeyword, className, typeParameters, | 4840 commentAndMetadata.comment, |
4697 equals, abstractKeyword, superclass, withClause, implementsClause, | 4841 commentAndMetadata.metadata, |
4842 classKeyword, | |
4843 className, | |
4844 typeParameters, | |
4845 equals, | |
4846 abstractKeyword, | |
4847 superclass, | |
4848 withClause, | |
4849 implementsClause, | |
4698 semicolon); | 4850 semicolon); |
4699 } | 4851 } |
4700 | 4852 |
4701 /** | 4853 /** |
4702 * Parse a list of combinators in a directive. Return the combinators that | 4854 * Parse a list of combinators in a directive. Return the combinators that |
4703 * were parsed. | 4855 * were parsed. |
4704 * | 4856 * |
4705 * combinator ::= | 4857 * combinator ::= |
4706 * 'show' identifier (',' identifier)* | 4858 * 'show' identifier (',' identifier)* |
4707 * | 'hide' identifier (',' identifier)* | 4859 * | 'hide' identifier (',' identifier)* |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4917 _tokenMatchesIdentifier(_peek())) { | 5069 _tokenMatchesIdentifier(_peek())) { |
4918 _validateModifiersForTopLevelFunction(modifiers); | 5070 _validateModifiersForTopLevelFunction(modifiers); |
4919 return _parseFunctionDeclaration( | 5071 return _parseFunctionDeclaration( |
4920 commentAndMetadata, modifiers.externalKeyword, returnType); | 5072 commentAndMetadata, modifiers.externalKeyword, returnType); |
4921 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { | 5073 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
4922 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken); | 5074 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken); |
4923 return _convertToFunctionDeclaration(_parseOperator( | 5075 return _convertToFunctionDeclaration(_parseOperator( |
4924 commentAndMetadata, modifiers.externalKeyword, returnType)); | 5076 commentAndMetadata, modifiers.externalKeyword, returnType)); |
4925 } else if (_matchesIdentifier() && | 5077 } else if (_matchesIdentifier() && |
4926 _peek().matchesAny([ | 5078 _peek().matchesAny([ |
4927 TokenType.OPEN_PAREN, | 5079 TokenType.OPEN_PAREN, |
4928 TokenType.OPEN_CURLY_BRACKET, | 5080 TokenType.OPEN_CURLY_BRACKET, |
4929 TokenType.FUNCTION | 5081 TokenType.FUNCTION |
4930 ])) { | 5082 ])) { |
4931 _validateModifiersForTopLevelFunction(modifiers); | 5083 _validateModifiersForTopLevelFunction(modifiers); |
4932 return _parseFunctionDeclaration( | 5084 return _parseFunctionDeclaration( |
4933 commentAndMetadata, modifiers.externalKeyword, returnType); | 5085 commentAndMetadata, modifiers.externalKeyword, returnType); |
4934 } else { | 5086 } else { |
4935 // | 5087 // |
4936 // We have found an error of some kind. Try to recover. | 5088 // We have found an error of some kind. Try to recover. |
4937 // | 5089 // |
4938 if (_matchesIdentifier()) { | 5090 if (_matchesIdentifier()) { |
4939 if (_peek().matchesAny( | 5091 if (_peek().matchesAny( |
4940 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { | 5092 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { |
4941 // | 5093 // |
4942 // We appear to have a variable declaration with a type of "void". | 5094 // We appear to have a variable declaration with a type of "void". |
4943 // | 5095 // |
4944 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); | 5096 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); |
4945 return new TopLevelVariableDeclaration(commentAndMetadata.comment, | 5097 return new TopLevelVariableDeclaration( |
5098 commentAndMetadata.comment, | |
4946 commentAndMetadata.metadata, | 5099 commentAndMetadata.metadata, |
4947 _parseVariableDeclarationListAfterType(null, | 5100 _parseVariableDeclarationListAfterType(null, |
4948 _validateModifiersForTopLevelVariable(modifiers), null), | 5101 _validateModifiersForTopLevelVariable(modifiers), null), |
4949 _expect(TokenType.SEMICOLON)); | 5102 _expect(TokenType.SEMICOLON)); |
4950 } | 5103 } |
4951 } | 5104 } |
4952 _reportErrorForToken( | 5105 _reportErrorForToken( |
4953 ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); | 5106 ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); |
4954 return null; | 5107 return null; |
4955 } | 5108 } |
(...skipping 15 matching lines...) Expand all Loading... | |
4971 keyword = modifiers.constKeyword; | 5124 keyword = modifiers.constKeyword; |
4972 } | 5125 } |
4973 if (keyword != null) { | 5126 if (keyword != null) { |
4974 // | 5127 // |
4975 // We appear to have found an incomplete top-level variable declaration. | 5128 // We appear to have found an incomplete top-level variable declaration. |
4976 // | 5129 // |
4977 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); | 5130 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); |
4978 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 5131 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
4979 variables.add( | 5132 variables.add( |
4980 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); | 5133 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); |
4981 return new TopLevelVariableDeclaration(commentAndMetadata.comment, | 5134 return new TopLevelVariableDeclaration( |
5135 commentAndMetadata.comment, | |
4982 commentAndMetadata.metadata, | 5136 commentAndMetadata.metadata, |
4983 new VariableDeclarationList(null, null, keyword, null, variables), | 5137 new VariableDeclarationList(null, null, keyword, null, variables), |
4984 _expectSemicolon()); | 5138 _expectSemicolon()); |
4985 } | 5139 } |
4986 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); | 5140 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); |
4987 return null; | 5141 return null; |
4988 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { | 5142 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
4989 _validateModifiersForTopLevelFunction(modifiers); | 5143 _validateModifiersForTopLevelFunction(modifiers); |
4990 return _parseFunctionDeclaration( | 5144 return _parseFunctionDeclaration( |
4991 commentAndMetadata, modifiers.externalKeyword, null); | 5145 commentAndMetadata, modifiers.externalKeyword, null); |
4992 } else if (_peek() | 5146 } else if (_peek() |
4993 .matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { | 5147 .matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { |
4994 if (modifiers.constKeyword == null && | 5148 if (modifiers.constKeyword == null && |
4995 modifiers.finalKeyword == null && | 5149 modifiers.finalKeyword == null && |
4996 modifiers.varKeyword == null) { | 5150 modifiers.varKeyword == null) { |
4997 _reportErrorForCurrentToken( | 5151 _reportErrorForCurrentToken( |
4998 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE); | 5152 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE); |
4999 } | 5153 } |
5000 return new TopLevelVariableDeclaration(commentAndMetadata.comment, | 5154 return new TopLevelVariableDeclaration( |
5001 commentAndMetadata.metadata, _parseVariableDeclarationListAfterType( | 5155 commentAndMetadata.comment, |
5156 commentAndMetadata.metadata, | |
5157 _parseVariableDeclarationListAfterType( | |
5002 null, _validateModifiersForTopLevelVariable(modifiers), null), | 5158 null, _validateModifiersForTopLevelVariable(modifiers), null), |
5003 _expect(TokenType.SEMICOLON)); | 5159 _expect(TokenType.SEMICOLON)); |
5004 } | 5160 } |
5005 TypeName returnType = parseReturnType(); | 5161 TypeName returnType = parseReturnType(); |
5006 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && | 5162 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && |
5007 _tokenMatchesIdentifier(_peek())) { | 5163 _tokenMatchesIdentifier(_peek())) { |
5008 _validateModifiersForTopLevelFunction(modifiers); | 5164 _validateModifiersForTopLevelFunction(modifiers); |
5009 return _parseFunctionDeclaration( | 5165 return _parseFunctionDeclaration( |
5010 commentAndMetadata, modifiers.externalKeyword, returnType); | 5166 commentAndMetadata, modifiers.externalKeyword, returnType); |
5011 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { | 5167 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
5012 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken); | 5168 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken); |
5013 return _convertToFunctionDeclaration(_parseOperator( | 5169 return _convertToFunctionDeclaration(_parseOperator( |
5014 commentAndMetadata, modifiers.externalKeyword, returnType)); | 5170 commentAndMetadata, modifiers.externalKeyword, returnType)); |
5015 } else if (_matches(TokenType.AT)) { | 5171 } else if (_matches(TokenType.AT)) { |
5016 return new TopLevelVariableDeclaration(commentAndMetadata.comment, | 5172 return new TopLevelVariableDeclaration( |
5017 commentAndMetadata.metadata, _parseVariableDeclarationListAfterType( | 5173 commentAndMetadata.comment, |
5018 null, _validateModifiersForTopLevelVariable(modifiers), | 5174 commentAndMetadata.metadata, |
5019 returnType), _expect(TokenType.SEMICOLON)); | 5175 _parseVariableDeclarationListAfterType(null, |
5176 _validateModifiersForTopLevelVariable(modifiers), returnType), | |
5177 _expect(TokenType.SEMICOLON)); | |
5020 } else if (!_matchesIdentifier()) { | 5178 } else if (!_matchesIdentifier()) { |
5021 // TODO(brianwilkerson) Generalize this error. We could also be parsing a | 5179 // TODO(brianwilkerson) Generalize this error. We could also be parsing a |
5022 // top-level variable at this point. | 5180 // top-level variable at this point. |
5023 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); | 5181 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); |
5024 Token semicolon; | 5182 Token semicolon; |
5025 if (_matches(TokenType.SEMICOLON)) { | 5183 if (_matches(TokenType.SEMICOLON)) { |
5026 semicolon = getAndAdvance(); | 5184 semicolon = getAndAdvance(); |
5027 } else { | 5185 } else { |
5028 semicolon = _createSyntheticToken(TokenType.SEMICOLON); | 5186 semicolon = _createSyntheticToken(TokenType.SEMICOLON); |
5029 } | 5187 } |
5030 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 5188 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
5031 variables.add( | 5189 variables.add( |
5032 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); | 5190 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); |
5033 return new TopLevelVariableDeclaration(commentAndMetadata.comment, | 5191 return new TopLevelVariableDeclaration( |
5192 commentAndMetadata.comment, | |
5034 commentAndMetadata.metadata, | 5193 commentAndMetadata.metadata, |
5035 new VariableDeclarationList(null, null, null, returnType, variables), | 5194 new VariableDeclarationList(null, null, null, returnType, variables), |
5036 semicolon); | 5195 semicolon); |
5037 } | 5196 } |
5038 if (_peek().matchesAny([ | 5197 if (_peek().matchesAny([ |
5039 TokenType.OPEN_PAREN, | 5198 TokenType.OPEN_PAREN, |
5040 TokenType.FUNCTION, | 5199 TokenType.FUNCTION, |
5041 TokenType.OPEN_CURLY_BRACKET | 5200 TokenType.OPEN_CURLY_BRACKET |
5042 ])) { | 5201 ])) { |
5043 _validateModifiersForTopLevelFunction(modifiers); | 5202 _validateModifiersForTopLevelFunction(modifiers); |
5044 return _parseFunctionDeclaration( | 5203 return _parseFunctionDeclaration( |
5045 commentAndMetadata, modifiers.externalKeyword, returnType); | 5204 commentAndMetadata, modifiers.externalKeyword, returnType); |
5046 } | 5205 } |
5047 return new TopLevelVariableDeclaration(commentAndMetadata.comment, | 5206 return new TopLevelVariableDeclaration( |
5048 commentAndMetadata.metadata, _parseVariableDeclarationListAfterType( | 5207 commentAndMetadata.comment, |
5208 commentAndMetadata.metadata, | |
5209 _parseVariableDeclarationListAfterType( | |
5049 null, _validateModifiersForTopLevelVariable(modifiers), returnType), | 5210 null, _validateModifiersForTopLevelVariable(modifiers), returnType), |
5050 _expect(TokenType.SEMICOLON)); | 5211 _expect(TokenType.SEMICOLON)); |
5051 } | 5212 } |
5052 | 5213 |
5053 /** | 5214 /** |
5054 * Parse a const expression. Return the const expression that was parsed. | 5215 * Parse a const expression. Return the const expression that was parsed. |
5055 * | 5216 * |
5056 * constExpression ::= | 5217 * constExpression ::= |
5057 * instanceCreationExpression | 5218 * instanceCreationExpression |
5058 * | listLiteral | 5219 * | listLiteral |
5059 * | mapLiteral | 5220 * | mapLiteral |
5060 */ | 5221 */ |
5061 Expression _parseConstExpression() { | 5222 Expression _parseConstExpression() { |
5062 Token keyword = _expectKeyword(Keyword.CONST); | 5223 Token keyword = _expectKeyword(Keyword.CONST); |
5063 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.INDEX)) { | 5224 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.INDEX)) { |
5064 return _parseListLiteral(keyword, null); | 5225 return _parseListLiteral(keyword, null); |
5065 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) { | 5226 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
5066 return _parseMapLiteral(keyword, null); | 5227 return _parseMapLiteral(keyword, null); |
5067 } else if (_matches(TokenType.LT)) { | 5228 } else if (_matches(TokenType.LT)) { |
5068 return _parseListOrMapLiteral(keyword); | 5229 return _parseListOrMapLiteral(keyword); |
5069 } | 5230 } |
5070 return _parseInstanceCreationExpression(keyword); | 5231 return _parseInstanceCreationExpression(keyword); |
5071 } | 5232 } |
5072 | 5233 |
5073 ConstructorDeclaration _parseConstructor( | 5234 ConstructorDeclaration _parseConstructor( |
5074 CommentAndMetadata commentAndMetadata, Token externalKeyword, | 5235 CommentAndMetadata commentAndMetadata, |
5075 Token constKeyword, Token factoryKeyword, SimpleIdentifier returnType, | 5236 Token externalKeyword, |
5076 Token period, SimpleIdentifier name, FormalParameterList parameters) { | 5237 Token constKeyword, |
5238 Token factoryKeyword, | |
5239 SimpleIdentifier returnType, | |
5240 Token period, | |
5241 SimpleIdentifier name, | |
5242 FormalParameterList parameters) { | |
5077 bool bodyAllowed = externalKeyword == null; | 5243 bool bodyAllowed = externalKeyword == null; |
5078 Token separator = null; | 5244 Token separator = null; |
5079 List<ConstructorInitializer> initializers = null; | 5245 List<ConstructorInitializer> initializers = null; |
5080 if (_matches(TokenType.COLON)) { | 5246 if (_matches(TokenType.COLON)) { |
5081 separator = getAndAdvance(); | 5247 separator = getAndAdvance(); |
5082 initializers = new List<ConstructorInitializer>(); | 5248 initializers = new List<ConstructorInitializer>(); |
5083 do { | 5249 do { |
5084 if (_matchesKeyword(Keyword.THIS)) { | 5250 if (_matchesKeyword(Keyword.THIS)) { |
5085 if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { | 5251 if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
5086 bodyAllowed = false; | 5252 bodyAllowed = false; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5134 } else { | 5300 } else { |
5135 if (constKeyword != null) { | 5301 if (constKeyword != null) { |
5136 _reportErrorForNode( | 5302 _reportErrorForNode( |
5137 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body); | 5303 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body); |
5138 } else if (!bodyAllowed) { | 5304 } else if (!bodyAllowed) { |
5139 _reportErrorForNode( | 5305 _reportErrorForNode( |
5140 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body); | 5306 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body); |
5141 } | 5307 } |
5142 } | 5308 } |
5143 } | 5309 } |
5144 return new ConstructorDeclaration(commentAndMetadata.comment, | 5310 return new ConstructorDeclaration( |
5145 commentAndMetadata.metadata, externalKeyword, constKeyword, | 5311 commentAndMetadata.comment, |
5146 factoryKeyword, returnType, period, name, parameters, separator, | 5312 commentAndMetadata.metadata, |
5147 initializers, redirectedConstructor, body); | 5313 externalKeyword, |
5314 constKeyword, | |
5315 factoryKeyword, | |
5316 returnType, | |
5317 period, | |
5318 name, | |
5319 parameters, | |
5320 separator, | |
5321 initializers, | |
5322 redirectedConstructor, | |
5323 body); | |
5148 } | 5324 } |
5149 | 5325 |
5150 /** | 5326 /** |
5151 * Parse a field initializer within a constructor. Return the field | 5327 * Parse a field initializer within a constructor. Return the field |
5152 * initializer that was parsed. | 5328 * initializer that was parsed. |
5153 * | 5329 * |
5154 * fieldInitializer: | 5330 * fieldInitializer: |
5155 * ('this' '.')? identifier '=' conditionalExpression cascadeSection* | 5331 * ('this' '.')? identifier '=' conditionalExpression cascadeSection* |
5156 */ | 5332 */ |
5157 ConstructorFieldInitializer _parseConstructorFieldInitializer() { | 5333 ConstructorFieldInitializer _parseConstructorFieldInitializer() { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5405 break; | 5581 break; |
5406 } | 5582 } |
5407 constants.add(_parseEnumConstantDeclaration()); | 5583 constants.add(_parseEnumConstantDeclaration()); |
5408 } | 5584 } |
5409 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); | 5585 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); |
5410 } else { | 5586 } else { |
5411 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); | 5587 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); |
5412 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); | 5588 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); |
5413 _reportErrorForCurrentToken(ParserErrorCode.MISSING_ENUM_BODY); | 5589 _reportErrorForCurrentToken(ParserErrorCode.MISSING_ENUM_BODY); |
5414 } | 5590 } |
5415 return new EnumDeclaration(commentAndMetadata.comment, | 5591 return new EnumDeclaration( |
5416 commentAndMetadata.metadata, keyword, name, leftBracket, constants, | 5592 commentAndMetadata.comment, |
5593 commentAndMetadata.metadata, | |
5594 keyword, | |
5595 name, | |
5596 leftBracket, | |
5597 constants, | |
5417 rightBracket); | 5598 rightBracket); |
5418 } | 5599 } |
5419 | 5600 |
5420 /** | 5601 /** |
5421 * Parse an equality expression. Return the equality expression that was | 5602 * Parse an equality expression. Return the equality expression that was |
5422 * parsed. | 5603 * parsed. |
5423 * | 5604 * |
5424 * equalityExpression ::= | 5605 * equalityExpression ::= |
5425 * relationalExpression (equalityOperator relationalExpression)? | 5606 * relationalExpression (equalityOperator relationalExpression)? |
5426 * | 'super' equalityOperator relationalExpression | 5607 * | 'super' equalityOperator relationalExpression |
(...skipping 25 matching lines...) Expand all Loading... | |
5452 * associated with the directive. Return the export directive that was parsed. | 5633 * associated with the directive. Return the export directive that was parsed. |
5453 * | 5634 * |
5454 * exportDirective ::= | 5635 * exportDirective ::= |
5455 * metadata 'export' stringLiteral combinator*';' | 5636 * metadata 'export' stringLiteral combinator*';' |
5456 */ | 5637 */ |
5457 ExportDirective _parseExportDirective(CommentAndMetadata commentAndMetadata) { | 5638 ExportDirective _parseExportDirective(CommentAndMetadata commentAndMetadata) { |
5458 Token exportKeyword = _expectKeyword(Keyword.EXPORT); | 5639 Token exportKeyword = _expectKeyword(Keyword.EXPORT); |
5459 StringLiteral libraryUri = _parseUri(); | 5640 StringLiteral libraryUri = _parseUri(); |
5460 List<Combinator> combinators = _parseCombinators(); | 5641 List<Combinator> combinators = _parseCombinators(); |
5461 Token semicolon = _expectSemicolon(); | 5642 Token semicolon = _expectSemicolon(); |
5462 return new ExportDirective(commentAndMetadata.comment, | 5643 return new ExportDirective( |
5463 commentAndMetadata.metadata, exportKeyword, libraryUri, combinators, | 5644 commentAndMetadata.comment, |
5645 commentAndMetadata.metadata, | |
5646 exportKeyword, | |
5647 libraryUri, | |
5648 combinators, | |
5464 semicolon); | 5649 semicolon); |
5465 } | 5650 } |
5466 | 5651 |
5467 /** | 5652 /** |
5468 * Parse a list of expressions. Return the expression that was parsed. | 5653 * Parse a list of expressions. Return the expression that was parsed. |
5469 * | 5654 * |
5470 * expressionList ::= | 5655 * expressionList ::= |
5471 * expression (',' expression)* | 5656 * expression (',' expression)* |
5472 */ | 5657 */ |
5473 List<Expression> _parseExpressionList() { | 5658 List<Expression> _parseExpressionList() { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5633 // has content | 5818 // has content |
5634 } | 5819 } |
5635 identifier = variable.name; | 5820 identifier = variable.name; |
5636 } | 5821 } |
5637 } | 5822 } |
5638 Token inKeyword = getAndAdvance(); | 5823 Token inKeyword = getAndAdvance(); |
5639 Expression iterator = parseExpression2(); | 5824 Expression iterator = parseExpression2(); |
5640 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); | 5825 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
5641 Statement body = parseStatement2(); | 5826 Statement body = parseStatement2(); |
5642 if (loopVariable == null) { | 5827 if (loopVariable == null) { |
5643 return new ForEachStatement.withReference(awaitKeyword, forKeyword, | 5828 return new ForEachStatement.withReference( |
5644 leftParenthesis, identifier, inKeyword, iterator, | 5829 awaitKeyword, |
5645 rightParenthesis, body); | 5830 forKeyword, |
5831 leftParenthesis, | |
5832 identifier, | |
5833 inKeyword, | |
5834 iterator, | |
5835 rightParenthesis, | |
5836 body); | |
5646 } | 5837 } |
5647 return new ForEachStatement.withDeclaration(awaitKeyword, forKeyword, | 5838 return new ForEachStatement.withDeclaration( |
5648 leftParenthesis, loopVariable, inKeyword, iterator, | 5839 awaitKeyword, |
5649 rightParenthesis, body); | 5840 forKeyword, |
5841 leftParenthesis, | |
5842 loopVariable, | |
5843 inKeyword, | |
5844 iterator, | |
5845 rightParenthesis, | |
5846 body); | |
5650 } | 5847 } |
5651 } | 5848 } |
5652 if (awaitKeyword != null) { | 5849 if (awaitKeyword != null) { |
5653 _reportErrorForToken( | 5850 _reportErrorForToken( |
5654 ParserErrorCode.INVALID_AWAIT_IN_FOR, awaitKeyword); | 5851 ParserErrorCode.INVALID_AWAIT_IN_FOR, awaitKeyword); |
5655 } | 5852 } |
5656 Token leftSeparator = _expect(TokenType.SEMICOLON); | 5853 Token leftSeparator = _expect(TokenType.SEMICOLON); |
5657 Expression condition = null; | 5854 Expression condition = null; |
5658 if (!_matches(TokenType.SEMICOLON)) { | 5855 if (!_matches(TokenType.SEMICOLON)) { |
5659 condition = parseExpression2(); | 5856 condition = parseExpression2(); |
5660 } | 5857 } |
5661 Token rightSeparator = _expect(TokenType.SEMICOLON); | 5858 Token rightSeparator = _expect(TokenType.SEMICOLON); |
5662 List<Expression> updaters = null; | 5859 List<Expression> updaters = null; |
5663 if (!_matches(TokenType.CLOSE_PAREN)) { | 5860 if (!_matches(TokenType.CLOSE_PAREN)) { |
5664 updaters = _parseExpressionList(); | 5861 updaters = _parseExpressionList(); |
5665 } | 5862 } |
5666 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); | 5863 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
5667 Statement body = parseStatement2(); | 5864 Statement body = parseStatement2(); |
5668 return new ForStatement(forKeyword, leftParenthesis, variableList, | 5865 return new ForStatement( |
5669 initialization, leftSeparator, condition, rightSeparator, updaters, | 5866 forKeyword, |
5670 rightParenthesis, body); | 5867 leftParenthesis, |
5868 variableList, | |
5869 initialization, | |
5870 leftSeparator, | |
5871 condition, | |
5872 rightSeparator, | |
5873 updaters, | |
5874 rightParenthesis, | |
5875 body); | |
5671 } finally { | 5876 } finally { |
5672 _inLoop = wasInLoop; | 5877 _inLoop = wasInLoop; |
5673 } | 5878 } |
5674 } | 5879 } |
5675 | 5880 |
5676 /** | 5881 /** |
5677 * Parse a function body. The [mayBeEmpty] is `true` if the function body is | 5882 * Parse a function body. The [mayBeEmpty] is `true` if the function body is |
5678 * allowed to be empty. The [emptyErrorCode] is the error code to report if | 5883 * allowed to be empty. The [emptyErrorCode] is the error code to report if |
5679 * function body expected, but not found. The [inExpression] is `true` if the | 5884 * function body expected, but not found. The [inExpression] is `true` if the |
5680 * function body is being parsed as part of an expression and therefore does | 5885 * function body is being parsed as part of an expression and therefore does |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5790 * not external. The [returnType] is the return type, or `null` if there is no | 5995 * not external. The [returnType] is the return type, or `null` if there is no |
5791 * return type. The [isStatement] is `true` if the function declaration is | 5996 * return type. The [isStatement] is `true` if the function declaration is |
5792 * being parsed as a statement. Return the function declaration that was | 5997 * being parsed as a statement. Return the function declaration that was |
5793 * parsed. | 5998 * parsed. |
5794 * | 5999 * |
5795 * functionDeclaration ::= | 6000 * functionDeclaration ::= |
5796 * functionSignature functionBody | 6001 * functionSignature functionBody |
5797 * | returnType? getOrSet identifier formalParameterList functionBody | 6002 * | returnType? getOrSet identifier formalParameterList functionBody |
5798 */ | 6003 */ |
5799 FunctionDeclaration _parseFunctionDeclaration( | 6004 FunctionDeclaration _parseFunctionDeclaration( |
5800 CommentAndMetadata commentAndMetadata, Token externalKeyword, | 6005 CommentAndMetadata commentAndMetadata, |
6006 Token externalKeyword, | |
5801 TypeName returnType) { | 6007 TypeName returnType) { |
5802 Token keyword = null; | 6008 Token keyword = null; |
5803 bool isGetter = false; | 6009 bool isGetter = false; |
5804 if (_matchesKeyword(Keyword.GET) && | 6010 if (_matchesKeyword(Keyword.GET) && |
5805 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { | 6011 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
5806 keyword = getAndAdvance(); | 6012 keyword = getAndAdvance(); |
5807 isGetter = true; | 6013 isGetter = true; |
5808 } else if (_matchesKeyword(Keyword.SET) && | 6014 } else if (_matchesKeyword(Keyword.SET) && |
5809 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { | 6015 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
5810 keyword = getAndAdvance(); | 6016 keyword = getAndAdvance(); |
5811 } | 6017 } |
5812 SimpleIdentifier name = parseSimpleIdentifier(); | 6018 SimpleIdentifier name = parseSimpleIdentifier(); |
5813 TypeParameterList typeParameters = null; | 6019 TypeParameterList typeParameters = null; |
5814 if (parseGenericMethods && _matches(TokenType.LT)) { | 6020 if (parseGenericMethods && _matches(TokenType.LT)) { |
5815 typeParameters = parseTypeParameterList(); | 6021 typeParameters = parseTypeParameterList(); |
5816 } | 6022 } |
5817 FormalParameterList parameters = null; | 6023 FormalParameterList parameters = null; |
5818 if (!isGetter) { | 6024 if (!isGetter) { |
5819 if (_matches(TokenType.OPEN_PAREN)) { | 6025 if (_matches(TokenType.OPEN_PAREN)) { |
5820 parameters = parseFormalParameterList(); | 6026 parameters = parseFormalParameterList(); |
5821 _validateFormalParameterList(parameters); | 6027 _validateFormalParameterList(parameters); |
5822 } else { | 6028 } else { |
5823 _reportErrorForCurrentToken( | 6029 _reportErrorForCurrentToken( |
5824 ParserErrorCode.MISSING_FUNCTION_PARAMETERS); | 6030 ParserErrorCode.MISSING_FUNCTION_PARAMETERS); |
5825 parameters = new FormalParameterList( | 6031 parameters = new FormalParameterList( |
5826 _createSyntheticToken(TokenType.OPEN_PAREN), null, null, null, | 6032 _createSyntheticToken(TokenType.OPEN_PAREN), |
6033 null, | |
6034 null, | |
6035 null, | |
5827 _createSyntheticToken(TokenType.CLOSE_PAREN)); | 6036 _createSyntheticToken(TokenType.CLOSE_PAREN)); |
5828 } | 6037 } |
5829 } else if (_matches(TokenType.OPEN_PAREN)) { | 6038 } else if (_matches(TokenType.OPEN_PAREN)) { |
5830 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS); | 6039 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS); |
5831 parseFormalParameterList(); | 6040 parseFormalParameterList(); |
5832 } | 6041 } |
5833 FunctionBody body; | 6042 FunctionBody body; |
5834 if (externalKeyword == null) { | 6043 if (externalKeyword == null) { |
5835 body = _parseFunctionBody( | 6044 body = _parseFunctionBody( |
5836 false, ParserErrorCode.MISSING_FUNCTION_BODY, false); | 6045 false, ParserErrorCode.MISSING_FUNCTION_BODY, false); |
5837 } else { | 6046 } else { |
5838 body = new EmptyFunctionBody(_expect(TokenType.SEMICOLON)); | 6047 body = new EmptyFunctionBody(_expect(TokenType.SEMICOLON)); |
5839 } | 6048 } |
5840 // if (!isStatement && matches(TokenType.SEMICOLON)) { | 6049 // if (!isStatement && matches(TokenType.SEMICOLON)) { |
5841 // // TODO(brianwilkerson) Improve this error message. | 6050 // // TODO(brianwilkerson) Improve this error message. |
5842 // reportError(ParserErrorCode.UNEXPECTED_TOKEN, currentToken.getLexeme ()); | 6051 // reportError(ParserErrorCode.UNEXPECTED_TOKEN, currentToken.getLexeme ()); |
5843 // advance(); | 6052 // advance(); |
5844 // } | 6053 // } |
5845 return new FunctionDeclaration(commentAndMetadata.comment, | 6054 return new FunctionDeclaration( |
5846 commentAndMetadata.metadata, externalKeyword, returnType, keyword, name, | 6055 commentAndMetadata.comment, |
6056 commentAndMetadata.metadata, | |
6057 externalKeyword, | |
6058 returnType, | |
6059 keyword, | |
6060 name, | |
5847 new FunctionExpression(typeParameters, parameters, body)); | 6061 new FunctionExpression(typeParameters, parameters, body)); |
5848 } | 6062 } |
5849 | 6063 |
5850 /** | 6064 /** |
5851 * Parse a function declaration statement. Return the function declaration | 6065 * Parse a function declaration statement. Return the function declaration |
5852 * statement that was parsed. | 6066 * statement that was parsed. |
5853 * | 6067 * |
5854 * functionDeclarationStatement ::= | 6068 * functionDeclarationStatement ::= |
5855 * functionSignature functionBody | 6069 * functionSignature functionBody |
5856 */ | 6070 */ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5905 returnType = parseReturnType(); | 6119 returnType = parseReturnType(); |
5906 } | 6120 } |
5907 SimpleIdentifier name = parseSimpleIdentifier(); | 6121 SimpleIdentifier name = parseSimpleIdentifier(); |
5908 TypeParameterList typeParameters = null; | 6122 TypeParameterList typeParameters = null; |
5909 if (_matches(TokenType.LT)) { | 6123 if (_matches(TokenType.LT)) { |
5910 typeParameters = parseTypeParameterList(); | 6124 typeParameters = parseTypeParameterList(); |
5911 } | 6125 } |
5912 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.EOF)) { | 6126 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.EOF)) { |
5913 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS); | 6127 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS); |
5914 FormalParameterList parameters = new FormalParameterList( | 6128 FormalParameterList parameters = new FormalParameterList( |
5915 _createSyntheticToken(TokenType.OPEN_PAREN), null, null, null, | 6129 _createSyntheticToken(TokenType.OPEN_PAREN), |
6130 null, | |
6131 null, | |
6132 null, | |
5916 _createSyntheticToken(TokenType.CLOSE_PAREN)); | 6133 _createSyntheticToken(TokenType.CLOSE_PAREN)); |
5917 Token semicolon = _expect(TokenType.SEMICOLON); | 6134 Token semicolon = _expect(TokenType.SEMICOLON); |
5918 return new FunctionTypeAlias(commentAndMetadata.comment, | 6135 return new FunctionTypeAlias( |
5919 commentAndMetadata.metadata, keyword, returnType, name, | 6136 commentAndMetadata.comment, |
5920 typeParameters, parameters, semicolon); | 6137 commentAndMetadata.metadata, |
6138 keyword, | |
6139 returnType, | |
6140 name, | |
6141 typeParameters, | |
6142 parameters, | |
6143 semicolon); | |
5921 } else if (!_matches(TokenType.OPEN_PAREN)) { | 6144 } else if (!_matches(TokenType.OPEN_PAREN)) { |
5922 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS); | 6145 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS); |
5923 // TODO(brianwilkerson) Recover from this error. At the very least we | 6146 // TODO(brianwilkerson) Recover from this error. At the very least we |
5924 // should skip to the start of the next valid compilation unit member, | 6147 // should skip to the start of the next valid compilation unit member, |
5925 // allowing for the possibility of finding the typedef parameters before | 6148 // allowing for the possibility of finding the typedef parameters before |
5926 // that point. | 6149 // that point. |
5927 return new FunctionTypeAlias(commentAndMetadata.comment, | 6150 return new FunctionTypeAlias( |
5928 commentAndMetadata.metadata, keyword, returnType, name, | 6151 commentAndMetadata.comment, |
5929 typeParameters, new FormalParameterList( | 6152 commentAndMetadata.metadata, |
5930 _createSyntheticToken(TokenType.OPEN_PAREN), null, null, null, | 6153 keyword, |
5931 _createSyntheticToken(TokenType.CLOSE_PAREN)), | 6154 returnType, |
6155 name, | |
6156 typeParameters, | |
6157 new FormalParameterList(_createSyntheticToken(TokenType.OPEN_PAREN), | |
6158 null, null, null, _createSyntheticToken(TokenType.CLOSE_PAREN)), | |
5932 _createSyntheticToken(TokenType.SEMICOLON)); | 6159 _createSyntheticToken(TokenType.SEMICOLON)); |
5933 } | 6160 } |
5934 FormalParameterList parameters = parseFormalParameterList(); | 6161 FormalParameterList parameters = parseFormalParameterList(); |
5935 _validateFormalParameterList(parameters); | 6162 _validateFormalParameterList(parameters); |
5936 Token semicolon = _expect(TokenType.SEMICOLON); | 6163 Token semicolon = _expect(TokenType.SEMICOLON); |
5937 return new FunctionTypeAlias(commentAndMetadata.comment, | 6164 return new FunctionTypeAlias( |
5938 commentAndMetadata.metadata, keyword, returnType, name, typeParameters, | 6165 commentAndMetadata.comment, |
5939 parameters, semicolon); | 6166 commentAndMetadata.metadata, |
6167 keyword, | |
6168 returnType, | |
6169 name, | |
6170 typeParameters, | |
6171 parameters, | |
6172 semicolon); | |
5940 } | 6173 } |
5941 | 6174 |
5942 /** | 6175 /** |
5943 * Parse a getter. The [commentAndMetadata] is the documentation comment and | 6176 * Parse a getter. The [commentAndMetadata] is the documentation comment and |
5944 * metadata to be associated with the declaration. The externalKeyword] is the | 6177 * metadata to be associated with the declaration. The externalKeyword] is the |
5945 * 'external' token. The staticKeyword] is the static keyword, or `null` if | 6178 * 'external' token. The staticKeyword] is the static keyword, or `null` if |
5946 * the getter is not static. The [returnType] the return type that has already | 6179 * the getter is not static. The [returnType] the return type that has already |
5947 * been parsed, or `null` if there was no return type. Return the getter that | 6180 * been parsed, or `null` if there was no return type. Return the getter that |
5948 * was parsed. | 6181 * was parsed. |
5949 * | 6182 * |
5950 * getter ::= | 6183 * getter ::= |
5951 * getterSignature functionBody? | 6184 * getterSignature functionBody? |
5952 * | 6185 * |
5953 * getterSignature ::= | 6186 * getterSignature ::= |
5954 * 'external'? 'static'? returnType? 'get' identifier | 6187 * 'external'? 'static'? returnType? 'get' identifier |
5955 */ | 6188 */ |
5956 MethodDeclaration _parseGetter(CommentAndMetadata commentAndMetadata, | 6189 MethodDeclaration _parseGetter(CommentAndMetadata commentAndMetadata, |
5957 Token externalKeyword, Token staticKeyword, TypeName returnType) { | 6190 Token externalKeyword, Token staticKeyword, TypeName returnType) { |
5958 Token propertyKeyword = _expectKeyword(Keyword.GET); | 6191 Token propertyKeyword = _expectKeyword(Keyword.GET); |
5959 SimpleIdentifier name = parseSimpleIdentifier(); | 6192 SimpleIdentifier name = parseSimpleIdentifier(); |
5960 if (_matches(TokenType.OPEN_PAREN) && | 6193 if (_matches(TokenType.OPEN_PAREN) && |
5961 _tokenMatches(_peek(), TokenType.CLOSE_PAREN)) { | 6194 _tokenMatches(_peek(), TokenType.CLOSE_PAREN)) { |
5962 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS); | 6195 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS); |
5963 _advance(); | 6196 _advance(); |
5964 _advance(); | 6197 _advance(); |
5965 } | 6198 } |
5966 FunctionBody body = _parseFunctionBody( | 6199 FunctionBody body = _parseFunctionBody( |
5967 externalKeyword != null || staticKeyword == null, | 6200 externalKeyword != null || staticKeyword == null, |
5968 ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, false); | 6201 ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, |
6202 false); | |
5969 if (externalKeyword != null && body is! EmptyFunctionBody) { | 6203 if (externalKeyword != null && body is! EmptyFunctionBody) { |
5970 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY); | 6204 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY); |
5971 } | 6205 } |
5972 return new MethodDeclaration(commentAndMetadata.comment, | 6206 return new MethodDeclaration( |
5973 commentAndMetadata.metadata, externalKeyword, staticKeyword, returnType, | 6207 commentAndMetadata.comment, |
5974 propertyKeyword, null, name, null, null, body); | 6208 commentAndMetadata.metadata, |
6209 externalKeyword, | |
6210 staticKeyword, | |
6211 returnType, | |
6212 propertyKeyword, | |
6213 null, | |
6214 name, | |
6215 null, | |
6216 null, | |
6217 body); | |
5975 } | 6218 } |
5976 | 6219 |
5977 /** | 6220 /** |
5978 * Parse a list of identifiers. Return the list of identifiers that were | 6221 * Parse a list of identifiers. Return the list of identifiers that were |
5979 * parsed. | 6222 * parsed. |
5980 * | 6223 * |
5981 * identifierList ::= | 6224 * identifierList ::= |
5982 * identifier (',' identifier)* | 6225 * identifier (',' identifier)* |
5983 */ | 6226 */ |
5984 List<SimpleIdentifier> _parseIdentifierList() { | 6227 List<SimpleIdentifier> _parseIdentifierList() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6046 ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken]); | 6289 ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken]); |
6047 _advance(); | 6290 _advance(); |
6048 if (_matchesKeyword(Keyword.AS)) { | 6291 if (_matchesKeyword(Keyword.AS)) { |
6049 asToken = getAndAdvance(); | 6292 asToken = getAndAdvance(); |
6050 prefix = parseSimpleIdentifier(); | 6293 prefix = parseSimpleIdentifier(); |
6051 } | 6294 } |
6052 } | 6295 } |
6053 } | 6296 } |
6054 List<Combinator> combinators = _parseCombinators(); | 6297 List<Combinator> combinators = _parseCombinators(); |
6055 Token semicolon = _expectSemicolon(); | 6298 Token semicolon = _expectSemicolon(); |
6056 return new ImportDirective(commentAndMetadata.comment, | 6299 return new ImportDirective( |
6057 commentAndMetadata.metadata, importKeyword, libraryUri, deferredToken, | 6300 commentAndMetadata.comment, |
6058 asToken, prefix, combinators, semicolon); | 6301 commentAndMetadata.metadata, |
6302 importKeyword, | |
6303 libraryUri, | |
6304 deferredToken, | |
6305 asToken, | |
6306 prefix, | |
6307 combinators, | |
6308 semicolon); | |
6059 } | 6309 } |
6060 | 6310 |
6061 /** | 6311 /** |
6062 * Parse a list of initialized identifiers. The [commentAndMetadata] is the | 6312 * Parse a list of initialized identifiers. The [commentAndMetadata] is the |
6063 * documentation comment and metadata to be associated with the declaration. | 6313 * documentation comment and metadata to be associated with the declaration. |
6064 * The [staticKeyword] is the static keyword, or `null` if the getter is not | 6314 * The [staticKeyword] is the static keyword, or `null` if the getter is not |
6065 * static. The [keyword] is the token representing the 'final', 'const' or | 6315 * static. The [keyword] is the token representing the 'final', 'const' or |
6066 * 'var' keyword, or `null` if there is no keyword. The [type] is the type | 6316 * 'var' keyword, or `null` if there is no keyword. The [type] is the type |
6067 * that has already been parsed, or `null` if 'var' was provided. Return the | 6317 * that has already been parsed, or `null` if 'var' was provided. Return the |
6068 * getter that was parsed. | 6318 * getter that was parsed. |
6069 * | 6319 * |
6070 * ?? ::= | 6320 * ?? ::= |
6071 * 'static'? ('var' | type) initializedIdentifierList ';' | 6321 * 'static'? ('var' | type) initializedIdentifierList ';' |
6072 * | 'final' type? initializedIdentifierList ';' | 6322 * | 'final' type? initializedIdentifierList ';' |
6073 * | 6323 * |
6074 * initializedIdentifierList ::= | 6324 * initializedIdentifierList ::= |
6075 * initializedIdentifier (',' initializedIdentifier)* | 6325 * initializedIdentifier (',' initializedIdentifier)* |
6076 * | 6326 * |
6077 * initializedIdentifier ::= | 6327 * initializedIdentifier ::= |
6078 * identifier ('=' expression)? | 6328 * identifier ('=' expression)? |
6079 */ | 6329 */ |
6080 FieldDeclaration _parseInitializedIdentifierList( | 6330 FieldDeclaration _parseInitializedIdentifierList( |
6081 CommentAndMetadata commentAndMetadata, Token staticKeyword, Token keyword, | 6331 CommentAndMetadata commentAndMetadata, |
6332 Token staticKeyword, | |
6333 Token keyword, | |
6082 TypeName type) { | 6334 TypeName type) { |
6083 VariableDeclarationList fieldList = | 6335 VariableDeclarationList fieldList = |
6084 _parseVariableDeclarationListAfterType(null, keyword, type); | 6336 _parseVariableDeclarationListAfterType(null, keyword, type); |
6085 return new FieldDeclaration(commentAndMetadata.comment, | 6337 return new FieldDeclaration( |
6086 commentAndMetadata.metadata, staticKeyword, fieldList, | 6338 commentAndMetadata.comment, |
6339 commentAndMetadata.metadata, | |
6340 staticKeyword, | |
6341 fieldList, | |
6087 _expect(TokenType.SEMICOLON)); | 6342 _expect(TokenType.SEMICOLON)); |
6088 } | 6343 } |
6089 | 6344 |
6090 /** | 6345 /** |
6091 * Parse an instance creation expression. The [keyword] is the 'new' or | 6346 * Parse an instance creation expression. The [keyword] is the 'new' or |
6092 * 'const' keyword that introduces the expression. Return the instance | 6347 * 'const' keyword that introduces the expression. Return the instance |
6093 * creation expression that was parsed. | 6348 * creation expression that was parsed. |
6094 * | 6349 * |
6095 * instanceCreationExpression ::= | 6350 * instanceCreationExpression ::= |
6096 * ('new' | 'const') type ('.' identifier)? argumentList | 6351 * ('new' | 'const') type ('.' identifier)? argumentList |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6154 * no type arguments. Return the list literal that was parsed. | 6409 * no type arguments. Return the list literal that was parsed. |
6155 * | 6410 * |
6156 * listLiteral ::= | 6411 * listLiteral ::= |
6157 * 'const'? typeArguments? '[' (expressionList ','?)? ']' | 6412 * 'const'? typeArguments? '[' (expressionList ','?)? ']' |
6158 */ | 6413 */ |
6159 ListLiteral _parseListLiteral( | 6414 ListLiteral _parseListLiteral( |
6160 Token modifier, TypeArgumentList typeArguments) { | 6415 Token modifier, TypeArgumentList typeArguments) { |
6161 // may be empty list literal | 6416 // may be empty list literal |
6162 if (_matches(TokenType.INDEX)) { | 6417 if (_matches(TokenType.INDEX)) { |
6163 BeginToken leftBracket = _createToken( | 6418 BeginToken leftBracket = _createToken( |
6164 _currentToken, TokenType.OPEN_SQUARE_BRACKET, isBegin: true); | 6419 _currentToken, TokenType.OPEN_SQUARE_BRACKET, |
6420 isBegin: true); | |
6165 Token rightBracket = | 6421 Token rightBracket = |
6166 new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentToken.offset + 1); | 6422 new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentToken.offset + 1); |
6167 leftBracket.endToken = rightBracket; | 6423 leftBracket.endToken = rightBracket; |
6168 rightBracket.setNext(_currentToken.next); | 6424 rightBracket.setNext(_currentToken.next); |
6169 leftBracket.setNext(rightBracket); | 6425 leftBracket.setNext(rightBracket); |
6170 _currentToken.previous.setNext(leftBracket); | 6426 _currentToken.previous.setNext(leftBracket); |
6171 _currentToken = _currentToken.next; | 6427 _currentToken = _currentToken.next; |
6172 return new ListLiteral( | 6428 return new ListLiteral( |
6173 modifier, typeArguments, leftBracket, null, rightBracket); | 6429 modifier, typeArguments, leftBracket, null, rightBracket); |
6174 } | 6430 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6212 if (_matches(TokenType.LT)) { | 6468 if (_matches(TokenType.LT)) { |
6213 typeArguments = parseTypeArgumentList(); | 6469 typeArguments = parseTypeArgumentList(); |
6214 } | 6470 } |
6215 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { | 6471 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
6216 return _parseMapLiteral(modifier, typeArguments); | 6472 return _parseMapLiteral(modifier, typeArguments); |
6217 } else if (_matches(TokenType.OPEN_SQUARE_BRACKET) || | 6473 } else if (_matches(TokenType.OPEN_SQUARE_BRACKET) || |
6218 _matches(TokenType.INDEX)) { | 6474 _matches(TokenType.INDEX)) { |
6219 return _parseListLiteral(modifier, typeArguments); | 6475 return _parseListLiteral(modifier, typeArguments); |
6220 } | 6476 } |
6221 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL); | 6477 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL); |
6222 return new ListLiteral(modifier, typeArguments, | 6478 return new ListLiteral( |
6223 _createSyntheticToken(TokenType.OPEN_SQUARE_BRACKET), null, | 6479 modifier, |
6480 typeArguments, | |
6481 _createSyntheticToken(TokenType.OPEN_SQUARE_BRACKET), | |
6482 null, | |
6224 _createSyntheticToken(TokenType.CLOSE_SQUARE_BRACKET)); | 6483 _createSyntheticToken(TokenType.CLOSE_SQUARE_BRACKET)); |
6225 } | 6484 } |
6226 | 6485 |
6227 /** | 6486 /** |
6228 * Parse a logical and expression. Return the logical and expression that was | 6487 * Parse a logical and expression. Return the logical and expression that was |
6229 * parsed. | 6488 * parsed. |
6230 * | 6489 * |
6231 * logicalAndExpression ::= | 6490 * logicalAndExpression ::= |
6232 * equalityExpression ('&&' equalityExpression)* | 6491 * equalityExpression ('&&' equalityExpression)* |
6233 */ | 6492 */ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6283 * static keyword, or `null` if the getter is not static. The [returnType] is | 6542 * static keyword, or `null` if the getter is not static. The [returnType] is |
6284 * the return type of the method. The [name] is the name of the method. The | 6543 * the return type of the method. The [name] is the name of the method. The |
6285 * [parameters] is the parameters to the method. Return the method declaration | 6544 * [parameters] is the parameters to the method. Return the method declaration |
6286 * that was parsed. | 6545 * that was parsed. |
6287 * | 6546 * |
6288 * functionDeclaration ::= | 6547 * functionDeclaration ::= |
6289 * ('external' 'static'?)? functionSignature functionBody | 6548 * ('external' 'static'?)? functionSignature functionBody |
6290 * | 'external'? functionSignature ';' | 6549 * | 'external'? functionSignature ';' |
6291 */ | 6550 */ |
6292 MethodDeclaration _parseMethodDeclarationAfterParameters( | 6551 MethodDeclaration _parseMethodDeclarationAfterParameters( |
6293 CommentAndMetadata commentAndMetadata, Token externalKeyword, | 6552 CommentAndMetadata commentAndMetadata, |
6294 Token staticKeyword, TypeName returnType, SimpleIdentifier name, | 6553 Token externalKeyword, |
6295 TypeParameterList typeParameters, FormalParameterList parameters) { | 6554 Token staticKeyword, |
6555 TypeName returnType, | |
6556 SimpleIdentifier name, | |
6557 TypeParameterList typeParameters, | |
6558 FormalParameterList parameters) { | |
6296 FunctionBody body = _parseFunctionBody( | 6559 FunctionBody body = _parseFunctionBody( |
6297 externalKeyword != null || staticKeyword == null, | 6560 externalKeyword != null || staticKeyword == null, |
6298 ParserErrorCode.MISSING_FUNCTION_BODY, false); | 6561 ParserErrorCode.MISSING_FUNCTION_BODY, |
6562 false); | |
6299 if (externalKeyword != null) { | 6563 if (externalKeyword != null) { |
6300 if (body is! EmptyFunctionBody) { | 6564 if (body is! EmptyFunctionBody) { |
6301 _reportErrorForNode(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, body); | 6565 _reportErrorForNode(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, body); |
6302 } | 6566 } |
6303 } else if (staticKeyword != null) { | 6567 } else if (staticKeyword != null) { |
6304 if (body is EmptyFunctionBody && _parseFunctionBodies) { | 6568 if (body is EmptyFunctionBody && _parseFunctionBodies) { |
6305 _reportErrorForNode(ParserErrorCode.ABSTRACT_STATIC_METHOD, body); | 6569 _reportErrorForNode(ParserErrorCode.ABSTRACT_STATIC_METHOD, body); |
6306 } | 6570 } |
6307 } | 6571 } |
6308 return new MethodDeclaration(commentAndMetadata.comment, | 6572 return new MethodDeclaration( |
6309 commentAndMetadata.metadata, externalKeyword, staticKeyword, returnType, | 6573 commentAndMetadata.comment, |
6310 null, null, name, typeParameters, parameters, body); | 6574 commentAndMetadata.metadata, |
6575 externalKeyword, | |
6576 staticKeyword, | |
6577 returnType, | |
6578 null, | |
6579 null, | |
6580 name, | |
6581 typeParameters, | |
6582 parameters, | |
6583 body); | |
6311 } | 6584 } |
6312 | 6585 |
6313 /** | 6586 /** |
6314 * Parse a method declaration. The [commentAndMetadata] is the documentation | 6587 * Parse a method declaration. The [commentAndMetadata] is the documentation |
6315 * comment and metadata to be associated with the declaration. The | 6588 * comment and metadata to be associated with the declaration. The |
6316 * [externalKeyword] is the 'external' token. The [staticKeyword] is the | 6589 * [externalKeyword] is the 'external' token. The [staticKeyword] is the |
6317 * static keyword, or `null` if the getter is not static. The [returnType] is | 6590 * static keyword, or `null` if the getter is not static. The [returnType] is |
6318 * the return type of the method. Return the method declaration that was | 6591 * the return type of the method. Return the method declaration that was |
6319 * parsed. | 6592 * parsed. |
6320 * | 6593 * |
6321 * functionDeclaration ::= | 6594 * functionDeclaration ::= |
6322 * 'external'? 'static'? functionSignature functionBody | 6595 * 'external'? 'static'? functionSignature functionBody |
6323 * | 'external'? functionSignature ';' | 6596 * | 'external'? functionSignature ';' |
6324 */ | 6597 */ |
6325 MethodDeclaration _parseMethodDeclarationAfterReturnType( | 6598 MethodDeclaration _parseMethodDeclarationAfterReturnType( |
6326 CommentAndMetadata commentAndMetadata, Token externalKeyword, | 6599 CommentAndMetadata commentAndMetadata, |
6327 Token staticKeyword, TypeName returnType) { | 6600 Token externalKeyword, |
6601 Token staticKeyword, | |
6602 TypeName returnType) { | |
6328 SimpleIdentifier methodName = parseSimpleIdentifier(); | 6603 SimpleIdentifier methodName = parseSimpleIdentifier(); |
6329 TypeParameterList typeParameters = null; | 6604 TypeParameterList typeParameters = null; |
6330 if (parseGenericMethods && _matches(TokenType.LT)) { | 6605 if (parseGenericMethods && _matches(TokenType.LT)) { |
6331 typeParameters = parseTypeParameterList(); | 6606 typeParameters = parseTypeParameterList(); |
6332 } | 6607 } |
6333 FormalParameterList parameters; | 6608 FormalParameterList parameters; |
6334 if (!_matches(TokenType.OPEN_PAREN) && | 6609 if (!_matches(TokenType.OPEN_PAREN) && |
6335 (_matches(TokenType.OPEN_CURLY_BRACKET) || | 6610 (_matches(TokenType.OPEN_CURLY_BRACKET) || |
6336 _matches(TokenType.FUNCTION))) { | 6611 _matches(TokenType.FUNCTION))) { |
6337 _reportErrorForToken( | 6612 _reportErrorForToken( |
6338 ParserErrorCode.MISSING_METHOD_PARAMETERS, _currentToken.previous); | 6613 ParserErrorCode.MISSING_METHOD_PARAMETERS, _currentToken.previous); |
6339 parameters = new FormalParameterList( | 6614 parameters = new FormalParameterList( |
6340 _createSyntheticToken(TokenType.OPEN_PAREN), null, null, null, | 6615 _createSyntheticToken(TokenType.OPEN_PAREN), |
6616 null, | |
6617 null, | |
6618 null, | |
6341 _createSyntheticToken(TokenType.CLOSE_PAREN)); | 6619 _createSyntheticToken(TokenType.CLOSE_PAREN)); |
6342 } else { | 6620 } else { |
6343 parameters = parseFormalParameterList(); | 6621 parameters = parseFormalParameterList(); |
6344 } | 6622 } |
6345 _validateFormalParameterList(parameters); | 6623 _validateFormalParameterList(parameters); |
6346 return _parseMethodDeclarationAfterParameters(commentAndMetadata, | 6624 return _parseMethodDeclarationAfterParameters( |
6347 externalKeyword, staticKeyword, returnType, methodName, typeParameters, | 6625 commentAndMetadata, |
6626 externalKeyword, | |
6627 staticKeyword, | |
6628 returnType, | |
6629 methodName, | |
6630 typeParameters, | |
6348 parameters); | 6631 parameters); |
6349 } | 6632 } |
6350 | 6633 |
6351 /** | 6634 /** |
6352 * Parse the modifiers preceding a declaration. This method allows the | 6635 * Parse the modifiers preceding a declaration. This method allows the |
6353 * modifiers to appear in any order but does generate errors for duplicated | 6636 * modifiers to appear in any order but does generate errors for duplicated |
6354 * modifiers. Checks for other problems, such as having the modifiers appear | 6637 * modifiers. Checks for other problems, such as having the modifiers appear |
6355 * in the wrong order or specifying both 'const' and 'final', are reported in | 6638 * in the wrong order or specifying both 'const' and 'final', are reported in |
6356 * one of the methods whose name is prefixed with `validateModifiersFor`. | 6639 * one of the methods whose name is prefixed with `validateModifiersFor`. |
6357 * Return the modifiers that were parsed. | 6640 * Return the modifiers that were parsed. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6545 return _parseTryStatement(); | 6828 return _parseTryStatement(); |
6546 } else if (keyword == Keyword.WHILE) { | 6829 } else if (keyword == Keyword.WHILE) { |
6547 return _parseWhileStatement(); | 6830 return _parseWhileStatement(); |
6548 } else if (keyword == Keyword.VAR || keyword == Keyword.FINAL) { | 6831 } else if (keyword == Keyword.VAR || keyword == Keyword.FINAL) { |
6549 return _parseVariableDeclarationStatementAfterMetadata( | 6832 return _parseVariableDeclarationStatementAfterMetadata( |
6550 commentAndMetadata); | 6833 commentAndMetadata); |
6551 } else if (keyword == Keyword.VOID) { | 6834 } else if (keyword == Keyword.VOID) { |
6552 TypeName returnType = parseReturnType(); | 6835 TypeName returnType = parseReturnType(); |
6553 if (_matchesIdentifier() && | 6836 if (_matchesIdentifier() && |
6554 _peek().matchesAny([ | 6837 _peek().matchesAny([ |
6555 TokenType.OPEN_PAREN, | 6838 TokenType.OPEN_PAREN, |
6556 TokenType.OPEN_CURLY_BRACKET, | 6839 TokenType.OPEN_CURLY_BRACKET, |
6557 TokenType.FUNCTION | 6840 TokenType.FUNCTION |
6558 ])) { | 6841 ])) { |
6559 return _parseFunctionDeclarationStatementAfterReturnType( | 6842 return _parseFunctionDeclarationStatementAfterReturnType( |
6560 commentAndMetadata, returnType); | 6843 commentAndMetadata, returnType); |
6561 } else { | 6844 } else { |
6562 // | 6845 // |
6563 // We have found an error of some kind. Try to recover. | 6846 // We have found an error of some kind. Try to recover. |
6564 // | 6847 // |
6565 if (_matchesIdentifier()) { | 6848 if (_matchesIdentifier()) { |
6566 if (_peek().matchesAny( | 6849 if (_peek().matchesAny( |
6567 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { | 6850 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { |
6568 // | 6851 // |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6692 _advance(); | 6975 _advance(); |
6693 } | 6976 } |
6694 } | 6977 } |
6695 FormalParameterList parameters = parseFormalParameterList(); | 6978 FormalParameterList parameters = parseFormalParameterList(); |
6696 _validateFormalParameterList(parameters); | 6979 _validateFormalParameterList(parameters); |
6697 FunctionBody body = | 6980 FunctionBody body = |
6698 _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false); | 6981 _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false); |
6699 if (externalKeyword != null && body is! EmptyFunctionBody) { | 6982 if (externalKeyword != null && body is! EmptyFunctionBody) { |
6700 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY); | 6983 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY); |
6701 } | 6984 } |
6702 return new MethodDeclaration(commentAndMetadata.comment, | 6985 return new MethodDeclaration( |
6703 commentAndMetadata.metadata, externalKeyword, null, returnType, null, | 6986 commentAndMetadata.comment, |
6704 operatorKeyword, name, null, parameters, body); | 6987 commentAndMetadata.metadata, |
6988 externalKeyword, | |
6989 null, | |
6990 returnType, | |
6991 null, | |
6992 operatorKeyword, | |
6993 name, | |
6994 null, | |
6995 parameters, | |
6996 body); | |
6705 } | 6997 } |
6706 | 6998 |
6707 /** | 6999 /** |
6708 * Parse a return type if one is given, otherwise return `null` without | 7000 * Parse a return type if one is given, otherwise return `null` without |
6709 * advancing. Return the return type that was parsed. | 7001 * advancing. Return the return type that was parsed. |
6710 */ | 7002 */ |
6711 TypeName _parseOptionalReturnType() { | 7003 TypeName _parseOptionalReturnType() { |
6712 if (_matchesKeyword(Keyword.VOID)) { | 7004 if (_matchesKeyword(Keyword.VOID)) { |
6713 return parseReturnType(); | 7005 return parseReturnType(); |
6714 } else if (_matchesIdentifier() && | 7006 } else if (_matchesIdentifier() && |
(...skipping 24 matching lines...) Expand all Loading... | |
6739 * partOfDirective ::= | 7031 * partOfDirective ::= |
6740 * metadata 'part' 'of' identifier ';' | 7032 * metadata 'part' 'of' identifier ';' |
6741 */ | 7033 */ |
6742 Directive _parsePartDirective(CommentAndMetadata commentAndMetadata) { | 7034 Directive _parsePartDirective(CommentAndMetadata commentAndMetadata) { |
6743 Token partKeyword = _expectKeyword(Keyword.PART); | 7035 Token partKeyword = _expectKeyword(Keyword.PART); |
6744 if (_matchesString(_OF)) { | 7036 if (_matchesString(_OF)) { |
6745 Token ofKeyword = getAndAdvance(); | 7037 Token ofKeyword = getAndAdvance(); |
6746 LibraryIdentifier libraryName = _parseLibraryName( | 7038 LibraryIdentifier libraryName = _parseLibraryName( |
6747 ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE, ofKeyword); | 7039 ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE, ofKeyword); |
6748 Token semicolon = _expect(TokenType.SEMICOLON); | 7040 Token semicolon = _expect(TokenType.SEMICOLON); |
6749 return new PartOfDirective(commentAndMetadata.comment, | 7041 return new PartOfDirective( |
6750 commentAndMetadata.metadata, partKeyword, ofKeyword, libraryName, | 7042 commentAndMetadata.comment, |
7043 commentAndMetadata.metadata, | |
7044 partKeyword, | |
7045 ofKeyword, | |
7046 libraryName, | |
6751 semicolon); | 7047 semicolon); |
6752 } | 7048 } |
6753 StringLiteral partUri = _parseUri(); | 7049 StringLiteral partUri = _parseUri(); |
6754 Token semicolon = _expect(TokenType.SEMICOLON); | 7050 Token semicolon = _expect(TokenType.SEMICOLON); |
6755 return new PartDirective(commentAndMetadata.comment, | 7051 return new PartDirective(commentAndMetadata.comment, |
6756 commentAndMetadata.metadata, partKeyword, partUri, semicolon); | 7052 commentAndMetadata.metadata, partKeyword, partUri, semicolon); |
6757 } | 7053 } |
6758 | 7054 |
6759 /** | 7055 /** |
6760 * Parse a postfix expression. Return the postfix expression that was parsed. | 7056 * Parse a postfix expression. Return the postfix expression that was parsed. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6829 * | mapLiteral | 7125 * | mapLiteral |
6830 * | listLiteral | 7126 * | listLiteral |
6831 */ | 7127 */ |
6832 Expression _parsePrimaryExpression() { | 7128 Expression _parsePrimaryExpression() { |
6833 if (_matchesKeyword(Keyword.THIS)) { | 7129 if (_matchesKeyword(Keyword.THIS)) { |
6834 return new ThisExpression(getAndAdvance()); | 7130 return new ThisExpression(getAndAdvance()); |
6835 } else if (_matchesKeyword(Keyword.SUPER)) { | 7131 } else if (_matchesKeyword(Keyword.SUPER)) { |
6836 // TODO(paulberry): verify with Gilad that "super" must be followed by | 7132 // TODO(paulberry): verify with Gilad that "super" must be followed by |
6837 // unconditionalAssignableSelector in this case. | 7133 // unconditionalAssignableSelector in this case. |
6838 return _parseAssignableSelector( | 7134 return _parseAssignableSelector( |
6839 new SuperExpression(getAndAdvance()), false, allowConditional: false); | 7135 new SuperExpression(getAndAdvance()), false, |
7136 allowConditional: false); | |
6840 } else if (_matchesKeyword(Keyword.NULL)) { | 7137 } else if (_matchesKeyword(Keyword.NULL)) { |
6841 return new NullLiteral(getAndAdvance()); | 7138 return new NullLiteral(getAndAdvance()); |
6842 } else if (_matchesKeyword(Keyword.FALSE)) { | 7139 } else if (_matchesKeyword(Keyword.FALSE)) { |
6843 return new BooleanLiteral(getAndAdvance(), false); | 7140 return new BooleanLiteral(getAndAdvance(), false); |
6844 } else if (_matchesKeyword(Keyword.TRUE)) { | 7141 } else if (_matchesKeyword(Keyword.TRUE)) { |
6845 return new BooleanLiteral(getAndAdvance(), true); | 7142 return new BooleanLiteral(getAndAdvance(), true); |
6846 } else if (_matches(TokenType.DOUBLE)) { | 7143 } else if (_matches(TokenType.DOUBLE)) { |
6847 Token token = getAndAdvance(); | 7144 Token token = getAndAdvance(); |
6848 double value = 0.0; | 7145 double value = 0.0; |
6849 try { | 7146 try { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7032 * 'external'? 'static'? returnType? 'set' identifier formalParameterL ist | 7329 * 'external'? 'static'? returnType? 'set' identifier formalParameterL ist |
7033 */ | 7330 */ |
7034 MethodDeclaration _parseSetter(CommentAndMetadata commentAndMetadata, | 7331 MethodDeclaration _parseSetter(CommentAndMetadata commentAndMetadata, |
7035 Token externalKeyword, Token staticKeyword, TypeName returnType) { | 7332 Token externalKeyword, Token staticKeyword, TypeName returnType) { |
7036 Token propertyKeyword = _expectKeyword(Keyword.SET); | 7333 Token propertyKeyword = _expectKeyword(Keyword.SET); |
7037 SimpleIdentifier name = parseSimpleIdentifier(); | 7334 SimpleIdentifier name = parseSimpleIdentifier(); |
7038 FormalParameterList parameters = parseFormalParameterList(); | 7335 FormalParameterList parameters = parseFormalParameterList(); |
7039 _validateFormalParameterList(parameters); | 7336 _validateFormalParameterList(parameters); |
7040 FunctionBody body = _parseFunctionBody( | 7337 FunctionBody body = _parseFunctionBody( |
7041 externalKeyword != null || staticKeyword == null, | 7338 externalKeyword != null || staticKeyword == null, |
7042 ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, false); | 7339 ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, |
7340 false); | |
7043 if (externalKeyword != null && body is! EmptyFunctionBody) { | 7341 if (externalKeyword != null && body is! EmptyFunctionBody) { |
7044 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY); | 7342 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY); |
7045 } | 7343 } |
7046 return new MethodDeclaration(commentAndMetadata.comment, | 7344 return new MethodDeclaration( |
7047 commentAndMetadata.metadata, externalKeyword, staticKeyword, returnType, | 7345 commentAndMetadata.comment, |
7048 propertyKeyword, null, name, null, parameters, body); | 7346 commentAndMetadata.metadata, |
7347 externalKeyword, | |
7348 staticKeyword, | |
7349 returnType, | |
7350 propertyKeyword, | |
7351 null, | |
7352 name, | |
7353 null, | |
7354 parameters, | |
7355 body); | |
7049 } | 7356 } |
7050 | 7357 |
7051 /** | 7358 /** |
7052 * Parse a shift expression. Return the shift expression that was parsed. | 7359 * Parse a shift expression. Return the shift expression that was parsed. |
7053 * | 7360 * |
7054 * shiftExpression ::= | 7361 * shiftExpression ::= |
7055 * additiveExpression (shiftOperator additiveExpression)* | 7362 * additiveExpression (shiftOperator additiveExpression)* |
7056 * | 'super' (shiftOperator additiveExpression)+ | 7363 * | 'super' (shiftOperator additiveExpression)+ |
7057 */ | 7364 */ |
7058 Expression _parseShiftExpression() { | 7365 Expression _parseShiftExpression() { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7188 while (!_matches(TokenType.EOF) && | 7495 while (!_matches(TokenType.EOF) && |
7189 !_matches(TokenType.CLOSE_CURLY_BRACKET)) { | 7496 !_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
7190 List<Label> labels = new List<Label>(); | 7497 List<Label> labels = new List<Label>(); |
7191 while ( | 7498 while ( |
7192 _matchesIdentifier() && _tokenMatches(_peek(), TokenType.COLON)) { | 7499 _matchesIdentifier() && _tokenMatches(_peek(), TokenType.COLON)) { |
7193 SimpleIdentifier identifier = parseSimpleIdentifier(); | 7500 SimpleIdentifier identifier = parseSimpleIdentifier(); |
7194 String label = identifier.token.lexeme; | 7501 String label = identifier.token.lexeme; |
7195 if (definedLabels.contains(label)) { | 7502 if (definedLabels.contains(label)) { |
7196 _reportErrorForToken( | 7503 _reportErrorForToken( |
7197 ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, | 7504 ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, |
7198 identifier.token, [label]); | 7505 identifier.token, |
7506 [label]); | |
7199 } else { | 7507 } else { |
7200 definedLabels.add(label); | 7508 definedLabels.add(label); |
7201 } | 7509 } |
7202 Token colon = _expect(TokenType.COLON); | 7510 Token colon = _expect(TokenType.COLON); |
7203 labels.add(new Label(identifier, colon)); | 7511 labels.add(new Label(identifier, colon)); |
7204 } | 7512 } |
7205 if (_matchesKeyword(Keyword.CASE)) { | 7513 if (_matchesKeyword(Keyword.CASE)) { |
7206 Token caseKeyword = getAndAdvance(); | 7514 Token caseKeyword = getAndAdvance(); |
7207 Expression caseExpression = parseExpression2(); | 7515 Expression caseExpression = parseExpression2(); |
7208 Token colon = _expect(TokenType.COLON); | 7516 Token colon = _expect(TokenType.COLON); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7346 catchKeyword = getAndAdvance(); | 7654 catchKeyword = getAndAdvance(); |
7347 leftParenthesis = _expect(TokenType.OPEN_PAREN); | 7655 leftParenthesis = _expect(TokenType.OPEN_PAREN); |
7348 exceptionParameter = parseSimpleIdentifier(); | 7656 exceptionParameter = parseSimpleIdentifier(); |
7349 if (_matches(TokenType.COMMA)) { | 7657 if (_matches(TokenType.COMMA)) { |
7350 comma = getAndAdvance(); | 7658 comma = getAndAdvance(); |
7351 stackTraceParameter = parseSimpleIdentifier(); | 7659 stackTraceParameter = parseSimpleIdentifier(); |
7352 } | 7660 } |
7353 rightParenthesis = _expect(TokenType.CLOSE_PAREN); | 7661 rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
7354 } | 7662 } |
7355 Block catchBody = parseBlock(); | 7663 Block catchBody = parseBlock(); |
7356 catchClauses.add(new CatchClause(onKeyword, exceptionType, catchKeyword, | 7664 catchClauses.add(new CatchClause( |
7357 leftParenthesis, exceptionParameter, comma, stackTraceParameter, | 7665 onKeyword, |
7358 rightParenthesis, catchBody)); | 7666 exceptionType, |
7667 catchKeyword, | |
7668 leftParenthesis, | |
7669 exceptionParameter, | |
7670 comma, | |
7671 stackTraceParameter, | |
7672 rightParenthesis, | |
7673 catchBody)); | |
7359 } | 7674 } |
7360 Token finallyKeyword = null; | 7675 Token finallyKeyword = null; |
7361 if (_matchesKeyword(Keyword.FINALLY)) { | 7676 if (_matchesKeyword(Keyword.FINALLY)) { |
7362 finallyKeyword = getAndAdvance(); | 7677 finallyKeyword = getAndAdvance(); |
7363 finallyClause = parseBlock(); | 7678 finallyClause = parseBlock(); |
7364 } else { | 7679 } else { |
7365 if (catchClauses.isEmpty) { | 7680 if (catchClauses.isEmpty) { |
7366 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CATCH_OR_FINALLY); | 7681 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CATCH_OR_FINALLY); |
7367 } | 7682 } |
7368 } | 7683 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7461 // we cannot do the same for "++super" because "+super" is also not | 7776 // we cannot do the same for "++super" because "+super" is also not |
7462 // valid. | 7777 // valid. |
7463 // | 7778 // |
7464 if (operator.type == TokenType.MINUS_MINUS) { | 7779 if (operator.type == TokenType.MINUS_MINUS) { |
7465 Token firstOperator = _createToken(operator, TokenType.MINUS); | 7780 Token firstOperator = _createToken(operator, TokenType.MINUS); |
7466 Token secondOperator = | 7781 Token secondOperator = |
7467 new Token(TokenType.MINUS, operator.offset + 1); | 7782 new Token(TokenType.MINUS, operator.offset + 1); |
7468 secondOperator.setNext(_currentToken); | 7783 secondOperator.setNext(_currentToken); |
7469 firstOperator.setNext(secondOperator); | 7784 firstOperator.setNext(secondOperator); |
7470 operator.previous.setNext(firstOperator); | 7785 operator.previous.setNext(firstOperator); |
7471 return new PrefixExpression(firstOperator, new PrefixExpression( | 7786 return new PrefixExpression( |
7472 secondOperator, new SuperExpression(getAndAdvance()))); | 7787 firstOperator, |
7788 new PrefixExpression( | |
7789 secondOperator, new SuperExpression(getAndAdvance()))); | |
7473 } else { | 7790 } else { |
7474 // Invalid operator before 'super' | 7791 // Invalid operator before 'super' |
7475 _reportErrorForCurrentToken( | 7792 _reportErrorForCurrentToken( |
7476 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lexeme]); | 7793 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lexeme]); |
7477 return new PrefixExpression( | 7794 return new PrefixExpression( |
7478 operator, new SuperExpression(getAndAdvance())); | 7795 operator, new SuperExpression(getAndAdvance())); |
7479 } | 7796 } |
7480 } | 7797 } |
7481 return new PrefixExpression(operator, _parseAssignableExpression(false)); | 7798 return new PrefixExpression(operator, _parseAssignableExpression(false)); |
7482 } else if (_matches(TokenType.PLUS)) { | 7799 } else if (_matches(TokenType.PLUS)) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7601 } | 7918 } |
7602 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 7919 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
7603 variables.add(_parseVariableDeclaration()); | 7920 variables.add(_parseVariableDeclaration()); |
7604 while (_matches(TokenType.COMMA)) { | 7921 while (_matches(TokenType.COMMA)) { |
7605 _advance(); | 7922 _advance(); |
7606 variables.add(_parseVariableDeclaration()); | 7923 variables.add(_parseVariableDeclaration()); |
7607 } | 7924 } |
7608 return new VariableDeclarationList( | 7925 return new VariableDeclarationList( |
7609 commentAndMetadata != null ? commentAndMetadata.comment : null, | 7926 commentAndMetadata != null ? commentAndMetadata.comment : null, |
7610 commentAndMetadata != null ? commentAndMetadata.metadata : null, | 7927 commentAndMetadata != null ? commentAndMetadata.metadata : null, |
7611 keyword, type, variables); | 7928 keyword, |
7929 type, | |
7930 variables); | |
7612 } | 7931 } |
7613 | 7932 |
7614 /** | 7933 /** |
7615 * Parse a variable declaration statement. The [commentAndMetadata] is the | 7934 * Parse a variable declaration statement. The [commentAndMetadata] is the |
7616 * metadata to be associated with the variable declaration statement, or | 7935 * metadata to be associated with the variable declaration statement, or |
7617 * `null` if there is no attempt at parsing the comment and metadata. Return | 7936 * `null` if there is no attempt at parsing the comment and metadata. Return |
7618 * the variable declaration statement that was parsed. | 7937 * the variable declaration statement that was parsed. |
7619 * | 7938 * |
7620 * variableDeclarationStatement ::= | 7939 * variableDeclarationStatement ::= |
7621 * variableDeclarationList ';' | 7940 * variableDeclarationList ';' |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7860 } | 8179 } |
7861 Token next = startToken.next; | 8180 Token next = startToken.next; |
7862 if (_tokenMatches(next, TokenType.CLOSE_PAREN)) { | 8181 if (_tokenMatches(next, TokenType.CLOSE_PAREN)) { |
7863 return next.next; | 8182 return next.next; |
7864 } | 8183 } |
7865 // | 8184 // |
7866 // Look to see whether the token after the open parenthesis is something | 8185 // Look to see whether the token after the open parenthesis is something |
7867 // that should only occur at the beginning of a parameter list. | 8186 // that should only occur at the beginning of a parameter list. |
7868 // | 8187 // |
7869 if (next.matchesAny([ | 8188 if (next.matchesAny([ |
7870 TokenType.AT, | 8189 TokenType.AT, |
7871 TokenType.OPEN_SQUARE_BRACKET, | 8190 TokenType.OPEN_SQUARE_BRACKET, |
7872 TokenType.OPEN_CURLY_BRACKET | 8191 TokenType.OPEN_CURLY_BRACKET |
7873 ]) || | 8192 ]) || |
7874 _tokenMatchesKeyword(next, Keyword.VOID) || | 8193 _tokenMatchesKeyword(next, Keyword.VOID) || |
7875 (_tokenMatchesIdentifier(next) && | 8194 (_tokenMatchesIdentifier(next) && |
7876 (next.next.matchesAny([TokenType.COMMA, TokenType.CLOSE_PAREN])))) { | 8195 (next.next.matchesAny([TokenType.COMMA, TokenType.CLOSE_PAREN])))) { |
7877 return _skipPastMatchingToken(startToken); | 8196 return _skipPastMatchingToken(startToken); |
7878 } | 8197 } |
7879 // | 8198 // |
7880 // Look to see whether the first parameter is a function typed parameter | 8199 // Look to see whether the first parameter is a function typed parameter |
7881 // without a return type. | 8200 // without a return type. |
7882 // | 8201 // |
7883 if (_tokenMatchesIdentifier(next) && | 8202 if (_tokenMatchesIdentifier(next) && |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8343 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); | 8662 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); |
8344 if (!_isHexDigit(firstDigit) || | 8663 if (!_isHexDigit(firstDigit) || |
8345 !_isHexDigit(secondDigit) || | 8664 !_isHexDigit(secondDigit) || |
8346 !_isHexDigit(thirdDigit) || | 8665 !_isHexDigit(thirdDigit) || |
8347 !_isHexDigit(fourthDigit)) { | 8666 !_isHexDigit(fourthDigit)) { |
8348 // Illegal escape sequence: invalid hex digits | 8667 // Illegal escape sequence: invalid hex digits |
8349 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE); | 8668 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE); |
8350 } else { | 8669 } else { |
8351 _appendScalarValue( | 8670 _appendScalarValue( |
8352 buffer, | 8671 buffer, |
8353 lexeme | 8672 lexeme.substring(index, currentIndex + 1), |
8354 .substring( | |
8355 index, | |
8356 currentIndex + 1), | |
8357 (((((Character.digit(firstDigit, 16) << 4) + | 8673 (((((Character.digit(firstDigit, 16) << 4) + |
8358 Character.digit(secondDigit, 16)) << | 8674 Character.digit(secondDigit, 16)) << |
8359 4) + | 8675 4) + |
8360 Character.digit(thirdDigit, 16)) << | 8676 Character.digit(thirdDigit, 16)) << |
8361 4) + | 8677 4) + |
8362 Character | 8678 Character.digit(fourthDigit, 16), |
8363 .digit(fourthDigit, 16), | |
8364 index, | 8679 index, |
8365 currentIndex + | 8680 currentIndex + 3); |
8366 3); | |
8367 } | 8681 } |
8368 return currentIndex + 4; | 8682 return currentIndex + 4; |
8369 } | 8683 } |
8370 } else { | 8684 } else { |
8371 buffer.writeCharCode(currentChar); | 8685 buffer.writeCharCode(currentChar); |
8372 } | 8686 } |
8373 return currentIndex + 1; | 8687 return currentIndex + 1; |
8374 } | 8688 } |
8375 | 8689 |
8376 /** | 8690 /** |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8698 } | 9012 } |
8699 if (modifiers.finalKeyword != null) { | 9013 if (modifiers.finalKeyword != null) { |
8700 _reportErrorForToken( | 9014 _reportErrorForToken( |
8701 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword); | 9015 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword); |
8702 } | 9016 } |
8703 if (modifiers.varKeyword != null) { | 9017 if (modifiers.varKeyword != null) { |
8704 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); | 9018 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); |
8705 } | 9019 } |
8706 } | 9020 } |
8707 } | 9021 } |
9022 | |
8708 /** | 9023 /** |
8709 * A synthetic keyword token. | 9024 * A synthetic keyword token. |
8710 */ | 9025 */ |
8711 class Parser_SyntheticKeywordToken extends KeywordToken { | 9026 class Parser_SyntheticKeywordToken extends KeywordToken { |
8712 /** | 9027 /** |
8713 * Initialize a newly created token to represent the given [keyword] at the | 9028 * Initialize a newly created token to represent the given [keyword] at the |
8714 * given [offset]. | 9029 * given [offset]. |
8715 */ | 9030 */ |
8716 Parser_SyntheticKeywordToken(Keyword keyword, int offset) | 9031 Parser_SyntheticKeywordToken(Keyword keyword, int offset) |
8717 : super(keyword, offset); | 9032 : super(keyword, offset); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8926 'EXTERNAL_SETTER_WITH_BODY', "External setters cannot have a body"); | 9241 'EXTERNAL_SETTER_WITH_BODY', "External setters cannot have a body"); |
8927 | 9242 |
8928 static const ParserErrorCode EXTERNAL_TYPEDEF = const ParserErrorCode( | 9243 static const ParserErrorCode EXTERNAL_TYPEDEF = const ParserErrorCode( |
8929 'EXTERNAL_TYPEDEF', "Type aliases cannot be declared to be 'external'"); | 9244 'EXTERNAL_TYPEDEF', "Type aliases cannot be declared to be 'external'"); |
8930 | 9245 |
8931 static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION = | 9246 static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION = |
8932 const ParserErrorCode('FACTORY_TOP_LEVEL_DECLARATION', | 9247 const ParserErrorCode('FACTORY_TOP_LEVEL_DECLARATION', |
8933 "Top-level declarations cannot be declared to be 'factory'"); | 9248 "Top-level declarations cannot be declared to be 'factory'"); |
8934 | 9249 |
8935 static const ParserErrorCode FACTORY_WITH_INITIALIZERS = | 9250 static const ParserErrorCode FACTORY_WITH_INITIALIZERS = |
8936 const ParserErrorCode('FACTORY_WITH_INITIALIZERS', | 9251 const ParserErrorCode( |
9252 'FACTORY_WITH_INITIALIZERS', | |
8937 "A 'factory' constructor cannot have initializers", | 9253 "A 'factory' constructor cannot have initializers", |
8938 "Either remove the 'factory' keyword to make this a generative " | 9254 "Either remove the 'factory' keyword to make this a generative " |
8939 "constructor or remove the initializers."); | 9255 "constructor or remove the initializers."); |
8940 | 9256 |
8941 static const ParserErrorCode FACTORY_WITHOUT_BODY = const ParserErrorCode( | 9257 static const ParserErrorCode FACTORY_WITHOUT_BODY = const ParserErrorCode( |
8942 'FACTORY_WITHOUT_BODY', | 9258 'FACTORY_WITHOUT_BODY', |
8943 "A non-redirecting 'factory' constructor must have a body"); | 9259 "A non-redirecting 'factory' constructor must have a body"); |
8944 | 9260 |
8945 static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR = | 9261 static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR = |
8946 const ParserErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR', | 9262 const ParserErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR', |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9195 | 9511 |
9196 static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = | 9512 static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = |
9197 const ParserErrorCode('NON_IDENTIFIER_LIBRARY_NAME', | 9513 const ParserErrorCode('NON_IDENTIFIER_LIBRARY_NAME', |
9198 "The name of a library must be an identifier"); | 9514 "The name of a library must be an identifier"); |
9199 | 9515 |
9200 static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = | 9516 static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = |
9201 const ParserErrorCode('NON_PART_OF_DIRECTIVE_IN_PART', | 9517 const ParserErrorCode('NON_PART_OF_DIRECTIVE_IN_PART', |
9202 "The part-of directive must be the only directive in a part"); | 9518 "The part-of directive must be the only directive in a part"); |
9203 | 9519 |
9204 static const ParserErrorCode NON_STRING_LITERAL_AS_URI = | 9520 static const ParserErrorCode NON_STRING_LITERAL_AS_URI = |
9205 const ParserErrorCode('NON_STRING_LITERAL_AS_URI', | 9521 const ParserErrorCode( |
9522 'NON_STRING_LITERAL_AS_URI', | |
9206 "The URI must be a string literal", | 9523 "The URI must be a string literal", |
9207 "Enclose the URI in either single or double quotes."); | 9524 "Enclose the URI in either single or double quotes."); |
9208 | 9525 |
9209 static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR = | 9526 static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR = |
9210 const ParserErrorCode('NON_USER_DEFINABLE_OPERATOR', | 9527 const ParserErrorCode('NON_USER_DEFINABLE_OPERATOR', |
9211 "The operator '{0}' is not user definable"); | 9528 "The operator '{0}' is not user definable"); |
9212 | 9529 |
9213 static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS = | 9530 static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS = |
9214 const ParserErrorCode('NORMAL_BEFORE_OPTIONAL_PARAMETERS', | 9531 const ParserErrorCode('NORMAL_BEFORE_OPTIONAL_PARAMETERS', |
9215 "Normal parameters must occur before optional parameters"); | 9532 "Normal parameters must occur before optional parameters"); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9358 | 9675 |
9359 @override | 9676 @override |
9360 bool visitAdjacentStrings(AdjacentStrings node) { | 9677 bool visitAdjacentStrings(AdjacentStrings node) { |
9361 AdjacentStrings toNode = this._toNode as AdjacentStrings; | 9678 AdjacentStrings toNode = this._toNode as AdjacentStrings; |
9362 return _isEqualNodeLists(node.strings, toNode.strings); | 9679 return _isEqualNodeLists(node.strings, toNode.strings); |
9363 } | 9680 } |
9364 | 9681 |
9365 @override | 9682 @override |
9366 bool visitAnnotation(Annotation node) { | 9683 bool visitAnnotation(Annotation node) { |
9367 Annotation toNode = this._toNode as Annotation; | 9684 Annotation toNode = this._toNode as Annotation; |
9368 if (_and(_isEqualTokens(node.atSign, toNode.atSign), | 9685 if (_and( |
9686 _isEqualTokens(node.atSign, toNode.atSign), | |
9369 _isEqualNodes(node.name, toNode.name), | 9687 _isEqualNodes(node.name, toNode.name), |
9370 _isEqualTokens(node.period, toNode.period), | 9688 _isEqualTokens(node.period, toNode.period), |
9371 _isEqualNodes(node.constructorName, toNode.constructorName), | 9689 _isEqualNodes(node.constructorName, toNode.constructorName), |
9372 _isEqualNodes(node.arguments, toNode.arguments))) { | 9690 _isEqualNodes(node.arguments, toNode.arguments))) { |
9373 toNode.element = node.element; | 9691 toNode.element = node.element; |
9374 return true; | 9692 return true; |
9375 } | 9693 } |
9376 return false; | 9694 return false; |
9377 } | 9695 } |
9378 | 9696 |
9379 @override | 9697 @override |
9380 bool visitArgumentList(ArgumentList node) { | 9698 bool visitArgumentList(ArgumentList node) { |
9381 ArgumentList toNode = this._toNode as ArgumentList; | 9699 ArgumentList toNode = this._toNode as ArgumentList; |
9382 return _and(_isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 9700 return _and( |
9701 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | |
9383 _isEqualNodeLists(node.arguments, toNode.arguments), | 9702 _isEqualNodeLists(node.arguments, toNode.arguments), |
9384 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis)); | 9703 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis)); |
9385 } | 9704 } |
9386 | 9705 |
9387 @override | 9706 @override |
9388 bool visitAsExpression(AsExpression node) { | 9707 bool visitAsExpression(AsExpression node) { |
9389 AsExpression toNode = this._toNode as AsExpression; | 9708 AsExpression toNode = this._toNode as AsExpression; |
9390 if (_and(_isEqualNodes(node.expression, toNode.expression), | 9709 if (_and( |
9710 _isEqualNodes(node.expression, toNode.expression), | |
9391 _isEqualTokens(node.asOperator, toNode.asOperator), | 9711 _isEqualTokens(node.asOperator, toNode.asOperator), |
9392 _isEqualNodes(node.type, toNode.type))) { | 9712 _isEqualNodes(node.type, toNode.type))) { |
9393 toNode.propagatedType = node.propagatedType; | 9713 toNode.propagatedType = node.propagatedType; |
9394 toNode.staticType = node.staticType; | 9714 toNode.staticType = node.staticType; |
9395 return true; | 9715 return true; |
9396 } | 9716 } |
9397 return false; | 9717 return false; |
9398 } | 9718 } |
9399 | 9719 |
9400 @override | 9720 @override |
9401 bool visitAssertStatement(AssertStatement node) { | 9721 bool visitAssertStatement(AssertStatement node) { |
9402 AssertStatement toNode = this._toNode as AssertStatement; | 9722 AssertStatement toNode = this._toNode as AssertStatement; |
9403 return _and(_isEqualTokens(node.assertKeyword, toNode.assertKeyword), | 9723 return _and( |
9724 _isEqualTokens(node.assertKeyword, toNode.assertKeyword), | |
9404 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 9725 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
9405 _isEqualNodes(node.condition, toNode.condition), | 9726 _isEqualNodes(node.condition, toNode.condition), |
9406 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 9727 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
9407 _isEqualTokens(node.semicolon, toNode.semicolon)); | 9728 _isEqualTokens(node.semicolon, toNode.semicolon)); |
9408 } | 9729 } |
9409 | 9730 |
9410 @override | 9731 @override |
9411 bool visitAssignmentExpression(AssignmentExpression node) { | 9732 bool visitAssignmentExpression(AssignmentExpression node) { |
9412 AssignmentExpression toNode = this._toNode as AssignmentExpression; | 9733 AssignmentExpression toNode = this._toNode as AssignmentExpression; |
9413 if (_and(_isEqualNodes(node.leftHandSide, toNode.leftHandSide), | 9734 if (_and( |
9735 _isEqualNodes(node.leftHandSide, toNode.leftHandSide), | |
9414 _isEqualTokens(node.operator, toNode.operator), | 9736 _isEqualTokens(node.operator, toNode.operator), |
9415 _isEqualNodes(node.rightHandSide, toNode.rightHandSide))) { | 9737 _isEqualNodes(node.rightHandSide, toNode.rightHandSide))) { |
9416 toNode.propagatedElement = node.propagatedElement; | 9738 toNode.propagatedElement = node.propagatedElement; |
9417 toNode.propagatedType = node.propagatedType; | 9739 toNode.propagatedType = node.propagatedType; |
9418 toNode.staticElement = node.staticElement; | 9740 toNode.staticElement = node.staticElement; |
9419 toNode.staticType = node.staticType; | 9741 toNode.staticType = node.staticType; |
9420 return true; | 9742 return true; |
9421 } | 9743 } |
9422 return false; | 9744 return false; |
9423 } | 9745 } |
9424 | 9746 |
9425 @override | 9747 @override |
9426 bool visitAwaitExpression(AwaitExpression node) { | 9748 bool visitAwaitExpression(AwaitExpression node) { |
9427 AwaitExpression toNode = this._toNode as AwaitExpression; | 9749 AwaitExpression toNode = this._toNode as AwaitExpression; |
9428 if (_and(_isEqualTokens(node.awaitKeyword, toNode.awaitKeyword), | 9750 if (_and(_isEqualTokens(node.awaitKeyword, toNode.awaitKeyword), |
9429 _isEqualNodes(node.expression, toNode.expression))) { | 9751 _isEqualNodes(node.expression, toNode.expression))) { |
9430 toNode.propagatedType = node.propagatedType; | 9752 toNode.propagatedType = node.propagatedType; |
9431 toNode.staticType = node.staticType; | 9753 toNode.staticType = node.staticType; |
9432 return true; | 9754 return true; |
9433 } | 9755 } |
9434 return false; | 9756 return false; |
9435 } | 9757 } |
9436 | 9758 |
9437 @override | 9759 @override |
9438 bool visitBinaryExpression(BinaryExpression node) { | 9760 bool visitBinaryExpression(BinaryExpression node) { |
9439 BinaryExpression toNode = this._toNode as BinaryExpression; | 9761 BinaryExpression toNode = this._toNode as BinaryExpression; |
9440 if (_and(_isEqualNodes(node.leftOperand, toNode.leftOperand), | 9762 if (_and( |
9763 _isEqualNodes(node.leftOperand, toNode.leftOperand), | |
9441 _isEqualTokens(node.operator, toNode.operator), | 9764 _isEqualTokens(node.operator, toNode.operator), |
9442 _isEqualNodes(node.rightOperand, toNode.rightOperand))) { | 9765 _isEqualNodes(node.rightOperand, toNode.rightOperand))) { |
9443 toNode.propagatedElement = node.propagatedElement; | 9766 toNode.propagatedElement = node.propagatedElement; |
9444 toNode.propagatedType = node.propagatedType; | 9767 toNode.propagatedType = node.propagatedType; |
9445 toNode.staticElement = node.staticElement; | 9768 toNode.staticElement = node.staticElement; |
9446 toNode.staticType = node.staticType; | 9769 toNode.staticType = node.staticType; |
9447 return true; | 9770 return true; |
9448 } | 9771 } |
9449 return false; | 9772 return false; |
9450 } | 9773 } |
9451 | 9774 |
9452 @override | 9775 @override |
9453 bool visitBlock(Block node) { | 9776 bool visitBlock(Block node) { |
9454 Block toNode = this._toNode as Block; | 9777 Block toNode = this._toNode as Block; |
9455 return _and(_isEqualTokens(node.leftBracket, toNode.leftBracket), | 9778 return _and( |
9779 _isEqualTokens(node.leftBracket, toNode.leftBracket), | |
9456 _isEqualNodeLists(node.statements, toNode.statements), | 9780 _isEqualNodeLists(node.statements, toNode.statements), |
9457 _isEqualTokens(node.rightBracket, toNode.rightBracket)); | 9781 _isEqualTokens(node.rightBracket, toNode.rightBracket)); |
9458 } | 9782 } |
9459 | 9783 |
9460 @override | 9784 @override |
9461 bool visitBlockFunctionBody(BlockFunctionBody node) { | 9785 bool visitBlockFunctionBody(BlockFunctionBody node) { |
9462 BlockFunctionBody toNode = this._toNode as BlockFunctionBody; | 9786 BlockFunctionBody toNode = this._toNode as BlockFunctionBody; |
9463 return _isEqualNodes(node.block, toNode.block); | 9787 return _isEqualNodes(node.block, toNode.block); |
9464 } | 9788 } |
9465 | 9789 |
9466 @override | 9790 @override |
9467 bool visitBooleanLiteral(BooleanLiteral node) { | 9791 bool visitBooleanLiteral(BooleanLiteral node) { |
9468 BooleanLiteral toNode = this._toNode as BooleanLiteral; | 9792 BooleanLiteral toNode = this._toNode as BooleanLiteral; |
9469 if (_and(_isEqualTokens(node.literal, toNode.literal), | 9793 if (_and(_isEqualTokens(node.literal, toNode.literal), |
9470 node.value == toNode.value)) { | 9794 node.value == toNode.value)) { |
9471 toNode.propagatedType = node.propagatedType; | 9795 toNode.propagatedType = node.propagatedType; |
9472 toNode.staticType = node.staticType; | 9796 toNode.staticType = node.staticType; |
9473 return true; | 9797 return true; |
9474 } | 9798 } |
9475 return false; | 9799 return false; |
9476 } | 9800 } |
9477 | 9801 |
9478 @override | 9802 @override |
9479 bool visitBreakStatement(BreakStatement node) { | 9803 bool visitBreakStatement(BreakStatement node) { |
9480 BreakStatement toNode = this._toNode as BreakStatement; | 9804 BreakStatement toNode = this._toNode as BreakStatement; |
9481 if (_and(_isEqualTokens(node.breakKeyword, toNode.breakKeyword), | 9805 if (_and( |
9806 _isEqualTokens(node.breakKeyword, toNode.breakKeyword), | |
9482 _isEqualNodes(node.label, toNode.label), | 9807 _isEqualNodes(node.label, toNode.label), |
9483 _isEqualTokens(node.semicolon, toNode.semicolon))) { | 9808 _isEqualTokens(node.semicolon, toNode.semicolon))) { |
9484 // TODO(paulberry): map node.target to toNode.target. | 9809 // TODO(paulberry): map node.target to toNode.target. |
9485 return true; | 9810 return true; |
9486 } | 9811 } |
9487 return false; | 9812 return false; |
9488 } | 9813 } |
9489 | 9814 |
9490 @override | 9815 @override |
9491 bool visitCascadeExpression(CascadeExpression node) { | 9816 bool visitCascadeExpression(CascadeExpression node) { |
9492 CascadeExpression toNode = this._toNode as CascadeExpression; | 9817 CascadeExpression toNode = this._toNode as CascadeExpression; |
9493 if (_and(_isEqualNodes(node.target, toNode.target), | 9818 if (_and(_isEqualNodes(node.target, toNode.target), |
9494 _isEqualNodeLists(node.cascadeSections, toNode.cascadeSections))) { | 9819 _isEqualNodeLists(node.cascadeSections, toNode.cascadeSections))) { |
9495 toNode.propagatedType = node.propagatedType; | 9820 toNode.propagatedType = node.propagatedType; |
9496 toNode.staticType = node.staticType; | 9821 toNode.staticType = node.staticType; |
9497 return true; | 9822 return true; |
9498 } | 9823 } |
9499 return false; | 9824 return false; |
9500 } | 9825 } |
9501 | 9826 |
9502 @override | 9827 @override |
9503 bool visitCatchClause(CatchClause node) { | 9828 bool visitCatchClause(CatchClause node) { |
9504 CatchClause toNode = this._toNode as CatchClause; | 9829 CatchClause toNode = this._toNode as CatchClause; |
9505 return _and(_isEqualTokens(node.onKeyword, toNode.onKeyword), | 9830 return _and( |
9831 _isEqualTokens(node.onKeyword, toNode.onKeyword), | |
9506 _isEqualNodes(node.exceptionType, toNode.exceptionType), | 9832 _isEqualNodes(node.exceptionType, toNode.exceptionType), |
9507 _isEqualTokens(node.catchKeyword, toNode.catchKeyword), | 9833 _isEqualTokens(node.catchKeyword, toNode.catchKeyword), |
9508 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 9834 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
9509 _isEqualNodes(node.exceptionParameter, toNode.exceptionParameter), | 9835 _isEqualNodes(node.exceptionParameter, toNode.exceptionParameter), |
9510 _isEqualTokens(node.comma, toNode.comma), | 9836 _isEqualTokens(node.comma, toNode.comma), |
9511 _isEqualNodes(node.stackTraceParameter, toNode.stackTraceParameter), | 9837 _isEqualNodes(node.stackTraceParameter, toNode.stackTraceParameter), |
9512 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 9838 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
9513 _isEqualNodes(node.body, toNode.body)); | 9839 _isEqualNodes(node.body, toNode.body)); |
9514 } | 9840 } |
9515 | 9841 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9557 @override | 9883 @override |
9558 bool visitCommentReference(CommentReference node) { | 9884 bool visitCommentReference(CommentReference node) { |
9559 CommentReference toNode = this._toNode as CommentReference; | 9885 CommentReference toNode = this._toNode as CommentReference; |
9560 return _and(_isEqualTokens(node.newKeyword, toNode.newKeyword), | 9886 return _and(_isEqualTokens(node.newKeyword, toNode.newKeyword), |
9561 _isEqualNodes(node.identifier, toNode.identifier)); | 9887 _isEqualNodes(node.identifier, toNode.identifier)); |
9562 } | 9888 } |
9563 | 9889 |
9564 @override | 9890 @override |
9565 bool visitCompilationUnit(CompilationUnit node) { | 9891 bool visitCompilationUnit(CompilationUnit node) { |
9566 CompilationUnit toNode = this._toNode as CompilationUnit; | 9892 CompilationUnit toNode = this._toNode as CompilationUnit; |
9567 if (_and(_isEqualTokens(node.beginToken, toNode.beginToken), | 9893 if (_and( |
9894 _isEqualTokens(node.beginToken, toNode.beginToken), | |
9568 _isEqualNodes(node.scriptTag, toNode.scriptTag), | 9895 _isEqualNodes(node.scriptTag, toNode.scriptTag), |
9569 _isEqualNodeLists(node.directives, toNode.directives), | 9896 _isEqualNodeLists(node.directives, toNode.directives), |
9570 _isEqualNodeLists(node.declarations, toNode.declarations), | 9897 _isEqualNodeLists(node.declarations, toNode.declarations), |
9571 _isEqualTokens(node.endToken, toNode.endToken))) { | 9898 _isEqualTokens(node.endToken, toNode.endToken))) { |
9572 toNode.element = node.element; | 9899 toNode.element = node.element; |
9573 return true; | 9900 return true; |
9574 } | 9901 } |
9575 return false; | 9902 return false; |
9576 } | 9903 } |
9577 | 9904 |
9578 @override | 9905 @override |
9579 bool visitConditionalExpression(ConditionalExpression node) { | 9906 bool visitConditionalExpression(ConditionalExpression node) { |
9580 ConditionalExpression toNode = this._toNode as ConditionalExpression; | 9907 ConditionalExpression toNode = this._toNode as ConditionalExpression; |
9581 if (_and(_isEqualNodes(node.condition, toNode.condition), | 9908 if (_and( |
9909 _isEqualNodes(node.condition, toNode.condition), | |
9582 _isEqualTokens(node.question, toNode.question), | 9910 _isEqualTokens(node.question, toNode.question), |
9583 _isEqualNodes(node.thenExpression, toNode.thenExpression), | 9911 _isEqualNodes(node.thenExpression, toNode.thenExpression), |
9584 _isEqualTokens(node.colon, toNode.colon), | 9912 _isEqualTokens(node.colon, toNode.colon), |
9585 _isEqualNodes(node.elseExpression, toNode.elseExpression))) { | 9913 _isEqualNodes(node.elseExpression, toNode.elseExpression))) { |
9586 toNode.propagatedType = node.propagatedType; | 9914 toNode.propagatedType = node.propagatedType; |
9587 toNode.staticType = node.staticType; | 9915 toNode.staticType = node.staticType; |
9588 return true; | 9916 return true; |
9589 } | 9917 } |
9590 return false; | 9918 return false; |
9591 } | 9919 } |
(...skipping 18 matching lines...) Expand all Loading... | |
9610 toNode.element = node.element; | 9938 toNode.element = node.element; |
9611 return true; | 9939 return true; |
9612 } | 9940 } |
9613 return false; | 9941 return false; |
9614 } | 9942 } |
9615 | 9943 |
9616 @override | 9944 @override |
9617 bool visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 9945 bool visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
9618 ConstructorFieldInitializer toNode = | 9946 ConstructorFieldInitializer toNode = |
9619 this._toNode as ConstructorFieldInitializer; | 9947 this._toNode as ConstructorFieldInitializer; |
9620 return _and(_isEqualTokens(node.thisKeyword, toNode.thisKeyword), | 9948 return _and( |
9949 _isEqualTokens(node.thisKeyword, toNode.thisKeyword), | |
9621 _isEqualTokens(node.period, toNode.period), | 9950 _isEqualTokens(node.period, toNode.period), |
9622 _isEqualNodes(node.fieldName, toNode.fieldName), | 9951 _isEqualNodes(node.fieldName, toNode.fieldName), |
9623 _isEqualTokens(node.equals, toNode.equals), | 9952 _isEqualTokens(node.equals, toNode.equals), |
9624 _isEqualNodes(node.expression, toNode.expression)); | 9953 _isEqualNodes(node.expression, toNode.expression)); |
9625 } | 9954 } |
9626 | 9955 |
9627 @override | 9956 @override |
9628 bool visitConstructorName(ConstructorName node) { | 9957 bool visitConstructorName(ConstructorName node) { |
9629 ConstructorName toNode = this._toNode as ConstructorName; | 9958 ConstructorName toNode = this._toNode as ConstructorName; |
9630 if (_and(_isEqualNodes(node.type, toNode.type), | 9959 if (_and( |
9960 _isEqualNodes(node.type, toNode.type), | |
9631 _isEqualTokens(node.period, toNode.period), | 9961 _isEqualTokens(node.period, toNode.period), |
9632 _isEqualNodes(node.name, toNode.name))) { | 9962 _isEqualNodes(node.name, toNode.name))) { |
9633 toNode.staticElement = node.staticElement; | 9963 toNode.staticElement = node.staticElement; |
9634 return true; | 9964 return true; |
9635 } | 9965 } |
9636 return false; | 9966 return false; |
9637 } | 9967 } |
9638 | 9968 |
9639 @override | 9969 @override |
9640 bool visitContinueStatement(ContinueStatement node) { | 9970 bool visitContinueStatement(ContinueStatement node) { |
9641 ContinueStatement toNode = this._toNode as ContinueStatement; | 9971 ContinueStatement toNode = this._toNode as ContinueStatement; |
9642 if (_and(_isEqualTokens(node.continueKeyword, toNode.continueKeyword), | 9972 if (_and( |
9973 _isEqualTokens(node.continueKeyword, toNode.continueKeyword), | |
9643 _isEqualNodes(node.label, toNode.label), | 9974 _isEqualNodes(node.label, toNode.label), |
9644 _isEqualTokens(node.semicolon, toNode.semicolon))) { | 9975 _isEqualTokens(node.semicolon, toNode.semicolon))) { |
9645 // TODO(paulberry): map node.target to toNode.target. | 9976 // TODO(paulberry): map node.target to toNode.target. |
9646 return true; | 9977 return true; |
9647 } | 9978 } |
9648 return false; | 9979 return false; |
9649 } | 9980 } |
9650 | 9981 |
9651 @override | 9982 @override |
9652 bool visitDeclaredIdentifier(DeclaredIdentifier node) { | 9983 bool visitDeclaredIdentifier(DeclaredIdentifier node) { |
9653 DeclaredIdentifier toNode = this._toNode as DeclaredIdentifier; | 9984 DeclaredIdentifier toNode = this._toNode as DeclaredIdentifier; |
9654 return _and( | 9985 return _and( |
9655 _isEqualNodes(node.documentationComment, toNode.documentationComment), | 9986 _isEqualNodes(node.documentationComment, toNode.documentationComment), |
9656 _isEqualNodeLists(node.metadata, toNode.metadata), | 9987 _isEqualNodeLists(node.metadata, toNode.metadata), |
9657 _isEqualTokens(node.keyword, toNode.keyword), | 9988 _isEqualTokens(node.keyword, toNode.keyword), |
9658 _isEqualNodes(node.type, toNode.type), | 9989 _isEqualNodes(node.type, toNode.type), |
9659 _isEqualNodes(node.identifier, toNode.identifier)); | 9990 _isEqualNodes(node.identifier, toNode.identifier)); |
9660 } | 9991 } |
9661 | 9992 |
9662 @override | 9993 @override |
9663 bool visitDefaultFormalParameter(DefaultFormalParameter node) { | 9994 bool visitDefaultFormalParameter(DefaultFormalParameter node) { |
9664 DefaultFormalParameter toNode = this._toNode as DefaultFormalParameter; | 9995 DefaultFormalParameter toNode = this._toNode as DefaultFormalParameter; |
9665 return _and(_isEqualNodes(node.parameter, toNode.parameter), | 9996 return _and( |
9997 _isEqualNodes(node.parameter, toNode.parameter), | |
9666 node.kind == toNode.kind, | 9998 node.kind == toNode.kind, |
9667 _isEqualTokens(node.separator, toNode.separator), | 9999 _isEqualTokens(node.separator, toNode.separator), |
9668 _isEqualNodes(node.defaultValue, toNode.defaultValue)); | 10000 _isEqualNodes(node.defaultValue, toNode.defaultValue)); |
9669 } | 10001 } |
9670 | 10002 |
9671 @override | 10003 @override |
9672 bool visitDoStatement(DoStatement node) { | 10004 bool visitDoStatement(DoStatement node) { |
9673 DoStatement toNode = this._toNode as DoStatement; | 10005 DoStatement toNode = this._toNode as DoStatement; |
9674 return _and(_isEqualTokens(node.doKeyword, toNode.doKeyword), | 10006 return _and( |
10007 _isEqualTokens(node.doKeyword, toNode.doKeyword), | |
9675 _isEqualNodes(node.body, toNode.body), | 10008 _isEqualNodes(node.body, toNode.body), |
9676 _isEqualTokens(node.whileKeyword, toNode.whileKeyword), | 10009 _isEqualTokens(node.whileKeyword, toNode.whileKeyword), |
9677 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 10010 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
9678 _isEqualNodes(node.condition, toNode.condition), | 10011 _isEqualNodes(node.condition, toNode.condition), |
9679 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 10012 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
9680 _isEqualTokens(node.semicolon, toNode.semicolon)); | 10013 _isEqualTokens(node.semicolon, toNode.semicolon)); |
9681 } | 10014 } |
9682 | 10015 |
9683 @override | 10016 @override |
9684 bool visitDoubleLiteral(DoubleLiteral node) { | 10017 bool visitDoubleLiteral(DoubleLiteral node) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9785 _isEqualTokens(node.keyword, toNode.keyword), | 10118 _isEqualTokens(node.keyword, toNode.keyword), |
9786 _isEqualNodes(node.type, toNode.type), | 10119 _isEqualNodes(node.type, toNode.type), |
9787 _isEqualTokens(node.thisKeyword, toNode.thisKeyword), | 10120 _isEqualTokens(node.thisKeyword, toNode.thisKeyword), |
9788 _isEqualTokens(node.period, toNode.period), | 10121 _isEqualTokens(node.period, toNode.period), |
9789 _isEqualNodes(node.identifier, toNode.identifier)); | 10122 _isEqualNodes(node.identifier, toNode.identifier)); |
9790 } | 10123 } |
9791 | 10124 |
9792 @override | 10125 @override |
9793 bool visitForEachStatement(ForEachStatement node) { | 10126 bool visitForEachStatement(ForEachStatement node) { |
9794 ForEachStatement toNode = this._toNode as ForEachStatement; | 10127 ForEachStatement toNode = this._toNode as ForEachStatement; |
9795 return _and(_isEqualTokens(node.forKeyword, toNode.forKeyword), | 10128 return _and( |
10129 _isEqualTokens(node.forKeyword, toNode.forKeyword), | |
9796 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 10130 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
9797 _isEqualNodes(node.loopVariable, toNode.loopVariable), | 10131 _isEqualNodes(node.loopVariable, toNode.loopVariable), |
9798 _isEqualTokens(node.inKeyword, toNode.inKeyword), | 10132 _isEqualTokens(node.inKeyword, toNode.inKeyword), |
9799 _isEqualNodes(node.iterable, toNode.iterable), | 10133 _isEqualNodes(node.iterable, toNode.iterable), |
9800 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 10134 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
9801 _isEqualNodes(node.body, toNode.body)); | 10135 _isEqualNodes(node.body, toNode.body)); |
9802 } | 10136 } |
9803 | 10137 |
9804 @override | 10138 @override |
9805 bool visitFormalParameterList(FormalParameterList node) { | 10139 bool visitFormalParameterList(FormalParameterList node) { |
9806 FormalParameterList toNode = this._toNode as FormalParameterList; | 10140 FormalParameterList toNode = this._toNode as FormalParameterList; |
9807 return _and(_isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 10141 return _and( |
10142 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | |
9808 _isEqualNodeLists(node.parameters, toNode.parameters), | 10143 _isEqualNodeLists(node.parameters, toNode.parameters), |
9809 _isEqualTokens(node.leftDelimiter, toNode.leftDelimiter), | 10144 _isEqualTokens(node.leftDelimiter, toNode.leftDelimiter), |
9810 _isEqualTokens(node.rightDelimiter, toNode.rightDelimiter), | 10145 _isEqualTokens(node.rightDelimiter, toNode.rightDelimiter), |
9811 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis)); | 10146 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis)); |
9812 } | 10147 } |
9813 | 10148 |
9814 @override | 10149 @override |
9815 bool visitForStatement(ForStatement node) { | 10150 bool visitForStatement(ForStatement node) { |
9816 ForStatement toNode = this._toNode as ForStatement; | 10151 ForStatement toNode = this._toNode as ForStatement; |
9817 return _and(_isEqualTokens(node.forKeyword, toNode.forKeyword), | 10152 return _and( |
10153 _isEqualTokens(node.forKeyword, toNode.forKeyword), | |
9818 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 10154 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
9819 _isEqualNodes(node.variables, toNode.variables), | 10155 _isEqualNodes(node.variables, toNode.variables), |
9820 _isEqualNodes(node.initialization, toNode.initialization), | 10156 _isEqualNodes(node.initialization, toNode.initialization), |
9821 _isEqualTokens(node.leftSeparator, toNode.leftSeparator), | 10157 _isEqualTokens(node.leftSeparator, toNode.leftSeparator), |
9822 _isEqualNodes(node.condition, toNode.condition), | 10158 _isEqualNodes(node.condition, toNode.condition), |
9823 _isEqualTokens(node.rightSeparator, toNode.rightSeparator), | 10159 _isEqualTokens(node.rightSeparator, toNode.rightSeparator), |
9824 _isEqualNodeLists(node.updaters, toNode.updaters), | 10160 _isEqualNodeLists(node.updaters, toNode.updaters), |
9825 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 10161 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
9826 _isEqualNodes(node.body, toNode.body)); | 10162 _isEqualNodes(node.body, toNode.body)); |
9827 } | 10163 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9903 @override | 10239 @override |
9904 bool visitHideCombinator(HideCombinator node) { | 10240 bool visitHideCombinator(HideCombinator node) { |
9905 HideCombinator toNode = this._toNode as HideCombinator; | 10241 HideCombinator toNode = this._toNode as HideCombinator; |
9906 return _and(_isEqualTokens(node.keyword, toNode.keyword), | 10242 return _and(_isEqualTokens(node.keyword, toNode.keyword), |
9907 _isEqualNodeLists(node.hiddenNames, toNode.hiddenNames)); | 10243 _isEqualNodeLists(node.hiddenNames, toNode.hiddenNames)); |
9908 } | 10244 } |
9909 | 10245 |
9910 @override | 10246 @override |
9911 bool visitIfStatement(IfStatement node) { | 10247 bool visitIfStatement(IfStatement node) { |
9912 IfStatement toNode = this._toNode as IfStatement; | 10248 IfStatement toNode = this._toNode as IfStatement; |
9913 return _and(_isEqualTokens(node.ifKeyword, toNode.ifKeyword), | 10249 return _and( |
10250 _isEqualTokens(node.ifKeyword, toNode.ifKeyword), | |
9914 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 10251 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
9915 _isEqualNodes(node.condition, toNode.condition), | 10252 _isEqualNodes(node.condition, toNode.condition), |
9916 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 10253 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
9917 _isEqualNodes(node.thenStatement, toNode.thenStatement), | 10254 _isEqualNodes(node.thenStatement, toNode.thenStatement), |
9918 _isEqualTokens(node.elseKeyword, toNode.elseKeyword), | 10255 _isEqualTokens(node.elseKeyword, toNode.elseKeyword), |
9919 _isEqualNodes(node.elseStatement, toNode.elseStatement)); | 10256 _isEqualNodes(node.elseStatement, toNode.elseStatement)); |
9920 } | 10257 } |
9921 | 10258 |
9922 @override | 10259 @override |
9923 bool visitImplementsClause(ImplementsClause node) { | 10260 bool visitImplementsClause(ImplementsClause node) { |
(...skipping 17 matching lines...) Expand all Loading... | |
9941 _isEqualTokens(node.semicolon, toNode.semicolon))) { | 10278 _isEqualTokens(node.semicolon, toNode.semicolon))) { |
9942 toNode.element = node.element; | 10279 toNode.element = node.element; |
9943 return true; | 10280 return true; |
9944 } | 10281 } |
9945 return false; | 10282 return false; |
9946 } | 10283 } |
9947 | 10284 |
9948 @override | 10285 @override |
9949 bool visitIndexExpression(IndexExpression node) { | 10286 bool visitIndexExpression(IndexExpression node) { |
9950 IndexExpression toNode = this._toNode as IndexExpression; | 10287 IndexExpression toNode = this._toNode as IndexExpression; |
9951 if (_and(_isEqualNodes(node.target, toNode.target), | 10288 if (_and( |
10289 _isEqualNodes(node.target, toNode.target), | |
9952 _isEqualTokens(node.leftBracket, toNode.leftBracket), | 10290 _isEqualTokens(node.leftBracket, toNode.leftBracket), |
9953 _isEqualNodes(node.index, toNode.index), | 10291 _isEqualNodes(node.index, toNode.index), |
9954 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { | 10292 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { |
9955 toNode.auxiliaryElements = node.auxiliaryElements; | 10293 toNode.auxiliaryElements = node.auxiliaryElements; |
9956 toNode.propagatedElement = node.propagatedElement; | 10294 toNode.propagatedElement = node.propagatedElement; |
9957 toNode.propagatedType = node.propagatedType; | 10295 toNode.propagatedType = node.propagatedType; |
9958 toNode.staticElement = node.staticElement; | 10296 toNode.staticElement = node.staticElement; |
9959 toNode.staticType = node.staticType; | 10297 toNode.staticType = node.staticType; |
9960 return true; | 10298 return true; |
9961 } | 10299 } |
9962 return false; | 10300 return false; |
9963 } | 10301 } |
9964 | 10302 |
9965 @override | 10303 @override |
9966 bool visitInstanceCreationExpression(InstanceCreationExpression node) { | 10304 bool visitInstanceCreationExpression(InstanceCreationExpression node) { |
9967 InstanceCreationExpression toNode = | 10305 InstanceCreationExpression toNode = |
9968 this._toNode as InstanceCreationExpression; | 10306 this._toNode as InstanceCreationExpression; |
9969 if (_and(_isEqualTokens(node.keyword, toNode.keyword), | 10307 if (_and( |
10308 _isEqualTokens(node.keyword, toNode.keyword), | |
9970 _isEqualNodes(node.constructorName, toNode.constructorName), | 10309 _isEqualNodes(node.constructorName, toNode.constructorName), |
9971 _isEqualNodes(node.argumentList, toNode.argumentList))) { | 10310 _isEqualNodes(node.argumentList, toNode.argumentList))) { |
9972 toNode.propagatedType = node.propagatedType; | 10311 toNode.propagatedType = node.propagatedType; |
9973 toNode.staticElement = node.staticElement; | 10312 toNode.staticElement = node.staticElement; |
9974 toNode.staticType = node.staticType; | 10313 toNode.staticType = node.staticType; |
9975 return true; | 10314 return true; |
9976 } | 10315 } |
9977 return false; | 10316 return false; |
9978 } | 10317 } |
9979 | 10318 |
9980 @override | 10319 @override |
9981 bool visitIntegerLiteral(IntegerLiteral node) { | 10320 bool visitIntegerLiteral(IntegerLiteral node) { |
9982 IntegerLiteral toNode = this._toNode as IntegerLiteral; | 10321 IntegerLiteral toNode = this._toNode as IntegerLiteral; |
9983 if (_and(_isEqualTokens(node.literal, toNode.literal), | 10322 if (_and(_isEqualTokens(node.literal, toNode.literal), |
9984 node.value == toNode.value)) { | 10323 node.value == toNode.value)) { |
9985 toNode.propagatedType = node.propagatedType; | 10324 toNode.propagatedType = node.propagatedType; |
9986 toNode.staticType = node.staticType; | 10325 toNode.staticType = node.staticType; |
9987 return true; | 10326 return true; |
9988 } | 10327 } |
9989 return false; | 10328 return false; |
9990 } | 10329 } |
9991 | 10330 |
9992 @override | 10331 @override |
9993 bool visitInterpolationExpression(InterpolationExpression node) { | 10332 bool visitInterpolationExpression(InterpolationExpression node) { |
9994 InterpolationExpression toNode = this._toNode as InterpolationExpression; | 10333 InterpolationExpression toNode = this._toNode as InterpolationExpression; |
9995 return _and(_isEqualTokens(node.leftBracket, toNode.leftBracket), | 10334 return _and( |
10335 _isEqualTokens(node.leftBracket, toNode.leftBracket), | |
9996 _isEqualNodes(node.expression, toNode.expression), | 10336 _isEqualNodes(node.expression, toNode.expression), |
9997 _isEqualTokens(node.rightBracket, toNode.rightBracket)); | 10337 _isEqualTokens(node.rightBracket, toNode.rightBracket)); |
9998 } | 10338 } |
9999 | 10339 |
10000 @override | 10340 @override |
10001 bool visitInterpolationString(InterpolationString node) { | 10341 bool visitInterpolationString(InterpolationString node) { |
10002 InterpolationString toNode = this._toNode as InterpolationString; | 10342 InterpolationString toNode = this._toNode as InterpolationString; |
10003 return _and(_isEqualTokens(node.contents, toNode.contents), | 10343 return _and(_isEqualTokens(node.contents, toNode.contents), |
10004 node.value == toNode.value); | 10344 node.value == toNode.value); |
10005 } | 10345 } |
10006 | 10346 |
10007 @override | 10347 @override |
10008 bool visitIsExpression(IsExpression node) { | 10348 bool visitIsExpression(IsExpression node) { |
10009 IsExpression toNode = this._toNode as IsExpression; | 10349 IsExpression toNode = this._toNode as IsExpression; |
10010 if (_and(_isEqualNodes(node.expression, toNode.expression), | 10350 if (_and( |
10351 _isEqualNodes(node.expression, toNode.expression), | |
10011 _isEqualTokens(node.isOperator, toNode.isOperator), | 10352 _isEqualTokens(node.isOperator, toNode.isOperator), |
10012 _isEqualTokens(node.notOperator, toNode.notOperator), | 10353 _isEqualTokens(node.notOperator, toNode.notOperator), |
10013 _isEqualNodes(node.type, toNode.type))) { | 10354 _isEqualNodes(node.type, toNode.type))) { |
10014 toNode.propagatedType = node.propagatedType; | 10355 toNode.propagatedType = node.propagatedType; |
10015 toNode.staticType = node.staticType; | 10356 toNode.staticType = node.staticType; |
10016 return true; | 10357 return true; |
10017 } | 10358 } |
10018 return false; | 10359 return false; |
10019 } | 10360 } |
10020 | 10361 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10054 toNode.propagatedType = node.propagatedType; | 10395 toNode.propagatedType = node.propagatedType; |
10055 toNode.staticType = node.staticType; | 10396 toNode.staticType = node.staticType; |
10056 return true; | 10397 return true; |
10057 } | 10398 } |
10058 return false; | 10399 return false; |
10059 } | 10400 } |
10060 | 10401 |
10061 @override | 10402 @override |
10062 bool visitListLiteral(ListLiteral node) { | 10403 bool visitListLiteral(ListLiteral node) { |
10063 ListLiteral toNode = this._toNode as ListLiteral; | 10404 ListLiteral toNode = this._toNode as ListLiteral; |
10064 if (_and(_isEqualTokens(node.constKeyword, toNode.constKeyword), | 10405 if (_and( |
10406 _isEqualTokens(node.constKeyword, toNode.constKeyword), | |
10065 _isEqualNodes(node.typeArguments, toNode.typeArguments), | 10407 _isEqualNodes(node.typeArguments, toNode.typeArguments), |
10066 _isEqualTokens(node.leftBracket, toNode.leftBracket), | 10408 _isEqualTokens(node.leftBracket, toNode.leftBracket), |
10067 _isEqualNodeLists(node.elements, toNode.elements), | 10409 _isEqualNodeLists(node.elements, toNode.elements), |
10068 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { | 10410 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { |
10069 toNode.propagatedType = node.propagatedType; | 10411 toNode.propagatedType = node.propagatedType; |
10070 toNode.staticType = node.staticType; | 10412 toNode.staticType = node.staticType; |
10071 return true; | 10413 return true; |
10072 } | 10414 } |
10073 return false; | 10415 return false; |
10074 } | 10416 } |
10075 | 10417 |
10076 @override | 10418 @override |
10077 bool visitMapLiteral(MapLiteral node) { | 10419 bool visitMapLiteral(MapLiteral node) { |
10078 MapLiteral toNode = this._toNode as MapLiteral; | 10420 MapLiteral toNode = this._toNode as MapLiteral; |
10079 if (_and(_isEqualTokens(node.constKeyword, toNode.constKeyword), | 10421 if (_and( |
10422 _isEqualTokens(node.constKeyword, toNode.constKeyword), | |
10080 _isEqualNodes(node.typeArguments, toNode.typeArguments), | 10423 _isEqualNodes(node.typeArguments, toNode.typeArguments), |
10081 _isEqualTokens(node.leftBracket, toNode.leftBracket), | 10424 _isEqualTokens(node.leftBracket, toNode.leftBracket), |
10082 _isEqualNodeLists(node.entries, toNode.entries), | 10425 _isEqualNodeLists(node.entries, toNode.entries), |
10083 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { | 10426 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { |
10084 toNode.propagatedType = node.propagatedType; | 10427 toNode.propagatedType = node.propagatedType; |
10085 toNode.staticType = node.staticType; | 10428 toNode.staticType = node.staticType; |
10086 return true; | 10429 return true; |
10087 } | 10430 } |
10088 return false; | 10431 return false; |
10089 } | 10432 } |
10090 | 10433 |
10091 @override | 10434 @override |
10092 bool visitMapLiteralEntry(MapLiteralEntry node) { | 10435 bool visitMapLiteralEntry(MapLiteralEntry node) { |
10093 MapLiteralEntry toNode = this._toNode as MapLiteralEntry; | 10436 MapLiteralEntry toNode = this._toNode as MapLiteralEntry; |
10094 return _and(_isEqualNodes(node.key, toNode.key), | 10437 return _and( |
10438 _isEqualNodes(node.key, toNode.key), | |
10095 _isEqualTokens(node.separator, toNode.separator), | 10439 _isEqualTokens(node.separator, toNode.separator), |
10096 _isEqualNodes(node.value, toNode.value)); | 10440 _isEqualNodes(node.value, toNode.value)); |
10097 } | 10441 } |
10098 | 10442 |
10099 @override | 10443 @override |
10100 bool visitMethodDeclaration(MethodDeclaration node) { | 10444 bool visitMethodDeclaration(MethodDeclaration node) { |
10101 MethodDeclaration toNode = this._toNode as MethodDeclaration; | 10445 MethodDeclaration toNode = this._toNode as MethodDeclaration; |
10102 return _and( | 10446 return _and( |
10103 _isEqualNodes(node.documentationComment, toNode.documentationComment), | 10447 _isEqualNodes(node.documentationComment, toNode.documentationComment), |
10104 _isEqualNodeLists(node.metadata, toNode.metadata), | 10448 _isEqualNodeLists(node.metadata, toNode.metadata), |
10105 _isEqualTokens(node.externalKeyword, toNode.externalKeyword), | 10449 _isEqualTokens(node.externalKeyword, toNode.externalKeyword), |
10106 _isEqualTokens(node.modifierKeyword, toNode.modifierKeyword), | 10450 _isEqualTokens(node.modifierKeyword, toNode.modifierKeyword), |
10107 _isEqualNodes(node.returnType, toNode.returnType), | 10451 _isEqualNodes(node.returnType, toNode.returnType), |
10108 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword), | 10452 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword), |
10109 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword), | 10453 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword), |
10110 _isEqualNodes(node.name, toNode.name), | 10454 _isEqualNodes(node.name, toNode.name), |
10111 _isEqualNodes(node.parameters, toNode.parameters), | 10455 _isEqualNodes(node.parameters, toNode.parameters), |
10112 _isEqualNodes(node.body, toNode.body)); | 10456 _isEqualNodes(node.body, toNode.body)); |
10113 } | 10457 } |
10114 | 10458 |
10115 @override | 10459 @override |
10116 bool visitMethodInvocation(MethodInvocation node) { | 10460 bool visitMethodInvocation(MethodInvocation node) { |
10117 MethodInvocation toNode = this._toNode as MethodInvocation; | 10461 MethodInvocation toNode = this._toNode as MethodInvocation; |
10118 if (_and(_isEqualNodes(node.target, toNode.target), | 10462 if (_and( |
10463 _isEqualNodes(node.target, toNode.target), | |
10119 _isEqualTokens(node.operator, toNode.operator), | 10464 _isEqualTokens(node.operator, toNode.operator), |
10120 _isEqualNodes(node.methodName, toNode.methodName), | 10465 _isEqualNodes(node.methodName, toNode.methodName), |
10121 _isEqualNodes(node.argumentList, toNode.argumentList))) { | 10466 _isEqualNodes(node.argumentList, toNode.argumentList))) { |
10122 toNode.propagatedType = node.propagatedType; | 10467 toNode.propagatedType = node.propagatedType; |
10123 toNode.staticType = node.staticType; | 10468 toNode.staticType = node.staticType; |
10124 return true; | 10469 return true; |
10125 } | 10470 } |
10126 return false; | 10471 return false; |
10127 } | 10472 } |
10128 | 10473 |
(...skipping 12 matching lines...) Expand all Loading... | |
10141 @override | 10486 @override |
10142 bool visitNativeClause(NativeClause node) { | 10487 bool visitNativeClause(NativeClause node) { |
10143 NativeClause toNode = this._toNode as NativeClause; | 10488 NativeClause toNode = this._toNode as NativeClause; |
10144 return _and(_isEqualTokens(node.nativeKeyword, toNode.nativeKeyword), | 10489 return _and(_isEqualTokens(node.nativeKeyword, toNode.nativeKeyword), |
10145 _isEqualNodes(node.name, toNode.name)); | 10490 _isEqualNodes(node.name, toNode.name)); |
10146 } | 10491 } |
10147 | 10492 |
10148 @override | 10493 @override |
10149 bool visitNativeFunctionBody(NativeFunctionBody node) { | 10494 bool visitNativeFunctionBody(NativeFunctionBody node) { |
10150 NativeFunctionBody toNode = this._toNode as NativeFunctionBody; | 10495 NativeFunctionBody toNode = this._toNode as NativeFunctionBody; |
10151 return _and(_isEqualTokens(node.nativeKeyword, toNode.nativeKeyword), | 10496 return _and( |
10497 _isEqualTokens(node.nativeKeyword, toNode.nativeKeyword), | |
10152 _isEqualNodes(node.stringLiteral, toNode.stringLiteral), | 10498 _isEqualNodes(node.stringLiteral, toNode.stringLiteral), |
10153 _isEqualTokens(node.semicolon, toNode.semicolon)); | 10499 _isEqualTokens(node.semicolon, toNode.semicolon)); |
10154 } | 10500 } |
10155 | 10501 |
10156 @override | 10502 @override |
10157 bool visitNullLiteral(NullLiteral node) { | 10503 bool visitNullLiteral(NullLiteral node) { |
10158 NullLiteral toNode = this._toNode as NullLiteral; | 10504 NullLiteral toNode = this._toNode as NullLiteral; |
10159 if (_isEqualTokens(node.literal, toNode.literal)) { | 10505 if (_isEqualTokens(node.literal, toNode.literal)) { |
10160 toNode.propagatedType = node.propagatedType; | 10506 toNode.propagatedType = node.propagatedType; |
10161 toNode.staticType = node.staticType; | 10507 toNode.staticType = node.staticType; |
10162 return true; | 10508 return true; |
10163 } | 10509 } |
10164 return false; | 10510 return false; |
10165 } | 10511 } |
10166 | 10512 |
10167 @override | 10513 @override |
10168 bool visitParenthesizedExpression(ParenthesizedExpression node) { | 10514 bool visitParenthesizedExpression(ParenthesizedExpression node) { |
10169 ParenthesizedExpression toNode = this._toNode as ParenthesizedExpression; | 10515 ParenthesizedExpression toNode = this._toNode as ParenthesizedExpression; |
10170 if (_and(_isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 10516 if (_and( |
10517 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | |
10171 _isEqualNodes(node.expression, toNode.expression), | 10518 _isEqualNodes(node.expression, toNode.expression), |
10172 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis))) { | 10519 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis))) { |
10173 toNode.propagatedType = node.propagatedType; | 10520 toNode.propagatedType = node.propagatedType; |
10174 toNode.staticType = node.staticType; | 10521 toNode.staticType = node.staticType; |
10175 return true; | 10522 return true; |
10176 } | 10523 } |
10177 return false; | 10524 return false; |
10178 } | 10525 } |
10179 | 10526 |
10180 @override | 10527 @override |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10218 toNode.staticElement = node.staticElement; | 10565 toNode.staticElement = node.staticElement; |
10219 toNode.staticType = node.staticType; | 10566 toNode.staticType = node.staticType; |
10220 return true; | 10567 return true; |
10221 } | 10568 } |
10222 return false; | 10569 return false; |
10223 } | 10570 } |
10224 | 10571 |
10225 @override | 10572 @override |
10226 bool visitPrefixedIdentifier(PrefixedIdentifier node) { | 10573 bool visitPrefixedIdentifier(PrefixedIdentifier node) { |
10227 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier; | 10574 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier; |
10228 if (_and(_isEqualNodes(node.prefix, toNode.prefix), | 10575 if (_and( |
10576 _isEqualNodes(node.prefix, toNode.prefix), | |
10229 _isEqualTokens(node.period, toNode.period), | 10577 _isEqualTokens(node.period, toNode.period), |
10230 _isEqualNodes(node.identifier, toNode.identifier))) { | 10578 _isEqualNodes(node.identifier, toNode.identifier))) { |
10231 toNode.propagatedType = node.propagatedType; | 10579 toNode.propagatedType = node.propagatedType; |
10232 toNode.staticType = node.staticType; | 10580 toNode.staticType = node.staticType; |
10233 return true; | 10581 return true; |
10234 } | 10582 } |
10235 return false; | 10583 return false; |
10236 } | 10584 } |
10237 | 10585 |
10238 @override | 10586 @override |
10239 bool visitPrefixExpression(PrefixExpression node) { | 10587 bool visitPrefixExpression(PrefixExpression node) { |
10240 PrefixExpression toNode = this._toNode as PrefixExpression; | 10588 PrefixExpression toNode = this._toNode as PrefixExpression; |
10241 if (_and(_isEqualTokens(node.operator, toNode.operator), | 10589 if (_and(_isEqualTokens(node.operator, toNode.operator), |
10242 _isEqualNodes(node.operand, toNode.operand))) { | 10590 _isEqualNodes(node.operand, toNode.operand))) { |
10243 toNode.propagatedElement = node.propagatedElement; | 10591 toNode.propagatedElement = node.propagatedElement; |
10244 toNode.propagatedType = node.propagatedType; | 10592 toNode.propagatedType = node.propagatedType; |
10245 toNode.staticElement = node.staticElement; | 10593 toNode.staticElement = node.staticElement; |
10246 toNode.staticType = node.staticType; | 10594 toNode.staticType = node.staticType; |
10247 return true; | 10595 return true; |
10248 } | 10596 } |
10249 return false; | 10597 return false; |
10250 } | 10598 } |
10251 | 10599 |
10252 @override | 10600 @override |
10253 bool visitPropertyAccess(PropertyAccess node) { | 10601 bool visitPropertyAccess(PropertyAccess node) { |
10254 PropertyAccess toNode = this._toNode as PropertyAccess; | 10602 PropertyAccess toNode = this._toNode as PropertyAccess; |
10255 if (_and(_isEqualNodes(node.target, toNode.target), | 10603 if (_and( |
10604 _isEqualNodes(node.target, toNode.target), | |
10256 _isEqualTokens(node.operator, toNode.operator), | 10605 _isEqualTokens(node.operator, toNode.operator), |
10257 _isEqualNodes(node.propertyName, toNode.propertyName))) { | 10606 _isEqualNodes(node.propertyName, toNode.propertyName))) { |
10258 toNode.propagatedType = node.propagatedType; | 10607 toNode.propagatedType = node.propagatedType; |
10259 toNode.staticType = node.staticType; | 10608 toNode.staticType = node.staticType; |
10260 return true; | 10609 return true; |
10261 } | 10610 } |
10262 return false; | 10611 return false; |
10263 } | 10612 } |
10264 | 10613 |
10265 @override | 10614 @override |
10266 bool visitRedirectingConstructorInvocation( | 10615 bool visitRedirectingConstructorInvocation( |
10267 RedirectingConstructorInvocation node) { | 10616 RedirectingConstructorInvocation node) { |
10268 RedirectingConstructorInvocation toNode = | 10617 RedirectingConstructorInvocation toNode = |
10269 this._toNode as RedirectingConstructorInvocation; | 10618 this._toNode as RedirectingConstructorInvocation; |
10270 if (_and(_isEqualTokens(node.thisKeyword, toNode.thisKeyword), | 10619 if (_and( |
10620 _isEqualTokens(node.thisKeyword, toNode.thisKeyword), | |
10271 _isEqualTokens(node.period, toNode.period), | 10621 _isEqualTokens(node.period, toNode.period), |
10272 _isEqualNodes(node.constructorName, toNode.constructorName), | 10622 _isEqualNodes(node.constructorName, toNode.constructorName), |
10273 _isEqualNodes(node.argumentList, toNode.argumentList))) { | 10623 _isEqualNodes(node.argumentList, toNode.argumentList))) { |
10274 toNode.staticElement = node.staticElement; | 10624 toNode.staticElement = node.staticElement; |
10275 return true; | 10625 return true; |
10276 } | 10626 } |
10277 return false; | 10627 return false; |
10278 } | 10628 } |
10279 | 10629 |
10280 @override | 10630 @override |
10281 bool visitRethrowExpression(RethrowExpression node) { | 10631 bool visitRethrowExpression(RethrowExpression node) { |
10282 RethrowExpression toNode = this._toNode as RethrowExpression; | 10632 RethrowExpression toNode = this._toNode as RethrowExpression; |
10283 if (_isEqualTokens(node.rethrowKeyword, toNode.rethrowKeyword)) { | 10633 if (_isEqualTokens(node.rethrowKeyword, toNode.rethrowKeyword)) { |
10284 toNode.propagatedType = node.propagatedType; | 10634 toNode.propagatedType = node.propagatedType; |
10285 toNode.staticType = node.staticType; | 10635 toNode.staticType = node.staticType; |
10286 return true; | 10636 return true; |
10287 } | 10637 } |
10288 return false; | 10638 return false; |
10289 } | 10639 } |
10290 | 10640 |
10291 @override | 10641 @override |
10292 bool visitReturnStatement(ReturnStatement node) { | 10642 bool visitReturnStatement(ReturnStatement node) { |
10293 ReturnStatement toNode = this._toNode as ReturnStatement; | 10643 ReturnStatement toNode = this._toNode as ReturnStatement; |
10294 return _and(_isEqualTokens(node.returnKeyword, toNode.returnKeyword), | 10644 return _and( |
10645 _isEqualTokens(node.returnKeyword, toNode.returnKeyword), | |
10295 _isEqualNodes(node.expression, toNode.expression), | 10646 _isEqualNodes(node.expression, toNode.expression), |
10296 _isEqualTokens(node.semicolon, toNode.semicolon)); | 10647 _isEqualTokens(node.semicolon, toNode.semicolon)); |
10297 } | 10648 } |
10298 | 10649 |
10299 @override | 10650 @override |
10300 bool visitScriptTag(ScriptTag node) { | 10651 bool visitScriptTag(ScriptTag node) { |
10301 ScriptTag toNode = this._toNode as ScriptTag; | 10652 ScriptTag toNode = this._toNode as ScriptTag; |
10302 return _isEqualTokens(node.scriptTag, toNode.scriptTag); | 10653 return _isEqualTokens(node.scriptTag, toNode.scriptTag); |
10303 } | 10654 } |
10304 | 10655 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10354 toNode.staticType = node.staticType; | 10705 toNode.staticType = node.staticType; |
10355 return true; | 10706 return true; |
10356 } | 10707 } |
10357 return false; | 10708 return false; |
10358 } | 10709 } |
10359 | 10710 |
10360 @override | 10711 @override |
10361 bool visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 10712 bool visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
10362 SuperConstructorInvocation toNode = | 10713 SuperConstructorInvocation toNode = |
10363 this._toNode as SuperConstructorInvocation; | 10714 this._toNode as SuperConstructorInvocation; |
10364 if (_and(_isEqualTokens(node.superKeyword, toNode.superKeyword), | 10715 if (_and( |
10716 _isEqualTokens(node.superKeyword, toNode.superKeyword), | |
10365 _isEqualTokens(node.period, toNode.period), | 10717 _isEqualTokens(node.period, toNode.period), |
10366 _isEqualNodes(node.constructorName, toNode.constructorName), | 10718 _isEqualNodes(node.constructorName, toNode.constructorName), |
10367 _isEqualNodes(node.argumentList, toNode.argumentList))) { | 10719 _isEqualNodes(node.argumentList, toNode.argumentList))) { |
10368 toNode.staticElement = node.staticElement; | 10720 toNode.staticElement = node.staticElement; |
10369 return true; | 10721 return true; |
10370 } | 10722 } |
10371 return false; | 10723 return false; |
10372 } | 10724 } |
10373 | 10725 |
10374 @override | 10726 @override |
10375 bool visitSuperExpression(SuperExpression node) { | 10727 bool visitSuperExpression(SuperExpression node) { |
10376 SuperExpression toNode = this._toNode as SuperExpression; | 10728 SuperExpression toNode = this._toNode as SuperExpression; |
10377 if (_isEqualTokens(node.superKeyword, toNode.superKeyword)) { | 10729 if (_isEqualTokens(node.superKeyword, toNode.superKeyword)) { |
10378 toNode.propagatedType = node.propagatedType; | 10730 toNode.propagatedType = node.propagatedType; |
10379 toNode.staticType = node.staticType; | 10731 toNode.staticType = node.staticType; |
10380 return true; | 10732 return true; |
10381 } | 10733 } |
10382 return false; | 10734 return false; |
10383 } | 10735 } |
10384 | 10736 |
10385 @override | 10737 @override |
10386 bool visitSwitchCase(SwitchCase node) { | 10738 bool visitSwitchCase(SwitchCase node) { |
10387 SwitchCase toNode = this._toNode as SwitchCase; | 10739 SwitchCase toNode = this._toNode as SwitchCase; |
10388 return _and(_isEqualNodeLists(node.labels, toNode.labels), | 10740 return _and( |
10741 _isEqualNodeLists(node.labels, toNode.labels), | |
10389 _isEqualTokens(node.keyword, toNode.keyword), | 10742 _isEqualTokens(node.keyword, toNode.keyword), |
10390 _isEqualNodes(node.expression, toNode.expression), | 10743 _isEqualNodes(node.expression, toNode.expression), |
10391 _isEqualTokens(node.colon, toNode.colon), | 10744 _isEqualTokens(node.colon, toNode.colon), |
10392 _isEqualNodeLists(node.statements, toNode.statements)); | 10745 _isEqualNodeLists(node.statements, toNode.statements)); |
10393 } | 10746 } |
10394 | 10747 |
10395 @override | 10748 @override |
10396 bool visitSwitchDefault(SwitchDefault node) { | 10749 bool visitSwitchDefault(SwitchDefault node) { |
10397 SwitchDefault toNode = this._toNode as SwitchDefault; | 10750 SwitchDefault toNode = this._toNode as SwitchDefault; |
10398 return _and(_isEqualNodeLists(node.labels, toNode.labels), | 10751 return _and( |
10752 _isEqualNodeLists(node.labels, toNode.labels), | |
10399 _isEqualTokens(node.keyword, toNode.keyword), | 10753 _isEqualTokens(node.keyword, toNode.keyword), |
10400 _isEqualTokens(node.colon, toNode.colon), | 10754 _isEqualTokens(node.colon, toNode.colon), |
10401 _isEqualNodeLists(node.statements, toNode.statements)); | 10755 _isEqualNodeLists(node.statements, toNode.statements)); |
10402 } | 10756 } |
10403 | 10757 |
10404 @override | 10758 @override |
10405 bool visitSwitchStatement(SwitchStatement node) { | 10759 bool visitSwitchStatement(SwitchStatement node) { |
10406 SwitchStatement toNode = this._toNode as SwitchStatement; | 10760 SwitchStatement toNode = this._toNode as SwitchStatement; |
10407 return _and(_isEqualTokens(node.switchKeyword, toNode.switchKeyword), | 10761 return _and( |
10762 _isEqualTokens(node.switchKeyword, toNode.switchKeyword), | |
10408 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 10763 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
10409 _isEqualNodes(node.expression, toNode.expression), | 10764 _isEqualNodes(node.expression, toNode.expression), |
10410 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 10765 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
10411 _isEqualTokens(node.leftBracket, toNode.leftBracket), | 10766 _isEqualTokens(node.leftBracket, toNode.leftBracket), |
10412 _isEqualNodeLists(node.members, toNode.members), | 10767 _isEqualNodeLists(node.members, toNode.members), |
10413 _isEqualTokens(node.rightBracket, toNode.rightBracket)); | 10768 _isEqualTokens(node.rightBracket, toNode.rightBracket)); |
10414 } | 10769 } |
10415 | 10770 |
10416 @override | 10771 @override |
10417 bool visitSymbolLiteral(SymbolLiteral node) { | 10772 bool visitSymbolLiteral(SymbolLiteral node) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10455 return _and( | 10810 return _and( |
10456 _isEqualNodes(node.documentationComment, toNode.documentationComment), | 10811 _isEqualNodes(node.documentationComment, toNode.documentationComment), |
10457 _isEqualNodeLists(node.metadata, toNode.metadata), | 10812 _isEqualNodeLists(node.metadata, toNode.metadata), |
10458 _isEqualNodes(node.variables, toNode.variables), | 10813 _isEqualNodes(node.variables, toNode.variables), |
10459 _isEqualTokens(node.semicolon, toNode.semicolon)); | 10814 _isEqualTokens(node.semicolon, toNode.semicolon)); |
10460 } | 10815 } |
10461 | 10816 |
10462 @override | 10817 @override |
10463 bool visitTryStatement(TryStatement node) { | 10818 bool visitTryStatement(TryStatement node) { |
10464 TryStatement toNode = this._toNode as TryStatement; | 10819 TryStatement toNode = this._toNode as TryStatement; |
10465 return _and(_isEqualTokens(node.tryKeyword, toNode.tryKeyword), | 10820 return _and( |
10821 _isEqualTokens(node.tryKeyword, toNode.tryKeyword), | |
10466 _isEqualNodes(node.body, toNode.body), | 10822 _isEqualNodes(node.body, toNode.body), |
10467 _isEqualNodeLists(node.catchClauses, toNode.catchClauses), | 10823 _isEqualNodeLists(node.catchClauses, toNode.catchClauses), |
10468 _isEqualTokens(node.finallyKeyword, toNode.finallyKeyword), | 10824 _isEqualTokens(node.finallyKeyword, toNode.finallyKeyword), |
10469 _isEqualNodes(node.finallyBlock, toNode.finallyBlock)); | 10825 _isEqualNodes(node.finallyBlock, toNode.finallyBlock)); |
10470 } | 10826 } |
10471 | 10827 |
10472 @override | 10828 @override |
10473 bool visitTypeArgumentList(TypeArgumentList node) { | 10829 bool visitTypeArgumentList(TypeArgumentList node) { |
10474 TypeArgumentList toNode = this._toNode as TypeArgumentList; | 10830 TypeArgumentList toNode = this._toNode as TypeArgumentList; |
10475 return _and(_isEqualTokens(node.leftBracket, toNode.leftBracket), | 10831 return _and( |
10832 _isEqualTokens(node.leftBracket, toNode.leftBracket), | |
10476 _isEqualNodeLists(node.arguments, toNode.arguments), | 10833 _isEqualNodeLists(node.arguments, toNode.arguments), |
10477 _isEqualTokens(node.rightBracket, toNode.rightBracket)); | 10834 _isEqualTokens(node.rightBracket, toNode.rightBracket)); |
10478 } | 10835 } |
10479 | 10836 |
10480 @override | 10837 @override |
10481 bool visitTypeName(TypeName node) { | 10838 bool visitTypeName(TypeName node) { |
10482 TypeName toNode = this._toNode as TypeName; | 10839 TypeName toNode = this._toNode as TypeName; |
10483 if (_and(_isEqualNodes(node.name, toNode.name), | 10840 if (_and(_isEqualNodes(node.name, toNode.name), |
10484 _isEqualNodes(node.typeArguments, toNode.typeArguments))) { | 10841 _isEqualNodes(node.typeArguments, toNode.typeArguments))) { |
10485 toNode.type = node.type; | 10842 toNode.type = node.type; |
10486 return true; | 10843 return true; |
10487 } | 10844 } |
10488 return false; | 10845 return false; |
10489 } | 10846 } |
10490 | 10847 |
10491 @override | 10848 @override |
10492 bool visitTypeParameter(TypeParameter node) { | 10849 bool visitTypeParameter(TypeParameter node) { |
10493 TypeParameter toNode = this._toNode as TypeParameter; | 10850 TypeParameter toNode = this._toNode as TypeParameter; |
10494 return _and( | 10851 return _and( |
10495 _isEqualNodes(node.documentationComment, toNode.documentationComment), | 10852 _isEqualNodes(node.documentationComment, toNode.documentationComment), |
10496 _isEqualNodeLists(node.metadata, toNode.metadata), | 10853 _isEqualNodeLists(node.metadata, toNode.metadata), |
10497 _isEqualNodes(node.name, toNode.name), | 10854 _isEqualNodes(node.name, toNode.name), |
10498 _isEqualTokens(node.extendsKeyword, toNode.extendsKeyword), | 10855 _isEqualTokens(node.extendsKeyword, toNode.extendsKeyword), |
10499 _isEqualNodes(node.bound, toNode.bound)); | 10856 _isEqualNodes(node.bound, toNode.bound)); |
10500 } | 10857 } |
10501 | 10858 |
10502 @override | 10859 @override |
10503 bool visitTypeParameterList(TypeParameterList node) { | 10860 bool visitTypeParameterList(TypeParameterList node) { |
10504 TypeParameterList toNode = this._toNode as TypeParameterList; | 10861 TypeParameterList toNode = this._toNode as TypeParameterList; |
10505 return _and(_isEqualTokens(node.leftBracket, toNode.leftBracket), | 10862 return _and( |
10863 _isEqualTokens(node.leftBracket, toNode.leftBracket), | |
10506 _isEqualNodeLists(node.typeParameters, toNode.typeParameters), | 10864 _isEqualNodeLists(node.typeParameters, toNode.typeParameters), |
10507 _isEqualTokens(node.rightBracket, toNode.rightBracket)); | 10865 _isEqualTokens(node.rightBracket, toNode.rightBracket)); |
10508 } | 10866 } |
10509 | 10867 |
10510 @override | 10868 @override |
10511 bool visitVariableDeclaration(VariableDeclaration node) { | 10869 bool visitVariableDeclaration(VariableDeclaration node) { |
10512 VariableDeclaration toNode = this._toNode as VariableDeclaration; | 10870 VariableDeclaration toNode = this._toNode as VariableDeclaration; |
10513 return _and( | 10871 return _and( |
10514 _isEqualNodes(node.documentationComment, toNode.documentationComment), | 10872 _isEqualNodes(node.documentationComment, toNode.documentationComment), |
10515 _isEqualNodeLists(node.metadata, toNode.metadata), | 10873 _isEqualNodeLists(node.metadata, toNode.metadata), |
(...skipping 17 matching lines...) Expand all Loading... | |
10533 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 10891 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
10534 VariableDeclarationStatement toNode = | 10892 VariableDeclarationStatement toNode = |
10535 this._toNode as VariableDeclarationStatement; | 10893 this._toNode as VariableDeclarationStatement; |
10536 return _and(_isEqualNodes(node.variables, toNode.variables), | 10894 return _and(_isEqualNodes(node.variables, toNode.variables), |
10537 _isEqualTokens(node.semicolon, toNode.semicolon)); | 10895 _isEqualTokens(node.semicolon, toNode.semicolon)); |
10538 } | 10896 } |
10539 | 10897 |
10540 @override | 10898 @override |
10541 bool visitWhileStatement(WhileStatement node) { | 10899 bool visitWhileStatement(WhileStatement node) { |
10542 WhileStatement toNode = this._toNode as WhileStatement; | 10900 WhileStatement toNode = this._toNode as WhileStatement; |
10543 return _and(_isEqualTokens(node.whileKeyword, toNode.whileKeyword), | 10901 return _and( |
10902 _isEqualTokens(node.whileKeyword, toNode.whileKeyword), | |
10544 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 10903 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
10545 _isEqualNodes(node.condition, toNode.condition), | 10904 _isEqualNodes(node.condition, toNode.condition), |
10546 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 10905 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
10547 _isEqualNodes(node.body, toNode.body)); | 10906 _isEqualNodes(node.body, toNode.body)); |
10548 } | 10907 } |
10549 | 10908 |
10550 @override | 10909 @override |
10551 bool visitWithClause(WithClause node) { | 10910 bool visitWithClause(WithClause node) { |
10552 WithClause toNode = this._toNode as WithClause; | 10911 WithClause toNode = this._toNode as WithClause; |
10553 return _and(_isEqualTokens(node.withKeyword, toNode.withKeyword), | 10912 return _and(_isEqualTokens(node.withKeyword, toNode.withKeyword), |
10554 _isEqualNodeLists(node.mixinTypes, toNode.mixinTypes)); | 10913 _isEqualNodeLists(node.mixinTypes, toNode.mixinTypes)); |
10555 } | 10914 } |
10556 | 10915 |
10557 @override | 10916 @override |
10558 bool visitYieldStatement(YieldStatement node) { | 10917 bool visitYieldStatement(YieldStatement node) { |
10559 YieldStatement toNode = this._toNode as YieldStatement; | 10918 YieldStatement toNode = this._toNode as YieldStatement; |
10560 return _and(_isEqualTokens(node.yieldKeyword, toNode.yieldKeyword), | 10919 return _and( |
10920 _isEqualTokens(node.yieldKeyword, toNode.yieldKeyword), | |
10561 _isEqualNodes(node.expression, toNode.expression), | 10921 _isEqualNodes(node.expression, toNode.expression), |
10562 _isEqualTokens(node.semicolon, toNode.semicolon)); | 10922 _isEqualTokens(node.semicolon, toNode.semicolon)); |
10563 } | 10923 } |
10564 | 10924 |
10565 /** | 10925 /** |
10566 * Return `true` if all of the parameters are `true`. | 10926 * Return `true` if all of the parameters are `true`. |
10567 */ | 10927 */ |
10568 bool _and(bool b1, bool b2, [bool b3 = true, bool b4 = true, bool b5 = true, | 10928 bool _and(bool b1, bool b2, |
10569 bool b6 = true, bool b7 = true, bool b8 = true, bool b9 = true, | 10929 [bool b3 = true, |
10570 bool b10 = true, bool b11 = true, bool b12 = true, bool b13 = true]) { | 10930 bool b4 = true, |
10931 bool b5 = true, | |
10932 bool b6 = true, | |
10933 bool b7 = true, | |
10934 bool b8 = true, | |
10935 bool b9 = true, | |
10936 bool b10 = true, | |
10937 bool b11 = true, | |
10938 bool b12 = true, | |
10939 bool b13 = true]) { | |
10571 // TODO(brianwilkerson) Inline this method. | 10940 // TODO(brianwilkerson) Inline this method. |
10572 return b1 && | 10941 return b1 && |
10573 b2 && | 10942 b2 && |
10574 b3 && | 10943 b3 && |
10575 b4 && | 10944 b4 && |
10576 b5 && | 10945 b5 && |
10577 b6 && | 10946 b6 && |
10578 b7 && | 10947 b7 && |
10579 b8 && | 10948 b8 && |
10580 b9 && | 10949 b9 && |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10670 } | 11039 } |
10671 | 11040 |
10672 /** | 11041 /** |
10673 * Copy resolution data from the [fromNode] to the [toNode]. | 11042 * Copy resolution data from the [fromNode] to the [toNode]. |
10674 */ | 11043 */ |
10675 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 11044 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
10676 ResolutionCopier copier = new ResolutionCopier(); | 11045 ResolutionCopier copier = new ResolutionCopier(); |
10677 copier._isEqualNodes(fromNode, toNode); | 11046 copier._isEqualNodes(fromNode, toNode); |
10678 } | 11047 } |
10679 } | 11048 } |
OLD | NEW |