1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
package com.sun.tools.javafx.tree; |
27 | |
|
28 | |
import com.sun.javafx.api.tree.ClassDeclarationTree; |
29 | |
import com.sun.javafx.api.tree.JavaFXTree.JavaFXKind; |
30 | |
import com.sun.javafx.api.tree.JavaFXTreeVisitor; |
31 | |
import com.sun.tools.javafx.code.JavafxFlags; |
32 | |
import com.sun.source.tree.ExpressionTree; |
33 | |
import com.sun.source.tree.Tree; |
34 | |
import com.sun.tools.javac.tree.JCTree; |
35 | |
|
36 | |
import com.sun.tools.javac.util.List; |
37 | |
import com.sun.tools.javac.util.ListBuffer; |
38 | |
import com.sun.tools.javac.util.Name; |
39 | |
|
40 | |
import com.sun.tools.javac.code.Symbol.ClassSymbol; |
41 | |
import com.sun.tools.javac.code.Scope; |
42 | |
import com.sun.tools.javac.tree.Pretty; |
43 | |
import java.io.IOException; |
44 | |
import java.io.StringWriter; |
45 | |
import java.util.logging.Level; |
46 | |
import java.util.logging.Logger; |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | 2 | public class JFXClassDeclaration extends JFXStatement implements ClassDeclarationTree { |
52 | |
public JCModifiers mods; |
53 | |
private final Name name; |
54 | 1078 | private List<JCExpression> extending = null; |
55 | 1078 | private List<JCExpression> implementing = null; |
56 | |
private List<JCTree> defs; |
57 | |
private final List<JCExpression> supertypes; |
58 | |
|
59 | |
public ClassSymbol sym; |
60 | |
|
61 | |
public JFXFunctionDefinition runMethod; |
62 | |
public Scope runBodyScope; |
63 | 1078 | public boolean isModuleClass = false; |
64 | |
|
65 | 1078 | public boolean hasBeenTranslated = false; |
66 | |
|
67 | |
protected JFXClassDeclaration(JCModifiers mods, |
68 | |
Name name, |
69 | |
List<JCExpression> supertypes, |
70 | |
List<JCTree> declarations, |
71 | 1078 | ClassSymbol sym) { |
72 | 1078 | this.mods = mods; |
73 | 1078 | this.name = name; |
74 | 1078 | this.defs = declarations; |
75 | 1078 | this.sym = sym; |
76 | |
|
77 | 1078 | this.supertypes = supertypes; |
78 | 1078 | } |
79 | |
|
80 | |
public java.util.List<ExpressionTree> getSupertypeList() { |
81 | 0 | return JFXTree.convertList(ExpressionTree.class, supertypes); |
82 | |
} |
83 | |
|
84 | |
public JCModifiers getModifiers() { |
85 | 1928 | return mods; |
86 | |
} |
87 | |
|
88 | |
public Name getName() { |
89 | 9510 | return name; |
90 | |
} |
91 | |
|
92 | |
public List<JCExpression> getSupertypes() { |
93 | 5756 | return supertypes; |
94 | |
} |
95 | |
|
96 | |
public List<JCTree> getMembers() { |
97 | 6983 | return defs; |
98 | |
} |
99 | |
|
100 | |
public void setMembers(List<JCTree> members) { |
101 | 35 | defs = members; |
102 | 35 | } |
103 | |
|
104 | |
public List<JCExpression> getImplementing() { |
105 | 1314 | return implementing; |
106 | |
} |
107 | |
|
108 | |
public List<JCExpression> getExtending() { |
109 | 1224 | return extending; |
110 | |
} |
111 | |
|
112 | |
public void setDifferentiatedExtendingImplementing(List<JCExpression> extending, List<JCExpression> implementing) { |
113 | 702 | this.extending = extending; |
114 | 702 | this.implementing = implementing; |
115 | 702 | } |
116 | |
|
117 | |
public List<JCTypeParameter> getEmptyTypeParameters() { |
118 | 5391 | return List.<JCTypeParameter>nil(); |
119 | |
} |
120 | |
|
121 | |
public void appendToMembers(ListBuffer<JCTree> members) { |
122 | 60 | defs = defs.appendList(members.toList()); |
123 | 60 | } |
124 | |
|
125 | |
public boolean generateClassOnly () { |
126 | 9204 | return (sym.flags_field & JavafxFlags.COMPOUND_CLASS) == 0; |
127 | |
} |
128 | |
|
129 | |
@Override |
130 | |
public int getTag() { |
131 | 74945 | return JavafxTag.CLASS_DEF; |
132 | |
} |
133 | |
|
134 | |
public void accept(JavafxVisitor v) { |
135 | 4199 | v.visitClassDeclaration(this); |
136 | 4199 | } |
137 | |
|
138 | |
@Override |
139 | |
public void accept(Visitor v) { |
140 | 4199 | if (v instanceof JavafxVisitor) { |
141 | 4199 | this.accept((JavafxVisitor)v); |
142 | 0 | } else if (v instanceof Pretty) { |
143 | |
try { |
144 | 0 | StringWriter out = new StringWriter(); |
145 | 0 | new JavafxPretty(out, true).visitClassDeclaration(this); |
146 | 0 | ((Pretty) v).print(out.toString()); |
147 | 0 | } catch (IOException ex) { |
148 | 0 | Logger.getLogger(JFXClassDeclaration.class.getName()).log(Level.SEVERE, null, ex); |
149 | 0 | } |
150 | |
} else { |
151 | 0 | v.visitTree(this); |
152 | |
} |
153 | 4199 | } |
154 | |
|
155 | |
public JavaFXKind getJavaFXKind() { |
156 | 0 | return JavaFXKind.CLASS_DECLARATION; |
157 | |
} |
158 | |
|
159 | |
public <R, D> R accept(JavaFXTreeVisitor<R, D> visitor, D data) { |
160 | 4 | return visitor.visitClassDeclaration(this, data); |
161 | |
} |
162 | |
|
163 | |
public javax.lang.model.element.Name getSimpleName() { |
164 | 0 | return (javax.lang.model.element.Name)name; |
165 | |
} |
166 | |
|
167 | |
public java.util.List<ExpressionTree> getImplements() { |
168 | 2 | return JFXTree.convertList(ExpressionTree.class, implementing); |
169 | |
} |
170 | |
|
171 | |
public java.util.List<Tree> getClassMembers() { |
172 | 4 | return JFXTree.convertList(Tree.class, defs); |
173 | |
} |
174 | |
|
175 | |
public java.util.List<ExpressionTree> getExtends() { |
176 | 2 | return JFXTree.convertList(ExpressionTree.class, extending); |
177 | |
} |
178 | |
} |