001 /** 002 * 003 * Copyright 2005 Jeremy Rayner 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.codehaus.groovy.antlr.treewalker; 019 020 import org.codehaus.groovy.antlr.GroovySourceAST; 021 022 /** 023 * A simple preorder traversal over the supplied antlr AST. 024 * 025 * @author <a href="mailto:groovy@ross-rayner.com">Jeremy Rayner</a> 026 * @version $Revision: 1.3 $ 027 */ 028 public class PreOrderTraversal extends TraversalHelper { 029 030 /** 031 * A simple preorder traversal over the supplied antlr AST. 032 * @param visitor the Visitor to call for each node visited 033 */ 034 public PreOrderTraversal(Visitor visitor) { 035 super(visitor); 036 } 037 038 public void accept(GroovySourceAST currentNode) { 039 openingVisit(currentNode); 040 acceptChildren(currentNode); 041 closingVisit(currentNode); 042 } 043 }