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

Side by Side Diff: packages/analyzer/lib/dart/ast/visitor.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Defines AST visitors that support useful patterns for visiting the nodes in
7 * an [AST structure](ast.dart).
8 *
9 * Dart is an evolving language, and the AST structure must evolved with it.
10 * When the AST structure changes, the visitor interface will sometimes change
11 * as well. If it is desirable to get a compilation error when the structure of
12 * the AST has been modified, then you should consider implementing the
13 * interface [AstVisitor] directly. Doing so will ensure that changes that
14 * introduce new classes of nodes will be flagged. (Of course, not all changes
15 * to the AST structure require the addition of a new class of node, and hence
16 * cannot be caught this way.)
17 *
18 * But if automatic detection of these kinds of changes is not necessary then
19 * you will probably want to extend one of the classes in this library because
20 * doing so will simplify the task of writing your visitor and guard against
21 * future changes to the AST structure. For example, the [RecursiveAstVisitor]
22 * automates the process of visiting all of the descendants of a node.
23 */
24 library analyzer.dart.ast.visitor;
25
26 import 'dart:collection';
27
28 import 'package:analyzer/dart/ast/ast.dart';
29
30 /**
31 * An AST visitor that will recursively visit all of the nodes in an AST
32 * structure, similar to [GeneralizingAstVisitor]. This visitor uses a
33 * breadth-first ordering rather than the depth-first ordering of
34 * [GeneralizingAstVisitor].
35 *
36 * Subclasses that override a visit method must either invoke the overridden
37 * visit method or explicitly invoke the more general visit method. Failure to
38 * do so will cause the visit methods for superclasses of the node to not be
39 * invoked and will cause the children of the visited node to not be visited.
40 *
41 * In addition, subclasses should <b>not</b> explicitly visit the children of a
42 * node, but should ensure that the method [visitNode] is used to visit the
43 * children (either directly or indirectly). Failure to do will break the order
44 * in which nodes are visited.
45 *
46 * Note that, unlike other visitors that begin to visit a structure of nodes by
47 * asking the root node in the structure to accept the visitor, this visitor
48 * requires that clients start the visit by invoking the method [visitAllNodes]
49 * defined on the visitor with the root node as the argument:
50 *
51 * visitor.visitAllNodes(rootNode);
52 *
53 * Clients may extend this class.
54 */
55 class BreadthFirstVisitor<R> extends GeneralizingAstVisitor<R> {
56 /**
57 * A queue holding the nodes that have not yet been visited in the order in
58 * which they ought to be visited.
59 */
60 Queue<AstNode> _queue = new Queue<AstNode>();
61
62 /**
63 * A visitor, used to visit the children of the current node, that will add
64 * the nodes it visits to the [_queue].
65 */
66 _BreadthFirstChildVisitor _childVisitor;
67
68 /**
69 * Initialize a newly created visitor.
70 */
71 BreadthFirstVisitor() {
72 _childVisitor = new _BreadthFirstChildVisitor(this);
73 }
74
75 /**
76 * Visit all nodes in the tree starting at the given [root] node, in
77 * breadth-first order.
78 */
79 void visitAllNodes(AstNode root) {
80 _queue.add(root);
81 while (!_queue.isEmpty) {
82 AstNode next = _queue.removeFirst();
83 next.accept(this);
84 }
85 }
86
87 @override
88 R visitNode(AstNode node) {
89 node.visitChildren(_childVisitor);
90 return null;
91 }
92 }
93
94 /**
95 * An AST visitor that will recursively visit all of the nodes in an AST
96 * structure. For each node that is visited, the corresponding visit method on
97 * one or more other visitors (the 'delegates') will be invoked.
98 *
99 * For example, if an instance of this class is created with two delegates V1
100 * and V2, and that instance is used to visit the expression 'x + 1', then the
101 * following visit methods will be invoked:
102 * 1. V1.visitBinaryExpression
103 * 2. V2.visitBinaryExpression
104 * 3. V1.visitSimpleIdentifier
105 * 4. V2.visitSimpleIdentifier
106 * 5. V1.visitIntegerLiteral
107 * 6. V2.visitIntegerLiteral
108 *
109 * Clients may not extend, implement or mix-in this class.
110 */
111 class DelegatingAstVisitor<T> implements AstVisitor<T> {
112 /**
113 * The delegates whose visit methods will be invoked.
114 */
115 final Iterable<AstVisitor<T>> _delegates;
116
117 /**
118 * Initialize a newly created visitor to use each of the given delegate
119 * visitors to visit the nodes of an AST structure.
120 */
121 DelegatingAstVisitor(this._delegates);
122
123 @override
124 T visitAdjacentStrings(AdjacentStrings node) {
125 _delegates.forEach((delegate) => delegate.visitAdjacentStrings(node));
126 node.visitChildren(this);
127 return null;
128 }
129
130 @override
131 T visitAnnotation(Annotation node) {
132 _delegates.forEach((delegate) => delegate.visitAnnotation(node));
133 node.visitChildren(this);
134 return null;
135 }
136
137 @override
138 T visitArgumentList(ArgumentList node) {
139 _delegates.forEach((delegate) => delegate.visitArgumentList(node));
140 node.visitChildren(this);
141 return null;
142 }
143
144 @override
145 T visitAsExpression(AsExpression node) {
146 _delegates.forEach((delegate) => delegate.visitAsExpression(node));
147 node.visitChildren(this);
148 return null;
149 }
150
151 @override
152 T visitAssertStatement(AssertStatement node) {
153 _delegates.forEach((delegate) => delegate.visitAssertStatement(node));
154 node.visitChildren(this);
155 return null;
156 }
157
158 @override
159 T visitAssignmentExpression(AssignmentExpression node) {
160 _delegates.forEach((delegate) => delegate.visitAssignmentExpression(node));
161 node.visitChildren(this);
162 return null;
163 }
164
165 @override
166 T visitAwaitExpression(AwaitExpression node) {
167 _delegates.forEach((delegate) => delegate.visitAwaitExpression(node));
168 node.visitChildren(this);
169 return null;
170 }
171
172 @override
173 T visitBinaryExpression(BinaryExpression node) {
174 _delegates.forEach((delegate) => delegate.visitBinaryExpression(node));
175 node.visitChildren(this);
176 return null;
177 }
178
179 @override
180 T visitBlock(Block node) {
181 _delegates.forEach((delegate) => delegate.visitBlock(node));
182 node.visitChildren(this);
183 return null;
184 }
185
186 @override
187 T visitBlockFunctionBody(BlockFunctionBody node) {
188 _delegates.forEach((delegate) => delegate.visitBlockFunctionBody(node));
189 node.visitChildren(this);
190 return null;
191 }
192
193 @override
194 T visitBooleanLiteral(BooleanLiteral node) {
195 _delegates.forEach((delegate) => delegate.visitBooleanLiteral(node));
196 node.visitChildren(this);
197 return null;
198 }
199
200 @override
201 T visitBreakStatement(BreakStatement node) {
202 _delegates.forEach((delegate) => delegate.visitBreakStatement(node));
203 node.visitChildren(this);
204 return null;
205 }
206
207 @override
208 T visitCascadeExpression(CascadeExpression node) {
209 _delegates.forEach((delegate) => delegate.visitCascadeExpression(node));
210 node.visitChildren(this);
211 return null;
212 }
213
214 @override
215 T visitCatchClause(CatchClause node) {
216 _delegates.forEach((delegate) => delegate.visitCatchClause(node));
217 node.visitChildren(this);
218 return null;
219 }
220
221 @override
222 T visitClassDeclaration(ClassDeclaration node) {
223 _delegates.forEach((delegate) => delegate.visitClassDeclaration(node));
224 node.visitChildren(this);
225 return null;
226 }
227
228 @override
229 T visitClassTypeAlias(ClassTypeAlias node) {
230 _delegates.forEach((delegate) => delegate.visitClassTypeAlias(node));
231 node.visitChildren(this);
232 return null;
233 }
234
235 @override
236 T visitComment(Comment node) {
237 _delegates.forEach((delegate) => delegate.visitComment(node));
238 node.visitChildren(this);
239 return null;
240 }
241
242 @override
243 T visitCommentReference(CommentReference node) {
244 _delegates.forEach((delegate) => delegate.visitCommentReference(node));
245 node.visitChildren(this);
246 return null;
247 }
248
249 @override
250 T visitCompilationUnit(CompilationUnit node) {
251 _delegates.forEach((delegate) => delegate.visitCompilationUnit(node));
252 node.visitChildren(this);
253 return null;
254 }
255
256 @override
257 T visitConditionalExpression(ConditionalExpression node) {
258 _delegates.forEach((delegate) => delegate.visitConditionalExpression(node));
259 node.visitChildren(this);
260 return null;
261 }
262
263 @override
264 T visitConfiguration(Configuration node) {
265 _delegates.forEach((delegate) => delegate.visitConfiguration(node));
266 node.visitChildren(this);
267 return null;
268 }
269
270 @override
271 T visitConstructorDeclaration(ConstructorDeclaration node) {
272 _delegates
273 .forEach((delegate) => delegate.visitConstructorDeclaration(node));
274 node.visitChildren(this);
275 return null;
276 }
277
278 @override
279 T visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
280 _delegates
281 .forEach((delegate) => delegate.visitConstructorFieldInitializer(node));
282 node.visitChildren(this);
283 return null;
284 }
285
286 @override
287 T visitConstructorName(ConstructorName node) {
288 _delegates.forEach((delegate) => delegate.visitConstructorName(node));
289 node.visitChildren(this);
290 return null;
291 }
292
293 @override
294 T visitContinueStatement(ContinueStatement node) {
295 _delegates.forEach((delegate) => delegate.visitContinueStatement(node));
296 node.visitChildren(this);
297 return null;
298 }
299
300 @override
301 T visitDeclaredIdentifier(DeclaredIdentifier node) {
302 _delegates.forEach((delegate) => delegate.visitDeclaredIdentifier(node));
303 node.visitChildren(this);
304 return null;
305 }
306
307 @override
308 T visitDefaultFormalParameter(DefaultFormalParameter node) {
309 _delegates
310 .forEach((delegate) => delegate.visitDefaultFormalParameter(node));
311 node.visitChildren(this);
312 return null;
313 }
314
315 @override
316 T visitDoStatement(DoStatement node) {
317 _delegates.forEach((delegate) => delegate.visitDoStatement(node));
318 node.visitChildren(this);
319 return null;
320 }
321
322 @override
323 T visitDottedName(DottedName node) {
324 _delegates.forEach((delegate) => delegate.visitDottedName(node));
325 node.visitChildren(this);
326 return null;
327 }
328
329 @override
330 T visitDoubleLiteral(DoubleLiteral node) {
331 _delegates.forEach((delegate) => delegate.visitDoubleLiteral(node));
332 node.visitChildren(this);
333 return null;
334 }
335
336 @override
337 T visitEmptyFunctionBody(EmptyFunctionBody node) {
338 _delegates.forEach((delegate) => delegate.visitEmptyFunctionBody(node));
339 node.visitChildren(this);
340 return null;
341 }
342
343 @override
344 T visitEmptyStatement(EmptyStatement node) {
345 _delegates.forEach((delegate) => delegate.visitEmptyStatement(node));
346 node.visitChildren(this);
347 return null;
348 }
349
350 @override
351 T visitEnumConstantDeclaration(EnumConstantDeclaration node) {
352 _delegates
353 .forEach((delegate) => delegate.visitEnumConstantDeclaration(node));
354 node.visitChildren(this);
355 return null;
356 }
357
358 @override
359 T visitEnumDeclaration(EnumDeclaration node) {
360 _delegates.forEach((delegate) => delegate.visitEnumDeclaration(node));
361 node.visitChildren(this);
362 return null;
363 }
364
365 @override
366 T visitExportDirective(ExportDirective node) {
367 _delegates.forEach((delegate) => delegate.visitExportDirective(node));
368 node.visitChildren(this);
369 return null;
370 }
371
372 @override
373 T visitExpressionFunctionBody(ExpressionFunctionBody node) {
374 _delegates
375 .forEach((delegate) => delegate.visitExpressionFunctionBody(node));
376 node.visitChildren(this);
377 return null;
378 }
379
380 @override
381 T visitExpressionStatement(ExpressionStatement node) {
382 _delegates.forEach((delegate) => delegate.visitExpressionStatement(node));
383 node.visitChildren(this);
384 return null;
385 }
386
387 @override
388 T visitExtendsClause(ExtendsClause node) {
389 _delegates.forEach((delegate) => delegate.visitExtendsClause(node));
390 node.visitChildren(this);
391 return null;
392 }
393
394 @override
395 T visitFieldDeclaration(FieldDeclaration node) {
396 _delegates.forEach((delegate) => delegate.visitFieldDeclaration(node));
397 node.visitChildren(this);
398 return null;
399 }
400
401 @override
402 T visitFieldFormalParameter(FieldFormalParameter node) {
403 _delegates.forEach((delegate) => delegate.visitFieldFormalParameter(node));
404 node.visitChildren(this);
405 return null;
406 }
407
408 @override
409 T visitForEachStatement(ForEachStatement node) {
410 _delegates.forEach((delegate) => delegate.visitForEachStatement(node));
411 node.visitChildren(this);
412 return null;
413 }
414
415 @override
416 T visitFormalParameterList(FormalParameterList node) {
417 _delegates.forEach((delegate) => delegate.visitFormalParameterList(node));
418 node.visitChildren(this);
419 return null;
420 }
421
422 @override
423 T visitForStatement(ForStatement node) {
424 _delegates.forEach((delegate) => delegate.visitForStatement(node));
425 node.visitChildren(this);
426 return null;
427 }
428
429 @override
430 T visitFunctionDeclaration(FunctionDeclaration node) {
431 _delegates.forEach((delegate) => delegate.visitFunctionDeclaration(node));
432 node.visitChildren(this);
433 return null;
434 }
435
436 @override
437 T visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
438 _delegates.forEach(
439 (delegate) => delegate.visitFunctionDeclarationStatement(node));
440 node.visitChildren(this);
441 return null;
442 }
443
444 @override
445 T visitFunctionExpression(FunctionExpression node) {
446 _delegates.forEach((delegate) => delegate.visitFunctionExpression(node));
447 node.visitChildren(this);
448 return null;
449 }
450
451 @override
452 T visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
453 _delegates.forEach(
454 (delegate) => delegate.visitFunctionExpressionInvocation(node));
455 node.visitChildren(this);
456 return null;
457 }
458
459 @override
460 T visitFunctionTypeAlias(FunctionTypeAlias node) {
461 _delegates.forEach((delegate) => delegate.visitFunctionTypeAlias(node));
462 node.visitChildren(this);
463 return null;
464 }
465
466 @override
467 T visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
468 _delegates.forEach(
469 (delegate) => delegate.visitFunctionTypedFormalParameter(node));
470 node.visitChildren(this);
471 return null;
472 }
473
474 @override
475 T visitHideCombinator(HideCombinator node) {
476 _delegates.forEach((delegate) => delegate.visitHideCombinator(node));
477 node.visitChildren(this);
478 return null;
479 }
480
481 @override
482 T visitIfStatement(IfStatement node) {
483 _delegates.forEach((delegate) => delegate.visitIfStatement(node));
484 node.visitChildren(this);
485 return null;
486 }
487
488 @override
489 T visitImplementsClause(ImplementsClause node) {
490 _delegates.forEach((delegate) => delegate.visitImplementsClause(node));
491 node.visitChildren(this);
492 return null;
493 }
494
495 @override
496 T visitImportDirective(ImportDirective node) {
497 _delegates.forEach((delegate) => delegate.visitImportDirective(node));
498 node.visitChildren(this);
499 return null;
500 }
501
502 @override
503 T visitIndexExpression(IndexExpression node) {
504 _delegates.forEach((delegate) => delegate.visitIndexExpression(node));
505 node.visitChildren(this);
506 return null;
507 }
508
509 @override
510 T visitInstanceCreationExpression(InstanceCreationExpression node) {
511 _delegates
512 .forEach((delegate) => delegate.visitInstanceCreationExpression(node));
513 node.visitChildren(this);
514 return null;
515 }
516
517 @override
518 T visitIntegerLiteral(IntegerLiteral node) {
519 _delegates.forEach((delegate) => delegate.visitIntegerLiteral(node));
520 node.visitChildren(this);
521 return null;
522 }
523
524 @override
525 T visitInterpolationExpression(InterpolationExpression node) {
526 _delegates
527 .forEach((delegate) => delegate.visitInterpolationExpression(node));
528 node.visitChildren(this);
529 return null;
530 }
531
532 @override
533 T visitInterpolationString(InterpolationString node) {
534 _delegates.forEach((delegate) => delegate.visitInterpolationString(node));
535 node.visitChildren(this);
536 return null;
537 }
538
539 @override
540 T visitIsExpression(IsExpression node) {
541 _delegates.forEach((delegate) => delegate.visitIsExpression(node));
542 node.visitChildren(this);
543 return null;
544 }
545
546 @override
547 T visitLabel(Label node) {
548 _delegates.forEach((delegate) => delegate.visitLabel(node));
549 node.visitChildren(this);
550 return null;
551 }
552
553 @override
554 T visitLabeledStatement(LabeledStatement node) {
555 _delegates.forEach((delegate) => delegate.visitLabeledStatement(node));
556 node.visitChildren(this);
557 return null;
558 }
559
560 @override
561 T visitLibraryDirective(LibraryDirective node) {
562 _delegates.forEach((delegate) => delegate.visitLibraryDirective(node));
563 node.visitChildren(this);
564 return null;
565 }
566
567 @override
568 T visitLibraryIdentifier(LibraryIdentifier node) {
569 _delegates.forEach((delegate) => delegate.visitLibraryIdentifier(node));
570 node.visitChildren(this);
571 return null;
572 }
573
574 @override
575 T visitListLiteral(ListLiteral node) {
576 _delegates.forEach((delegate) => delegate.visitListLiteral(node));
577 node.visitChildren(this);
578 return null;
579 }
580
581 @override
582 T visitMapLiteral(MapLiteral node) {
583 _delegates.forEach((delegate) => delegate.visitMapLiteral(node));
584 node.visitChildren(this);
585 return null;
586 }
587
588 @override
589 T visitMapLiteralEntry(MapLiteralEntry node) {
590 _delegates.forEach((delegate) => delegate.visitMapLiteralEntry(node));
591 node.visitChildren(this);
592 return null;
593 }
594
595 @override
596 T visitMethodDeclaration(MethodDeclaration node) {
597 _delegates.forEach((delegate) => delegate.visitMethodDeclaration(node));
598 node.visitChildren(this);
599 return null;
600 }
601
602 @override
603 T visitMethodInvocation(MethodInvocation node) {
604 _delegates.forEach((delegate) => delegate.visitMethodInvocation(node));
605 node.visitChildren(this);
606 return null;
607 }
608
609 @override
610 T visitNamedExpression(NamedExpression node) {
611 _delegates.forEach((delegate) => delegate.visitNamedExpression(node));
612 node.visitChildren(this);
613 return null;
614 }
615
616 @override
617 T visitNativeClause(NativeClause node) {
618 _delegates.forEach((delegate) => delegate.visitNativeClause(node));
619 node.visitChildren(this);
620 return null;
621 }
622
623 @override
624 T visitNativeFunctionBody(NativeFunctionBody node) {
625 _delegates.forEach((delegate) => delegate.visitNativeFunctionBody(node));
626 node.visitChildren(this);
627 return null;
628 }
629
630 @override
631 T visitNullLiteral(NullLiteral node) {
632 _delegates.forEach((delegate) => delegate.visitNullLiteral(node));
633 node.visitChildren(this);
634 return null;
635 }
636
637 @override
638 T visitParenthesizedExpression(ParenthesizedExpression node) {
639 _delegates
640 .forEach((delegate) => delegate.visitParenthesizedExpression(node));
641 node.visitChildren(this);
642 return null;
643 }
644
645 @override
646 T visitPartDirective(PartDirective node) {
647 _delegates.forEach((delegate) => delegate.visitPartDirective(node));
648 node.visitChildren(this);
649 return null;
650 }
651
652 @override
653 T visitPartOfDirective(PartOfDirective node) {
654 _delegates.forEach((delegate) => delegate.visitPartOfDirective(node));
655 node.visitChildren(this);
656 return null;
657 }
658
659 @override
660 T visitPostfixExpression(PostfixExpression node) {
661 _delegates.forEach((delegate) => delegate.visitPostfixExpression(node));
662 node.visitChildren(this);
663 return null;
664 }
665
666 @override
667 T visitPrefixedIdentifier(PrefixedIdentifier node) {
668 _delegates.forEach((delegate) => delegate.visitPrefixedIdentifier(node));
669 node.visitChildren(this);
670 return null;
671 }
672
673 @override
674 T visitPrefixExpression(PrefixExpression node) {
675 _delegates.forEach((delegate) => delegate.visitPrefixExpression(node));
676 node.visitChildren(this);
677 return null;
678 }
679
680 @override
681 T visitPropertyAccess(PropertyAccess node) {
682 _delegates.forEach((delegate) => delegate.visitPropertyAccess(node));
683 node.visitChildren(this);
684 return null;
685 }
686
687 @override
688 T visitRedirectingConstructorInvocation(
689 RedirectingConstructorInvocation node) {
690 _delegates.forEach(
691 (delegate) => delegate.visitRedirectingConstructorInvocation(node));
692 node.visitChildren(this);
693 return null;
694 }
695
696 @override
697 T visitRethrowExpression(RethrowExpression node) {
698 _delegates.forEach((delegate) => delegate.visitRethrowExpression(node));
699 node.visitChildren(this);
700 return null;
701 }
702
703 @override
704 T visitReturnStatement(ReturnStatement node) {
705 _delegates.forEach((delegate) => delegate.visitReturnStatement(node));
706 node.visitChildren(this);
707 return null;
708 }
709
710 @override
711 T visitScriptTag(ScriptTag node) {
712 _delegates.forEach((delegate) => delegate.visitScriptTag(node));
713 node.visitChildren(this);
714 return null;
715 }
716
717 @override
718 T visitShowCombinator(ShowCombinator node) {
719 _delegates.forEach((delegate) => delegate.visitShowCombinator(node));
720 node.visitChildren(this);
721 return null;
722 }
723
724 @override
725 T visitSimpleFormalParameter(SimpleFormalParameter node) {
726 _delegates.forEach((delegate) => delegate.visitSimpleFormalParameter(node));
727 node.visitChildren(this);
728 return null;
729 }
730
731 @override
732 T visitSimpleIdentifier(SimpleIdentifier node) {
733 _delegates.forEach((delegate) => delegate.visitSimpleIdentifier(node));
734 node.visitChildren(this);
735 return null;
736 }
737
738 @override
739 T visitSimpleStringLiteral(SimpleStringLiteral node) {
740 _delegates.forEach((delegate) => delegate.visitSimpleStringLiteral(node));
741 node.visitChildren(this);
742 return null;
743 }
744
745 @override
746 T visitStringInterpolation(StringInterpolation node) {
747 _delegates.forEach((delegate) => delegate.visitStringInterpolation(node));
748 node.visitChildren(this);
749 return null;
750 }
751
752 @override
753 T visitSuperConstructorInvocation(SuperConstructorInvocation node) {
754 _delegates
755 .forEach((delegate) => delegate.visitSuperConstructorInvocation(node));
756 node.visitChildren(this);
757 return null;
758 }
759
760 @override
761 T visitSuperExpression(SuperExpression node) {
762 _delegates.forEach((delegate) => delegate.visitSuperExpression(node));
763 node.visitChildren(this);
764 return null;
765 }
766
767 @override
768 T visitSwitchCase(SwitchCase node) {
769 _delegates.forEach((delegate) => delegate.visitSwitchCase(node));
770 node.visitChildren(this);
771 return null;
772 }
773
774 @override
775 T visitSwitchDefault(SwitchDefault node) {
776 _delegates.forEach((delegate) => delegate.visitSwitchDefault(node));
777 node.visitChildren(this);
778 return null;
779 }
780
781 @override
782 T visitSwitchStatement(SwitchStatement node) {
783 _delegates.forEach((delegate) => delegate.visitSwitchStatement(node));
784 node.visitChildren(this);
785 return null;
786 }
787
788 @override
789 T visitSymbolLiteral(SymbolLiteral node) {
790 _delegates.forEach((delegate) => delegate.visitSymbolLiteral(node));
791 node.visitChildren(this);
792 return null;
793 }
794
795 @override
796 T visitThisExpression(ThisExpression node) {
797 _delegates.forEach((delegate) => delegate.visitThisExpression(node));
798 node.visitChildren(this);
799 return null;
800 }
801
802 @override
803 T visitThrowExpression(ThrowExpression node) {
804 _delegates.forEach((delegate) => delegate.visitThrowExpression(node));
805 node.visitChildren(this);
806 return null;
807 }
808
809 @override
810 T visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
811 _delegates
812 .forEach((delegate) => delegate.visitTopLevelVariableDeclaration(node));
813 node.visitChildren(this);
814 return null;
815 }
816
817 @override
818 T visitTryStatement(TryStatement node) {
819 _delegates.forEach((delegate) => delegate.visitTryStatement(node));
820 node.visitChildren(this);
821 return null;
822 }
823
824 @override
825 T visitTypeArgumentList(TypeArgumentList node) {
826 _delegates.forEach((delegate) => delegate.visitTypeArgumentList(node));
827 node.visitChildren(this);
828 return null;
829 }
830
831 @override
832 T visitTypeName(TypeName node) {
833 _delegates.forEach((delegate) => delegate.visitTypeName(node));
834 node.visitChildren(this);
835 return null;
836 }
837
838 @override
839 T visitTypeParameter(TypeParameter node) {
840 _delegates.forEach((delegate) => delegate.visitTypeParameter(node));
841 node.visitChildren(this);
842 return null;
843 }
844
845 @override
846 T visitTypeParameterList(TypeParameterList node) {
847 _delegates.forEach((delegate) => delegate.visitTypeParameterList(node));
848 node.visitChildren(this);
849 return null;
850 }
851
852 @override
853 T visitVariableDeclaration(VariableDeclaration node) {
854 _delegates.forEach((delegate) => delegate.visitVariableDeclaration(node));
855 node.visitChildren(this);
856 return null;
857 }
858
859 @override
860 T visitVariableDeclarationList(VariableDeclarationList node) {
861 _delegates
862 .forEach((delegate) => delegate.visitVariableDeclarationList(node));
863 node.visitChildren(this);
864 return null;
865 }
866
867 @override
868 T visitVariableDeclarationStatement(VariableDeclarationStatement node) {
869 _delegates.forEach(
870 (delegate) => delegate.visitVariableDeclarationStatement(node));
871 node.visitChildren(this);
872 return null;
873 }
874
875 @override
876 T visitWhileStatement(WhileStatement node) {
877 _delegates.forEach((delegate) => delegate.visitWhileStatement(node));
878 node.visitChildren(this);
879 return null;
880 }
881
882 @override
883 T visitWithClause(WithClause node) {
884 _delegates.forEach((delegate) => delegate.visitWithClause(node));
885 node.visitChildren(this);
886 return null;
887 }
888
889 @override
890 T visitYieldStatement(YieldStatement node) {
891 _delegates.forEach((delegate) => delegate.visitYieldStatement(node));
892 node.visitChildren(this);
893 return null;
894 }
895 }
896
897 /**
898 * An AST visitor that will recursively visit all of the nodes in an AST
899 * structure (like instances of the class [RecursiveAstVisitor]). In addition,
900 * when a node of a specific type is visited not only will the visit method for
901 * that specific type of node be invoked, but additional methods for the
902 * superclasses of that node will also be invoked. For example, using an
903 * instance of this class to visit a [Block] will cause the method [visitBlock]
904 * to be invoked but will also cause the methods [visitStatement] and
905 * [visitNode] to be subsequently invoked. This allows visitors to be written
906 * that visit all statements without needing to override the visit method for
907 * each of the specific subclasses of [Statement].
908 *
909 * Subclasses that override a visit method must either invoke the overridden
910 * visit method or explicitly invoke the more general visit method. Failure to
911 * do so will cause the visit methods for superclasses of the node to not be
912 * invoked and will cause the children of the visited node to not be visited.
913 *
914 * Clients may extend this class.
915 */
916 class GeneralizingAstVisitor<R> implements AstVisitor<R> {
917 @override
918 R visitAdjacentStrings(AdjacentStrings node) => visitStringLiteral(node);
919
920 R visitAnnotatedNode(AnnotatedNode node) => visitNode(node);
921
922 @override
923 R visitAnnotation(Annotation node) => visitNode(node);
924
925 @override
926 R visitArgumentList(ArgumentList node) => visitNode(node);
927
928 @override
929 R visitAsExpression(AsExpression node) => visitExpression(node);
930
931 @override
932 R visitAssertStatement(AssertStatement node) => visitStatement(node);
933
934 @override
935 R visitAssignmentExpression(AssignmentExpression node) =>
936 visitExpression(node);
937
938 @override
939 R visitAwaitExpression(AwaitExpression node) => visitExpression(node);
940
941 @override
942 R visitBinaryExpression(BinaryExpression node) => visitExpression(node);
943
944 @override
945 R visitBlock(Block node) => visitStatement(node);
946
947 @override
948 R visitBlockFunctionBody(BlockFunctionBody node) => visitFunctionBody(node);
949
950 @override
951 R visitBooleanLiteral(BooleanLiteral node) => visitLiteral(node);
952
953 @override
954 R visitBreakStatement(BreakStatement node) => visitStatement(node);
955
956 @override
957 R visitCascadeExpression(CascadeExpression node) => visitExpression(node);
958
959 @override
960 R visitCatchClause(CatchClause node) => visitNode(node);
961
962 @override
963 R visitClassDeclaration(ClassDeclaration node) =>
964 visitNamedCompilationUnitMember(node);
965
966 R visitClassMember(ClassMember node) => visitDeclaration(node);
967
968 @override
969 R visitClassTypeAlias(ClassTypeAlias node) => visitTypeAlias(node);
970
971 R visitCombinator(Combinator node) => visitNode(node);
972
973 @override
974 R visitComment(Comment node) => visitNode(node);
975
976 @override
977 R visitCommentReference(CommentReference node) => visitNode(node);
978
979 @override
980 R visitCompilationUnit(CompilationUnit node) => visitNode(node);
981
982 R visitCompilationUnitMember(CompilationUnitMember node) =>
983 visitDeclaration(node);
984
985 @override
986 R visitConditionalExpression(ConditionalExpression node) =>
987 visitExpression(node);
988
989 @override
990 R visitConfiguration(Configuration node) => visitNode(node);
991
992 @override
993 R visitConstructorDeclaration(ConstructorDeclaration node) =>
994 visitClassMember(node);
995
996 @override
997 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) =>
998 visitConstructorInitializer(node);
999
1000 R visitConstructorInitializer(ConstructorInitializer node) => visitNode(node);
1001
1002 @override
1003 R visitConstructorName(ConstructorName node) => visitNode(node);
1004
1005 @override
1006 R visitContinueStatement(ContinueStatement node) => visitStatement(node);
1007
1008 R visitDeclaration(Declaration node) => visitAnnotatedNode(node);
1009
1010 @override
1011 R visitDeclaredIdentifier(DeclaredIdentifier node) => visitDeclaration(node);
1012
1013 @override
1014 R visitDefaultFormalParameter(DefaultFormalParameter node) =>
1015 visitFormalParameter(node);
1016
1017 R visitDirective(Directive node) => visitAnnotatedNode(node);
1018
1019 @override
1020 R visitDoStatement(DoStatement node) => visitStatement(node);
1021
1022 @override
1023 R visitDottedName(DottedName node) => visitNode(node);
1024
1025 @override
1026 R visitDoubleLiteral(DoubleLiteral node) => visitLiteral(node);
1027
1028 @override
1029 R visitEmptyFunctionBody(EmptyFunctionBody node) => visitFunctionBody(node);
1030
1031 @override
1032 R visitEmptyStatement(EmptyStatement node) => visitStatement(node);
1033
1034 @override
1035 R visitEnumConstantDeclaration(EnumConstantDeclaration node) =>
1036 visitDeclaration(node);
1037
1038 @override
1039 R visitEnumDeclaration(EnumDeclaration node) =>
1040 visitNamedCompilationUnitMember(node);
1041
1042 @override
1043 R visitExportDirective(ExportDirective node) => visitNamespaceDirective(node);
1044
1045 R visitExpression(Expression node) => visitNode(node);
1046
1047 @override
1048 R visitExpressionFunctionBody(ExpressionFunctionBody node) =>
1049 visitFunctionBody(node);
1050
1051 @override
1052 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node);
1053
1054 @override
1055 R visitExtendsClause(ExtendsClause node) => visitNode(node);
1056
1057 @override
1058 R visitFieldDeclaration(FieldDeclaration node) => visitClassMember(node);
1059
1060 @override
1061 R visitFieldFormalParameter(FieldFormalParameter node) =>
1062 visitNormalFormalParameter(node);
1063
1064 @override
1065 R visitForEachStatement(ForEachStatement node) => visitStatement(node);
1066
1067 R visitFormalParameter(FormalParameter node) => visitNode(node);
1068
1069 @override
1070 R visitFormalParameterList(FormalParameterList node) => visitNode(node);
1071
1072 @override
1073 R visitForStatement(ForStatement node) => visitStatement(node);
1074
1075 R visitFunctionBody(FunctionBody node) => visitNode(node);
1076
1077 @override
1078 R visitFunctionDeclaration(FunctionDeclaration node) =>
1079 visitNamedCompilationUnitMember(node);
1080
1081 @override
1082 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) =>
1083 visitStatement(node);
1084
1085 @override
1086 R visitFunctionExpression(FunctionExpression node) => visitExpression(node);
1087
1088 @override
1089 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) =>
1090 visitExpression(node);
1091
1092 @override
1093 R visitFunctionTypeAlias(FunctionTypeAlias node) => visitTypeAlias(node);
1094
1095 @override
1096 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) =>
1097 visitNormalFormalParameter(node);
1098
1099 @override
1100 R visitHideCombinator(HideCombinator node) => visitCombinator(node);
1101
1102 R visitIdentifier(Identifier node) => visitExpression(node);
1103
1104 @override
1105 R visitIfStatement(IfStatement node) => visitStatement(node);
1106
1107 @override
1108 R visitImplementsClause(ImplementsClause node) => visitNode(node);
1109
1110 @override
1111 R visitImportDirective(ImportDirective node) => visitNamespaceDirective(node);
1112
1113 @override
1114 R visitIndexExpression(IndexExpression node) => visitExpression(node);
1115
1116 @override
1117 R visitInstanceCreationExpression(InstanceCreationExpression node) =>
1118 visitExpression(node);
1119
1120 @override
1121 R visitIntegerLiteral(IntegerLiteral node) => visitLiteral(node);
1122
1123 R visitInterpolationElement(InterpolationElement node) => visitNode(node);
1124
1125 @override
1126 R visitInterpolationExpression(InterpolationExpression node) =>
1127 visitInterpolationElement(node);
1128
1129 @override
1130 R visitInterpolationString(InterpolationString node) =>
1131 visitInterpolationElement(node);
1132
1133 @override
1134 R visitIsExpression(IsExpression node) => visitExpression(node);
1135
1136 @override
1137 R visitLabel(Label node) => visitNode(node);
1138
1139 @override
1140 R visitLabeledStatement(LabeledStatement node) => visitStatement(node);
1141
1142 @override
1143 R visitLibraryDirective(LibraryDirective node) => visitDirective(node);
1144
1145 @override
1146 R visitLibraryIdentifier(LibraryIdentifier node) => visitIdentifier(node);
1147
1148 @override
1149 R visitListLiteral(ListLiteral node) => visitTypedLiteral(node);
1150
1151 R visitLiteral(Literal node) => visitExpression(node);
1152
1153 @override
1154 R visitMapLiteral(MapLiteral node) => visitTypedLiteral(node);
1155
1156 @override
1157 R visitMapLiteralEntry(MapLiteralEntry node) => visitNode(node);
1158
1159 @override
1160 R visitMethodDeclaration(MethodDeclaration node) => visitClassMember(node);
1161
1162 @override
1163 R visitMethodInvocation(MethodInvocation node) => visitExpression(node);
1164
1165 R visitNamedCompilationUnitMember(NamedCompilationUnitMember node) =>
1166 visitCompilationUnitMember(node);
1167
1168 @override
1169 R visitNamedExpression(NamedExpression node) => visitExpression(node);
1170
1171 R visitNamespaceDirective(NamespaceDirective node) =>
1172 visitUriBasedDirective(node);
1173
1174 @override
1175 R visitNativeClause(NativeClause node) => visitNode(node);
1176
1177 @override
1178 R visitNativeFunctionBody(NativeFunctionBody node) => visitFunctionBody(node);
1179
1180 R visitNode(AstNode node) {
1181 node.visitChildren(this);
1182 return null;
1183 }
1184
1185 R visitNormalFormalParameter(NormalFormalParameter node) =>
1186 visitFormalParameter(node);
1187
1188 @override
1189 R visitNullLiteral(NullLiteral node) => visitLiteral(node);
1190
1191 @override
1192 R visitParenthesizedExpression(ParenthesizedExpression node) =>
1193 visitExpression(node);
1194
1195 @override
1196 R visitPartDirective(PartDirective node) => visitUriBasedDirective(node);
1197
1198 @override
1199 R visitPartOfDirective(PartOfDirective node) => visitDirective(node);
1200
1201 @override
1202 R visitPostfixExpression(PostfixExpression node) => visitExpression(node);
1203
1204 @override
1205 R visitPrefixedIdentifier(PrefixedIdentifier node) => visitIdentifier(node);
1206
1207 @override
1208 R visitPrefixExpression(PrefixExpression node) => visitExpression(node);
1209
1210 @override
1211 R visitPropertyAccess(PropertyAccess node) => visitExpression(node);
1212
1213 @override
1214 R visitRedirectingConstructorInvocation(
1215 RedirectingConstructorInvocation node) =>
1216 visitConstructorInitializer(node);
1217
1218 @override
1219 R visitRethrowExpression(RethrowExpression node) => visitExpression(node);
1220
1221 @override
1222 R visitReturnStatement(ReturnStatement node) => visitStatement(node);
1223
1224 @override
1225 R visitScriptTag(ScriptTag scriptTag) => visitNode(scriptTag);
1226
1227 @override
1228 R visitShowCombinator(ShowCombinator node) => visitCombinator(node);
1229
1230 @override
1231 R visitSimpleFormalParameter(SimpleFormalParameter node) =>
1232 visitNormalFormalParameter(node);
1233
1234 @override
1235 R visitSimpleIdentifier(SimpleIdentifier node) => visitIdentifier(node);
1236
1237 @override
1238 R visitSimpleStringLiteral(SimpleStringLiteral node) =>
1239 visitSingleStringLiteral(node);
1240
1241 R visitSingleStringLiteral(SingleStringLiteral node) =>
1242 visitStringLiteral(node);
1243
1244 R visitStatement(Statement node) => visitNode(node);
1245
1246 @override
1247 R visitStringInterpolation(StringInterpolation node) =>
1248 visitSingleStringLiteral(node);
1249
1250 R visitStringLiteral(StringLiteral node) => visitLiteral(node);
1251
1252 @override
1253 R visitSuperConstructorInvocation(SuperConstructorInvocation node) =>
1254 visitConstructorInitializer(node);
1255
1256 @override
1257 R visitSuperExpression(SuperExpression node) => visitExpression(node);
1258
1259 @override
1260 R visitSwitchCase(SwitchCase node) => visitSwitchMember(node);
1261
1262 @override
1263 R visitSwitchDefault(SwitchDefault node) => visitSwitchMember(node);
1264
1265 R visitSwitchMember(SwitchMember node) => visitNode(node);
1266
1267 @override
1268 R visitSwitchStatement(SwitchStatement node) => visitStatement(node);
1269
1270 @override
1271 R visitSymbolLiteral(SymbolLiteral node) => visitLiteral(node);
1272
1273 @override
1274 R visitThisExpression(ThisExpression node) => visitExpression(node);
1275
1276 @override
1277 R visitThrowExpression(ThrowExpression node) => visitExpression(node);
1278
1279 @override
1280 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) =>
1281 visitCompilationUnitMember(node);
1282
1283 @override
1284 R visitTryStatement(TryStatement node) => visitStatement(node);
1285
1286 R visitTypeAlias(TypeAlias node) => visitNamedCompilationUnitMember(node);
1287
1288 @override
1289 R visitTypeArgumentList(TypeArgumentList node) => visitNode(node);
1290
1291 R visitTypedLiteral(TypedLiteral node) => visitLiteral(node);
1292
1293 @override
1294 R visitTypeName(TypeName node) => visitNode(node);
1295
1296 @override
1297 R visitTypeParameter(TypeParameter node) => visitNode(node);
1298
1299 @override
1300 R visitTypeParameterList(TypeParameterList node) => visitNode(node);
1301
1302 R visitUriBasedDirective(UriBasedDirective node) => visitDirective(node);
1303
1304 @override
1305 R visitVariableDeclaration(VariableDeclaration node) =>
1306 visitDeclaration(node);
1307
1308 @override
1309 R visitVariableDeclarationList(VariableDeclarationList node) =>
1310 visitNode(node);
1311
1312 @override
1313 R visitVariableDeclarationStatement(VariableDeclarationStatement node) =>
1314 visitStatement(node);
1315
1316 @override
1317 R visitWhileStatement(WhileStatement node) => visitStatement(node);
1318
1319 @override
1320 R visitWithClause(WithClause node) => visitNode(node);
1321
1322 @override
1323 R visitYieldStatement(YieldStatement node) => visitStatement(node);
1324 }
1325
1326 /**
1327 * An AST visitor that will recursively visit all of the nodes in an AST
1328 * structure. For example, using an instance of this class to visit a [Block]
1329 * will also cause all of the statements in the block to be visited.
1330 *
1331 * Subclasses that override a visit method must either invoke the overridden
1332 * visit method or must explicitly ask the visited node to visit its children.
1333 * Failure to do so will cause the children of the visited node to not be
1334 * visited.
1335 *
1336 * Clients may extend this class.
1337 */
1338 class RecursiveAstVisitor<R> implements AstVisitor<R> {
1339 @override
1340 R visitAdjacentStrings(AdjacentStrings node) {
1341 node.visitChildren(this);
1342 return null;
1343 }
1344
1345 @override
1346 R visitAnnotation(Annotation node) {
1347 node.visitChildren(this);
1348 return null;
1349 }
1350
1351 @override
1352 R visitArgumentList(ArgumentList node) {
1353 node.visitChildren(this);
1354 return null;
1355 }
1356
1357 @override
1358 R visitAsExpression(AsExpression node) {
1359 node.visitChildren(this);
1360 return null;
1361 }
1362
1363 @override
1364 R visitAssertStatement(AssertStatement node) {
1365 node.visitChildren(this);
1366 return null;
1367 }
1368
1369 @override
1370 R visitAssignmentExpression(AssignmentExpression node) {
1371 node.visitChildren(this);
1372 return null;
1373 }
1374
1375 @override
1376 R visitAwaitExpression(AwaitExpression node) {
1377 node.visitChildren(this);
1378 return null;
1379 }
1380
1381 @override
1382 R visitBinaryExpression(BinaryExpression node) {
1383 node.visitChildren(this);
1384 return null;
1385 }
1386
1387 @override
1388 R visitBlock(Block node) {
1389 node.visitChildren(this);
1390 return null;
1391 }
1392
1393 @override
1394 R visitBlockFunctionBody(BlockFunctionBody node) {
1395 node.visitChildren(this);
1396 return null;
1397 }
1398
1399 @override
1400 R visitBooleanLiteral(BooleanLiteral node) {
1401 node.visitChildren(this);
1402 return null;
1403 }
1404
1405 @override
1406 R visitBreakStatement(BreakStatement node) {
1407 node.visitChildren(this);
1408 return null;
1409 }
1410
1411 @override
1412 R visitCascadeExpression(CascadeExpression node) {
1413 node.visitChildren(this);
1414 return null;
1415 }
1416
1417 @override
1418 R visitCatchClause(CatchClause node) {
1419 node.visitChildren(this);
1420 return null;
1421 }
1422
1423 @override
1424 R visitClassDeclaration(ClassDeclaration node) {
1425 node.visitChildren(this);
1426 return null;
1427 }
1428
1429 @override
1430 R visitClassTypeAlias(ClassTypeAlias node) {
1431 node.visitChildren(this);
1432 return null;
1433 }
1434
1435 @override
1436 R visitComment(Comment node) {
1437 node.visitChildren(this);
1438 return null;
1439 }
1440
1441 @override
1442 R visitCommentReference(CommentReference node) {
1443 node.visitChildren(this);
1444 return null;
1445 }
1446
1447 @override
1448 R visitCompilationUnit(CompilationUnit node) {
1449 node.visitChildren(this);
1450 return null;
1451 }
1452
1453 @override
1454 R visitConditionalExpression(ConditionalExpression node) {
1455 node.visitChildren(this);
1456 return null;
1457 }
1458
1459 @override
1460 R visitConfiguration(Configuration node) {
1461 node.visitChildren(this);
1462 return null;
1463 }
1464
1465 @override
1466 R visitConstructorDeclaration(ConstructorDeclaration node) {
1467 node.visitChildren(this);
1468 return null;
1469 }
1470
1471 @override
1472 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
1473 node.visitChildren(this);
1474 return null;
1475 }
1476
1477 @override
1478 R visitConstructorName(ConstructorName node) {
1479 node.visitChildren(this);
1480 return null;
1481 }
1482
1483 @override
1484 R visitContinueStatement(ContinueStatement node) {
1485 node.visitChildren(this);
1486 return null;
1487 }
1488
1489 @override
1490 R visitDeclaredIdentifier(DeclaredIdentifier node) {
1491 node.visitChildren(this);
1492 return null;
1493 }
1494
1495 @override
1496 R visitDefaultFormalParameter(DefaultFormalParameter node) {
1497 node.visitChildren(this);
1498 return null;
1499 }
1500
1501 @override
1502 R visitDoStatement(DoStatement node) {
1503 node.visitChildren(this);
1504 return null;
1505 }
1506
1507 @override
1508 R visitDottedName(DottedName node) {
1509 node.visitChildren(this);
1510 return null;
1511 }
1512
1513 @override
1514 R visitDoubleLiteral(DoubleLiteral node) {
1515 node.visitChildren(this);
1516 return null;
1517 }
1518
1519 @override
1520 R visitEmptyFunctionBody(EmptyFunctionBody node) {
1521 node.visitChildren(this);
1522 return null;
1523 }
1524
1525 @override
1526 R visitEmptyStatement(EmptyStatement node) {
1527 node.visitChildren(this);
1528 return null;
1529 }
1530
1531 @override
1532 R visitEnumConstantDeclaration(EnumConstantDeclaration node) {
1533 node.visitChildren(this);
1534 return null;
1535 }
1536
1537 @override
1538 R visitEnumDeclaration(EnumDeclaration node) {
1539 node.visitChildren(this);
1540 return null;
1541 }
1542
1543 @override
1544 R visitExportDirective(ExportDirective node) {
1545 node.visitChildren(this);
1546 return null;
1547 }
1548
1549 @override
1550 R visitExpressionFunctionBody(ExpressionFunctionBody node) {
1551 node.visitChildren(this);
1552 return null;
1553 }
1554
1555 @override
1556 R visitExpressionStatement(ExpressionStatement node) {
1557 node.visitChildren(this);
1558 return null;
1559 }
1560
1561 @override
1562 R visitExtendsClause(ExtendsClause node) {
1563 node.visitChildren(this);
1564 return null;
1565 }
1566
1567 @override
1568 R visitFieldDeclaration(FieldDeclaration node) {
1569 node.visitChildren(this);
1570 return null;
1571 }
1572
1573 @override
1574 R visitFieldFormalParameter(FieldFormalParameter node) {
1575 node.visitChildren(this);
1576 return null;
1577 }
1578
1579 @override
1580 R visitForEachStatement(ForEachStatement node) {
1581 node.visitChildren(this);
1582 return null;
1583 }
1584
1585 @override
1586 R visitFormalParameterList(FormalParameterList node) {
1587 node.visitChildren(this);
1588 return null;
1589 }
1590
1591 @override
1592 R visitForStatement(ForStatement node) {
1593 node.visitChildren(this);
1594 return null;
1595 }
1596
1597 @override
1598 R visitFunctionDeclaration(FunctionDeclaration node) {
1599 node.visitChildren(this);
1600 return null;
1601 }
1602
1603 @override
1604 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
1605 node.visitChildren(this);
1606 return null;
1607 }
1608
1609 @override
1610 R visitFunctionExpression(FunctionExpression node) {
1611 node.visitChildren(this);
1612 return null;
1613 }
1614
1615 @override
1616 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
1617 node.visitChildren(this);
1618 return null;
1619 }
1620
1621 @override
1622 R visitFunctionTypeAlias(FunctionTypeAlias node) {
1623 node.visitChildren(this);
1624 return null;
1625 }
1626
1627 @override
1628 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
1629 node.visitChildren(this);
1630 return null;
1631 }
1632
1633 @override
1634 R visitHideCombinator(HideCombinator node) {
1635 node.visitChildren(this);
1636 return null;
1637 }
1638
1639 @override
1640 R visitIfStatement(IfStatement node) {
1641 node.visitChildren(this);
1642 return null;
1643 }
1644
1645 @override
1646 R visitImplementsClause(ImplementsClause node) {
1647 node.visitChildren(this);
1648 return null;
1649 }
1650
1651 @override
1652 R visitImportDirective(ImportDirective node) {
1653 node.visitChildren(this);
1654 return null;
1655 }
1656
1657 @override
1658 R visitIndexExpression(IndexExpression node) {
1659 node.visitChildren(this);
1660 return null;
1661 }
1662
1663 @override
1664 R visitInstanceCreationExpression(InstanceCreationExpression node) {
1665 node.visitChildren(this);
1666 return null;
1667 }
1668
1669 @override
1670 R visitIntegerLiteral(IntegerLiteral node) {
1671 node.visitChildren(this);
1672 return null;
1673 }
1674
1675 @override
1676 R visitInterpolationExpression(InterpolationExpression node) {
1677 node.visitChildren(this);
1678 return null;
1679 }
1680
1681 @override
1682 R visitInterpolationString(InterpolationString node) {
1683 node.visitChildren(this);
1684 return null;
1685 }
1686
1687 @override
1688 R visitIsExpression(IsExpression node) {
1689 node.visitChildren(this);
1690 return null;
1691 }
1692
1693 @override
1694 R visitLabel(Label node) {
1695 node.visitChildren(this);
1696 return null;
1697 }
1698
1699 @override
1700 R visitLabeledStatement(LabeledStatement node) {
1701 node.visitChildren(this);
1702 return null;
1703 }
1704
1705 @override
1706 R visitLibraryDirective(LibraryDirective node) {
1707 node.visitChildren(this);
1708 return null;
1709 }
1710
1711 @override
1712 R visitLibraryIdentifier(LibraryIdentifier node) {
1713 node.visitChildren(this);
1714 return null;
1715 }
1716
1717 @override
1718 R visitListLiteral(ListLiteral node) {
1719 node.visitChildren(this);
1720 return null;
1721 }
1722
1723 @override
1724 R visitMapLiteral(MapLiteral node) {
1725 node.visitChildren(this);
1726 return null;
1727 }
1728
1729 @override
1730 R visitMapLiteralEntry(MapLiteralEntry node) {
1731 node.visitChildren(this);
1732 return null;
1733 }
1734
1735 @override
1736 R visitMethodDeclaration(MethodDeclaration node) {
1737 node.visitChildren(this);
1738 return null;
1739 }
1740
1741 @override
1742 R visitMethodInvocation(MethodInvocation node) {
1743 node.visitChildren(this);
1744 return null;
1745 }
1746
1747 @override
1748 R visitNamedExpression(NamedExpression node) {
1749 node.visitChildren(this);
1750 return null;
1751 }
1752
1753 @override
1754 R visitNativeClause(NativeClause node) {
1755 node.visitChildren(this);
1756 return null;
1757 }
1758
1759 @override
1760 R visitNativeFunctionBody(NativeFunctionBody node) {
1761 node.visitChildren(this);
1762 return null;
1763 }
1764
1765 @override
1766 R visitNullLiteral(NullLiteral node) {
1767 node.visitChildren(this);
1768 return null;
1769 }
1770
1771 @override
1772 R visitParenthesizedExpression(ParenthesizedExpression node) {
1773 node.visitChildren(this);
1774 return null;
1775 }
1776
1777 @override
1778 R visitPartDirective(PartDirective node) {
1779 node.visitChildren(this);
1780 return null;
1781 }
1782
1783 @override
1784 R visitPartOfDirective(PartOfDirective node) {
1785 node.visitChildren(this);
1786 return null;
1787 }
1788
1789 @override
1790 R visitPostfixExpression(PostfixExpression node) {
1791 node.visitChildren(this);
1792 return null;
1793 }
1794
1795 @override
1796 R visitPrefixedIdentifier(PrefixedIdentifier node) {
1797 node.visitChildren(this);
1798 return null;
1799 }
1800
1801 @override
1802 R visitPrefixExpression(PrefixExpression node) {
1803 node.visitChildren(this);
1804 return null;
1805 }
1806
1807 @override
1808 R visitPropertyAccess(PropertyAccess node) {
1809 node.visitChildren(this);
1810 return null;
1811 }
1812
1813 @override
1814 R visitRedirectingConstructorInvocation(
1815 RedirectingConstructorInvocation node) {
1816 node.visitChildren(this);
1817 return null;
1818 }
1819
1820 @override
1821 R visitRethrowExpression(RethrowExpression node) {
1822 node.visitChildren(this);
1823 return null;
1824 }
1825
1826 @override
1827 R visitReturnStatement(ReturnStatement node) {
1828 node.visitChildren(this);
1829 return null;
1830 }
1831
1832 @override
1833 R visitScriptTag(ScriptTag node) {
1834 node.visitChildren(this);
1835 return null;
1836 }
1837
1838 @override
1839 R visitShowCombinator(ShowCombinator node) {
1840 node.visitChildren(this);
1841 return null;
1842 }
1843
1844 @override
1845 R visitSimpleFormalParameter(SimpleFormalParameter node) {
1846 node.visitChildren(this);
1847 return null;
1848 }
1849
1850 @override
1851 R visitSimpleIdentifier(SimpleIdentifier node) {
1852 node.visitChildren(this);
1853 return null;
1854 }
1855
1856 @override
1857 R visitSimpleStringLiteral(SimpleStringLiteral node) {
1858 node.visitChildren(this);
1859 return null;
1860 }
1861
1862 @override
1863 R visitStringInterpolation(StringInterpolation node) {
1864 node.visitChildren(this);
1865 return null;
1866 }
1867
1868 @override
1869 R visitSuperConstructorInvocation(SuperConstructorInvocation node) {
1870 node.visitChildren(this);
1871 return null;
1872 }
1873
1874 @override
1875 R visitSuperExpression(SuperExpression node) {
1876 node.visitChildren(this);
1877 return null;
1878 }
1879
1880 @override
1881 R visitSwitchCase(SwitchCase node) {
1882 node.visitChildren(this);
1883 return null;
1884 }
1885
1886 @override
1887 R visitSwitchDefault(SwitchDefault node) {
1888 node.visitChildren(this);
1889 return null;
1890 }
1891
1892 @override
1893 R visitSwitchStatement(SwitchStatement node) {
1894 node.visitChildren(this);
1895 return null;
1896 }
1897
1898 @override
1899 R visitSymbolLiteral(SymbolLiteral node) {
1900 node.visitChildren(this);
1901 return null;
1902 }
1903
1904 @override
1905 R visitThisExpression(ThisExpression node) {
1906 node.visitChildren(this);
1907 return null;
1908 }
1909
1910 @override
1911 R visitThrowExpression(ThrowExpression node) {
1912 node.visitChildren(this);
1913 return null;
1914 }
1915
1916 @override
1917 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
1918 node.visitChildren(this);
1919 return null;
1920 }
1921
1922 @override
1923 R visitTryStatement(TryStatement node) {
1924 node.visitChildren(this);
1925 return null;
1926 }
1927
1928 @override
1929 R visitTypeArgumentList(TypeArgumentList node) {
1930 node.visitChildren(this);
1931 return null;
1932 }
1933
1934 @override
1935 R visitTypeName(TypeName node) {
1936 node.visitChildren(this);
1937 return null;
1938 }
1939
1940 @override
1941 R visitTypeParameter(TypeParameter node) {
1942 node.visitChildren(this);
1943 return null;
1944 }
1945
1946 @override
1947 R visitTypeParameterList(TypeParameterList node) {
1948 node.visitChildren(this);
1949 return null;
1950 }
1951
1952 @override
1953 R visitVariableDeclaration(VariableDeclaration node) {
1954 node.visitChildren(this);
1955 return null;
1956 }
1957
1958 @override
1959 R visitVariableDeclarationList(VariableDeclarationList node) {
1960 node.visitChildren(this);
1961 return null;
1962 }
1963
1964 @override
1965 R visitVariableDeclarationStatement(VariableDeclarationStatement node) {
1966 node.visitChildren(this);
1967 return null;
1968 }
1969
1970 @override
1971 R visitWhileStatement(WhileStatement node) {
1972 node.visitChildren(this);
1973 return null;
1974 }
1975
1976 @override
1977 R visitWithClause(WithClause node) {
1978 node.visitChildren(this);
1979 return null;
1980 }
1981
1982 @override
1983 R visitYieldStatement(YieldStatement node) {
1984 node.visitChildren(this);
1985 return null;
1986 }
1987 }
1988
1989 /**
1990 * An AST visitor that will do nothing when visiting an AST node. It is intended
1991 * to be a superclass for classes that use the visitor pattern primarily as a
1992 * dispatch mechanism (and hence don't need to recursively visit a whole
1993 * structure) and that only need to visit a small number of node types.
1994 *
1995 * Clients may extend this class.
1996 */
1997 class SimpleAstVisitor<R> implements AstVisitor<R> {
1998 @override
1999 R visitAdjacentStrings(AdjacentStrings node) => null;
2000
2001 @override
2002 R visitAnnotation(Annotation node) => null;
2003
2004 @override
2005 R visitArgumentList(ArgumentList node) => null;
2006
2007 @override
2008 R visitAsExpression(AsExpression node) => null;
2009
2010 @override
2011 R visitAssertStatement(AssertStatement node) => null;
2012
2013 @override
2014 R visitAssignmentExpression(AssignmentExpression node) => null;
2015
2016 @override
2017 R visitAwaitExpression(AwaitExpression node) => null;
2018
2019 @override
2020 R visitBinaryExpression(BinaryExpression node) => null;
2021
2022 @override
2023 R visitBlock(Block node) => null;
2024
2025 @override
2026 R visitBlockFunctionBody(BlockFunctionBody node) => null;
2027
2028 @override
2029 R visitBooleanLiteral(BooleanLiteral node) => null;
2030
2031 @override
2032 R visitBreakStatement(BreakStatement node) => null;
2033
2034 @override
2035 R visitCascadeExpression(CascadeExpression node) => null;
2036
2037 @override
2038 R visitCatchClause(CatchClause node) => null;
2039
2040 @override
2041 R visitClassDeclaration(ClassDeclaration node) => null;
2042
2043 @override
2044 R visitClassTypeAlias(ClassTypeAlias node) => null;
2045
2046 @override
2047 R visitComment(Comment node) => null;
2048
2049 @override
2050 R visitCommentReference(CommentReference node) => null;
2051
2052 @override
2053 R visitCompilationUnit(CompilationUnit node) => null;
2054
2055 @override
2056 R visitConditionalExpression(ConditionalExpression node) => null;
2057
2058 @override
2059 R visitConfiguration(Configuration node) => null;
2060
2061 @override
2062 R visitConstructorDeclaration(ConstructorDeclaration node) => null;
2063
2064 @override
2065 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) => null;
2066
2067 @override
2068 R visitConstructorName(ConstructorName node) => null;
2069
2070 @override
2071 R visitContinueStatement(ContinueStatement node) => null;
2072
2073 @override
2074 R visitDeclaredIdentifier(DeclaredIdentifier node) => null;
2075
2076 @override
2077 R visitDefaultFormalParameter(DefaultFormalParameter node) => null;
2078
2079 @override
2080 R visitDoStatement(DoStatement node) => null;
2081
2082 @override
2083 R visitDottedName(DottedName node) => null;
2084
2085 @override
2086 R visitDoubleLiteral(DoubleLiteral node) => null;
2087
2088 @override
2089 R visitEmptyFunctionBody(EmptyFunctionBody node) => null;
2090
2091 @override
2092 R visitEmptyStatement(EmptyStatement node) => null;
2093
2094 @override
2095 R visitEnumConstantDeclaration(EnumConstantDeclaration node) => null;
2096
2097 @override
2098 R visitEnumDeclaration(EnumDeclaration node) => null;
2099
2100 @override
2101 R visitExportDirective(ExportDirective node) => null;
2102
2103 @override
2104 R visitExpressionFunctionBody(ExpressionFunctionBody node) => null;
2105
2106 @override
2107 R visitExpressionStatement(ExpressionStatement node) => null;
2108
2109 @override
2110 R visitExtendsClause(ExtendsClause node) => null;
2111
2112 @override
2113 R visitFieldDeclaration(FieldDeclaration node) => null;
2114
2115 @override
2116 R visitFieldFormalParameter(FieldFormalParameter node) => null;
2117
2118 @override
2119 R visitForEachStatement(ForEachStatement node) => null;
2120
2121 @override
2122 R visitFormalParameterList(FormalParameterList node) => null;
2123
2124 @override
2125 R visitForStatement(ForStatement node) => null;
2126
2127 @override
2128 R visitFunctionDeclaration(FunctionDeclaration node) => null;
2129
2130 @override
2131 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) =>
2132 null;
2133
2134 @override
2135 R visitFunctionExpression(FunctionExpression node) => null;
2136
2137 @override
2138 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) =>
2139 null;
2140
2141 @override
2142 R visitFunctionTypeAlias(FunctionTypeAlias node) => null;
2143
2144 @override
2145 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) =>
2146 null;
2147
2148 @override
2149 R visitHideCombinator(HideCombinator node) => null;
2150
2151 @override
2152 R visitIfStatement(IfStatement node) => null;
2153
2154 @override
2155 R visitImplementsClause(ImplementsClause node) => null;
2156
2157 @override
2158 R visitImportDirective(ImportDirective node) => null;
2159
2160 @override
2161 R visitIndexExpression(IndexExpression node) => null;
2162
2163 @override
2164 R visitInstanceCreationExpression(InstanceCreationExpression node) => null;
2165
2166 @override
2167 R visitIntegerLiteral(IntegerLiteral node) => null;
2168
2169 @override
2170 R visitInterpolationExpression(InterpolationExpression node) => null;
2171
2172 @override
2173 R visitInterpolationString(InterpolationString node) => null;
2174
2175 @override
2176 R visitIsExpression(IsExpression node) => null;
2177
2178 @override
2179 R visitLabel(Label node) => null;
2180
2181 @override
2182 R visitLabeledStatement(LabeledStatement node) => null;
2183
2184 @override
2185 R visitLibraryDirective(LibraryDirective node) => null;
2186
2187 @override
2188 R visitLibraryIdentifier(LibraryIdentifier node) => null;
2189
2190 @override
2191 R visitListLiteral(ListLiteral node) => null;
2192
2193 @override
2194 R visitMapLiteral(MapLiteral node) => null;
2195
2196 @override
2197 R visitMapLiteralEntry(MapLiteralEntry node) => null;
2198
2199 @override
2200 R visitMethodDeclaration(MethodDeclaration node) => null;
2201
2202 @override
2203 R visitMethodInvocation(MethodInvocation node) => null;
2204
2205 @override
2206 R visitNamedExpression(NamedExpression node) => null;
2207
2208 @override
2209 R visitNativeClause(NativeClause node) => null;
2210
2211 @override
2212 R visitNativeFunctionBody(NativeFunctionBody node) => null;
2213
2214 @override
2215 R visitNullLiteral(NullLiteral node) => null;
2216
2217 @override
2218 R visitParenthesizedExpression(ParenthesizedExpression node) => null;
2219
2220 @override
2221 R visitPartDirective(PartDirective node) => null;
2222
2223 @override
2224 R visitPartOfDirective(PartOfDirective node) => null;
2225
2226 @override
2227 R visitPostfixExpression(PostfixExpression node) => null;
2228
2229 @override
2230 R visitPrefixedIdentifier(PrefixedIdentifier node) => null;
2231
2232 @override
2233 R visitPrefixExpression(PrefixExpression node) => null;
2234
2235 @override
2236 R visitPropertyAccess(PropertyAccess node) => null;
2237
2238 @override
2239 R visitRedirectingConstructorInvocation(
2240 RedirectingConstructorInvocation node) =>
2241 null;
2242
2243 @override
2244 R visitRethrowExpression(RethrowExpression node) => null;
2245
2246 @override
2247 R visitReturnStatement(ReturnStatement node) => null;
2248
2249 @override
2250 R visitScriptTag(ScriptTag node) => null;
2251
2252 @override
2253 R visitShowCombinator(ShowCombinator node) => null;
2254
2255 @override
2256 R visitSimpleFormalParameter(SimpleFormalParameter node) => null;
2257
2258 @override
2259 R visitSimpleIdentifier(SimpleIdentifier node) => null;
2260
2261 @override
2262 R visitSimpleStringLiteral(SimpleStringLiteral node) => null;
2263
2264 @override
2265 R visitStringInterpolation(StringInterpolation node) => null;
2266
2267 @override
2268 R visitSuperConstructorInvocation(SuperConstructorInvocation node) => null;
2269
2270 @override
2271 R visitSuperExpression(SuperExpression node) => null;
2272
2273 @override
2274 R visitSwitchCase(SwitchCase node) => null;
2275
2276 @override
2277 R visitSwitchDefault(SwitchDefault node) => null;
2278
2279 @override
2280 R visitSwitchStatement(SwitchStatement node) => null;
2281
2282 @override
2283 R visitSymbolLiteral(SymbolLiteral node) => null;
2284
2285 @override
2286 R visitThisExpression(ThisExpression node) => null;
2287
2288 @override
2289 R visitThrowExpression(ThrowExpression node) => null;
2290
2291 @override
2292 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) => null;
2293
2294 @override
2295 R visitTryStatement(TryStatement node) => null;
2296
2297 @override
2298 R visitTypeArgumentList(TypeArgumentList node) => null;
2299
2300 @override
2301 R visitTypeName(TypeName node) => null;
2302
2303 @override
2304 R visitTypeParameter(TypeParameter node) => null;
2305
2306 @override
2307 R visitTypeParameterList(TypeParameterList node) => null;
2308
2309 @override
2310 R visitVariableDeclaration(VariableDeclaration node) => null;
2311
2312 @override
2313 R visitVariableDeclarationList(VariableDeclarationList node) => null;
2314
2315 @override
2316 R visitVariableDeclarationStatement(VariableDeclarationStatement node) =>
2317 null;
2318
2319 @override
2320 R visitWhileStatement(WhileStatement node) => null;
2321
2322 @override
2323 R visitWithClause(WithClause node) => null;
2324
2325 @override
2326 R visitYieldStatement(YieldStatement node) => null;
2327 }
2328
2329 /**
2330 * An AST visitor that will throw an exception if any of the visit methods that
2331 * are invoked have not been overridden. It is intended to be a superclass for
2332 * classes that implement the visitor pattern and need to (a) override all of
2333 * the visit methods or (b) need to override a subset of the visit method and
2334 * want to catch when any other visit methods have been invoked.
2335 *
2336 * Clients may extend this class.
2337 */
2338 class ThrowingAstVisitor<R> implements AstVisitor<R> {
2339 @override
2340 R visitAdjacentStrings(AdjacentStrings node) => _throw(node);
2341
2342 @override
2343 R visitAnnotation(Annotation node) => _throw(node);
2344
2345 @override
2346 R visitArgumentList(ArgumentList node) => _throw(node);
2347
2348 @override
2349 R visitAsExpression(AsExpression node) => _throw(node);
2350
2351 @override
2352 R visitAssertInitializer(AssertInitializer node) => _throw(node);
2353
2354 @override
2355 R visitAssertStatement(AssertStatement node) => _throw(node);
2356
2357 @override
2358 R visitAssignmentExpression(AssignmentExpression node) => _throw(node);
2359
2360 @override
2361 R visitAwaitExpression(AwaitExpression node) => _throw(node);
2362
2363 @override
2364 R visitBinaryExpression(BinaryExpression node) => _throw(node);
2365
2366 @override
2367 R visitBlock(Block node) => _throw(node);
2368
2369 @override
2370 R visitBlockFunctionBody(BlockFunctionBody node) => _throw(node);
2371
2372 @override
2373 R visitBooleanLiteral(BooleanLiteral node) => _throw(node);
2374
2375 @override
2376 R visitBreakStatement(BreakStatement node) => _throw(node);
2377
2378 @override
2379 R visitCascadeExpression(CascadeExpression node) => _throw(node);
2380
2381 @override
2382 R visitCatchClause(CatchClause node) => _throw(node);
2383
2384 @override
2385 R visitClassDeclaration(ClassDeclaration node) => _throw(node);
2386
2387 @override
2388 R visitClassTypeAlias(ClassTypeAlias node) => _throw(node);
2389
2390 @override
2391 R visitComment(Comment node) => _throw(node);
2392
2393 @override
2394 R visitCommentReference(CommentReference node) => _throw(node);
2395
2396 @override
2397 R visitCompilationUnit(CompilationUnit node) => _throw(node);
2398
2399 @override
2400 R visitConditionalExpression(ConditionalExpression node) => _throw(node);
2401
2402 @override
2403 R visitConfiguration(Configuration node) => _throw(node);
2404
2405 @override
2406 R visitConstructorDeclaration(ConstructorDeclaration node) => _throw(node);
2407
2408 @override
2409 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) =>
2410 _throw(node);
2411
2412 @override
2413 R visitConstructorName(ConstructorName node) => _throw(node);
2414
2415 @override
2416 R visitContinueStatement(ContinueStatement node) => _throw(node);
2417
2418 @override
2419 R visitDeclaredIdentifier(DeclaredIdentifier node) => _throw(node);
2420
2421 @override
2422 R visitDefaultFormalParameter(DefaultFormalParameter node) => _throw(node);
2423
2424 @override
2425 R visitDoStatement(DoStatement node) => _throw(node);
2426
2427 @override
2428 R visitDottedName(DottedName node) => _throw(node);
2429
2430 @override
2431 R visitDoubleLiteral(DoubleLiteral node) => _throw(node);
2432
2433 @override
2434 R visitEmptyFunctionBody(EmptyFunctionBody node) => _throw(node);
2435
2436 @override
2437 R visitEmptyStatement(EmptyStatement node) => _throw(node);
2438
2439 @override
2440 R visitEnumConstantDeclaration(EnumConstantDeclaration node) => _throw(node);
2441
2442 @override
2443 R visitEnumDeclaration(EnumDeclaration node) => _throw(node);
2444
2445 @override
2446 R visitExportDirective(ExportDirective node) => _throw(node);
2447
2448 @override
2449 R visitExpressionFunctionBody(ExpressionFunctionBody node) => _throw(node);
2450
2451 @override
2452 R visitExpressionStatement(ExpressionStatement node) => _throw(node);
2453
2454 @override
2455 R visitExtendsClause(ExtendsClause node) => _throw(node);
2456
2457 @override
2458 R visitFieldDeclaration(FieldDeclaration node) => _throw(node);
2459
2460 @override
2461 R visitFieldFormalParameter(FieldFormalParameter node) => _throw(node);
2462
2463 @override
2464 R visitForEachStatement(ForEachStatement node) => _throw(node);
2465
2466 @override
2467 R visitFormalParameterList(FormalParameterList node) => _throw(node);
2468
2469 @override
2470 R visitForStatement(ForStatement node) => _throw(node);
2471
2472 @override
2473 R visitFunctionDeclaration(FunctionDeclaration node) => _throw(node);
2474
2475 @override
2476 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) =>
2477 _throw(node);
2478
2479 @override
2480 R visitFunctionExpression(FunctionExpression node) => _throw(node);
2481
2482 @override
2483 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) =>
2484 _throw(node);
2485
2486 @override
2487 R visitFunctionTypeAlias(FunctionTypeAlias node) => _throw(node);
2488
2489 @override
2490 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) =>
2491 _throw(node);
2492
2493 @override
2494 R visitHideCombinator(HideCombinator node) => _throw(node);
2495
2496 @override
2497 R visitIfStatement(IfStatement node) => _throw(node);
2498
2499 @override
2500 R visitImplementsClause(ImplementsClause node) => _throw(node);
2501
2502 @override
2503 R visitImportDirective(ImportDirective node) => _throw(node);
2504
2505 @override
2506 R visitIndexExpression(IndexExpression node) => _throw(node);
2507
2508 @override
2509 R visitInstanceCreationExpression(InstanceCreationExpression node) =>
2510 _throw(node);
2511
2512 @override
2513 R visitIntegerLiteral(IntegerLiteral node) => _throw(node);
2514
2515 @override
2516 R visitInterpolationExpression(InterpolationExpression node) => _throw(node);
2517
2518 @override
2519 R visitInterpolationString(InterpolationString node) => _throw(node);
2520
2521 @override
2522 R visitIsExpression(IsExpression node) => _throw(node);
2523
2524 @override
2525 R visitLabel(Label node) => _throw(node);
2526
2527 @override
2528 R visitLabeledStatement(LabeledStatement node) => _throw(node);
2529
2530 @override
2531 R visitLibraryDirective(LibraryDirective node) => _throw(node);
2532
2533 @override
2534 R visitLibraryIdentifier(LibraryIdentifier node) => _throw(node);
2535
2536 @override
2537 R visitListLiteral(ListLiteral node) => _throw(node);
2538
2539 @override
2540 R visitMapLiteral(MapLiteral node) => _throw(node);
2541
2542 @override
2543 R visitMapLiteralEntry(MapLiteralEntry node) => _throw(node);
2544
2545 @override
2546 R visitMethodDeclaration(MethodDeclaration node) => _throw(node);
2547
2548 @override
2549 R visitMethodInvocation(MethodInvocation node) => _throw(node);
2550
2551 @override
2552 R visitNamedExpression(NamedExpression node) => _throw(node);
2553
2554 @override
2555 R visitNativeClause(NativeClause node) => _throw(node);
2556
2557 @override
2558 R visitNativeFunctionBody(NativeFunctionBody node) => _throw(node);
2559
2560 @override
2561 R visitNullLiteral(NullLiteral node) => _throw(node);
2562
2563 @override
2564 R visitParenthesizedExpression(ParenthesizedExpression node) => _throw(node);
2565
2566 @override
2567 R visitPartDirective(PartDirective node) => _throw(node);
2568
2569 @override
2570 R visitPartOfDirective(PartOfDirective node) => _throw(node);
2571
2572 @override
2573 R visitPostfixExpression(PostfixExpression node) => _throw(node);
2574
2575 @override
2576 R visitPrefixedIdentifier(PrefixedIdentifier node) => _throw(node);
2577
2578 @override
2579 R visitPrefixExpression(PrefixExpression node) => _throw(node);
2580
2581 @override
2582 R visitPropertyAccess(PropertyAccess node) => _throw(node);
2583
2584 @override
2585 R visitRedirectingConstructorInvocation(
2586 RedirectingConstructorInvocation node) =>
2587 _throw(node);
2588
2589 @override
2590 R visitRethrowExpression(RethrowExpression node) => _throw(node);
2591
2592 @override
2593 R visitReturnStatement(ReturnStatement node) => _throw(node);
2594
2595 @override
2596 R visitScriptTag(ScriptTag node) => _throw(node);
2597
2598 @override
2599 R visitShowCombinator(ShowCombinator node) => _throw(node);
2600
2601 @override
2602 R visitSimpleFormalParameter(SimpleFormalParameter node) => _throw(node);
2603
2604 @override
2605 R visitSimpleIdentifier(SimpleIdentifier node) => _throw(node);
2606
2607 @override
2608 R visitSimpleStringLiteral(SimpleStringLiteral node) => _throw(node);
2609
2610 @override
2611 R visitStringInterpolation(StringInterpolation node) => _throw(node);
2612
2613 @override
2614 R visitSuperConstructorInvocation(SuperConstructorInvocation node) =>
2615 _throw(node);
2616
2617 @override
2618 R visitSuperExpression(SuperExpression node) => _throw(node);
2619
2620 @override
2621 R visitSwitchCase(SwitchCase node) => _throw(node);
2622
2623 @override
2624 R visitSwitchDefault(SwitchDefault node) => _throw(node);
2625
2626 @override
2627 R visitSwitchStatement(SwitchStatement node) => _throw(node);
2628
2629 @override
2630 R visitSymbolLiteral(SymbolLiteral node) => _throw(node);
2631
2632 @override
2633 R visitThisExpression(ThisExpression node) => _throw(node);
2634
2635 @override
2636 R visitThrowExpression(ThrowExpression node) => _throw(node);
2637
2638 @override
2639 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) =>
2640 _throw(node);
2641
2642 @override
2643 R visitTryStatement(TryStatement node) => _throw(node);
2644
2645 @override
2646 R visitTypeArgumentList(TypeArgumentList node) => _throw(node);
2647
2648 @override
2649 R visitTypeName(TypeName node) => _throw(node);
2650
2651 @override
2652 R visitTypeParameter(TypeParameter node) => _throw(node);
2653
2654 @override
2655 R visitTypeParameterList(TypeParameterList node) => _throw(node);
2656
2657 @override
2658 R visitVariableDeclaration(VariableDeclaration node) => _throw(node);
2659
2660 @override
2661 R visitVariableDeclarationList(VariableDeclarationList node) => _throw(node);
2662
2663 @override
2664 R visitVariableDeclarationStatement(VariableDeclarationStatement node) =>
2665 _throw(node);
2666
2667 @override
2668 R visitWhileStatement(WhileStatement node) => _throw(node);
2669
2670 @override
2671 R visitWithClause(WithClause node) => _throw(node);
2672
2673 @override
2674 R visitYieldStatement(YieldStatement node) => _throw(node);
2675
2676 R _throw(AstNode node) {
2677 throw new Exception('Missing implementation of visit${node.runtimeType}');
2678 }
2679 }
2680
2681 /**
2682 * An AST visitor that captures visit call timings.
2683 *
2684 * Clients may not extend, implement or mix-in this class.
2685 */
2686 class TimedAstVisitor<T> implements AstVisitor<T> {
2687 /**
2688 * The base visitor whose visit methods will be timed.
2689 */
2690 final AstVisitor<T> _baseVisitor;
2691
2692 /**
2693 * Collects elapsed time for visit calls.
2694 */
2695 final Stopwatch stopwatch;
2696
2697 /**
2698 * Initialize a newly created visitor to time calls to the given base
2699 * visitor's visits.
2700 */
2701 TimedAstVisitor(this._baseVisitor, [Stopwatch watch])
2702 : stopwatch = watch ?? new Stopwatch();
2703
2704 @override
2705 T visitAdjacentStrings(AdjacentStrings node) {
2706 stopwatch.start();
2707 T result = _baseVisitor.visitAdjacentStrings(node);
2708 stopwatch.stop();
2709 return result;
2710 }
2711
2712 @override
2713 T visitAnnotation(Annotation node) {
2714 stopwatch.start();
2715 T result = _baseVisitor.visitAnnotation(node);
2716 stopwatch.stop();
2717 return result;
2718 }
2719
2720 @override
2721 T visitArgumentList(ArgumentList node) {
2722 stopwatch.start();
2723 T result = _baseVisitor.visitArgumentList(node);
2724 stopwatch.stop();
2725 return result;
2726 }
2727
2728 @override
2729 T visitAsExpression(AsExpression node) {
2730 stopwatch.start();
2731 T result = _baseVisitor.visitAsExpression(node);
2732 stopwatch.stop();
2733 return result;
2734 }
2735
2736 @override
2737 T visitAssertStatement(AssertStatement node) {
2738 stopwatch.start();
2739 T result = _baseVisitor.visitAssertStatement(node);
2740 stopwatch.stop();
2741 return result;
2742 }
2743
2744 @override
2745 T visitAssignmentExpression(AssignmentExpression node) {
2746 stopwatch.start();
2747 T result = _baseVisitor.visitAssignmentExpression(node);
2748 stopwatch.stop();
2749 return result;
2750 }
2751
2752 @override
2753 T visitAwaitExpression(AwaitExpression node) {
2754 stopwatch.start();
2755 T result = _baseVisitor.visitAwaitExpression(node);
2756 stopwatch.stop();
2757 return result;
2758 }
2759
2760 @override
2761 T visitBinaryExpression(BinaryExpression node) {
2762 stopwatch.start();
2763 T result = _baseVisitor.visitBinaryExpression(node);
2764 stopwatch.stop();
2765 return result;
2766 }
2767
2768 @override
2769 T visitBlock(Block node) {
2770 stopwatch.start();
2771 T result = _baseVisitor.visitBlock(node);
2772 stopwatch.stop();
2773 return result;
2774 }
2775
2776 @override
2777 T visitBlockFunctionBody(BlockFunctionBody node) {
2778 stopwatch.start();
2779 T result = _baseVisitor.visitBlockFunctionBody(node);
2780 stopwatch.stop();
2781 return result;
2782 }
2783
2784 @override
2785 T visitBooleanLiteral(BooleanLiteral node) {
2786 stopwatch.start();
2787 T result = _baseVisitor.visitBooleanLiteral(node);
2788 stopwatch.stop();
2789 return result;
2790 }
2791
2792 @override
2793 T visitBreakStatement(BreakStatement node) {
2794 stopwatch.start();
2795 T result = _baseVisitor.visitBreakStatement(node);
2796 stopwatch.stop();
2797 return result;
2798 }
2799
2800 @override
2801 T visitCascadeExpression(CascadeExpression node) {
2802 stopwatch.start();
2803 T result = _baseVisitor.visitCascadeExpression(node);
2804 stopwatch.stop();
2805 return result;
2806 }
2807
2808 @override
2809 T visitCatchClause(CatchClause node) {
2810 stopwatch.start();
2811 T result = _baseVisitor.visitCatchClause(node);
2812 stopwatch.stop();
2813 return result;
2814 }
2815
2816 @override
2817 T visitClassDeclaration(ClassDeclaration node) {
2818 stopwatch.start();
2819 T result = _baseVisitor.visitClassDeclaration(node);
2820 stopwatch.stop();
2821 return result;
2822 }
2823
2824 @override
2825 T visitClassTypeAlias(ClassTypeAlias node) {
2826 stopwatch.start();
2827 T result = _baseVisitor.visitClassTypeAlias(node);
2828 stopwatch.stop();
2829 return result;
2830 }
2831
2832 @override
2833 T visitComment(Comment node) {
2834 stopwatch.start();
2835 T result = _baseVisitor.visitComment(node);
2836 stopwatch.stop();
2837 return result;
2838 }
2839
2840 @override
2841 T visitCommentReference(CommentReference node) {
2842 stopwatch.start();
2843 T result = _baseVisitor.visitCommentReference(node);
2844 stopwatch.stop();
2845 return result;
2846 }
2847
2848 @override
2849 T visitCompilationUnit(CompilationUnit node) {
2850 stopwatch.start();
2851 T result = _baseVisitor.visitCompilationUnit(node);
2852 stopwatch.stop();
2853 return result;
2854 }
2855
2856 @override
2857 T visitConditionalExpression(ConditionalExpression node) {
2858 stopwatch.start();
2859 T result = _baseVisitor.visitConditionalExpression(node);
2860 stopwatch.stop();
2861 return result;
2862 }
2863
2864 @override
2865 T visitConfiguration(Configuration node) {
2866 stopwatch.start();
2867 T result = _baseVisitor.visitConfiguration(node);
2868 stopwatch.stop();
2869 return result;
2870 }
2871
2872 @override
2873 T visitConstructorDeclaration(ConstructorDeclaration node) {
2874 stopwatch.start();
2875 T result = _baseVisitor.visitConstructorDeclaration(node);
2876 stopwatch.stop();
2877 return result;
2878 }
2879
2880 @override
2881 T visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
2882 stopwatch.start();
2883 T result = _baseVisitor.visitConstructorFieldInitializer(node);
2884 stopwatch.stop();
2885 return result;
2886 }
2887
2888 @override
2889 T visitConstructorName(ConstructorName node) {
2890 stopwatch.start();
2891 T result = _baseVisitor.visitConstructorName(node);
2892 stopwatch.stop();
2893 return result;
2894 }
2895
2896 @override
2897 T visitContinueStatement(ContinueStatement node) {
2898 stopwatch.start();
2899 T result = _baseVisitor.visitContinueStatement(node);
2900 stopwatch.stop();
2901 return result;
2902 }
2903
2904 @override
2905 T visitDeclaredIdentifier(DeclaredIdentifier node) {
2906 stopwatch.start();
2907 T result = _baseVisitor.visitDeclaredIdentifier(node);
2908 stopwatch.stop();
2909 return result;
2910 }
2911
2912 @override
2913 T visitDefaultFormalParameter(DefaultFormalParameter node) {
2914 stopwatch.start();
2915 T result = _baseVisitor.visitDefaultFormalParameter(node);
2916 stopwatch.stop();
2917 return result;
2918 }
2919
2920 @override
2921 T visitDoStatement(DoStatement node) {
2922 stopwatch.start();
2923 T result = _baseVisitor.visitDoStatement(node);
2924 stopwatch.stop();
2925 return result;
2926 }
2927
2928 @override
2929 T visitDottedName(DottedName node) {
2930 stopwatch.start();
2931 T result = _baseVisitor.visitDottedName(node);
2932 stopwatch.stop();
2933 return result;
2934 }
2935
2936 @override
2937 T visitDoubleLiteral(DoubleLiteral node) {
2938 stopwatch.start();
2939 T result = _baseVisitor.visitDoubleLiteral(node);
2940 stopwatch.stop();
2941 return result;
2942 }
2943
2944 @override
2945 T visitEmptyFunctionBody(EmptyFunctionBody node) {
2946 stopwatch.start();
2947 T result = _baseVisitor.visitEmptyFunctionBody(node);
2948 stopwatch.stop();
2949 return result;
2950 }
2951
2952 @override
2953 T visitEmptyStatement(EmptyStatement node) {
2954 stopwatch.start();
2955 T result = _baseVisitor.visitEmptyStatement(node);
2956 stopwatch.stop();
2957 return result;
2958 }
2959
2960 @override
2961 T visitEnumConstantDeclaration(EnumConstantDeclaration node) {
2962 stopwatch.start();
2963 T result = _baseVisitor.visitEnumConstantDeclaration(node);
2964 stopwatch.stop();
2965 return result;
2966 }
2967
2968 @override
2969 T visitEnumDeclaration(EnumDeclaration node) {
2970 stopwatch.start();
2971 T result = _baseVisitor.visitEnumDeclaration(node);
2972 stopwatch.stop();
2973 return result;
2974 }
2975
2976 @override
2977 T visitExportDirective(ExportDirective node) {
2978 stopwatch.start();
2979 T result = _baseVisitor.visitExportDirective(node);
2980 stopwatch.stop();
2981 return result;
2982 }
2983
2984 @override
2985 T visitExpressionFunctionBody(ExpressionFunctionBody node) {
2986 stopwatch.start();
2987 T result = _baseVisitor.visitExpressionFunctionBody(node);
2988 stopwatch.stop();
2989 return result;
2990 }
2991
2992 @override
2993 T visitExpressionStatement(ExpressionStatement node) {
2994 stopwatch.start();
2995 T result = _baseVisitor.visitExpressionStatement(node);
2996 stopwatch.stop();
2997 return result;
2998 }
2999
3000 @override
3001 T visitExtendsClause(ExtendsClause node) {
3002 stopwatch.start();
3003 T result = _baseVisitor.visitExtendsClause(node);
3004 stopwatch.stop();
3005 return result;
3006 }
3007
3008 @override
3009 T visitFieldDeclaration(FieldDeclaration node) {
3010 stopwatch.start();
3011 T result = _baseVisitor.visitFieldDeclaration(node);
3012 stopwatch.stop();
3013 return result;
3014 }
3015
3016 @override
3017 T visitFieldFormalParameter(FieldFormalParameter node) {
3018 stopwatch.start();
3019 T result = _baseVisitor.visitFieldFormalParameter(node);
3020 stopwatch.stop();
3021 return result;
3022 }
3023
3024 @override
3025 T visitForEachStatement(ForEachStatement node) {
3026 stopwatch.start();
3027 T result = _baseVisitor.visitForEachStatement(node);
3028 stopwatch.stop();
3029 return result;
3030 }
3031
3032 @override
3033 T visitFormalParameterList(FormalParameterList node) {
3034 stopwatch.start();
3035 T result = _baseVisitor.visitFormalParameterList(node);
3036 stopwatch.stop();
3037 return result;
3038 }
3039
3040 @override
3041 T visitForStatement(ForStatement node) {
3042 stopwatch.start();
3043 T result = _baseVisitor.visitForStatement(node);
3044 stopwatch.stop();
3045 return result;
3046 }
3047
3048 @override
3049 T visitFunctionDeclaration(FunctionDeclaration node) {
3050 stopwatch.start();
3051 T result = _baseVisitor.visitFunctionDeclaration(node);
3052 stopwatch.stop();
3053 return result;
3054 }
3055
3056 @override
3057 T visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
3058 stopwatch.start();
3059 T result = _baseVisitor.visitFunctionDeclarationStatement(node);
3060 stopwatch.stop();
3061 return result;
3062 }
3063
3064 @override
3065 T visitFunctionExpression(FunctionExpression node) {
3066 stopwatch.start();
3067 T result = _baseVisitor.visitFunctionExpression(node);
3068 stopwatch.stop();
3069 return result;
3070 }
3071
3072 @override
3073 T visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
3074 stopwatch.start();
3075 T result = _baseVisitor.visitFunctionExpressionInvocation(node);
3076 stopwatch.stop();
3077 return result;
3078 }
3079
3080 @override
3081 T visitFunctionTypeAlias(FunctionTypeAlias node) {
3082 stopwatch.start();
3083 T result = _baseVisitor.visitFunctionTypeAlias(node);
3084 stopwatch.stop();
3085 return result;
3086 }
3087
3088 @override
3089 T visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
3090 stopwatch.start();
3091 T result = _baseVisitor.visitFunctionTypedFormalParameter(node);
3092 stopwatch.stop();
3093 return result;
3094 }
3095
3096 @override
3097 T visitHideCombinator(HideCombinator node) {
3098 stopwatch.start();
3099 T result = _baseVisitor.visitHideCombinator(node);
3100 stopwatch.stop();
3101 return result;
3102 }
3103
3104 @override
3105 T visitIfStatement(IfStatement node) {
3106 stopwatch.start();
3107 T result = _baseVisitor.visitIfStatement(node);
3108 stopwatch.stop();
3109 return result;
3110 }
3111
3112 @override
3113 T visitImplementsClause(ImplementsClause node) {
3114 stopwatch.start();
3115 T result = _baseVisitor.visitImplementsClause(node);
3116 stopwatch.stop();
3117 return result;
3118 }
3119
3120 @override
3121 T visitImportDirective(ImportDirective node) {
3122 stopwatch.start();
3123 T result = _baseVisitor.visitImportDirective(node);
3124 stopwatch.stop();
3125 return result;
3126 }
3127
3128 @override
3129 T visitIndexExpression(IndexExpression node) {
3130 stopwatch.start();
3131 T result = _baseVisitor.visitIndexExpression(node);
3132 stopwatch.stop();
3133 return result;
3134 }
3135
3136 @override
3137 T visitInstanceCreationExpression(InstanceCreationExpression node) {
3138 stopwatch.start();
3139 T result = _baseVisitor.visitInstanceCreationExpression(node);
3140 stopwatch.stop();
3141 return result;
3142 }
3143
3144 @override
3145 T visitIntegerLiteral(IntegerLiteral node) {
3146 stopwatch.start();
3147 T result = _baseVisitor.visitIntegerLiteral(node);
3148 stopwatch.stop();
3149 return result;
3150 }
3151
3152 @override
3153 T visitInterpolationExpression(InterpolationExpression node) {
3154 stopwatch.start();
3155 T result = _baseVisitor.visitInterpolationExpression(node);
3156 stopwatch.stop();
3157 return result;
3158 }
3159
3160 @override
3161 T visitInterpolationString(InterpolationString node) {
3162 stopwatch.start();
3163 T result = _baseVisitor.visitInterpolationString(node);
3164 stopwatch.stop();
3165 return result;
3166 }
3167
3168 @override
3169 T visitIsExpression(IsExpression node) {
3170 stopwatch.start();
3171 T result = _baseVisitor.visitIsExpression(node);
3172 stopwatch.stop();
3173 return result;
3174 }
3175
3176 @override
3177 T visitLabel(Label node) {
3178 stopwatch.start();
3179 T result = _baseVisitor.visitLabel(node);
3180 stopwatch.stop();
3181 return result;
3182 }
3183
3184 @override
3185 T visitLabeledStatement(LabeledStatement node) {
3186 stopwatch.start();
3187 T result = _baseVisitor.visitLabeledStatement(node);
3188 stopwatch.stop();
3189 return result;
3190 }
3191
3192 @override
3193 T visitLibraryDirective(LibraryDirective node) {
3194 stopwatch.start();
3195 T result = _baseVisitor.visitLibraryDirective(node);
3196 stopwatch.stop();
3197 return result;
3198 }
3199
3200 @override
3201 T visitLibraryIdentifier(LibraryIdentifier node) {
3202 stopwatch.start();
3203 T result = _baseVisitor.visitLibraryIdentifier(node);
3204 stopwatch.stop();
3205 return result;
3206 }
3207
3208 @override
3209 T visitListLiteral(ListLiteral node) {
3210 stopwatch.start();
3211 T result = _baseVisitor.visitListLiteral(node);
3212 stopwatch.stop();
3213 return result;
3214 }
3215
3216 @override
3217 T visitMapLiteral(MapLiteral node) {
3218 stopwatch.start();
3219 T result = _baseVisitor.visitMapLiteral(node);
3220 stopwatch.stop();
3221 return result;
3222 }
3223
3224 @override
3225 T visitMapLiteralEntry(MapLiteralEntry node) {
3226 stopwatch.start();
3227 T result = _baseVisitor.visitMapLiteralEntry(node);
3228 stopwatch.stop();
3229 return result;
3230 }
3231
3232 @override
3233 T visitMethodDeclaration(MethodDeclaration node) {
3234 stopwatch.start();
3235 T result = _baseVisitor.visitMethodDeclaration(node);
3236 stopwatch.stop();
3237 return result;
3238 }
3239
3240 @override
3241 T visitMethodInvocation(MethodInvocation node) {
3242 stopwatch.start();
3243 T result = _baseVisitor.visitMethodInvocation(node);
3244 stopwatch.stop();
3245 return result;
3246 }
3247
3248 @override
3249 T visitNamedExpression(NamedExpression node) {
3250 stopwatch.start();
3251 T result = _baseVisitor.visitNamedExpression(node);
3252 stopwatch.stop();
3253 return result;
3254 }
3255
3256 @override
3257 T visitNativeClause(NativeClause node) {
3258 stopwatch.start();
3259 T result = _baseVisitor.visitNativeClause(node);
3260 stopwatch.stop();
3261 return result;
3262 }
3263
3264 @override
3265 T visitNativeFunctionBody(NativeFunctionBody node) {
3266 stopwatch.start();
3267 T result = _baseVisitor.visitNativeFunctionBody(node);
3268 stopwatch.stop();
3269 return result;
3270 }
3271
3272 @override
3273 T visitNullLiteral(NullLiteral node) {
3274 stopwatch.start();
3275 T result = _baseVisitor.visitNullLiteral(node);
3276 stopwatch.stop();
3277 return result;
3278 }
3279
3280 @override
3281 T visitParenthesizedExpression(ParenthesizedExpression node) {
3282 stopwatch.start();
3283 T result = _baseVisitor.visitParenthesizedExpression(node);
3284 stopwatch.stop();
3285 return result;
3286 }
3287
3288 @override
3289 T visitPartDirective(PartDirective node) {
3290 stopwatch.start();
3291 T result = _baseVisitor.visitPartDirective(node);
3292 stopwatch.stop();
3293 return result;
3294 }
3295
3296 @override
3297 T visitPartOfDirective(PartOfDirective node) {
3298 stopwatch.start();
3299 T result = _baseVisitor.visitPartOfDirective(node);
3300 stopwatch.stop();
3301 return result;
3302 }
3303
3304 @override
3305 T visitPostfixExpression(PostfixExpression node) {
3306 stopwatch.start();
3307 T result = _baseVisitor.visitPostfixExpression(node);
3308 stopwatch.stop();
3309 return result;
3310 }
3311
3312 @override
3313 T visitPrefixedIdentifier(PrefixedIdentifier node) {
3314 stopwatch.start();
3315 T result = _baseVisitor.visitPrefixedIdentifier(node);
3316 stopwatch.stop();
3317 return result;
3318 }
3319
3320 @override
3321 T visitPrefixExpression(PrefixExpression node) {
3322 stopwatch.start();
3323 T result = _baseVisitor.visitPrefixExpression(node);
3324 stopwatch.stop();
3325 return result;
3326 }
3327
3328 @override
3329 T visitPropertyAccess(PropertyAccess node) {
3330 stopwatch.start();
3331 T result = _baseVisitor.visitPropertyAccess(node);
3332 stopwatch.stop();
3333 return result;
3334 }
3335
3336 @override
3337 T visitRedirectingConstructorInvocation(
3338 RedirectingConstructorInvocation node) {
3339 stopwatch.start();
3340 T result = _baseVisitor.visitRedirectingConstructorInvocation(node);
3341 stopwatch.stop();
3342 return result;
3343 }
3344
3345 @override
3346 T visitRethrowExpression(RethrowExpression node) {
3347 stopwatch.start();
3348 T result = _baseVisitor.visitRethrowExpression(node);
3349 stopwatch.stop();
3350 return result;
3351 }
3352
3353 @override
3354 T visitReturnStatement(ReturnStatement node) {
3355 stopwatch.start();
3356 T result = _baseVisitor.visitReturnStatement(node);
3357 stopwatch.stop();
3358 return result;
3359 }
3360
3361 @override
3362 T visitScriptTag(ScriptTag node) {
3363 stopwatch.start();
3364 T result = _baseVisitor.visitScriptTag(node);
3365 stopwatch.stop();
3366 return result;
3367 }
3368
3369 @override
3370 T visitShowCombinator(ShowCombinator node) {
3371 stopwatch.start();
3372 T result = _baseVisitor.visitShowCombinator(node);
3373 stopwatch.stop();
3374 return result;
3375 }
3376
3377 @override
3378 T visitSimpleFormalParameter(SimpleFormalParameter node) {
3379 stopwatch.start();
3380 T result = _baseVisitor.visitSimpleFormalParameter(node);
3381 stopwatch.stop();
3382 return result;
3383 }
3384
3385 @override
3386 T visitSimpleIdentifier(SimpleIdentifier node) {
3387 stopwatch.start();
3388 T result = _baseVisitor.visitSimpleIdentifier(node);
3389 stopwatch.stop();
3390 return result;
3391 }
3392
3393 @override
3394 T visitSimpleStringLiteral(SimpleStringLiteral node) {
3395 stopwatch.start();
3396 T result = _baseVisitor.visitSimpleStringLiteral(node);
3397 stopwatch.stop();
3398 return result;
3399 }
3400
3401 @override
3402 T visitStringInterpolation(StringInterpolation node) {
3403 stopwatch.start();
3404 T result = _baseVisitor.visitStringInterpolation(node);
3405 stopwatch.stop();
3406 return result;
3407 }
3408
3409 @override
3410 T visitSuperConstructorInvocation(SuperConstructorInvocation node) {
3411 stopwatch.start();
3412 T result = _baseVisitor.visitSuperConstructorInvocation(node);
3413 stopwatch.stop();
3414 return result;
3415 }
3416
3417 @override
3418 T visitSuperExpression(SuperExpression node) {
3419 stopwatch.start();
3420 T result = _baseVisitor.visitSuperExpression(node);
3421 stopwatch.stop();
3422 return result;
3423 }
3424
3425 @override
3426 T visitSwitchCase(SwitchCase node) {
3427 stopwatch.start();
3428 T result = _baseVisitor.visitSwitchCase(node);
3429 stopwatch.stop();
3430 return result;
3431 }
3432
3433 @override
3434 T visitSwitchDefault(SwitchDefault node) {
3435 stopwatch.start();
3436 T result = _baseVisitor.visitSwitchDefault(node);
3437 stopwatch.stop();
3438 return result;
3439 }
3440
3441 @override
3442 T visitSwitchStatement(SwitchStatement node) {
3443 stopwatch.start();
3444 T result = _baseVisitor.visitSwitchStatement(node);
3445 stopwatch.stop();
3446 return result;
3447 }
3448
3449 @override
3450 T visitSymbolLiteral(SymbolLiteral node) {
3451 stopwatch.start();
3452 T result = _baseVisitor.visitSymbolLiteral(node);
3453 stopwatch.stop();
3454 return result;
3455 }
3456
3457 @override
3458 T visitThisExpression(ThisExpression node) {
3459 stopwatch.start();
3460 T result = _baseVisitor.visitThisExpression(node);
3461 stopwatch.stop();
3462 return result;
3463 }
3464
3465 @override
3466 T visitThrowExpression(ThrowExpression node) {
3467 stopwatch.start();
3468 T result = _baseVisitor.visitThrowExpression(node);
3469 stopwatch.stop();
3470 return result;
3471 }
3472
3473 @override
3474 T visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
3475 stopwatch.start();
3476 T result = _baseVisitor.visitTopLevelVariableDeclaration(node);
3477 stopwatch.stop();
3478 return result;
3479 }
3480
3481 @override
3482 T visitTryStatement(TryStatement node) {
3483 stopwatch.start();
3484 T result = _baseVisitor.visitTryStatement(node);
3485 stopwatch.stop();
3486 return result;
3487 }
3488
3489 @override
3490 T visitTypeArgumentList(TypeArgumentList node) {
3491 stopwatch.start();
3492 T result = _baseVisitor.visitTypeArgumentList(node);
3493 stopwatch.stop();
3494 return result;
3495 }
3496
3497 @override
3498 T visitTypeName(TypeName node) {
3499 stopwatch.start();
3500 T result = _baseVisitor.visitTypeName(node);
3501 stopwatch.stop();
3502 return result;
3503 }
3504
3505 @override
3506 T visitTypeParameter(TypeParameter node) {
3507 stopwatch.start();
3508 T result = _baseVisitor.visitTypeParameter(node);
3509 stopwatch.stop();
3510 return result;
3511 }
3512
3513 @override
3514 T visitTypeParameterList(TypeParameterList node) {
3515 stopwatch.start();
3516 T result = _baseVisitor.visitTypeParameterList(node);
3517 stopwatch.stop();
3518 return result;
3519 }
3520
3521 @override
3522 T visitVariableDeclaration(VariableDeclaration node) {
3523 stopwatch.start();
3524 T result = _baseVisitor.visitVariableDeclaration(node);
3525 stopwatch.stop();
3526 return result;
3527 }
3528
3529 @override
3530 T visitVariableDeclarationList(VariableDeclarationList node) {
3531 stopwatch.start();
3532 T result = _baseVisitor.visitVariableDeclarationList(node);
3533 stopwatch.stop();
3534 return result;
3535 }
3536
3537 @override
3538 T visitVariableDeclarationStatement(VariableDeclarationStatement node) {
3539 stopwatch.start();
3540 T result = _baseVisitor.visitVariableDeclarationStatement(node);
3541 stopwatch.stop();
3542 return result;
3543 }
3544
3545 @override
3546 T visitWhileStatement(WhileStatement node) {
3547 stopwatch.start();
3548 T result = _baseVisitor.visitWhileStatement(node);
3549 stopwatch.stop();
3550 return result;
3551 }
3552
3553 @override
3554 T visitWithClause(WithClause node) {
3555 stopwatch.start();
3556 T result = _baseVisitor.visitWithClause(node);
3557 stopwatch.stop();
3558 return result;
3559 }
3560
3561 @override
3562 T visitYieldStatement(YieldStatement node) {
3563 stopwatch.start();
3564 T result = _baseVisitor.visitYieldStatement(node);
3565 stopwatch.stop();
3566 return result;
3567 }
3568 }
3569
3570 /**
3571 * An AST visitor that will recursively visit all of the nodes in an AST
3572 * structure (like instances of the class [RecursiveAstVisitor]). In addition,
3573 * every node will also be visited by using a single unified [visitNode] method.
3574 *
3575 * Subclasses that override a visit method must either invoke the overridden
3576 * visit method or explicitly invoke the more general [visitNode] method.
3577 * Failure to do so will cause the children of the visited node to not be
3578 * visited.
3579 *
3580 * Clients may extend this class.
3581 */
3582 class UnifyingAstVisitor<R> implements AstVisitor<R> {
3583 @override
3584 R visitAdjacentStrings(AdjacentStrings node) => visitNode(node);
3585
3586 @override
3587 R visitAnnotation(Annotation node) => visitNode(node);
3588
3589 @override
3590 R visitArgumentList(ArgumentList node) => visitNode(node);
3591
3592 @override
3593 R visitAsExpression(AsExpression node) => visitNode(node);
3594
3595 @override
3596 R visitAssertStatement(AssertStatement node) => visitNode(node);
3597
3598 @override
3599 R visitAssignmentExpression(AssignmentExpression node) => visitNode(node);
3600
3601 @override
3602 R visitAwaitExpression(AwaitExpression node) => visitNode(node);
3603
3604 @override
3605 R visitBinaryExpression(BinaryExpression node) => visitNode(node);
3606
3607 @override
3608 R visitBlock(Block node) => visitNode(node);
3609
3610 @override
3611 R visitBlockFunctionBody(BlockFunctionBody node) => visitNode(node);
3612
3613 @override
3614 R visitBooleanLiteral(BooleanLiteral node) => visitNode(node);
3615
3616 @override
3617 R visitBreakStatement(BreakStatement node) => visitNode(node);
3618
3619 @override
3620 R visitCascadeExpression(CascadeExpression node) => visitNode(node);
3621
3622 @override
3623 R visitCatchClause(CatchClause node) => visitNode(node);
3624
3625 @override
3626 R visitClassDeclaration(ClassDeclaration node) => visitNode(node);
3627
3628 @override
3629 R visitClassTypeAlias(ClassTypeAlias node) => visitNode(node);
3630
3631 @override
3632 R visitComment(Comment node) => visitNode(node);
3633
3634 @override
3635 R visitCommentReference(CommentReference node) => visitNode(node);
3636
3637 @override
3638 R visitCompilationUnit(CompilationUnit node) => visitNode(node);
3639
3640 @override
3641 R visitConditionalExpression(ConditionalExpression node) => visitNode(node);
3642
3643 @override
3644 R visitConfiguration(Configuration node) => visitNode(node);
3645
3646 @override
3647 R visitConstructorDeclaration(ConstructorDeclaration node) => visitNode(node);
3648
3649 @override
3650 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) =>
3651 visitNode(node);
3652
3653 @override
3654 R visitConstructorName(ConstructorName node) => visitNode(node);
3655
3656 @override
3657 R visitContinueStatement(ContinueStatement node) => visitNode(node);
3658
3659 @override
3660 R visitDeclaredIdentifier(DeclaredIdentifier node) => visitNode(node);
3661
3662 @override
3663 R visitDefaultFormalParameter(DefaultFormalParameter node) => visitNode(node);
3664
3665 @override
3666 R visitDoStatement(DoStatement node) => visitNode(node);
3667
3668 @override
3669 R visitDottedName(DottedName node) => visitNode(node);
3670
3671 @override
3672 R visitDoubleLiteral(DoubleLiteral node) => visitNode(node);
3673
3674 @override
3675 R visitEmptyFunctionBody(EmptyFunctionBody node) => visitNode(node);
3676
3677 @override
3678 R visitEmptyStatement(EmptyStatement node) => visitNode(node);
3679
3680 @override
3681 R visitEnumConstantDeclaration(EnumConstantDeclaration node) =>
3682 visitNode(node);
3683
3684 @override
3685 R visitEnumDeclaration(EnumDeclaration node) => visitNode(node);
3686
3687 @override
3688 R visitExportDirective(ExportDirective node) => visitNode(node);
3689
3690 @override
3691 R visitExpressionFunctionBody(ExpressionFunctionBody node) => visitNode(node);
3692
3693 @override
3694 R visitExpressionStatement(ExpressionStatement node) => visitNode(node);
3695
3696 @override
3697 R visitExtendsClause(ExtendsClause node) => visitNode(node);
3698
3699 @override
3700 R visitFieldDeclaration(FieldDeclaration node) => visitNode(node);
3701
3702 @override
3703 R visitFieldFormalParameter(FieldFormalParameter node) => visitNode(node);
3704
3705 @override
3706 R visitForEachStatement(ForEachStatement node) => visitNode(node);
3707
3708 @override
3709 R visitFormalParameterList(FormalParameterList node) => visitNode(node);
3710
3711 @override
3712 R visitForStatement(ForStatement node) => visitNode(node);
3713
3714 @override
3715 R visitFunctionDeclaration(FunctionDeclaration node) => visitNode(node);
3716
3717 @override
3718 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) =>
3719 visitNode(node);
3720
3721 @override
3722 R visitFunctionExpression(FunctionExpression node) => visitNode(node);
3723
3724 @override
3725 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) =>
3726 visitNode(node);
3727
3728 @override
3729 R visitFunctionTypeAlias(FunctionTypeAlias node) => visitNode(node);
3730
3731 @override
3732 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) =>
3733 visitNode(node);
3734
3735 @override
3736 R visitHideCombinator(HideCombinator node) => visitNode(node);
3737
3738 @override
3739 R visitIfStatement(IfStatement node) => visitNode(node);
3740
3741 @override
3742 R visitImplementsClause(ImplementsClause node) => visitNode(node);
3743
3744 @override
3745 R visitImportDirective(ImportDirective node) => visitNode(node);
3746
3747 @override
3748 R visitIndexExpression(IndexExpression node) => visitNode(node);
3749
3750 @override
3751 R visitInstanceCreationExpression(InstanceCreationExpression node) =>
3752 visitNode(node);
3753
3754 @override
3755 R visitIntegerLiteral(IntegerLiteral node) => visitNode(node);
3756
3757 @override
3758 R visitInterpolationExpression(InterpolationExpression node) =>
3759 visitNode(node);
3760
3761 @override
3762 R visitInterpolationString(InterpolationString node) => visitNode(node);
3763
3764 @override
3765 R visitIsExpression(IsExpression node) => visitNode(node);
3766
3767 @override
3768 R visitLabel(Label node) => visitNode(node);
3769
3770 @override
3771 R visitLabeledStatement(LabeledStatement node) => visitNode(node);
3772
3773 @override
3774 R visitLibraryDirective(LibraryDirective node) => visitNode(node);
3775
3776 @override
3777 R visitLibraryIdentifier(LibraryIdentifier node) => visitNode(node);
3778
3779 @override
3780 R visitListLiteral(ListLiteral node) => visitNode(node);
3781
3782 @override
3783 R visitMapLiteral(MapLiteral node) => visitNode(node);
3784
3785 @override
3786 R visitMapLiteralEntry(MapLiteralEntry node) => visitNode(node);
3787
3788 @override
3789 R visitMethodDeclaration(MethodDeclaration node) => visitNode(node);
3790
3791 @override
3792 R visitMethodInvocation(MethodInvocation node) => visitNode(node);
3793
3794 @override
3795 R visitNamedExpression(NamedExpression node) => visitNode(node);
3796
3797 @override
3798 R visitNativeClause(NativeClause node) => visitNode(node);
3799
3800 @override
3801 R visitNativeFunctionBody(NativeFunctionBody node) => visitNode(node);
3802
3803 R visitNode(AstNode node) {
3804 node.visitChildren(this);
3805 return null;
3806 }
3807
3808 @override
3809 R visitNullLiteral(NullLiteral node) => visitNode(node);
3810
3811 @override
3812 R visitParenthesizedExpression(ParenthesizedExpression node) =>
3813 visitNode(node);
3814
3815 @override
3816 R visitPartDirective(PartDirective node) => visitNode(node);
3817
3818 @override
3819 R visitPartOfDirective(PartOfDirective node) => visitNode(node);
3820
3821 @override
3822 R visitPostfixExpression(PostfixExpression node) => visitNode(node);
3823
3824 @override
3825 R visitPrefixedIdentifier(PrefixedIdentifier node) => visitNode(node);
3826
3827 @override
3828 R visitPrefixExpression(PrefixExpression node) => visitNode(node);
3829
3830 @override
3831 R visitPropertyAccess(PropertyAccess node) => visitNode(node);
3832
3833 @override
3834 R visitRedirectingConstructorInvocation(
3835 RedirectingConstructorInvocation node) =>
3836 visitNode(node);
3837
3838 @override
3839 R visitRethrowExpression(RethrowExpression node) => visitNode(node);
3840
3841 @override
3842 R visitReturnStatement(ReturnStatement node) => visitNode(node);
3843
3844 @override
3845 R visitScriptTag(ScriptTag scriptTag) => visitNode(scriptTag);
3846
3847 @override
3848 R visitShowCombinator(ShowCombinator node) => visitNode(node);
3849
3850 @override
3851 R visitSimpleFormalParameter(SimpleFormalParameter node) => visitNode(node);
3852
3853 @override
3854 R visitSimpleIdentifier(SimpleIdentifier node) => visitNode(node);
3855
3856 @override
3857 R visitSimpleStringLiteral(SimpleStringLiteral node) => visitNode(node);
3858
3859 @override
3860 R visitStringInterpolation(StringInterpolation node) => visitNode(node);
3861
3862 @override
3863 R visitSuperConstructorInvocation(SuperConstructorInvocation node) =>
3864 visitNode(node);
3865
3866 @override
3867 R visitSuperExpression(SuperExpression node) => visitNode(node);
3868
3869 @override
3870 R visitSwitchCase(SwitchCase node) => visitNode(node);
3871
3872 @override
3873 R visitSwitchDefault(SwitchDefault node) => visitNode(node);
3874
3875 @override
3876 R visitSwitchStatement(SwitchStatement node) => visitNode(node);
3877
3878 @override
3879 R visitSymbolLiteral(SymbolLiteral node) => visitNode(node);
3880
3881 @override
3882 R visitThisExpression(ThisExpression node) => visitNode(node);
3883
3884 @override
3885 R visitThrowExpression(ThrowExpression node) => visitNode(node);
3886
3887 @override
3888 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) =>
3889 visitNode(node);
3890
3891 @override
3892 R visitTryStatement(TryStatement node) => visitNode(node);
3893
3894 @override
3895 R visitTypeArgumentList(TypeArgumentList node) => visitNode(node);
3896
3897 @override
3898 R visitTypeName(TypeName node) => visitNode(node);
3899
3900 @override
3901 R visitTypeParameter(TypeParameter node) => visitNode(node);
3902
3903 @override
3904 R visitTypeParameterList(TypeParameterList node) => visitNode(node);
3905
3906 @override
3907 R visitVariableDeclaration(VariableDeclaration node) => visitNode(node);
3908
3909 @override
3910 R visitVariableDeclarationList(VariableDeclarationList node) =>
3911 visitNode(node);
3912
3913 @override
3914 R visitVariableDeclarationStatement(VariableDeclarationStatement node) =>
3915 visitNode(node);
3916
3917 @override
3918 R visitWhileStatement(WhileStatement node) => visitNode(node);
3919
3920 @override
3921 R visitWithClause(WithClause node) => visitNode(node);
3922
3923 @override
3924 R visitYieldStatement(YieldStatement node) => visitNode(node);
3925 }
3926
3927 /**
3928 * A helper class used to implement the correct order of visits for a
3929 * [BreadthFirstVisitor].
3930 */
3931 class _BreadthFirstChildVisitor extends UnifyingAstVisitor<Object> {
3932 /**
3933 * The [BreadthFirstVisitor] being helped by this visitor.
3934 */
3935 final BreadthFirstVisitor outerVisitor;
3936
3937 /**
3938 * Initialize a newly created visitor to help the [outerVisitor].
3939 */
3940 _BreadthFirstChildVisitor(this.outerVisitor);
3941
3942 @override
3943 Object visitNode(AstNode node) {
3944 outerVisitor._queue.add(node);
3945 return null;
3946 }
3947 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/dart/ast/token.dart ('k') | packages/analyzer/lib/dart/constant/value.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698