ada.editor/src/org/netbeans/modules/ada/editor/ast/nodes/visitors/DefaultVisitor.java
author Andrea Lucarelli <raster@netbeans.org>
Sun, 22 Aug 2010 23:37:11 +0200
branchrelease68
changeset 16367 d2820c029d3a
parent 15779 367c7fdb5d23
permissions -rw-r--r--
Add JVM compiler support.
     1 /*
     2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3  *
     4  * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
     5  *
     6  * The contents of this file are subject to the terms of either the GNU
     7  * General Public License Version 2 only ("GPL") or the Common
     8  * Development and Distribution License("CDDL") (collectively, the
     9  * "License"). You may not use this file except in compliance with the
    10  * License. You can obtain a copy of the License at
    11  * http://www.netbeans.org/cddl-gplv2.html
    12  * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    13  * specific language governing permissions and limitations under the
    14  * License.  When distributing the software, include this License Header
    15  * Notice in each file and include the License file at
    16  * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    17  * particular file as subject to the "Classpath" exception as provided
    18  * by Sun in the GPL Version 2 section of the License file that
    19  * accompanied this code. If applicable, add the following below the
    20  * License Header, with the fields enclosed by brackets [] replaced by
    21  * your own identifying information:
    22  * "Portions Copyrighted [year] [name of copyright owner]"
    23  *
    24  * If you wish your version of this file to be governed by only the CDDL
    25  * or only the GPL Version 2, indicate your decision by adding
    26  * "[Contributor] elects to include this software in this distribution
    27  * under the [CDDL or GPL Version 2] license." If you do not indicate a
    28  * single choice of license, a recipient has the option to distribute
    29  * your version of this file under either the CDDL, the GPL Version 2 or
    30  * to extend the choice of license to its licensees as provided above.
    31  * However, if you add GPL Version 2 code and therefore, elected the GPL
    32  * Version 2 license, then the option applies only if the new code is
    33  * made subject to such option by the copyright holder.
    34  *
    35  * Contributor(s):
    36  *
    37  * Portions Copyrighted 2008 Sun Microsystems, Inc.
    38  */
    39 package org.netbeans.modules.ada.editor.ast.nodes.visitors;
    40 
    41 import org.netbeans.modules.ada.editor.ast.ASTError;
    42 import org.netbeans.modules.ada.editor.ast.ASTNode;
    43 import org.netbeans.modules.ada.editor.ast.nodes.AbortStatement;
    44 import org.netbeans.modules.ada.editor.ast.nodes.ArrayAccess;
    45 import org.netbeans.modules.ada.editor.ast.nodes.Assignment;
    46 import org.netbeans.modules.ada.editor.ast.nodes.Block;
    47 import org.netbeans.modules.ada.editor.ast.nodes.BlockStatement;
    48 import org.netbeans.modules.ada.editor.ast.nodes.CaseStatement;
    49 import org.netbeans.modules.ada.editor.ast.nodes.CaseWhen;
    50 import org.netbeans.modules.ada.editor.ast.nodes.CodeStatement;
    51 import org.netbeans.modules.ada.editor.ast.nodes.Comment;
    52 import org.netbeans.modules.ada.editor.ast.nodes.DelayStatement;
    53 import org.netbeans.modules.ada.editor.ast.nodes.ExitStatement;
    54 import org.netbeans.modules.ada.editor.ast.nodes.FieldsDeclaration;
    55 import org.netbeans.modules.ada.editor.ast.nodes.FormalParameter;
    56 import org.netbeans.modules.ada.editor.ast.nodes.GotoStatement;
    57 import org.netbeans.modules.ada.editor.ast.nodes.Identifier;
    58 import org.netbeans.modules.ada.editor.ast.nodes.IfStatement;
    59 import org.netbeans.modules.ada.editor.ast.nodes.InfixExpression;
    60 import org.netbeans.modules.ada.editor.ast.nodes.LoopStatement;
    61 import org.netbeans.modules.ada.editor.ast.nodes.MethodDeclaration;
    62 import org.netbeans.modules.ada.editor.ast.nodes.NullStatement;
    63 import org.netbeans.modules.ada.editor.ast.nodes.PackageBody;
    64 import org.netbeans.modules.ada.editor.ast.nodes.PackageInstanceCreation;
    65 import org.netbeans.modules.ada.editor.ast.nodes.PackageRenames;
    66 import org.netbeans.modules.ada.editor.ast.nodes.PackageSpecification;
    67 import org.netbeans.modules.ada.editor.ast.nodes.PackageName;
    68 import org.netbeans.modules.ada.editor.ast.nodes.Program;
    69 import org.netbeans.modules.ada.editor.ast.nodes.QualifiedExpression;
    70 import org.netbeans.modules.ada.editor.ast.nodes.RaiseStatement;
    71 import org.netbeans.modules.ada.editor.ast.nodes.Range;
    72 import org.netbeans.modules.ada.editor.ast.nodes.Reference;
    73 import org.netbeans.modules.ada.editor.ast.nodes.ReturnStatement;
    74 import org.netbeans.modules.ada.editor.ast.nodes.Scalar;
    75 import org.netbeans.modules.ada.editor.ast.nodes.SingleFieldDeclaration;
    76 import org.netbeans.modules.ada.editor.ast.nodes.SubprogramBody;
    77 import org.netbeans.modules.ada.editor.ast.nodes.SubprogramSpecification;
    78 import org.netbeans.modules.ada.editor.ast.nodes.SubtypeDeclaration;
    79 import org.netbeans.modules.ada.editor.ast.nodes.TaskName;
    80 import org.netbeans.modules.ada.editor.ast.nodes.TypeDeclaration;
    81 import org.netbeans.modules.ada.editor.ast.nodes.TypeName;
    82 import org.netbeans.modules.ada.editor.ast.nodes.UnaryOperation;
    83 import org.netbeans.modules.ada.editor.ast.nodes.Use;
    84 import org.netbeans.modules.ada.editor.ast.nodes.Variable;
    85 import org.netbeans.modules.ada.editor.ast.nodes.With;
    86 
    87 /**
    88  * Based on org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor
    89  * 
    90  * @author Andrea Lucarelli
    91  */
    92 public class DefaultVisitor implements Visitor {
    93 
    94     public void scan(ASTNode node) {
    95         if (node != null) {
    96             node.accept(this);
    97         }
    98     }
    99 
   100     public void scan(Iterable<? extends ASTNode> nodes) {
   101         if (nodes != null) {
   102             for (ASTNode n : nodes) {
   103                 scan(n);
   104             }
   105         }
   106     }
   107 
   108     public void visit(ASTError node) {
   109     }
   110 
   111     public void visit(ASTNode node) {
   112     }
   113 
   114     public void visit(AbortStatement node) {
   115         scan(node.getTasks());
   116     }
   117 
   118     public void visit(ArrayAccess node) {
   119         scan(node.getName());
   120         scan(node.getIndex());
   121     }
   122 
   123     public void visit(Assignment node) {
   124         scan(node.getLeftHandSide());
   125         scan(node.getRightHandSide());
   126     }
   127 
   128     public void visit(Block node) {
   129         scan(node.getStatements());
   130     }
   131 
   132     public void visit(BlockStatement node) {
   133         scan(node.getLabel());
   134         scan(node.getDeclarations());
   135         scan(node.getBody());
   136     }
   137 
   138     public void visit(CaseStatement node) {
   139         scan(node.getExpression());
   140         scan(node.getBody());
   141     }
   142 
   143     public void visit(CaseWhen node) {
   144         scan(node.getValue());
   145         scan(node.getActions());
   146     }
   147 
   148     public void visit(CodeStatement node) {
   149         scan(node.getExpression());
   150     }
   151 
   152     public void visit(Comment comment) {
   153     }
   154 
   155     public void visit(ExitStatement node) {
   156         scan(node.getWhenCondition());
   157     }
   158 
   159     public void visit(DelayStatement node) {
   160         scan(node.getExpression());
   161     }
   162 
   163     public void visit(FieldsDeclaration node) {
   164         scan(node.getFields());
   165     }
   166 
   167     public void visit(FormalParameter node) {
   168         scan(node.getParameterName());
   169         scan(node.getParameterType());
   170         scan(node.getDefaultValue());
   171     }
   172 
   173     public void visit(GotoStatement node) {
   174     }
   175 
   176     public void visit(Identifier node) {
   177     }
   178 
   179     public void visit(IfStatement node) {
   180         scan(node.getCondition());
   181         scan(node.getTrueStatement());
   182         scan(node.getFalseStatement());
   183     }
   184 
   185     public void visit(InfixExpression node) {
   186         scan(node.getLeft());
   187         scan(node.getRight());
   188     }
   189 
   190     public void visit(LoopStatement node) {
   191         scan(node.getCondition());
   192         scan(node.getBody());
   193     }
   194 
   195     public void visit(MethodDeclaration node) {
   196         if (node.isSpefication()) {
   197             scan(node.getSubprogramSpecification());
   198         } else {
   199             scan(node.getSubprogramBody());
   200         }
   201     }
   202 
   203     public void visit(NullStatement node) {
   204     }
   205 
   206     public void visit(PackageBody node) {
   207         scan(node.getName());
   208         scan(node.getBody());
   209     }
   210 
   211     public void visit(PackageInstanceCreation node) {
   212         scan(node.getPackageName());
   213         scan(node.ctorParams());
   214     }
   215 
   216     public void visit(PackageName node) {
   217         scan(node.getPackageName());
   218     }
   219 
   220     public void visit(PackageSpecification node) {
   221         scan(node.getName());
   222         scan(node.getBody());
   223     }
   224 
   225     public void visit(PackageRenames node) {
   226         scan(node.getName());
   227         scan(node.getPackageRenames());
   228     }
   229 
   230     public void visit(Program node) {
   231         scan(node.getStatements());
   232     }
   233 
   234     public void visit(QualifiedExpression node) {
   235         scan(node.getSubtypeMark());
   236         scan(node.getExpression());
   237     }
   238 
   239     public void visit(Range node) {
   240         scan(node.getLeft());
   241         scan(node.getRight());
   242     }
   243 
   244     public void visit(Reference node) {
   245         scan(node.getExpression());
   246     }
   247 
   248     public void visit(SubprogramBody node) {
   249         scan(node.getSubprogramSpecification().getSubprogramName());
   250         scan(node.getSubprogramSpecification().getFormalParameters());
   251         scan(node.getDeclarations());
   252         scan(node.getBody());
   253     }
   254 
   255     public void visit(SubprogramSpecification node) {
   256         scan(node.getSubprogramName());
   257         scan(node.getFormalParameters());
   258     }
   259 
   260     public void visit(SubtypeDeclaration node) {
   261         scan(node.getSubTypeName());
   262         scan(node.getParentType());
   263     }
   264 
   265     public void visit(TaskName node) {
   266         scan(node.getTaskName());
   267     }
   268 
   269     public void visit(TypeName node) {
   270         scan(node.getTypeName());
   271     }
   272 
   273     public void visit(TypeDeclaration node) {
   274         scan(node.getTypeName());
   275     }
   276 
   277     public void visit(RaiseStatement node) {
   278     }
   279 
   280     public void visit(ReturnStatement node) {
   281         scan(node.getExpression());
   282     }
   283 
   284     public void visit(Scalar scalar) {
   285     }
   286 
   287     public void visit(SingleFieldDeclaration node) {
   288         scan(node.getName());
   289         scan(node.getValue());
   290     }
   291 
   292     public void visit(Use node) {
   293         scan(node.getPackages());
   294     }
   295 
   296     public void visit(Variable node) {
   297         scan(node.getName());
   298         scan(node.getVariableType());
   299     }
   300 
   301     public void visit(With node) {
   302         scan(node.getPackages());
   303     }
   304 
   305     public void visit(UnaryOperation node) {
   306         scan(node.getExpression());
   307     }
   308 }