Coverage Report - com.sun.tools.javafx.tree.JFXExpression
 
Classes in this File Line Coverage Branch Coverage Complexity
JFXExpression
38%
10/26
25%
2/8
0
 
 1  
 /*
 2  
  * Copyright 1999-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.JavaFXExpressionTree;
 29  
 import com.sun.javafx.api.tree.JavaFXTreeVisitor;
 30  
 import com.sun.tools.javac.tree.JCTree.JCExpression;
 31  
 import com.sun.tools.javac.tree.JCTree.Visitor;
 32  
 
 33  
 import com.sun.source.tree.TreeVisitor;
 34  
 import com.sun.tools.javac.tree.JCTree;
 35  
 import com.sun.tools.javac.tree.Pretty;
 36  
 import java.io.IOException;
 37  
 import java.io.StringWriter;
 38  
 import java.util.Map;
 39  
 
 40  
 /**
 41  
  * Statements.
 42  
  * Should be a subclass of JFXTree (but can't for now)
 43  
  * @see JFXTree
 44  
  */
 45  10
 public abstract class JFXExpression extends JCExpression implements JavaFXExpressionTree {
 46  
     
 47  
     /** Initialize tree with given tag.
 48  
      */
 49  12365
     protected JFXExpression() {
 50  12365
     }
 51  
     
 52  
     public abstract void accept(JavafxVisitor v);
 53  
     
 54  
     @Override
 55  
     public void accept(Visitor v) {
 56  34220
         if (v instanceof JavafxVisitor) {
 57  34220
             this.accept((JavafxVisitor)v);
 58  0
         } else if (v instanceof Pretty) {
 59  
             try {
 60  0
                 Pretty pretty = (Pretty) v;
 61  0
                 pretty.print('[');
 62  0
                 pretty.print(getClass().getName());
 63  
                 //pretty.print(' ');
 64  
                 //v.visitTree(this); visit children?
 65  0
                 pretty.print(']');
 66  0
             } catch (java.io.IOException ex) { throw new RuntimeException(ex); }
 67  
         } else {
 68  0
             assert false : "should be seen by a non-JavaFX visitor: " + this.getClass();
 69  0
             v.visitTree(this);
 70  
         }
 71  34217
     }
 72  
 
 73  
     @Override
 74  
     public final Kind getKind() {
 75  12
         return Kind.OTHER;
 76  
     }
 77  
 
 78  
     @Override
 79  
     public final <R, D> R accept(TreeVisitor<R, D> v, D d) {
 80  16
         if (v instanceof JavaFXTreeVisitor) {
 81  16
             return (R)this.accept((JavaFXTreeVisitor)v, d);
 82  
         } else {
 83  0
             throw new UnsupportedOperationException(getClass().getSimpleName() + " support not implemented");
 84  
         }
 85  
     }
 86  
 
 87  
     /** Convert a tree to a pretty-printed string. */
 88  
     @Override
 89  
     public String toString() {
 90  0
         StringWriter s = new StringWriter();
 91  
         try {
 92  0
             new JavafxPretty(s, false).printExpr(this);
 93  
         }
 94  0
         catch (IOException e) {
 95  
             // should never happen, because StringWriter is defined
 96  
             // never to throw any IOExceptions
 97  0
             throw new AssertionError(e);
 98  0
         }
 99  0
         return s.toString();
 100  
     }
 101  
     
 102  
     @Override
 103  
     public int getStartPosition() {
 104  45554
         return JavafxTreeInfo.getStartPos(this);
 105  
     }
 106  
     
 107  
     @Override
 108  
     public int getEndPosition(Map<JCTree, Integer> endPosTable) {
 109  0
         return JavafxTreeInfo.getEndPos(this, endPosTable);
 110  
     }
 111  
 
 112  
 }