| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** |
| 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 */ |
| 5 library analyzer.dart.ast.visitor; | 24 library analyzer.dart.ast.visitor; |
| 6 | 25 |
| 7 import 'dart:collection'; | 26 import 'dart:collection'; |
| 8 | 27 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 28 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 | 29 |
| 11 /** | 30 /** |
| 12 * An AST visitor that will recursively visit all of the nodes in an AST | 31 * An AST visitor that will recursively visit all of the nodes in an AST |
| 13 * structure, similar to [GeneralizingAstVisitor]. This visitor uses a | 32 * structure, similar to [GeneralizingAstVisitor]. This visitor uses a |
| 14 * breadth-first ordering rather than the depth-first ordering of | 33 * breadth-first ordering rather than the depth-first ordering of |
| (...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 * Initialize a newly created visitor to help the [outerVisitor]. | 1894 * Initialize a newly created visitor to help the [outerVisitor]. |
| 1876 */ | 1895 */ |
| 1877 _BreadthFirstChildVisitor(this.outerVisitor); | 1896 _BreadthFirstChildVisitor(this.outerVisitor); |
| 1878 | 1897 |
| 1879 @override | 1898 @override |
| 1880 Object visitNode(AstNode node) { | 1899 Object visitNode(AstNode node) { |
| 1881 outerVisitor._queue.add(node); | 1900 outerVisitor._queue.add(node); |
| 1882 return null; | 1901 return null; |
| 1883 } | 1902 } |
| 1884 } | 1903 } |
| OLD | NEW |