Thu, 09 Oct 2008 16:07:38 +0100
6406133: JCDiagnostic.getMessage ignores locale argument
Summary: Compiler API should take into account locale settings
Reviewed-by: jjg
duke@1 | 1 | /* |
xdono@117 | 2 | * Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.javac.tree; |
duke@1 | 27 | |
duke@1 | 28 | import com.sun.source.tree.*; |
duke@1 | 29 | import com.sun.tools.javac.tree.JCTree.*; |
duke@1 | 30 | import com.sun.tools.javac.util.List; |
duke@1 | 31 | import com.sun.tools.javac.util.ListBuffer; |
duke@1 | 32 | |
duke@1 | 33 | /** |
duke@1 | 34 | * Creates a copy of a tree, using a given TreeMaker. |
duke@1 | 35 | * Names, literal values, etc are shared with the original. |
duke@1 | 36 | * |
duke@1 | 37 | * <p><b>This is NOT part of any API supported by Sun Microsystems. If |
duke@1 | 38 | * you write code that depends on this, you do so at your own risk. |
duke@1 | 39 | * This code and its internal interfaces are subject to change or |
duke@1 | 40 | * deletion without notice.</b> |
duke@1 | 41 | */ |
duke@1 | 42 | public class TreeCopier<P> implements TreeVisitor<JCTree,P> { |
duke@1 | 43 | private TreeMaker M; |
duke@1 | 44 | |
duke@1 | 45 | /** Creates a new instance of TreeCopier */ |
duke@1 | 46 | public TreeCopier(TreeMaker M) { |
duke@1 | 47 | this.M = M; |
duke@1 | 48 | } |
duke@1 | 49 | |
duke@1 | 50 | public <T extends JCTree> T copy(T tree) { |
duke@1 | 51 | return copy(tree, null); |
duke@1 | 52 | } |
duke@1 | 53 | |
duke@1 | 54 | @SuppressWarnings("unchecked") |
duke@1 | 55 | public <T extends JCTree> T copy(T tree, P p) { |
duke@1 | 56 | if (tree == null) |
duke@1 | 57 | return null; |
duke@1 | 58 | return (T) (tree.accept(this, p)); |
duke@1 | 59 | } |
duke@1 | 60 | |
duke@1 | 61 | public <T extends JCTree> List<T> copy(List<T> trees) { |
duke@1 | 62 | return copy(trees, null); |
duke@1 | 63 | } |
duke@1 | 64 | |
duke@1 | 65 | public <T extends JCTree> List<T> copy(List<T> trees, P p) { |
duke@1 | 66 | if (trees == null) |
duke@1 | 67 | return null; |
duke@1 | 68 | ListBuffer<T> lb = new ListBuffer<T>(); |
duke@1 | 69 | for (T tree: trees) |
duke@1 | 70 | lb.append(copy(tree, p)); |
duke@1 | 71 | return lb.toList(); |
duke@1 | 72 | } |
duke@1 | 73 | |
duke@1 | 74 | public JCTree visitAnnotation(AnnotationTree node, P p) { |
duke@1 | 75 | JCAnnotation t = (JCAnnotation) node; |
duke@1 | 76 | JCTree annotationType = copy(t.annotationType, p); |
duke@1 | 77 | List<JCExpression> args = copy(t.args, p); |
duke@1 | 78 | return M.at(t.pos).Annotation(annotationType, args); |
duke@1 | 79 | } |
duke@1 | 80 | |
duke@1 | 81 | public JCTree visitAssert(AssertTree node, P p) { |
duke@1 | 82 | JCAssert t = (JCAssert) node; |
duke@1 | 83 | JCExpression cond = copy(t.cond, p); |
duke@1 | 84 | JCExpression detail = copy(t.detail, p); |
duke@1 | 85 | return M.at(t.pos).Assert(cond, detail); |
duke@1 | 86 | } |
duke@1 | 87 | |
duke@1 | 88 | public JCTree visitAssignment(AssignmentTree node, P p) { |
duke@1 | 89 | JCAssign t = (JCAssign) node; |
duke@1 | 90 | JCExpression lhs = copy(t.lhs, p); |
duke@1 | 91 | JCExpression rhs = copy(t.rhs, p); |
duke@1 | 92 | return M.at(t.pos).Assign(lhs, rhs); |
duke@1 | 93 | } |
duke@1 | 94 | |
duke@1 | 95 | public JCTree visitCompoundAssignment(CompoundAssignmentTree node, P p) { |
duke@1 | 96 | JCAssignOp t = (JCAssignOp) node; |
duke@1 | 97 | JCTree lhs = copy(t.lhs, p); |
duke@1 | 98 | JCTree rhs = copy(t.rhs, p); |
duke@1 | 99 | return M.at(t.pos).Assignop(t.getTag(), lhs, rhs); |
duke@1 | 100 | } |
duke@1 | 101 | |
duke@1 | 102 | public JCTree visitBinary(BinaryTree node, P p) { |
duke@1 | 103 | JCBinary t = (JCBinary) node; |
duke@1 | 104 | JCExpression lhs = copy(t.lhs, p); |
duke@1 | 105 | JCExpression rhs = copy(t.rhs, p); |
duke@1 | 106 | return M.at(t.pos).Binary(t.getTag(), lhs, rhs); |
duke@1 | 107 | } |
duke@1 | 108 | |
duke@1 | 109 | public JCTree visitBlock(BlockTree node, P p) { |
duke@1 | 110 | JCBlock t = (JCBlock) node; |
duke@1 | 111 | List<JCStatement> stats = copy(t.stats, p); |
duke@1 | 112 | return M.at(t.pos).Block(t.flags, stats); |
duke@1 | 113 | } |
duke@1 | 114 | |
duke@1 | 115 | public JCTree visitBreak(BreakTree node, P p) { |
duke@1 | 116 | JCBreak t = (JCBreak) node; |
duke@1 | 117 | return M.at(t.pos).Break(t.label); |
duke@1 | 118 | } |
duke@1 | 119 | |
duke@1 | 120 | public JCTree visitCase(CaseTree node, P p) { |
duke@1 | 121 | JCCase t = (JCCase) node; |
duke@1 | 122 | JCExpression pat = copy(t.pat, p); |
duke@1 | 123 | List<JCStatement> stats = copy(t.stats, p); |
duke@1 | 124 | return M.at(t.pos).Case(pat, stats); |
duke@1 | 125 | } |
duke@1 | 126 | |
duke@1 | 127 | public JCTree visitCatch(CatchTree node, P p) { |
duke@1 | 128 | JCCatch t = (JCCatch) node; |
duke@1 | 129 | JCVariableDecl param = copy(t.param, p); |
duke@1 | 130 | JCBlock body = copy(t.body, p); |
duke@1 | 131 | return M.at(t.pos).Catch(param, body); |
duke@1 | 132 | } |
duke@1 | 133 | |
duke@1 | 134 | public JCTree visitClass(ClassTree node, P p) { |
duke@1 | 135 | JCClassDecl t = (JCClassDecl) node; |
duke@1 | 136 | JCModifiers mods = copy(t.mods, p); |
duke@1 | 137 | List<JCTypeParameter> typarams = copy(t.typarams, p); |
duke@1 | 138 | JCTree extending = copy(t.extending, p); |
duke@1 | 139 | List<JCExpression> implementing = copy(t.implementing, p); |
duke@1 | 140 | List<JCTree> defs = copy(t.defs, p); |
duke@1 | 141 | return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs); |
duke@1 | 142 | } |
duke@1 | 143 | |
duke@1 | 144 | public JCTree visitConditionalExpression(ConditionalExpressionTree node, P p) { |
duke@1 | 145 | JCConditional t = (JCConditional) node; |
duke@1 | 146 | JCExpression cond = copy(t.cond, p); |
duke@1 | 147 | JCExpression truepart = copy(t.truepart, p); |
duke@1 | 148 | JCExpression falsepart = copy(t.falsepart, p); |
duke@1 | 149 | return M.at(t.pos).Conditional(cond, truepart, falsepart); |
duke@1 | 150 | } |
duke@1 | 151 | |
duke@1 | 152 | public JCTree visitContinue(ContinueTree node, P p) { |
duke@1 | 153 | JCContinue t = (JCContinue) node; |
duke@1 | 154 | return M.at(t.pos).Continue(t.label); |
duke@1 | 155 | } |
duke@1 | 156 | |
duke@1 | 157 | public JCTree visitDoWhileLoop(DoWhileLoopTree node, P p) { |
duke@1 | 158 | JCDoWhileLoop t = (JCDoWhileLoop) node; |
duke@1 | 159 | JCStatement body = copy(t.body, p); |
duke@1 | 160 | JCExpression cond = copy(t.cond, p); |
duke@1 | 161 | return M.at(t.pos).DoLoop(body, cond); |
duke@1 | 162 | } |
duke@1 | 163 | |
duke@1 | 164 | public JCTree visitErroneous(ErroneousTree node, P p) { |
duke@1 | 165 | JCErroneous t = (JCErroneous) node; |
duke@1 | 166 | List<? extends JCTree> errs = copy(t.errs, p); |
duke@1 | 167 | return M.at(t.pos).Erroneous(errs); |
duke@1 | 168 | } |
duke@1 | 169 | |
duke@1 | 170 | public JCTree visitExpressionStatement(ExpressionStatementTree node, P p) { |
duke@1 | 171 | JCExpressionStatement t = (JCExpressionStatement) node; |
duke@1 | 172 | JCExpression expr = copy(t.expr, p); |
duke@1 | 173 | return M.at(t.pos).Exec(expr); |
duke@1 | 174 | } |
duke@1 | 175 | |
duke@1 | 176 | public JCTree visitEnhancedForLoop(EnhancedForLoopTree node, P p) { |
duke@1 | 177 | JCEnhancedForLoop t = (JCEnhancedForLoop) node; |
duke@1 | 178 | JCVariableDecl var = copy(t.var, p); |
duke@1 | 179 | JCExpression expr = copy(t.expr, p); |
duke@1 | 180 | JCStatement body = copy(t.body, p); |
duke@1 | 181 | return M.at(t.pos).ForeachLoop(var, expr, body); |
duke@1 | 182 | } |
duke@1 | 183 | |
duke@1 | 184 | public JCTree visitForLoop(ForLoopTree node, P p) { |
duke@1 | 185 | JCForLoop t = (JCForLoop) node; |
duke@1 | 186 | List<JCStatement> init = copy(t.init, p); |
duke@1 | 187 | JCExpression cond = copy(t.cond, p); |
duke@1 | 188 | List<JCExpressionStatement> step = copy(t.step, p); |
duke@1 | 189 | JCStatement body = copy(t.body, p); |
duke@1 | 190 | return M.at(t.pos).ForLoop(init, cond, step, body); |
duke@1 | 191 | } |
duke@1 | 192 | |
duke@1 | 193 | public JCTree visitIdentifier(IdentifierTree node, P p) { |
duke@1 | 194 | JCIdent t = (JCIdent) node; |
duke@1 | 195 | return M.at(t.pos).Ident(t.name); |
duke@1 | 196 | } |
duke@1 | 197 | |
duke@1 | 198 | public JCTree visitIf(IfTree node, P p) { |
duke@1 | 199 | JCIf t = (JCIf) node; |
duke@1 | 200 | JCExpression cond = copy(t.cond, p); |
duke@1 | 201 | JCStatement thenpart = copy(t.thenpart, p); |
duke@1 | 202 | JCStatement elsepart = copy(t.elsepart, p); |
duke@1 | 203 | return M.at(t.pos).If(cond, thenpart, elsepart); |
duke@1 | 204 | } |
duke@1 | 205 | |
duke@1 | 206 | public JCTree visitImport(ImportTree node, P p) { |
duke@1 | 207 | JCImport t = (JCImport) node; |
duke@1 | 208 | JCTree qualid = copy(t.qualid, p); |
duke@1 | 209 | return M.at(t.pos).Import(qualid, t.staticImport); |
duke@1 | 210 | } |
duke@1 | 211 | |
duke@1 | 212 | public JCTree visitArrayAccess(ArrayAccessTree node, P p) { |
duke@1 | 213 | JCArrayAccess t = (JCArrayAccess) node; |
duke@1 | 214 | JCExpression indexed = copy(t.indexed, p); |
duke@1 | 215 | JCExpression index = copy(t.index, p); |
duke@1 | 216 | return M.at(t.pos).Indexed(indexed, index); |
duke@1 | 217 | } |
duke@1 | 218 | |
duke@1 | 219 | public JCTree visitLabeledStatement(LabeledStatementTree node, P p) { |
duke@1 | 220 | JCLabeledStatement t = (JCLabeledStatement) node; |
duke@1 | 221 | JCStatement body = copy(t.body, p); |
duke@1 | 222 | return M.at(t.pos).Labelled(t.label, t.body); |
duke@1 | 223 | } |
duke@1 | 224 | |
duke@1 | 225 | public JCTree visitLiteral(LiteralTree node, P p) { |
duke@1 | 226 | JCLiteral t = (JCLiteral) node; |
duke@1 | 227 | return M.at(t.pos).Literal(t.typetag, t.value); |
duke@1 | 228 | } |
duke@1 | 229 | |
duke@1 | 230 | public JCTree visitMethod(MethodTree node, P p) { |
duke@1 | 231 | JCMethodDecl t = (JCMethodDecl) node; |
duke@1 | 232 | JCModifiers mods = copy(t.mods, p); |
duke@1 | 233 | JCExpression restype = copy(t.restype, p); |
duke@1 | 234 | List<JCTypeParameter> typarams = copy(t.typarams, p); |
duke@1 | 235 | List<JCVariableDecl> params = copy(t.params, p); |
duke@1 | 236 | List<JCExpression> thrown = copy(t.thrown, p); |
duke@1 | 237 | JCBlock body = copy(t.body, p); |
duke@1 | 238 | JCExpression defaultValue = copy(t.defaultValue, p); |
duke@1 | 239 | return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, thrown, body, defaultValue); |
duke@1 | 240 | } |
duke@1 | 241 | |
duke@1 | 242 | public JCTree visitMethodInvocation(MethodInvocationTree node, P p) { |
duke@1 | 243 | JCMethodInvocation t = (JCMethodInvocation) node; |
duke@1 | 244 | List<JCExpression> typeargs = copy(t.typeargs, p); |
duke@1 | 245 | JCExpression meth = copy(t.meth, p); |
duke@1 | 246 | List<JCExpression> args = copy(t.args, p); |
duke@1 | 247 | return M.at(t.pos).Apply(typeargs, meth, args); |
duke@1 | 248 | } |
duke@1 | 249 | |
duke@1 | 250 | public JCTree visitModifiers(ModifiersTree node, P p) { |
duke@1 | 251 | JCModifiers t = (JCModifiers) node; |
duke@1 | 252 | List<JCAnnotation> annotations = copy(t.annotations, p); |
duke@1 | 253 | return M.at(t.pos).Modifiers(t.flags, annotations); |
duke@1 | 254 | } |
duke@1 | 255 | |
duke@1 | 256 | public JCTree visitNewArray(NewArrayTree node, P p) { |
duke@1 | 257 | JCNewArray t = (JCNewArray) node; |
duke@1 | 258 | JCExpression elemtype = copy(t.elemtype, p); |
duke@1 | 259 | List<JCExpression> dims = copy(t.dims, p); |
duke@1 | 260 | List<JCExpression> elems = copy(t.elems, p); |
duke@1 | 261 | return M.at(t.pos).NewArray(elemtype, dims, elems); |
duke@1 | 262 | } |
duke@1 | 263 | |
duke@1 | 264 | public JCTree visitNewClass(NewClassTree node, P p) { |
duke@1 | 265 | JCNewClass t = (JCNewClass) node; |
duke@1 | 266 | JCExpression encl = copy(t.encl, p); |
duke@1 | 267 | List<JCExpression> typeargs = copy(t.typeargs, p); |
duke@1 | 268 | JCExpression clazz = copy(t.clazz, p); |
duke@1 | 269 | List<JCExpression> args = copy(t.args, p); |
duke@1 | 270 | JCClassDecl def = copy(t.def, p); |
duke@1 | 271 | return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def); |
duke@1 | 272 | } |
duke@1 | 273 | |
duke@1 | 274 | public JCTree visitParenthesized(ParenthesizedTree node, P p) { |
duke@1 | 275 | JCParens t = (JCParens) node; |
duke@1 | 276 | JCExpression expr = copy(t.expr, p); |
duke@1 | 277 | return M.at(t.pos).Parens(expr); |
duke@1 | 278 | } |
duke@1 | 279 | |
duke@1 | 280 | public JCTree visitReturn(ReturnTree node, P p) { |
duke@1 | 281 | JCReturn t = (JCReturn) node; |
duke@1 | 282 | JCExpression expr = copy(t.expr, p); |
duke@1 | 283 | return M.at(t.pos).Return(expr); |
duke@1 | 284 | } |
duke@1 | 285 | |
duke@1 | 286 | public JCTree visitMemberSelect(MemberSelectTree node, P p) { |
duke@1 | 287 | JCFieldAccess t = (JCFieldAccess) node; |
duke@1 | 288 | JCExpression selected = copy(t.selected, p); |
duke@1 | 289 | return M.at(t.pos).Select(selected, t.name); |
duke@1 | 290 | } |
duke@1 | 291 | |
duke@1 | 292 | public JCTree visitEmptyStatement(EmptyStatementTree node, P p) { |
duke@1 | 293 | JCSkip t = (JCSkip) node; |
duke@1 | 294 | return M.at(t.pos).Skip(); |
duke@1 | 295 | } |
duke@1 | 296 | |
duke@1 | 297 | public JCTree visitSwitch(SwitchTree node, P p) { |
duke@1 | 298 | JCSwitch t = (JCSwitch) node; |
duke@1 | 299 | JCExpression selector = copy(t.selector, p); |
duke@1 | 300 | List<JCCase> cases = copy(t.cases, p); |
duke@1 | 301 | return M.at(t.pos).Switch(selector, cases); |
duke@1 | 302 | } |
duke@1 | 303 | |
duke@1 | 304 | public JCTree visitSynchronized(SynchronizedTree node, P p) { |
duke@1 | 305 | JCSynchronized t = (JCSynchronized) node; |
duke@1 | 306 | JCExpression lock = copy(t.lock, p); |
duke@1 | 307 | JCBlock body = copy(t.body, p); |
duke@1 | 308 | return M.at(t.pos).Synchronized(lock, body); |
duke@1 | 309 | } |
duke@1 | 310 | |
duke@1 | 311 | public JCTree visitThrow(ThrowTree node, P p) { |
duke@1 | 312 | JCThrow t = (JCThrow) node; |
duke@1 | 313 | JCTree expr = copy(t.expr, p); |
duke@1 | 314 | return M.at(t.pos).Throw(expr); |
duke@1 | 315 | } |
duke@1 | 316 | |
duke@1 | 317 | public JCTree visitCompilationUnit(CompilationUnitTree node, P p) { |
duke@1 | 318 | JCCompilationUnit t = (JCCompilationUnit) node; |
duke@1 | 319 | List<JCAnnotation> packageAnnotations = copy(t.packageAnnotations, p); |
duke@1 | 320 | JCExpression pid = copy(t.pid, p); |
duke@1 | 321 | List<JCTree> defs = copy(t.defs, p); |
duke@1 | 322 | return M.at(t.pos).TopLevel(packageAnnotations, pid, defs); |
duke@1 | 323 | } |
duke@1 | 324 | |
duke@1 | 325 | public JCTree visitTry(TryTree node, P p) { |
duke@1 | 326 | JCTry t = (JCTry) node; |
duke@1 | 327 | JCBlock body = copy(t.body, p); |
duke@1 | 328 | List<JCCatch> catchers = copy(t.catchers, p); |
duke@1 | 329 | JCBlock finalizer = copy(t.finalizer, p); |
duke@1 | 330 | return M.at(t.pos).Try(body, catchers, finalizer); |
duke@1 | 331 | } |
duke@1 | 332 | |
duke@1 | 333 | public JCTree visitParameterizedType(ParameterizedTypeTree node, P p) { |
duke@1 | 334 | JCTypeApply t = (JCTypeApply) node; |
duke@1 | 335 | JCExpression clazz = copy(t.clazz, p); |
duke@1 | 336 | List<JCExpression> arguments = copy(t.arguments, p); |
duke@1 | 337 | return M.at(t.pos).TypeApply(clazz, arguments); |
duke@1 | 338 | } |
duke@1 | 339 | |
duke@1 | 340 | public JCTree visitArrayType(ArrayTypeTree node, P p) { |
duke@1 | 341 | JCArrayTypeTree t = (JCArrayTypeTree) node; |
duke@1 | 342 | JCExpression elemtype = copy(t.elemtype, p); |
duke@1 | 343 | return M.at(t.pos).TypeArray(elemtype); |
duke@1 | 344 | } |
duke@1 | 345 | |
duke@1 | 346 | public JCTree visitTypeCast(TypeCastTree node, P p) { |
duke@1 | 347 | JCTypeCast t = (JCTypeCast) node; |
duke@1 | 348 | JCTree clazz = copy(t.clazz, p); |
duke@1 | 349 | JCExpression expr = copy(t.expr, p); |
duke@1 | 350 | return M.at(t.pos).TypeCast(clazz, expr); |
duke@1 | 351 | } |
duke@1 | 352 | |
duke@1 | 353 | public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) { |
duke@1 | 354 | JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node; |
duke@1 | 355 | return M.at(t.pos).TypeIdent(t.typetag); |
duke@1 | 356 | } |
duke@1 | 357 | |
duke@1 | 358 | public JCTree visitTypeParameter(TypeParameterTree node, P p) { |
duke@1 | 359 | JCTypeParameter t = (JCTypeParameter) node; |
duke@1 | 360 | List<JCExpression> bounds = copy(t.bounds, p); |
duke@1 | 361 | return M.at(t.pos).TypeParameter(t.name, t.bounds); |
duke@1 | 362 | } |
duke@1 | 363 | |
duke@1 | 364 | public JCTree visitInstanceOf(InstanceOfTree node, P p) { |
duke@1 | 365 | JCInstanceOf t = (JCInstanceOf) node; |
duke@1 | 366 | JCExpression expr = copy(t.expr, p); |
duke@1 | 367 | JCTree clazz = copy(t.clazz, p); |
duke@1 | 368 | return M.at(t.pos).TypeTest(expr, clazz); |
duke@1 | 369 | } |
duke@1 | 370 | |
duke@1 | 371 | public JCTree visitUnary(UnaryTree node, P p) { |
duke@1 | 372 | JCUnary t = (JCUnary) node; |
duke@1 | 373 | JCExpression arg = copy(t.arg, p); |
duke@1 | 374 | return M.at(t.pos).Unary(t.getTag(), arg); |
duke@1 | 375 | } |
duke@1 | 376 | |
duke@1 | 377 | public JCTree visitVariable(VariableTree node, P p) { |
duke@1 | 378 | JCVariableDecl t = (JCVariableDecl) node; |
duke@1 | 379 | JCModifiers mods = copy(t.mods, p); |
duke@1 | 380 | JCExpression vartype = copy(t.vartype, p); |
duke@1 | 381 | JCExpression init = copy(t.init, p); |
duke@1 | 382 | return M.at(t.pos).VarDef(mods, t.name, vartype, init); |
duke@1 | 383 | } |
duke@1 | 384 | |
duke@1 | 385 | public JCTree visitWhileLoop(WhileLoopTree node, P p) { |
duke@1 | 386 | JCWhileLoop t = (JCWhileLoop) node; |
duke@1 | 387 | JCStatement body = copy(t.body, p); |
duke@1 | 388 | JCExpression cond = copy(t.cond, p); |
duke@1 | 389 | return M.at(t.pos).WhileLoop(cond, body); |
duke@1 | 390 | } |
duke@1 | 391 | |
duke@1 | 392 | public JCTree visitWildcard(WildcardTree node, P p) { |
duke@1 | 393 | JCWildcard t = (JCWildcard) node; |
duke@1 | 394 | TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind); |
duke@1 | 395 | JCTree inner = copy(t.inner, p); |
duke@1 | 396 | return M.at(t.pos).Wildcard(kind, inner); |
duke@1 | 397 | } |
duke@1 | 398 | |
duke@1 | 399 | public JCTree visitOther(Tree node, P p) { |
duke@1 | 400 | JCTree tree = (JCTree) node; |
duke@1 | 401 | switch (tree.getTag()) { |
duke@1 | 402 | case JCTree.LETEXPR: { |
duke@1 | 403 | LetExpr t = (LetExpr) node; |
duke@1 | 404 | List<JCVariableDecl> defs = copy(t.defs, p); |
duke@1 | 405 | JCTree expr = copy(t.expr, p); |
duke@1 | 406 | return M.at(t.pos).LetExpr(defs, expr); |
duke@1 | 407 | } |
duke@1 | 408 | default: |
duke@1 | 409 | throw new AssertionError("unknown tree tag: " + tree.getTag()); |
duke@1 | 410 | } |
duke@1 | 411 | } |
duke@1 | 412 | |
duke@1 | 413 | } |