1 /* 2 * Copyright (c) 2006, 2016, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 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. 24 */ 25 26 package com.sun.tools.javac.tree; 27 28 import com.sun.source.tree.*; 29 import com.sun.source.tree.Tree.Kind; 30 import com.sun.tools.javac.tree.JCTree.*; 31 import com.sun.tools.javac.util.DefinedBy; 32 import com.sun.tools.javac.util.DefinedBy.Api; 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 * 40 * <p><b>This is NOT part of any supported API. 41 * If you write code that depends on this, you do so at your own risk. 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; 71 ListBuffer<T> lb = new ListBuffer<>(); 72 for (T tree: trees) 73 lb.append(copy(tree, p)); 74 return lb.toList(); 75 } 76 77 @DefinedBy(Api.COMPILER_TREE) 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 85 @DefinedBy(Api.COMPILER_TREE) 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); 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 } 99 } 100 101 @DefinedBy(Api.COMPILER_TREE) 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 109 @DefinedBy(Api.COMPILER_TREE) 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 117 @DefinedBy(Api.COMPILER_TREE) 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 125 @DefinedBy(Api.COMPILER_TREE) 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 133 @DefinedBy(Api.COMPILER_TREE) 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 140 @DefinedBy(Api.COMPILER_TREE) 141 public JCTree visitBreak(BreakTree node, P p) { 142 JCBreak t = (JCBreak) node; 143 return M.at(t.pos).Break(t.label); 144 } 145 146 @DefinedBy(Api.COMPILER_TREE) 147 public JCTree visitCase(CaseTree node, P p) { 148 JCCase t = (JCCase) node; 149 JCExpression pat = copy(t.pat, p); 150 List<JCStatement> stats = copy(t.stats, p); 151 return M.at(t.pos).Case(pat, stats); 152 } 153 154 @DefinedBy(Api.COMPILER_TREE) 155 public JCTree visitCatch(CatchTree node, P p) { 156 JCCatch t = (JCCatch) node; 157 JCVariableDecl param = copy(t.param, p); 158 JCBlock body = copy(t.body, p); 159 return M.at(t.pos).Catch(param, body); 160 } 161 162 @DefinedBy(Api.COMPILER_TREE) 163 public JCTree visitClass(ClassTree node, P p) { 164 JCClassDecl t = (JCClassDecl) node; 165 JCModifiers mods = copy(t.mods, p); 166 List<JCTypeParameter> typarams = copy(t.typarams, p); 167 JCExpression extending = copy(t.extending, p); 168 List<JCExpression> implementing = copy(t.implementing, p); 169 List<JCTree> defs = copy(t.defs, p); 170 return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs); 171 } 172 173 @DefinedBy(Api.COMPILER_TREE) 174 public JCTree visitConditionalExpression(ConditionalExpressionTree node, P p) { 175 JCConditional t = (JCConditional) node; 176 JCExpression cond = copy(t.cond, p); 177 JCExpression truepart = copy(t.truepart, p); 178 JCExpression falsepart = copy(t.falsepart, p); 179 return M.at(t.pos).Conditional(cond, truepart, falsepart); 180 } 181 182 @DefinedBy(Api.COMPILER_TREE) 183 public JCTree visitContinue(ContinueTree node, P p) { 184 JCContinue t = (JCContinue) node; 185 return M.at(t.pos).Continue(t.label); 186 } 187 188 @DefinedBy(Api.COMPILER_TREE) 189 public JCTree visitDoWhileLoop(DoWhileLoopTree node, P p) { 190 JCDoWhileLoop t = (JCDoWhileLoop) node; 191 JCStatement body = copy(t.body, p); 192 JCExpression cond = copy(t.cond, p); 193 return M.at(t.pos).DoLoop(body, cond); 194 } 195 196 @DefinedBy(Api.COMPILER_TREE) 197 public JCTree visitErroneous(ErroneousTree node, P p) { 198 JCErroneous t = (JCErroneous) node; 199 List<? extends JCTree> errs = copy(t.errs, p); 200 return M.at(t.pos).Erroneous(errs); 201 } 202 203 @DefinedBy(Api.COMPILER_TREE) 204 public JCTree visitExpressionStatement(ExpressionStatementTree node, P p) { 205 JCExpressionStatement t = (JCExpressionStatement) node; 206 JCExpression expr = copy(t.expr, p); 207 return M.at(t.pos).Exec(expr); 208 } 209 210 @DefinedBy(Api.COMPILER_TREE) 211 public JCTree visitEnhancedForLoop(EnhancedForLoopTree node, P p) { 212 JCEnhancedForLoop t = (JCEnhancedForLoop) node; 213 JCVariableDecl var = copy(t.var, p); 214 JCExpression expr = copy(t.expr, p); 215 JCStatement body = copy(t.body, p); 216 return M.at(t.pos).ForeachLoop(var, expr, body); 217 } 218 219 @DefinedBy(Api.COMPILER_TREE) 220 public JCTree visitForLoop(ForLoopTree node, P p) { 221 JCForLoop t = (JCForLoop) node; 222 List<JCStatement> init = copy(t.init, p); 223 JCExpression cond = copy(t.cond, p); 224 List<JCExpressionStatement> step = copy(t.step, p); 225 JCStatement body = copy(t.body, p); 226 return M.at(t.pos).ForLoop(init, cond, step, body); 227 } 228 229 @DefinedBy(Api.COMPILER_TREE) 230 public JCTree visitIdentifier(IdentifierTree node, P p) { 231 JCIdent t = (JCIdent) node; 232 return M.at(t.pos).Ident(t.name); 233 } 234 235 @DefinedBy(Api.COMPILER_TREE) 236 public JCTree visitIf(IfTree node, P p) { 237 JCIf t = (JCIf) node; 238 JCExpression cond = copy(t.cond, p); 239 JCStatement thenpart = copy(t.thenpart, p); 240 JCStatement elsepart = copy(t.elsepart, p); 241 return M.at(t.pos).If(cond, thenpart, elsepart); 242 } 243 244 @DefinedBy(Api.COMPILER_TREE) 245 public JCTree visitImport(ImportTree node, P p) { 246 JCImport t = (JCImport) node; 247 JCTree qualid = copy(t.qualid, p); 248 return M.at(t.pos).Import(qualid, t.staticImport); 249 } 250 251 @DefinedBy(Api.COMPILER_TREE) 252 public JCTree visitArrayAccess(ArrayAccessTree node, P p) { 253 JCArrayAccess t = (JCArrayAccess) node; 254 JCExpression indexed = copy(t.indexed, p); 255 JCExpression index = copy(t.index, p); 256 return M.at(t.pos).Indexed(indexed, index); 257 } 258 259 @DefinedBy(Api.COMPILER_TREE) 260 public JCTree visitLabeledStatement(LabeledStatementTree node, P p) { 261 JCLabeledStatement t = (JCLabeledStatement) node; 262 JCStatement body = copy(t.body, p); 263 return M.at(t.pos).Labelled(t.label, body); 264 } 265 266 @DefinedBy(Api.COMPILER_TREE) 267 public JCTree visitLiteral(LiteralTree node, P p) { 268 JCLiteral t = (JCLiteral) node; 269 return M.at(t.pos).Literal(t.typetag, t.value); 270 } 271 272 @DefinedBy(Api.COMPILER_TREE) 273 public JCTree visitMethod(MethodTree node, P p) { 274 JCMethodDecl t = (JCMethodDecl) node; 275 JCModifiers mods = copy(t.mods, p); 276 JCExpression restype = copy(t.restype, p); 277 List<JCTypeParameter> typarams = copy(t.typarams, p); 278 List<JCVariableDecl> params = copy(t.params, p); 279 JCVariableDecl recvparam = copy(t.recvparam, p); 280 List<JCExpression> thrown = copy(t.thrown, p); 281 JCBlock body = copy(t.body, p); 282 JCExpression defaultValue = copy(t.defaultValue, p); 283 return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue); 284 } 285 286 @DefinedBy(Api.COMPILER_TREE) 287 public JCTree visitMethodInvocation(MethodInvocationTree node, P p) { 288 JCMethodInvocation t = (JCMethodInvocation) node; 289 List<JCExpression> typeargs = copy(t.typeargs, p); 290 JCExpression meth = copy(t.meth, p); 291 List<JCExpression> args = copy(t.args, p); 292 return M.at(t.pos).Apply(typeargs, meth, args); 293 } 294 295 @DefinedBy(Api.COMPILER_TREE) 296 public JCTree visitModifiers(ModifiersTree node, P p) { 297 JCModifiers t = (JCModifiers) node; 298 List<JCAnnotation> annotations = copy(t.annotations, p); 299 return M.at(t.pos).Modifiers(t.flags, annotations); 300 } 301 302 @DefinedBy(Api.COMPILER_TREE) 303 public JCTree visitNewArray(NewArrayTree node, P p) { 304 JCNewArray t = (JCNewArray) node; 305 JCExpression elemtype = copy(t.elemtype, p); 306 List<JCExpression> dims = copy(t.dims, p); 307 List<JCExpression> elems = copy(t.elems, p); 308 return M.at(t.pos).NewArray(elemtype, dims, elems); 309 } 310 311 @DefinedBy(Api.COMPILER_TREE) 312 public JCTree visitNewClass(NewClassTree node, P p) { 313 JCNewClass t = (JCNewClass) node; 314 JCExpression encl = copy(t.encl, p); 315 List<JCExpression> typeargs = copy(t.typeargs, p); 316 JCExpression clazz = copy(t.clazz, p); 317 List<JCExpression> args = copy(t.args, p); 318 JCClassDecl def = copy(t.def, p); 319 return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def); 320 } 321 322 @DefinedBy(Api.COMPILER_TREE) 323 public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) { 324 JCLambda t = (JCLambda) node; 325 List<JCVariableDecl> params = copy(t.params, p); 326 JCTree body = copy(t.body, p); 327 return M.at(t.pos).Lambda(params, body); 328 } 329 330 @DefinedBy(Api.COMPILER_TREE) 331 public JCTree visitParenthesized(ParenthesizedTree node, P p) { 332 JCParens t = (JCParens) node; 333 JCExpression expr = copy(t.expr, p); 334 return M.at(t.pos).Parens(expr); 335 } 336 337 @DefinedBy(Api.COMPILER_TREE) 338 public JCTree visitReturn(ReturnTree node, P p) { 339 JCReturn t = (JCReturn) node; 340 JCExpression expr = copy(t.expr, p); 341 return M.at(t.pos).Return(expr); 342 } 343 344 @DefinedBy(Api.COMPILER_TREE) 345 public JCTree visitMemberSelect(MemberSelectTree node, P p) { 346 JCFieldAccess t = (JCFieldAccess) node; 347 JCExpression selected = copy(t.selected, p); 348 return M.at(t.pos).Select(selected, t.name); 349 } 350 351 @DefinedBy(Api.COMPILER_TREE) 352 public JCTree visitMemberReference(MemberReferenceTree node, P p) { 353 JCMemberReference t = (JCMemberReference) node; 354 JCExpression expr = copy(t.expr, p); 355 List<JCExpression> typeargs = copy(t.typeargs, p); 356 return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs); 357 } 358 359 @DefinedBy(Api.COMPILER_TREE) 360 public JCTree visitEmptyStatement(EmptyStatementTree node, P p) { 361 JCSkip t = (JCSkip) node; 362 return M.at(t.pos).Skip(); 363 } 364 365 @DefinedBy(Api.COMPILER_TREE) 366 public JCTree visitSwitch(SwitchTree node, P p) { 367 JCSwitch t = (JCSwitch) node; 368 JCExpression selector = copy(t.selector, p); 369 List<JCCase> cases = copy(t.cases, p); 370 return M.at(t.pos).Switch(selector, cases); 371 } 372 373 @DefinedBy(Api.COMPILER_TREE) 374 public JCTree visitSynchronized(SynchronizedTree node, P p) { 375 JCSynchronized t = (JCSynchronized) node; 376 JCExpression lock = copy(t.lock, p); 377 JCBlock body = copy(t.body, p); 378 return M.at(t.pos).Synchronized(lock, body); 379 } 380 381 @DefinedBy(Api.COMPILER_TREE) 382 public JCTree visitThrow(ThrowTree node, P p) { 383 JCThrow t = (JCThrow) node; 384 JCExpression expr = copy(t.expr, p); 385 return M.at(t.pos).Throw(expr); 386 } 387 388 @DefinedBy(Api.COMPILER_TREE) 389 public JCTree visitCompilationUnit(CompilationUnitTree node, P p) { 390 JCCompilationUnit t = (JCCompilationUnit) node; 391 List<JCTree> defs = copy(t.defs, p); 392 return M.at(t.pos).TopLevel(defs); 393 } 394 395 @DefinedBy(Api.COMPILER_TREE) 396 public JCTree visitPackage(PackageTree node, P p) { 397 JCPackageDecl t = (JCPackageDecl) node; 398 List<JCAnnotation> annotations = copy(t.annotations, p); 399 JCExpression pid = copy(t.pid, p); 400 return M.at(t.pos).PackageDecl(annotations, pid); 401 } 402 403 @DefinedBy(Api.COMPILER_TREE) 404 public JCTree visitTry(TryTree node, P p) { 405 JCTry t = (JCTry) node; 406 List<JCTree> resources = copy(t.resources, p); 407 JCBlock body = copy(t.body, p); 408 List<JCCatch> catchers = copy(t.catchers, p); 409 JCBlock finalizer = copy(t.finalizer, p); 410 return M.at(t.pos).Try(resources, body, catchers, finalizer); 411 } 412 413 @DefinedBy(Api.COMPILER_TREE) 414 public JCTree visitParameterizedType(ParameterizedTypeTree node, P p) { 415 JCTypeApply t = (JCTypeApply) node; 416 JCExpression clazz = copy(t.clazz, p); 417 List<JCExpression> arguments = copy(t.arguments, p); 418 return M.at(t.pos).TypeApply(clazz, arguments); 419 } 420 421 @DefinedBy(Api.COMPILER_TREE) 422 public JCTree visitUnionType(UnionTypeTree node, P p) { 423 JCTypeUnion t = (JCTypeUnion) node; 424 List<JCExpression> components = copy(t.alternatives, p); 425 return M.at(t.pos).TypeUnion(components); 426 } 427 428 @DefinedBy(Api.COMPILER_TREE) 429 public JCTree visitIntersectionType(IntersectionTypeTree node, P p) { 430 JCTypeIntersection t = (JCTypeIntersection) node; 431 List<JCExpression> bounds = copy(t.bounds, p); 432 return M.at(t.pos).TypeIntersection(bounds); 433 } 434 435 @DefinedBy(Api.COMPILER_TREE) 436 public JCTree visitArrayType(ArrayTypeTree node, P p) { 437 JCArrayTypeTree t = (JCArrayTypeTree) node; 438 JCExpression elemtype = copy(t.elemtype, p); 439 return M.at(t.pos).TypeArray(elemtype); 440 } 441 442 @DefinedBy(Api.COMPILER_TREE) 443 public JCTree visitTypeCast(TypeCastTree node, P p) { 444 JCTypeCast t = (JCTypeCast) node; 445 JCTree clazz = copy(t.clazz, p); 446 JCExpression expr = copy(t.expr, p); 447 return M.at(t.pos).TypeCast(clazz, expr); 448 } 449 450 @DefinedBy(Api.COMPILER_TREE) 451 public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) { 452 JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node; 453 return M.at(t.pos).TypeIdent(t.typetag); 454 } 455 456 @DefinedBy(Api.COMPILER_TREE) 457 public JCTree visitTypeParameter(TypeParameterTree node, P p) { 458 JCTypeParameter t = (JCTypeParameter) node; 459 List<JCAnnotation> annos = copy(t.annotations, p); 460 List<JCExpression> bounds = copy(t.bounds, p); 461 return M.at(t.pos).TypeParameter(t.name, bounds, annos); 462 } 463 464 @DefinedBy(Api.COMPILER_TREE) 465 public JCTree visitInstanceOf(InstanceOfTree node, P p) { 466 JCInstanceOf t = (JCInstanceOf) node; 467 JCExpression expr = copy(t.expr, p); 468 JCTree clazz = copy(t.clazz, p); 469 return M.at(t.pos).TypeTest(expr, clazz); 470 } 471 472 @DefinedBy(Api.COMPILER_TREE) 473 public JCTree visitUnary(UnaryTree node, P p) { 474 JCUnary t = (JCUnary) node; 475 JCExpression arg = copy(t.arg, p); 476 return M.at(t.pos).Unary(t.getTag(), arg); 477 } 478 479 @DefinedBy(Api.COMPILER_TREE) 480 public JCTree visitVariable(VariableTree node, P p) { 481 JCVariableDecl t = (JCVariableDecl) node; 482 JCModifiers mods = copy(t.mods, p); 483 JCExpression vartype = copy(t.vartype, p); 484 if (t.nameexpr == null) { 485 JCExpression init = copy(t.init, p); 486 return M.at(t.pos).VarDef(mods, t.name, vartype, init); 487 } else { 488 JCExpression nameexpr = copy(t.nameexpr, p); 489 return M.at(t.pos).ReceiverVarDef(mods, nameexpr, vartype); 490 } 491 } 492 493 @DefinedBy(Api.COMPILER_TREE) 494 public JCTree visitWhileLoop(WhileLoopTree node, P p) { 495 JCWhileLoop t = (JCWhileLoop) node; 496 JCStatement body = copy(t.body, p); 497 JCExpression cond = copy(t.cond, p); 498 return M.at(t.pos).WhileLoop(cond, body); 499 } 500 501 @DefinedBy(Api.COMPILER_TREE) 502 public JCTree visitWildcard(WildcardTree node, P p) { 503 JCWildcard t = (JCWildcard) node; 504 TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind); 505 JCTree inner = copy(t.inner, p); 506 return M.at(t.pos).Wildcard(kind, inner); 507 } 508 509 @Override @DefinedBy(Api.COMPILER_TREE) 510 public JCTree visitModule(ModuleTree node, P p) { 511 JCModuleDecl t = (JCModuleDecl) node; 512 JCModifiers mods = copy(t.mods, p); 513 JCExpression qualId = copy(t.qualId); 514 List<JCDirective> directives = copy(t.directives); 515 return M.at(t.pos).ModuleDef(mods, t.getModuleType(), qualId, directives); 516 } 517 518 @Override @DefinedBy(Api.COMPILER_TREE) 519 public JCExports visitExports(ExportsTree node, P p) { 520 JCExports t = (JCExports) node; 521 JCExpression qualId = copy(t.qualid, p); 522 List<JCExpression> moduleNames = copy(t.moduleNames, p); 523 return M.at(t.pos).Exports(qualId, moduleNames); 524 } 525 526 @Override @DefinedBy(Api.COMPILER_TREE) 527 public JCOpens visitOpens(OpensTree node, P p) { 528 JCOpens t = (JCOpens) node; 529 JCExpression qualId = copy(t.qualid, p); 530 List<JCExpression> moduleNames = copy(t.moduleNames, p); 531 return M.at(t.pos).Opens(qualId, moduleNames); 532 } 533 534 @Override @DefinedBy(Api.COMPILER_TREE) 535 public JCProvides visitProvides(ProvidesTree node, P p) { 536 JCProvides t = (JCProvides) node; 537 JCExpression serviceName = copy(t.serviceName, p); 538 List<JCExpression> implNames = copy(t.implNames, p); 539 return M.at(t.pos).Provides(serviceName, implNames); 540 } 541 542 @Override @DefinedBy(Api.COMPILER_TREE) 543 public JCRequires visitRequires(RequiresTree node, P p) { 544 JCRequires t = (JCRequires) node; 545 JCExpression moduleName = copy(t.moduleName, p); 546 return M.at(t.pos).Requires(t.isTransitive, t.isStaticPhase, moduleName); 547 } 548 549 @Override @DefinedBy(Api.COMPILER_TREE) 550 public JCUses visitUses(UsesTree node, P p) { 551 JCUses t = (JCUses) node; 552 JCExpression serviceName = copy(t.qualid, p); 553 return M.at(t.pos).Uses(serviceName); 554 } 555 556 @DefinedBy(Api.COMPILER_TREE) 557 public JCTree visitOther(Tree node, P p) { 558 JCTree tree = (JCTree) node; 559 switch (tree.getTag()) { 560 case LETEXPR: { 561 LetExpr t = (LetExpr) node; 562 List<JCVariableDecl> defs = copy(t.defs, p); 563 JCExpression expr = copy(t.expr, p); 564 return M.at(t.pos).LetExpr(defs, expr); 565 } 566 default: 567 throw new AssertionError("unknown tree tag: " + tree.getTag()); 568 } 569 } 570 571 }