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 | /* |
duke@1 | 2 | * Copyright 2001-2006 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.tools.javac.util.*; |
duke@1 | 29 | import com.sun.tools.javac.tree.JCTree.*; |
duke@1 | 30 | |
duke@1 | 31 | /** A subclass of Tree.Visitor, this class defines |
duke@1 | 32 | * a general tree scanner pattern. Translation proceeds recursively in |
duke@1 | 33 | * left-to-right order down a tree. There is one visitor method in this class |
duke@1 | 34 | * for every possible kind of tree node. To obtain a specific |
duke@1 | 35 | * scanner, it suffices to override those visitor methods which |
duke@1 | 36 | * do some interesting work. The scanner class itself takes care of all |
duke@1 | 37 | * navigational aspects. |
duke@1 | 38 | * |
duke@1 | 39 | * <p><b>This is NOT part of any API supported by Sun Microsystems. If |
duke@1 | 40 | * you write code that depends on this, you do so at your own risk. |
duke@1 | 41 | * This code and its internal interfaces are subject to change or |
duke@1 | 42 | * deletion without notice.</b> |
duke@1 | 43 | */ |
duke@1 | 44 | public class TreeScanner extends Visitor { |
duke@1 | 45 | |
duke@1 | 46 | /** Visitor method: Scan a single node. |
duke@1 | 47 | */ |
duke@1 | 48 | public void scan(JCTree tree) { |
duke@1 | 49 | if(tree!=null) tree.accept(this); |
duke@1 | 50 | } |
duke@1 | 51 | |
duke@1 | 52 | /** Visitor method: scan a list of nodes. |
duke@1 | 53 | */ |
duke@1 | 54 | public void scan(List<? extends JCTree> trees) { |
duke@1 | 55 | if (trees != null) |
duke@1 | 56 | for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) |
duke@1 | 57 | scan(l.head); |
duke@1 | 58 | } |
duke@1 | 59 | |
duke@1 | 60 | |
duke@1 | 61 | /* *************************************************************************** |
duke@1 | 62 | * Visitor methods |
duke@1 | 63 | ****************************************************************************/ |
duke@1 | 64 | |
duke@1 | 65 | public void visitTopLevel(JCCompilationUnit tree) { |
duke@1 | 66 | scan(tree.packageAnnotations); |
duke@1 | 67 | scan(tree.pid); |
duke@1 | 68 | scan(tree.defs); |
duke@1 | 69 | } |
duke@1 | 70 | |
duke@1 | 71 | public void visitImport(JCImport tree) { |
duke@1 | 72 | scan(tree.qualid); |
duke@1 | 73 | } |
duke@1 | 74 | |
duke@1 | 75 | public void visitClassDef(JCClassDecl tree) { |
duke@1 | 76 | scan(tree.mods); |
duke@1 | 77 | scan(tree.typarams); |
duke@1 | 78 | scan(tree.extending); |
duke@1 | 79 | scan(tree.implementing); |
duke@1 | 80 | scan(tree.defs); |
duke@1 | 81 | } |
duke@1 | 82 | |
duke@1 | 83 | public void visitMethodDef(JCMethodDecl tree) { |
duke@1 | 84 | scan(tree.mods); |
duke@1 | 85 | scan(tree.restype); |
duke@1 | 86 | scan(tree.typarams); |
duke@1 | 87 | scan(tree.params); |
duke@1 | 88 | scan(tree.thrown); |
duke@1 | 89 | scan(tree.body); |
duke@1 | 90 | } |
duke@1 | 91 | |
duke@1 | 92 | public void visitVarDef(JCVariableDecl tree) { |
duke@1 | 93 | scan(tree.mods); |
duke@1 | 94 | scan(tree.vartype); |
duke@1 | 95 | scan(tree.init); |
duke@1 | 96 | } |
duke@1 | 97 | |
duke@1 | 98 | public void visitSkip(JCSkip tree) { |
duke@1 | 99 | } |
duke@1 | 100 | |
duke@1 | 101 | public void visitBlock(JCBlock tree) { |
duke@1 | 102 | scan(tree.stats); |
duke@1 | 103 | } |
duke@1 | 104 | |
duke@1 | 105 | public void visitDoLoop(JCDoWhileLoop tree) { |
duke@1 | 106 | scan(tree.body); |
duke@1 | 107 | scan(tree.cond); |
duke@1 | 108 | } |
duke@1 | 109 | |
duke@1 | 110 | public void visitWhileLoop(JCWhileLoop tree) { |
duke@1 | 111 | scan(tree.cond); |
duke@1 | 112 | scan(tree.body); |
duke@1 | 113 | } |
duke@1 | 114 | |
duke@1 | 115 | public void visitForLoop(JCForLoop tree) { |
duke@1 | 116 | scan(tree.init); |
duke@1 | 117 | scan(tree.cond); |
duke@1 | 118 | scan(tree.step); |
duke@1 | 119 | scan(tree.body); |
duke@1 | 120 | } |
duke@1 | 121 | |
duke@1 | 122 | public void visitForeachLoop(JCEnhancedForLoop tree) { |
duke@1 | 123 | scan(tree.var); |
duke@1 | 124 | scan(tree.expr); |
duke@1 | 125 | scan(tree.body); |
duke@1 | 126 | } |
duke@1 | 127 | |
duke@1 | 128 | public void visitLabelled(JCLabeledStatement tree) { |
duke@1 | 129 | scan(tree.body); |
duke@1 | 130 | } |
duke@1 | 131 | |
duke@1 | 132 | public void visitSwitch(JCSwitch tree) { |
duke@1 | 133 | scan(tree.selector); |
duke@1 | 134 | scan(tree.cases); |
duke@1 | 135 | } |
duke@1 | 136 | |
duke@1 | 137 | public void visitCase(JCCase tree) { |
duke@1 | 138 | scan(tree.pat); |
duke@1 | 139 | scan(tree.stats); |
duke@1 | 140 | } |
duke@1 | 141 | |
duke@1 | 142 | public void visitSynchronized(JCSynchronized tree) { |
duke@1 | 143 | scan(tree.lock); |
duke@1 | 144 | scan(tree.body); |
duke@1 | 145 | } |
duke@1 | 146 | |
duke@1 | 147 | public void visitTry(JCTry tree) { |
duke@1 | 148 | scan(tree.body); |
duke@1 | 149 | scan(tree.catchers); |
duke@1 | 150 | scan(tree.finalizer); |
duke@1 | 151 | } |
duke@1 | 152 | |
duke@1 | 153 | public void visitCatch(JCCatch tree) { |
duke@1 | 154 | scan(tree.param); |
duke@1 | 155 | scan(tree.body); |
duke@1 | 156 | } |
duke@1 | 157 | |
duke@1 | 158 | public void visitConditional(JCConditional tree) { |
duke@1 | 159 | scan(tree.cond); |
duke@1 | 160 | scan(tree.truepart); |
duke@1 | 161 | scan(tree.falsepart); |
duke@1 | 162 | } |
duke@1 | 163 | |
duke@1 | 164 | public void visitIf(JCIf tree) { |
duke@1 | 165 | scan(tree.cond); |
duke@1 | 166 | scan(tree.thenpart); |
duke@1 | 167 | scan(tree.elsepart); |
duke@1 | 168 | } |
duke@1 | 169 | |
duke@1 | 170 | public void visitExec(JCExpressionStatement tree) { |
duke@1 | 171 | scan(tree.expr); |
duke@1 | 172 | } |
duke@1 | 173 | |
duke@1 | 174 | public void visitBreak(JCBreak tree) { |
duke@1 | 175 | } |
duke@1 | 176 | |
duke@1 | 177 | public void visitContinue(JCContinue tree) { |
duke@1 | 178 | } |
duke@1 | 179 | |
duke@1 | 180 | public void visitReturn(JCReturn tree) { |
duke@1 | 181 | scan(tree.expr); |
duke@1 | 182 | } |
duke@1 | 183 | |
duke@1 | 184 | public void visitThrow(JCThrow tree) { |
duke@1 | 185 | scan(tree.expr); |
duke@1 | 186 | } |
duke@1 | 187 | |
duke@1 | 188 | public void visitAssert(JCAssert tree) { |
duke@1 | 189 | scan(tree.cond); |
duke@1 | 190 | scan(tree.detail); |
duke@1 | 191 | } |
duke@1 | 192 | |
duke@1 | 193 | public void visitApply(JCMethodInvocation tree) { |
duke@1 | 194 | scan(tree.meth); |
duke@1 | 195 | scan(tree.args); |
duke@1 | 196 | } |
duke@1 | 197 | |
duke@1 | 198 | public void visitNewClass(JCNewClass tree) { |
duke@1 | 199 | scan(tree.encl); |
duke@1 | 200 | scan(tree.clazz); |
duke@1 | 201 | scan(tree.args); |
duke@1 | 202 | scan(tree.def); |
duke@1 | 203 | } |
duke@1 | 204 | |
duke@1 | 205 | public void visitNewArray(JCNewArray tree) { |
duke@1 | 206 | scan(tree.elemtype); |
duke@1 | 207 | scan(tree.dims); |
duke@1 | 208 | scan(tree.elems); |
duke@1 | 209 | } |
duke@1 | 210 | |
duke@1 | 211 | public void visitParens(JCParens tree) { |
duke@1 | 212 | scan(tree.expr); |
duke@1 | 213 | } |
duke@1 | 214 | |
duke@1 | 215 | public void visitAssign(JCAssign tree) { |
duke@1 | 216 | scan(tree.lhs); |
duke@1 | 217 | scan(tree.rhs); |
duke@1 | 218 | } |
duke@1 | 219 | |
duke@1 | 220 | public void visitAssignop(JCAssignOp tree) { |
duke@1 | 221 | scan(tree.lhs); |
duke@1 | 222 | scan(tree.rhs); |
duke@1 | 223 | } |
duke@1 | 224 | |
duke@1 | 225 | public void visitUnary(JCUnary tree) { |
duke@1 | 226 | scan(tree.arg); |
duke@1 | 227 | } |
duke@1 | 228 | |
duke@1 | 229 | public void visitBinary(JCBinary tree) { |
duke@1 | 230 | scan(tree.lhs); |
duke@1 | 231 | scan(tree.rhs); |
duke@1 | 232 | } |
duke@1 | 233 | |
duke@1 | 234 | public void visitTypeCast(JCTypeCast tree) { |
duke@1 | 235 | scan(tree.clazz); |
duke@1 | 236 | scan(tree.expr); |
duke@1 | 237 | } |
duke@1 | 238 | |
duke@1 | 239 | public void visitTypeTest(JCInstanceOf tree) { |
duke@1 | 240 | scan(tree.expr); |
duke@1 | 241 | scan(tree.clazz); |
duke@1 | 242 | } |
duke@1 | 243 | |
duke@1 | 244 | public void visitIndexed(JCArrayAccess tree) { |
duke@1 | 245 | scan(tree.indexed); |
duke@1 | 246 | scan(tree.index); |
duke@1 | 247 | } |
duke@1 | 248 | |
duke@1 | 249 | public void visitSelect(JCFieldAccess tree) { |
duke@1 | 250 | scan(tree.selected); |
duke@1 | 251 | } |
duke@1 | 252 | |
duke@1 | 253 | public void visitIdent(JCIdent tree) { |
duke@1 | 254 | } |
duke@1 | 255 | |
duke@1 | 256 | public void visitLiteral(JCLiteral tree) { |
duke@1 | 257 | } |
duke@1 | 258 | |
duke@1 | 259 | public void visitTypeIdent(JCPrimitiveTypeTree tree) { |
duke@1 | 260 | } |
duke@1 | 261 | |
duke@1 | 262 | public void visitTypeArray(JCArrayTypeTree tree) { |
duke@1 | 263 | scan(tree.elemtype); |
duke@1 | 264 | } |
duke@1 | 265 | |
duke@1 | 266 | public void visitTypeApply(JCTypeApply tree) { |
duke@1 | 267 | scan(tree.clazz); |
duke@1 | 268 | scan(tree.arguments); |
duke@1 | 269 | } |
duke@1 | 270 | |
duke@1 | 271 | public void visitTypeParameter(JCTypeParameter tree) { |
duke@1 | 272 | scan(tree.bounds); |
duke@1 | 273 | } |
duke@1 | 274 | |
duke@1 | 275 | @Override |
duke@1 | 276 | public void visitWildcard(JCWildcard tree) { |
duke@1 | 277 | scan(tree.kind); |
duke@1 | 278 | if (tree.inner != null) |
duke@1 | 279 | scan(tree.inner); |
duke@1 | 280 | } |
duke@1 | 281 | |
duke@1 | 282 | @Override |
duke@1 | 283 | public void visitTypeBoundKind(TypeBoundKind that) { |
duke@1 | 284 | } |
duke@1 | 285 | |
duke@1 | 286 | public void visitModifiers(JCModifiers tree) { |
duke@1 | 287 | scan(tree.annotations); |
duke@1 | 288 | } |
duke@1 | 289 | |
duke@1 | 290 | public void visitAnnotation(JCAnnotation tree) { |
duke@1 | 291 | scan(tree.annotationType); |
duke@1 | 292 | scan(tree.args); |
duke@1 | 293 | } |
duke@1 | 294 | |
duke@1 | 295 | public void visitErroneous(JCErroneous tree) { |
duke@1 | 296 | } |
duke@1 | 297 | |
duke@1 | 298 | public void visitLetExpr(LetExpr tree) { |
duke@1 | 299 | scan(tree.defs); |
duke@1 | 300 | scan(tree.expr); |
duke@1 | 301 | } |
duke@1 | 302 | |
duke@1 | 303 | public void visitTree(JCTree tree) { |
duke@1 | 304 | assert false; |
duke@1 | 305 | } |
duke@1 | 306 | } |