1 | /**
|
2 | * @license
|
3 | * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
4 | * This code may only be used under the BSD style license found at
|
5 | * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
|
6 | * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
|
7 | * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
|
8 | * Google as part of the polymer project is also subject to an additional IP
|
9 | * rights grant found at http://polymer.github.io/PATENTS.txt
|
10 | */
|
11 | /**
|
12 | * Class that implements a visitor pattern for ASTs produced by the Parser.
|
13 | * Extend the NodeVisitor class to implement useful tree traversal operations
|
14 | * such as stringification.
|
15 | */
|
16 | declare class NodeVisitor<Node extends {
|
17 | type: any;
|
18 | }, ReturnValue> {
|
19 | private path_;
|
20 | /**
|
21 | * Create a NodeVisitor instance.
|
22 | */
|
23 | constructor();
|
24 | /**
|
25 | * A list of nodes that corresponds to the current path through an AST being
|
26 | * visited, leading to where the currently visited node will be found.
|
27 | */
|
28 | readonly path: Node[];
|
29 | /**
|
30 | * Visit a node. The visited node will be added to the `path` before it is
|
31 | * visited, and will be removed after it is visited. Nodes are "visited" by
|
32 | * calling a method on the NodeVisitor instance that matches the node's type,
|
33 | * if one is available on the NodeVisitor instance.
|
34 | * @param node The node to be visited.
|
35 | * @return The return value of the method visiting the node, if any.
|
36 | */
|
37 | visit(node: Node): ReturnValue | undefined;
|
38 | }
|
39 | export { NodeVisitor };
|