Revert the portion of r7378 that renames argument names in generated code.
Patch by: jat
Review by: rjrjr (TBR)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7385 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/i18n/rebind/LookupMethodCreator.java b/user/src/com/google/gwt/i18n/rebind/LookupMethodCreator.java
index c550087..a9a9dd7 100644
--- a/user/src/com/google/gwt/i18n/rebind/LookupMethodCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/LookupMethodCreator.java
@@ -17,7 +17,6 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.typeinfo.JMethod;
-import com.google.gwt.core.ext.typeinfo.JParameter;
import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.i18n.rebind.AbstractResource.ResourceList;
@@ -67,13 +66,7 @@
}
void createMethodFor(JMethod targetMethod) {
- JParameter[] args = targetMethod.getParameters();
- if (args.length != 1) {
- throw new IllegalStateException(
- "ConstantsWithLookup methods must have exactly one argument");
- }
- String arg0 = args[0].getName();
- String template = "{0} target = ({0}) cache.get(" + arg0 + ");";
+ String template = "{0} target = ({0}) cache.get(arg0);";
String returnTypeName = getReturnTypeName();
String lookup = MessageFormat.format(template, new Object[] {returnTypeName});
println(lookup);
@@ -88,7 +81,7 @@
if (methods[i].getReturnType().getErasedType().equals(erasedType)
&& methods[i] != targetMethod) {
String methodName = methods[i].getName();
- String body = "if(" + arg0 + ".equals(" + wrap(methodName) + ")) {";
+ String body = "if(arg0.equals(" + wrap(methodName) + ")) {";
println(body);
indent();
printFound(methodName);
@@ -98,7 +91,7 @@
}
String format = "throw new java.util.MissingResourceException(\"Cannot find constant ''\" +"
+ "{0} + \"''; expecting a method name\", \"{1}\", {0});";
- String result = MessageFormat.format(format, arg0,
+ String result = MessageFormat.format(format, "arg0",
this.currentCreator.getTarget().getQualifiedSourceName());
println(result);
}
diff --git a/user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java b/user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java
index a6725e2..a360356 100644
--- a/user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java
@@ -338,8 +338,7 @@
generated.append(PluralRule.class.getCanonicalName());
generated.append(" rule = new " + rule.getClass().getCanonicalName()
+ "();\n");
- generated.append("switch (rule.select("
- + params[pluralParamIndex].getName() + ")) {\n");
+ generated.append("switch (rule.select(arg" + pluralParamIndex + ")) {\n");
PluralForm[] pluralForms = rule.pluralForms();
resourceList.setPluralForms(key, pluralForms);
// Skip default plural form (index 0); the fall-through case will handle
@@ -371,8 +370,8 @@
if (!seenFlags[i]) {
Optional optional = params[i].getAnnotation(Optional.class);
if (optional == null) {
- throw error(logger, "Required argument " + params[i].getName()
- + " not present: " + template);
+ throw error(logger, "Required argument " + i + " not present: "
+ + template);
}
}
}
@@ -460,7 +459,7 @@
+ " beyond range of arguments: " + template);
}
seenFlag[argNumber] = true;
- String arg = params[argNumber].getName();
+ String arg = "arg" + argNumber;
String format = argChunk.getFormat();
if (format != null) {
String subformat = argChunk.getSubFormat();
diff --git a/user/src/com/google/gwt/user/rebind/AbstractGeneratorClassCreator.java b/user/src/com/google/gwt/user/rebind/AbstractGeneratorClassCreator.java
index 0790903..45e23c4 100644
--- a/user/src/com/google/gwt/user/rebind/AbstractGeneratorClassCreator.java
+++ b/user/src/com/google/gwt/user/rebind/AbstractGeneratorClassCreator.java
@@ -253,8 +253,8 @@
getWriter().print(",");
}
getWriter().print(
- params[i].getType().getParameterizedQualifiedSourceName() + " "
- + params[i].getName());
+ params[i].getType().getParameterizedQualifiedSourceName() + " arg"
+ + (i));
}
getWriter().println(") {");
getWriter().indent();