Coverage Report - com.sun.tools.javafx.tree.JavafxTreeScanner
 
Classes in this File Line Coverage Branch Coverage Complexity
JavafxTreeScanner
87%
102/117
68%
15/22
0
 
 1  
 /*
 2  
  * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
 3  
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  
  *
 5  
  * This code is free software; you can redistribute it and/or modify it
 6  
  * under the terms of the GNU General Public License version 2 only, as
 7  
  * published by the Free Software Foundation.  Sun designates this
 8  
  * particular file as subject to the "Classpath" exception as provided
 9  
  * by Sun in the LICENSE file that accompanied this code.
 10  
  *
 11  
  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  
  * version 2 for more details (a copy is included in the LICENSE file that
 15  
  * accompanied this code).
 16  
  *
 17  
  * You should have received a copy of the GNU General Public License version
 18  
  * 2 along with this work; if not, write to the Free Software Foundation,
 19  
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  
  *
 21  
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 22  
  * CA 95054 USA or visit www.sun.com if you need additional information or
 23  
  * have any questions.
 24  
  */
 25  
 
 26  
 package com.sun.tools.javafx.tree;
 27  
 
 28  
 import com.sun.javafx.api.tree.ForExpressionInClauseTree;
 29  
 import com.sun.source.tree.Tree;
 30  
 import com.sun.tools.javac.tree.JCTree;
 31  
 import com.sun.tools.javac.tree.JCTree.JCBlock;
 32  
 import com.sun.tools.javac.tree.JCTree.JCExpression;
 33  
 import com.sun.tools.javac.tree.TreeScanner;
 34  
 import com.sun.tools.javac.util.List;
 35  
 
 36  
 /**
 37  
  * An abstract tree walker (visitor) for ASTs ({@code JCTree}s).
 38  
  * Each {@code visitXxx} method calls {@code scan} to visit its child
 39  
  * trees.  The {@code scan} method calls the {@code JCTree}-subclass-specific
 40  
  * {@code accept} method.  A sub-class can override a specific {@code visitXxx}
 41  
  * method, or the {@code scan method}.
 42  
  * 
 43  
  * @author Robert Field
 44  
  * @author Per Bothner
 45  
  */
 46  12
 public class JavafxTreeScanner extends TreeScanner implements JavafxVisitor {
 47  
 
 48  4918
     public JavafxTreeScanner() {
 49  4918
     }
 50  
 
 51  
     /** Visitor method: Scan a single node.
 52  
    */
 53  
     @Override
 54  
     public void scan(JCTree tree) {
 55  169897
         if(tree!=null) tree.accept(this);
 56  169897
     }
 57  
 
 58  
     /** Visitor method: scan a list of nodes.
 59  
      */
 60  
     @Override
 61  
     public void scan(List<? extends JCTree> trees) {
 62  34124
         if (trees != null)
 63  68611
         for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
 64  34487
             scan(l.head);
 65  34124
     }
 66  
 
 67  
     /** Visitor method: scan a list of nodes.
 68  
      */
 69  
     public void scan(java.util.List<? extends Tree> trees) {
 70  0
         if (trees != null)
 71  0
             for (Tree t : trees)
 72  0
                 scan((JCTree)t);
 73  0
     }
 74  
 
 75  
 
 76  
 /* ***************************************************************************
 77  
  * Visitor methods
 78  
  ****************************************************************************/
 79  
     // Begin JavaFX trees
 80  
     
 81  
     @Override
 82  
     public void visitClassDeclaration(JFXClassDeclaration that) {
 83  1634
         scan(that.mods);
 84  1634
         for (Tree member : that.getMembers()) {
 85  4908
             scan((JCTree)member);
 86  
         }
 87  1634
     }
 88  
     
 89  
     @Override
 90  
     public void visitFunctionValue(JFXFunctionValue tree) {
 91  4570
         for (JFXVar param : tree.getParams()) {
 92  3986
             scan(param);
 93  
         }
 94  4570
         scan(tree.getBodyExpression());
 95  4570
     }
 96  
 
 97  
     @Override
 98  
     public void visitFunctionDefinition(JFXFunctionDefinition tree) {
 99  2810
         scan(tree.getModifiers());
 100  2810
         scan(tree.getJFXReturnType());
 101  2810
         visitFunctionValue(tree.operation);
 102  2810
     }
 103  
 
 104  
     @Override
 105  
     public void visitInitDefinition(JFXInitDefinition that) {
 106  150
         scan((JCBlock)that.getBody());
 107  150
     }
 108  
 
 109  
     public void visitPostInitDefinition(JFXPostInitDefinition that) {
 110  50
         scan((JCBlock)that.getBody());
 111  50
     }
 112  
 
 113  
     @Override
 114  
     public void visitSequenceEmpty(JFXSequenceEmpty that) {
 115  216
     }
 116  
     
 117  
     @Override
 118  
     public void visitSequenceRange(JFXSequenceRange that) {
 119  839
         scan( that.getLower() );
 120  839
         scan( that.getUpper() );
 121  839
         scan( that.getStepOrNull() );
 122  839
     }
 123  
     
 124  
     @Override
 125  
     public void visitSequenceExplicit(JFXSequenceExplicit that) {
 126  1588
         scan( that.getItems() );
 127  1588
     }
 128  
 
 129  
     @Override
 130  
     public void visitSequenceIndexed(JFXSequenceIndexed that) {
 131  1979
         scan(that.getSequence());
 132  1979
         scan(that.getIndex());
 133  1979
     }
 134  
     
 135  
     public void visitSequenceSlice(JFXSequenceSlice that) {
 136  265
         scan(that.getSequence());
 137  265
         scan(that.getFirstIndex());
 138  265
         scan(that.getLastIndex());
 139  265
     }
 140  
     
 141  
     @Override
 142  
     public void visitSequenceInsert(JFXSequenceInsert that) {
 143  930
         scan(that.getSequence());
 144  930
         scan(that.getElement());
 145  930
     }
 146  
     
 147  
     @Override
 148  
     public void visitSequenceDelete(JFXSequenceDelete that) {
 149  615
         scan(that.getSequence());
 150  615
         scan(that.getElement());
 151  615
     }
 152  
 
 153  
     @Override
 154  
     public void visitStringExpression(JFXStringExpression that) {
 155  2959
         List<JCExpression> parts = that.getParts();
 156  2959
         parts = parts.tail;
 157  7623
         while (parts.nonEmpty()) {
 158  4664
             parts = parts.tail;
 159  4664
             scan(parts.head);
 160  4664
             parts = parts.tail;
 161  4664
             parts = parts.tail;
 162  
         }
 163  2959
     }
 164  
     
 165  
     @Override
 166  
     public void visitInstanciate(JFXInstanciate tree) {
 167  2560
        scan(tree.getIdentifier());
 168  2560
        scan(tree.getArgs());
 169  2560
        scan(tree.getParts());
 170  2560
        scan(tree.getLocalvars());
 171  2560
        scan(tree.getClassBody());
 172  2560
     }
 173  
     
 174  
     @Override
 175  
     public void visitSetAttributeToObjectBeingInitialized(JFXSetAttributeToObjectBeingInitialized that) {
 176  0
     }
 177  
     
 178  
     @Override
 179  
     public void visitObjectLiteralPart(JFXObjectLiteralPart that) {
 180  2203
         scan(that.getExpression());
 181  2203
     }  
 182  
     
 183  
     @Override
 184  
     public void visitTypeAny(JFXTypeAny that) {
 185  0
     }
 186  
     
 187  
     @Override
 188  
     public void visitTypeClass(JFXTypeClass that) {
 189  7297
     }
 190  
     
 191  
     @Override
 192  
     public void visitTypeFunctional(JFXTypeFunctional that) {
 193  102
         for (JCTree param : (List<JFXType>)that.getParameters()) {
 194  90
             scan(param);
 195  
         }
 196  102
         scan((JFXType)that.getReturnType());
 197  102
     }
 198  
     
 199  
     @Override
 200  
     public void visitTypeUnknown(JFXTypeUnknown that) {
 201  5610
     }
 202  
     
 203  
     @Override
 204  
     public void visitVar(JFXVar tree) {
 205  9376
         scan(tree.getJFXType());
 206  9376
         scan(tree.mods);
 207  9376
         scan(tree.init);
 208  9376
         scan(tree.getOnReplace());
 209  9376
     }
 210  
     
 211  
     @Override
 212  
     public void visitOverrideAttribute(JFXOverrideAttribute tree) {
 213  51
         scan(tree.getId());
 214  51
         scan(tree.getInitializer());
 215  51
         scan(tree.getOnReplace());
 216  51
     }
 217  
 
 218  
     @Override
 219  
     public void visitOnReplace(JFXOnReplace tree) {
 220  506
         scan(tree.getFirstIndex());
 221  506
         scan(tree.getOldValue());  
 222  506
         scan(tree.getBody());
 223  506
         scan(tree.getLastIndex());
 224  506
         scan(tree.getNewElements());
 225  506
     }
 226  
     
 227  
     
 228  
     @Override
 229  
     public void visitForExpression(JFXForExpression that) {
 230  789
         for (ForExpressionInClauseTree cl : that.getInClauses()) {
 231  821
             JFXForExpressionInClause clause = (JFXForExpressionInClause)cl;
 232  821
             scan(clause);
 233  821
         }
 234  789
         scan(that.getBodyExpression());
 235  789
     }
 236  
     
 237  
     @Override
 238  
     public void visitForExpressionInClause(JFXForExpressionInClause that) {
 239  821
         scan(that.getVar());
 240  821
         scan(that.getSequenceExpression());
 241  821
         scan(that.getWhereExpression());
 242  821
     }
 243  
     
 244  
     @Override
 245  
     public void visitBindExpression(JFXBindExpression that) {
 246  4
         scan(that.expr);
 247  4
     }
 248  
     
 249  
     @Override
 250  
     public void visitBlockExpression(JFXBlockExpression that) {
 251  5396
         scan(that.stats);
 252  5396
         scan(that.value);
 253  5396
     }
 254  
     
 255  
     @Override
 256  
     public void visitIndexof(JFXIndexof that) {
 257  111
     }
 258  
 
 259  
     @Override
 260  
     public void visitTree(JCTree that) {
 261  0
         assert false : "Should not be here!!!";
 262  0
     }
 263  
 
 264  
     public void visitTimeLiteral(JFXTimeLiteral tree) {
 265  89
     }
 266  
 
 267  
     public void visitInterpolate(JFXInterpolate that) {
 268  0
         scan(that.var);
 269  0
         scan(that.values);
 270  0
     }
 271  
 
 272  
     public void visitInterpolateValue(JFXInterpolateValue that) {
 273  20
         scan(that.attribute);
 274  20
         scan(that.value);
 275  20
     }
 276  
     
 277  
     public void visitKeyFrameLiteral(JFXKeyFrameLiteral that) {
 278  0
         scan(that.start);
 279  0
         scan(that.exprs);
 280  0
         scan(that.trigger);
 281  0
     }
 282  
 }