Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JFXStatement |
|
| 0.0;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.JavaFXStatementTree; | |
29 | import com.sun.javafx.api.tree.JavaFXTreeVisitor; | |
30 | import com.sun.source.tree.Tree.Kind; | |
31 | import com.sun.tools.javac.tree.JCTree.JCStatement; | |
32 | import com.sun.tools.javac.tree.JCTree.Visitor; | |
33 | ||
34 | import com.sun.source.tree.TreeVisitor; | |
35 | import com.sun.tools.javac.tree.JCTree; | |
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 | 12 | public abstract class JFXStatement extends JCStatement implements JavaFXStatementTree { |
46 | ||
47 | /** Initialize tree with given tag. | |
48 | */ | |
49 | 3666 | protected JFXStatement() { |
50 | 3666 | } |
51 | ||
52 | public abstract void accept(JavafxVisitor v); | |
53 | ||
54 | @Override | |
55 | public void accept(Visitor v) { | |
56 | 5920 | if (v instanceof JavafxVisitor) { |
57 | 5920 | this.accept((JavafxVisitor)v); |
58 | } else { | |
59 | 0 | assert false : "FX tree should not reach here"; |
60 | 0 | v.visitTree(this); |
61 | } | |
62 | 5920 | } |
63 | ||
64 | @Override | |
65 | public final Kind getKind() { | |
66 | 7 | return Kind.OTHER; |
67 | } | |
68 | ||
69 | @Override | |
70 | public final <R, D> R accept(TreeVisitor<R, D> v, D d) { | |
71 | 7 | if (v instanceof JavaFXTreeVisitor) { |
72 | 7 | return (R)this.accept((JavaFXTreeVisitor)v, d); |
73 | } else { | |
74 | 0 | throw new UnsupportedOperationException(getClass().getSimpleName() + " support not implemented"); |
75 | } | |
76 | } | |
77 | ||
78 | /** Convert a tree to a pretty-printed string. */ | |
79 | @Override | |
80 | public String toString() { | |
81 | 0 | StringWriter s = new StringWriter(); |
82 | try { | |
83 | 0 | new JavafxPretty(s, false).printExpr(this); |
84 | } | |
85 | 0 | catch (IOException e) { |
86 | // should never happen, because StringWriter is defined | |
87 | // never to throw any IOExceptions | |
88 | 0 | throw new AssertionError(e); |
89 | 0 | } |
90 | 0 | return s.toString(); |
91 | } | |
92 | ||
93 | @Override | |
94 | public int getStartPosition() { | |
95 | 84608 | return JavafxTreeInfo.getStartPos(this); |
96 | } | |
97 | ||
98 | @Override | |
99 | public int getEndPosition(Map<JCTree, Integer> endPosTable) { | |
100 | 0 | return JavafxTreeInfo.getEndPos(this, endPosTable); |
101 | } | |
102 | } |