author | jlahoda |
Tue, 12 Nov 2019 06:32:13 +0000 | |
changeset 59021 | cfc7bb9a5a92 |
parent 58713 | ad69fd32778e |
child 59285 | 7799a51dbe30 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
55306 | 2 |
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.tree; |
|
27 |
||
28 |
import com.sun.source.tree.*; |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
29 |
import com.sun.source.tree.Tree.Kind; |
10 | 30 |
import com.sun.tools.javac.tree.JCTree.*; |
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
31 |
import com.sun.tools.javac.util.DefinedBy; |
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
32 |
import com.sun.tools.javac.util.DefinedBy.Api; |
10 | 33 |
import com.sun.tools.javac.util.List; |
34 |
import com.sun.tools.javac.util.ListBuffer; |
|
35 |
||
36 |
/** |
|
37 |
* Creates a copy of a tree, using a given TreeMaker. |
|
38 |
* Names, literal values, etc are shared with the original. |
|
39 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
40 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
41 |
* If you write code that depends on this, you do so at your own risk. |
10 | 42 |
* This code and its internal interfaces are subject to change or |
43 |
* deletion without notice.</b> |
|
44 |
*/ |
|
45 |
public class TreeCopier<P> implements TreeVisitor<JCTree,P> { |
|
46 |
private TreeMaker M; |
|
47 |
||
48 |
/** Creates a new instance of TreeCopier */ |
|
49 |
public TreeCopier(TreeMaker M) { |
|
50 |
this.M = M; |
|
51 |
} |
|
52 |
||
53 |
public <T extends JCTree> T copy(T tree) { |
|
54 |
return copy(tree, null); |
|
55 |
} |
|
56 |
||
57 |
@SuppressWarnings("unchecked") |
|
58 |
public <T extends JCTree> T copy(T tree, P p) { |
|
59 |
if (tree == null) |
|
60 |
return null; |
|
61 |
return (T) (tree.accept(this, p)); |
|
62 |
} |
|
63 |
||
64 |
public <T extends JCTree> List<T> copy(List<T> trees) { |
|
65 |
return copy(trees, null); |
|
66 |
} |
|
67 |
||
68 |
public <T extends JCTree> List<T> copy(List<T> trees, P p) { |
|
69 |
if (trees == null) |
|
70 |
return null; |
|
22163 | 71 |
ListBuffer<T> lb = new ListBuffer<>(); |
10 | 72 |
for (T tree: trees) |
73 |
lb.append(copy(tree, p)); |
|
74 |
return lb.toList(); |
|
75 |
} |
|
76 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
77 |
@DefinedBy(Api.COMPILER_TREE) |
15385 | 78 |
public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) { |
79 |
JCAnnotatedType t = (JCAnnotatedType) node; |
|
80 |
List<JCAnnotation> annotations = copy(t.annotations, p); |
|
81 |
JCExpression underlyingType = copy(t.underlyingType, p); |
|
82 |
return M.at(t.pos).AnnotatedType(annotations, underlyingType); |
|
83 |
} |
|
84 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
85 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 86 |
public JCTree visitAnnotation(AnnotationTree node, P p) { |
87 |
JCAnnotation t = (JCAnnotation) node; |
|
88 |
JCTree annotationType = copy(t.annotationType, p); |
|
89 |
List<JCExpression> args = copy(t.args, p); |
|
15385 | 90 |
if (t.getKind() == Tree.Kind.TYPE_ANNOTATION) { |
91 |
JCAnnotation newTA = M.at(t.pos).TypeAnnotation(annotationType, args); |
|
92 |
newTA.attribute = t.attribute; |
|
93 |
return newTA; |
|
94 |
} else { |
|
95 |
JCAnnotation newT = M.at(t.pos).Annotation(annotationType, args); |
|
96 |
newT.attribute = t.attribute; |
|
97 |
return newT; |
|
98 |
} |
|
10 | 99 |
} |
100 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
101 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 102 |
public JCTree visitAssert(AssertTree node, P p) { |
103 |
JCAssert t = (JCAssert) node; |
|
104 |
JCExpression cond = copy(t.cond, p); |
|
105 |
JCExpression detail = copy(t.detail, p); |
|
106 |
return M.at(t.pos).Assert(cond, detail); |
|
107 |
} |
|
108 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
109 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 110 |
public JCTree visitAssignment(AssignmentTree node, P p) { |
111 |
JCAssign t = (JCAssign) node; |
|
112 |
JCExpression lhs = copy(t.lhs, p); |
|
113 |
JCExpression rhs = copy(t.rhs, p); |
|
114 |
return M.at(t.pos).Assign(lhs, rhs); |
|
115 |
} |
|
116 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
117 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 118 |
public JCTree visitCompoundAssignment(CompoundAssignmentTree node, P p) { |
119 |
JCAssignOp t = (JCAssignOp) node; |
|
120 |
JCTree lhs = copy(t.lhs, p); |
|
121 |
JCTree rhs = copy(t.rhs, p); |
|
122 |
return M.at(t.pos).Assignop(t.getTag(), lhs, rhs); |
|
123 |
} |
|
124 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
125 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 126 |
public JCTree visitBinary(BinaryTree node, P p) { |
127 |
JCBinary t = (JCBinary) node; |
|
128 |
JCExpression lhs = copy(t.lhs, p); |
|
129 |
JCExpression rhs = copy(t.rhs, p); |
|
130 |
return M.at(t.pos).Binary(t.getTag(), lhs, rhs); |
|
131 |
} |
|
132 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
133 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 134 |
public JCTree visitBlock(BlockTree node, P p) { |
135 |
JCBlock t = (JCBlock) node; |
|
136 |
List<JCStatement> stats = copy(t.stats, p); |
|
137 |
return M.at(t.pos).Block(t.flags, stats); |
|
138 |
} |
|
139 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
140 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 141 |
public JCTree visitBreak(BreakTree node, P p) { |
142 |
JCBreak t = (JCBreak) node; |
|
55306 | 143 |
return M.at(t.pos).Break(t.label); |
144 |
} |
|
145 |
||
146 |
@DefinedBy(Api.COMPILER_TREE) |
|
147 |
public JCTree visitYield(YieldTree node, P p) { |
|
148 |
JCYield t = (JCYield) node; |
|
51563
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
149 |
JCExpression value = copy(t.value, p); |
55306 | 150 |
return M.at(t.pos).Yield(value); |
10 | 151 |
} |
152 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
153 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 154 |
public JCTree visitCase(CaseTree node, P p) { |
155 |
JCCase t = (JCCase) node; |
|
51563
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
156 |
List<JCExpression> pats = copy(t.pats, p); |
10 | 157 |
List<JCStatement> stats = copy(t.stats, p); |
51563
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
158 |
JCTree body = copy(t.body, p); |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
159 |
return M.at(t.pos).Case(t.caseKind, pats, stats, body); |
10 | 160 |
} |
161 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
162 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 163 |
public JCTree visitCatch(CatchTree node, P p) { |
164 |
JCCatch t = (JCCatch) node; |
|
165 |
JCVariableDecl param = copy(t.param, p); |
|
166 |
JCBlock body = copy(t.body, p); |
|
167 |
return M.at(t.pos).Catch(param, body); |
|
168 |
} |
|
169 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
170 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 171 |
public JCTree visitClass(ClassTree node, P p) { |
172 |
JCClassDecl t = (JCClassDecl) node; |
|
173 |
JCModifiers mods = copy(t.mods, p); |
|
174 |
List<JCTypeParameter> typarams = copy(t.typarams, p); |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8031
diff
changeset
|
175 |
JCExpression extending = copy(t.extending, p); |
10 | 176 |
List<JCExpression> implementing = copy(t.implementing, p); |
177 |
List<JCTree> defs = copy(t.defs, p); |
|
178 |
return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs); |
|
179 |
} |
|
180 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
181 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 182 |
public JCTree visitConditionalExpression(ConditionalExpressionTree node, P p) { |
183 |
JCConditional t = (JCConditional) node; |
|
184 |
JCExpression cond = copy(t.cond, p); |
|
185 |
JCExpression truepart = copy(t.truepart, p); |
|
186 |
JCExpression falsepart = copy(t.falsepart, p); |
|
187 |
return M.at(t.pos).Conditional(cond, truepart, falsepart); |
|
188 |
} |
|
189 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
190 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 191 |
public JCTree visitContinue(ContinueTree node, P p) { |
192 |
JCContinue t = (JCContinue) node; |
|
193 |
return M.at(t.pos).Continue(t.label); |
|
194 |
} |
|
195 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
196 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 197 |
public JCTree visitDoWhileLoop(DoWhileLoopTree node, P p) { |
198 |
JCDoWhileLoop t = (JCDoWhileLoop) node; |
|
199 |
JCStatement body = copy(t.body, p); |
|
200 |
JCExpression cond = copy(t.cond, p); |
|
201 |
return M.at(t.pos).DoLoop(body, cond); |
|
202 |
} |
|
203 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
204 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 205 |
public JCTree visitErroneous(ErroneousTree node, P p) { |
206 |
JCErroneous t = (JCErroneous) node; |
|
207 |
List<? extends JCTree> errs = copy(t.errs, p); |
|
208 |
return M.at(t.pos).Erroneous(errs); |
|
209 |
} |
|
210 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
211 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 212 |
public JCTree visitExpressionStatement(ExpressionStatementTree node, P p) { |
213 |
JCExpressionStatement t = (JCExpressionStatement) node; |
|
214 |
JCExpression expr = copy(t.expr, p); |
|
215 |
return M.at(t.pos).Exec(expr); |
|
216 |
} |
|
217 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
218 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 219 |
public JCTree visitEnhancedForLoop(EnhancedForLoopTree node, P p) { |
220 |
JCEnhancedForLoop t = (JCEnhancedForLoop) node; |
|
221 |
JCVariableDecl var = copy(t.var, p); |
|
222 |
JCExpression expr = copy(t.expr, p); |
|
223 |
JCStatement body = copy(t.body, p); |
|
224 |
return M.at(t.pos).ForeachLoop(var, expr, body); |
|
225 |
} |
|
226 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
227 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 228 |
public JCTree visitForLoop(ForLoopTree node, P p) { |
229 |
JCForLoop t = (JCForLoop) node; |
|
230 |
List<JCStatement> init = copy(t.init, p); |
|
231 |
JCExpression cond = copy(t.cond, p); |
|
232 |
List<JCExpressionStatement> step = copy(t.step, p); |
|
233 |
JCStatement body = copy(t.body, p); |
|
234 |
return M.at(t.pos).ForLoop(init, cond, step, body); |
|
235 |
} |
|
236 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
237 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 238 |
public JCTree visitIdentifier(IdentifierTree node, P p) { |
239 |
JCIdent t = (JCIdent) node; |
|
240 |
return M.at(t.pos).Ident(t.name); |
|
241 |
} |
|
242 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
243 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 244 |
public JCTree visitIf(IfTree node, P p) { |
245 |
JCIf t = (JCIf) node; |
|
246 |
JCExpression cond = copy(t.cond, p); |
|
247 |
JCStatement thenpart = copy(t.thenpart, p); |
|
248 |
JCStatement elsepart = copy(t.elsepart, p); |
|
249 |
return M.at(t.pos).If(cond, thenpart, elsepart); |
|
250 |
} |
|
251 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
252 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 253 |
public JCTree visitImport(ImportTree node, P p) { |
254 |
JCImport t = (JCImport) node; |
|
255 |
JCTree qualid = copy(t.qualid, p); |
|
256 |
return M.at(t.pos).Import(qualid, t.staticImport); |
|
257 |
} |
|
258 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
259 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 260 |
public JCTree visitArrayAccess(ArrayAccessTree node, P p) { |
261 |
JCArrayAccess t = (JCArrayAccess) node; |
|
262 |
JCExpression indexed = copy(t.indexed, p); |
|
263 |
JCExpression index = copy(t.index, p); |
|
264 |
return M.at(t.pos).Indexed(indexed, index); |
|
265 |
} |
|
266 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
267 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 268 |
public JCTree visitLabeledStatement(LabeledStatementTree node, P p) { |
269 |
JCLabeledStatement t = (JCLabeledStatement) node; |
|
270 |
JCStatement body = copy(t.body, p); |
|
20243
21740b37e9aa
8025110: TreeCopier does not correctly copy LabeledStatementTree
jjg
parents:
17807
diff
changeset
|
271 |
return M.at(t.pos).Labelled(t.label, body); |
10 | 272 |
} |
273 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
274 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 275 |
public JCTree visitLiteral(LiteralTree node, P p) { |
276 |
JCLiteral t = (JCLiteral) node; |
|
277 |
return M.at(t.pos).Literal(t.typetag, t.value); |
|
278 |
} |
|
279 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
280 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 281 |
public JCTree visitMethod(MethodTree node, P p) { |
282 |
JCMethodDecl t = (JCMethodDecl) node; |
|
283 |
JCModifiers mods = copy(t.mods, p); |
|
284 |
JCExpression restype = copy(t.restype, p); |
|
285 |
List<JCTypeParameter> typarams = copy(t.typarams, p); |
|
286 |
List<JCVariableDecl> params = copy(t.params, p); |
|
15385 | 287 |
JCVariableDecl recvparam = copy(t.recvparam, p); |
10 | 288 |
List<JCExpression> thrown = copy(t.thrown, p); |
289 |
JCBlock body = copy(t.body, p); |
|
290 |
JCExpression defaultValue = copy(t.defaultValue, p); |
|
15385 | 291 |
return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue); |
10 | 292 |
} |
293 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
294 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 295 |
public JCTree visitMethodInvocation(MethodInvocationTree node, P p) { |
296 |
JCMethodInvocation t = (JCMethodInvocation) node; |
|
297 |
List<JCExpression> typeargs = copy(t.typeargs, p); |
|
298 |
JCExpression meth = copy(t.meth, p); |
|
299 |
List<JCExpression> args = copy(t.args, p); |
|
300 |
return M.at(t.pos).Apply(typeargs, meth, args); |
|
301 |
} |
|
302 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
303 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 304 |
public JCTree visitModifiers(ModifiersTree node, P p) { |
305 |
JCModifiers t = (JCModifiers) node; |
|
306 |
List<JCAnnotation> annotations = copy(t.annotations, p); |
|
307 |
return M.at(t.pos).Modifiers(t.flags, annotations); |
|
308 |
} |
|
309 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
310 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 311 |
public JCTree visitNewArray(NewArrayTree node, P p) { |
312 |
JCNewArray t = (JCNewArray) node; |
|
313 |
JCExpression elemtype = copy(t.elemtype, p); |
|
314 |
List<JCExpression> dims = copy(t.dims, p); |
|
315 |
List<JCExpression> elems = copy(t.elems, p); |
|
316 |
return M.at(t.pos).NewArray(elemtype, dims, elems); |
|
317 |
} |
|
318 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
319 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 320 |
public JCTree visitNewClass(NewClassTree node, P p) { |
321 |
JCNewClass t = (JCNewClass) node; |
|
322 |
JCExpression encl = copy(t.encl, p); |
|
323 |
List<JCExpression> typeargs = copy(t.typeargs, p); |
|
324 |
JCExpression clazz = copy(t.clazz, p); |
|
325 |
List<JCExpression> args = copy(t.args, p); |
|
326 |
JCClassDecl def = copy(t.def, p); |
|
327 |
return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def); |
|
328 |
} |
|
329 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
330 |
@DefinedBy(Api.COMPILER_TREE) |
11141 | 331 |
public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) { |
332 |
JCLambda t = (JCLambda) node; |
|
333 |
List<JCVariableDecl> params = copy(t.params, p); |
|
334 |
JCTree body = copy(t.body, p); |
|
335 |
return M.at(t.pos).Lambda(params, body); |
|
336 |
} |
|
337 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
338 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 339 |
public JCTree visitParenthesized(ParenthesizedTree node, P p) { |
340 |
JCParens t = (JCParens) node; |
|
341 |
JCExpression expr = copy(t.expr, p); |
|
342 |
return M.at(t.pos).Parens(expr); |
|
343 |
} |
|
344 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
345 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 346 |
public JCTree visitReturn(ReturnTree node, P p) { |
347 |
JCReturn t = (JCReturn) node; |
|
348 |
JCExpression expr = copy(t.expr, p); |
|
349 |
return M.at(t.pos).Return(expr); |
|
350 |
} |
|
351 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
352 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 353 |
public JCTree visitMemberSelect(MemberSelectTree node, P p) { |
354 |
JCFieldAccess t = (JCFieldAccess) node; |
|
355 |
JCExpression selected = copy(t.selected, p); |
|
356 |
return M.at(t.pos).Select(selected, t.name); |
|
357 |
} |
|
358 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
359 |
@DefinedBy(Api.COMPILER_TREE) |
11142 | 360 |
public JCTree visitMemberReference(MemberReferenceTree node, P p) { |
361 |
JCMemberReference t = (JCMemberReference) node; |
|
362 |
JCExpression expr = copy(t.expr, p); |
|
363 |
List<JCExpression> typeargs = copy(t.typeargs, p); |
|
364 |
return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs); |
|
365 |
} |
|
366 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
367 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 368 |
public JCTree visitEmptyStatement(EmptyStatementTree node, P p) { |
369 |
JCSkip t = (JCSkip) node; |
|
370 |
return M.at(t.pos).Skip(); |
|
371 |
} |
|
372 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
373 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 374 |
public JCTree visitSwitch(SwitchTree node, P p) { |
375 |
JCSwitch t = (JCSwitch) node; |
|
376 |
JCExpression selector = copy(t.selector, p); |
|
377 |
List<JCCase> cases = copy(t.cases, p); |
|
378 |
return M.at(t.pos).Switch(selector, cases); |
|
379 |
} |
|
380 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
381 |
@DefinedBy(Api.COMPILER_TREE) |
51563
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
382 |
public JCTree visitSwitchExpression(SwitchExpressionTree node, P p) { |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
383 |
JCSwitchExpression t = (JCSwitchExpression) node; |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
384 |
JCExpression selector = copy(t.selector, p); |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
385 |
List<JCCase> cases = copy(t.cases, p); |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
386 |
return M.at(t.pos).SwitchExpression(selector, cases); |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
387 |
} |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
388 |
|
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
389 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 390 |
public JCTree visitSynchronized(SynchronizedTree node, P p) { |
391 |
JCSynchronized t = (JCSynchronized) node; |
|
392 |
JCExpression lock = copy(t.lock, p); |
|
393 |
JCBlock body = copy(t.body, p); |
|
394 |
return M.at(t.pos).Synchronized(lock, body); |
|
395 |
} |
|
396 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
397 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 398 |
public JCTree visitThrow(ThrowTree node, P p) { |
399 |
JCThrow t = (JCThrow) node; |
|
17807
36cff8c58cdf
7030476: Fix conflicting use of JCTree/JCExpression
vromero
parents:
17578
diff
changeset
|
400 |
JCExpression expr = copy(t.expr, p); |
10 | 401 |
return M.at(t.pos).Throw(expr); |
402 |
} |
|
403 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
404 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 405 |
public JCTree visitCompilationUnit(CompilationUnitTree node, P p) { |
406 |
JCCompilationUnit t = (JCCompilationUnit) node; |
|
24069 | 407 |
List<JCTree> defs = copy(t.defs, p); |
408 |
return M.at(t.pos).TopLevel(defs); |
|
409 |
} |
|
410 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
411 |
@DefinedBy(Api.COMPILER_TREE) |
24069 | 412 |
public JCTree visitPackage(PackageTree node, P p) { |
413 |
JCPackageDecl t = (JCPackageDecl) node; |
|
414 |
List<JCAnnotation> annotations = copy(t.annotations, p); |
|
10 | 415 |
JCExpression pid = copy(t.pid, p); |
24069 | 416 |
return M.at(t.pos).PackageDecl(annotations, pid); |
10 | 417 |
} |
418 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
419 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 420 |
public JCTree visitTry(TryTree node, P p) { |
421 |
JCTry t = (JCTry) node; |
|
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
422 |
List<JCTree> resources = copy(t.resources, p); |
10 | 423 |
JCBlock body = copy(t.body, p); |
424 |
List<JCCatch> catchers = copy(t.catchers, p); |
|
425 |
JCBlock finalizer = copy(t.finalizer, p); |
|
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
426 |
return M.at(t.pos).Try(resources, body, catchers, finalizer); |
10 | 427 |
} |
428 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
429 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 430 |
public JCTree visitParameterizedType(ParameterizedTypeTree node, P p) { |
431 |
JCTypeApply t = (JCTypeApply) node; |
|
432 |
JCExpression clazz = copy(t.clazz, p); |
|
433 |
List<JCExpression> arguments = copy(t.arguments, p); |
|
434 |
return M.at(t.pos).TypeApply(clazz, arguments); |
|
435 |
} |
|
436 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
437 |
@DefinedBy(Api.COMPILER_TREE) |
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
438 |
public JCTree visitUnionType(UnionTypeTree node, P p) { |
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
439 |
JCTypeUnion t = (JCTypeUnion) node; |
7074 | 440 |
List<JCExpression> components = copy(t.alternatives, p); |
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
441 |
return M.at(t.pos).TypeUnion(components); |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
442 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
443 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
444 |
@DefinedBy(Api.COMPILER_TREE) |
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
445 |
public JCTree visitIntersectionType(IntersectionTypeTree node, P p) { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
446 |
JCTypeIntersection t = (JCTypeIntersection) node; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
447 |
List<JCExpression> bounds = copy(t.bounds, p); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
448 |
return M.at(t.pos).TypeIntersection(bounds); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
449 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
450 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
451 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 452 |
public JCTree visitArrayType(ArrayTypeTree node, P p) { |
453 |
JCArrayTypeTree t = (JCArrayTypeTree) node; |
|
454 |
JCExpression elemtype = copy(t.elemtype, p); |
|
455 |
return M.at(t.pos).TypeArray(elemtype); |
|
456 |
} |
|
457 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
458 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 459 |
public JCTree visitTypeCast(TypeCastTree node, P p) { |
460 |
JCTypeCast t = (JCTypeCast) node; |
|
461 |
JCTree clazz = copy(t.clazz, p); |
|
462 |
JCExpression expr = copy(t.expr, p); |
|
463 |
return M.at(t.pos).TypeCast(clazz, expr); |
|
464 |
} |
|
465 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
466 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 467 |
public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) { |
468 |
JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node; |
|
469 |
return M.at(t.pos).TypeIdent(t.typetag); |
|
470 |
} |
|
471 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
472 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 473 |
public JCTree visitTypeParameter(TypeParameterTree node, P p) { |
474 |
JCTypeParameter t = (JCTypeParameter) node; |
|
15385 | 475 |
List<JCAnnotation> annos = copy(t.annotations, p); |
10 | 476 |
List<JCExpression> bounds = copy(t.bounds, p); |
15385 | 477 |
return M.at(t.pos).TypeParameter(t.name, bounds, annos); |
10 | 478 |
} |
479 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
480 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 481 |
public JCTree visitInstanceOf(InstanceOfTree node, P p) { |
482 |
JCInstanceOf t = (JCInstanceOf) node; |
|
483 |
JCExpression expr = copy(t.expr, p); |
|
484 |
JCTree clazz = copy(t.clazz, p); |
|
485 |
return M.at(t.pos).TypeTest(expr, clazz); |
|
486 |
} |
|
487 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
488 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 489 |
public JCTree visitUnary(UnaryTree node, P p) { |
490 |
JCUnary t = (JCUnary) node; |
|
491 |
JCExpression arg = copy(t.arg, p); |
|
492 |
return M.at(t.pos).Unary(t.getTag(), arg); |
|
493 |
} |
|
494 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
495 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 496 |
public JCTree visitVariable(VariableTree node, P p) { |
497 |
JCVariableDecl t = (JCVariableDecl) node; |
|
498 |
JCModifiers mods = copy(t.mods, p); |
|
499 |
JCExpression vartype = copy(t.vartype, p); |
|
17578 | 500 |
if (t.nameexpr == null) { |
501 |
JCExpression init = copy(t.init, p); |
|
502 |
return M.at(t.pos).VarDef(mods, t.name, vartype, init); |
|
503 |
} else { |
|
504 |
JCExpression nameexpr = copy(t.nameexpr, p); |
|
505 |
return M.at(t.pos).ReceiverVarDef(mods, nameexpr, vartype); |
|
506 |
} |
|
10 | 507 |
} |
508 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
509 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 510 |
public JCTree visitWhileLoop(WhileLoopTree node, P p) { |
511 |
JCWhileLoop t = (JCWhileLoop) node; |
|
512 |
JCStatement body = copy(t.body, p); |
|
513 |
JCExpression cond = copy(t.cond, p); |
|
514 |
return M.at(t.pos).WhileLoop(cond, body); |
|
515 |
} |
|
516 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
517 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 518 |
public JCTree visitWildcard(WildcardTree node, P p) { |
519 |
JCWildcard t = (JCWildcard) node; |
|
520 |
TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind); |
|
521 |
JCTree inner = copy(t.inner, p); |
|
522 |
return M.at(t.pos).Wildcard(kind, inner); |
|
523 |
} |
|
524 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
525 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 526 |
public JCTree visitModule(ModuleTree node, P p) { |
527 |
JCModuleDecl t = (JCModuleDecl) node; |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
528 |
JCModifiers mods = copy(t.mods, p); |
36526 | 529 |
JCExpression qualId = copy(t.qualId); |
530 |
List<JCDirective> directives = copy(t.directives); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
531 |
return M.at(t.pos).ModuleDef(mods, t.getModuleType(), qualId, directives); |
36526 | 532 |
} |
533 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
534 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 535 |
public JCExports visitExports(ExportsTree node, P p) { |
536 |
JCExports t = (JCExports) node; |
|
537 |
JCExpression qualId = copy(t.qualid, p); |
|
538 |
List<JCExpression> moduleNames = copy(t.moduleNames, p); |
|
539 |
return M.at(t.pos).Exports(qualId, moduleNames); |
|
540 |
} |
|
541 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
542 |
@Override @DefinedBy(Api.COMPILER_TREE) |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
543 |
public JCOpens visitOpens(OpensTree node, P p) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
544 |
JCOpens t = (JCOpens) node; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
545 |
JCExpression qualId = copy(t.qualid, p); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
546 |
List<JCExpression> moduleNames = copy(t.moduleNames, p); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
547 |
return M.at(t.pos).Opens(qualId, moduleNames); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
548 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
549 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
550 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 551 |
public JCProvides visitProvides(ProvidesTree node, P p) { |
552 |
JCProvides t = (JCProvides) node; |
|
553 |
JCExpression serviceName = copy(t.serviceName, p); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
554 |
List<JCExpression> implNames = copy(t.implNames, p); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
555 |
return M.at(t.pos).Provides(serviceName, implNames); |
36526 | 556 |
} |
557 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
558 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 559 |
public JCRequires visitRequires(RequiresTree node, P p) { |
560 |
JCRequires t = (JCRequires) node; |
|
561 |
JCExpression moduleName = copy(t.moduleName, p); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
562 |
return M.at(t.pos).Requires(t.isTransitive, t.isStaticPhase, moduleName); |
36526 | 563 |
} |
564 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
565 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 566 |
public JCUses visitUses(UsesTree node, P p) { |
567 |
JCUses t = (JCUses) node; |
|
568 |
JCExpression serviceName = copy(t.qualid, p); |
|
569 |
return M.at(t.pos).Uses(serviceName); |
|
570 |
} |
|
571 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
572 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 573 |
public JCTree visitOther(Tree node, P p) { |
574 |
JCTree tree = (JCTree) node; |
|
575 |
switch (tree.getTag()) { |
|
10950 | 576 |
case LETEXPR: { |
10 | 577 |
LetExpr t = (LetExpr) node; |
51563
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
47216
diff
changeset
|
578 |
List<JCStatement> defs = copy(t.defs, p); |
33707
d74fef6b01e0
8141639: Signatures in Lower could be made tighter by using JCExpression instead of JCTree
mcimadamore
parents:
26266
diff
changeset
|
579 |
JCExpression expr = copy(t.expr, p); |
10 | 580 |
return M.at(t.pos).LetExpr(defs, expr); |
581 |
} |
|
582 |
default: |
|
583 |
throw new AssertionError("unknown tree tag: " + tree.getTag()); |
|
584 |
} |
|
585 |
} |
|
586 |
||
587 |
} |