| 1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
| 2 | * |
| 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 | |
| 7 | package org.mozilla.javascript.ast; |
| 8 | |
| 9 | /** |
| 10 | * Simple visitor interface for traversing the AST. The nodes are visited in |
| 11 | * an arbitrary order. The visitor must cast nodes to the appropriate |
| 12 | * type based on their token-type. |
| 13 | */ |
| 14 | public interface NodeVisitor { |
| 15 | |
| 16 | /** |
| 17 | * Visits an AST node. |
| 18 | * @param node the AST node. Will never visit an {@link AstRoot} node, |
| 19 | * since the {@code AstRoot} is where the visiting begins. |
| 20 | * @return {@code true} if the children should be visited. |
| 21 | * If {@code false}, the subtree rooted at this node is skipped. |
| 22 | * The {@code node} argument should <em>never</em> be {@code null} -- |
| 23 | * the individual {@link AstNode} classes should skip any children |
| 24 | * that are not present in the source when they invoke this method. |
| 25 | */ |
| 26 | boolean visit(AstNode node); |
| 27 | } |