Enhance error messages generated by the RemoteServiceAsyncValidator to include parameterization of types. JPrimitiveType now has a getter for its boxed type. JParameter's toString() includes its parameterization. Patch by: mmastrac Review by: bobv git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2228 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/typeinfo/JParameter.java b/dev/core/src/com/google/gwt/core/ext/typeinfo/JParameter.java index 767cbea..cb964a9 100644 --- a/dev/core/src/com/google/gwt/core/ext/typeinfo/JParameter.java +++ b/dev/core/src/com/google/gwt/core/ext/typeinfo/JParameter.java
@@ -91,7 +91,7 @@ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append(type.getQualifiedSourceName()); + sb.append(type.getParameterizedQualifiedSourceName()); sb.append(" "); sb.append(getName()); return sb.toString();
diff --git a/dev/core/src/com/google/gwt/core/ext/typeinfo/JPrimitiveType.java b/dev/core/src/com/google/gwt/core/ext/typeinfo/JPrimitiveType.java index e743709..34582b5 100644 --- a/dev/core/src/com/google/gwt/core/ext/typeinfo/JPrimitiveType.java +++ b/dev/core/src/com/google/gwt/core/ext/typeinfo/JPrimitiveType.java
@@ -15,6 +15,8 @@ */ package com.google.gwt.core.ext.typeinfo; +import static com.google.gwt.core.ext.typeinfo.JniConstants.*; + import java.util.HashMap; import java.util.Map; @@ -22,23 +24,20 @@ * Represents a primitive type in a declaration. */ public class JPrimitiveType extends JType { - public static final JPrimitiveType BOOLEAN = create("boolean", - JniConstants.DESC_BOOLEAN); - public static final JPrimitiveType BYTE = create("byte", - JniConstants.DESC_BYTE); - public static final JPrimitiveType CHAR = create("char", - JniConstants.DESC_CHAR); - public static final JPrimitiveType DOUBLE = create("double", - JniConstants.DESC_DOUBLE); - public static final JPrimitiveType FLOAT = create("float", - JniConstants.DESC_FLOAT); - public static final JPrimitiveType INT = create("int", JniConstants.DESC_INT); - public static final JPrimitiveType LONG = create("long", - JniConstants.DESC_LONG); - public static final JPrimitiveType SHORT = create("short", - JniConstants.DESC_SHORT); - public static final JPrimitiveType VOID = create("void", - JniConstants.DESC_VOID); + public static final JPrimitiveType BOOLEAN = create("boolean", "Boolean", + DESC_BOOLEAN); + public static final JPrimitiveType BYTE = create("byte", "Byte", DESC_BYTE); + public static final JPrimitiveType CHAR = create("char", "Character", + DESC_CHAR); + public static final JPrimitiveType DOUBLE = create("double", "Double", + DESC_DOUBLE); + public static final JPrimitiveType FLOAT = create("float", "Float", + DESC_FLOAT); + public static final JPrimitiveType INT = create("int", "Integer", DESC_INT); + public static final JPrimitiveType LONG = create("long", "Long", DESC_LONG); + public static final JPrimitiveType SHORT = create("short", "Short", + DESC_SHORT); + public static final JPrimitiveType VOID = create("void", "Void", DESC_VOID); private static Map<String, JPrimitiveType> map; @@ -46,8 +45,9 @@ return getMap().get(typeName); } - private static JPrimitiveType create(String name, char jni) { - JPrimitiveType type = new JPrimitiveType(name, String.valueOf(jni)); + private static JPrimitiveType create(String name, String boxedName, char jni) { + JPrimitiveType type = new JPrimitiveType(name, boxedName, + String.valueOf(jni)); Object existing = getMap().put(name, type); assert (existing == null); return type; @@ -60,12 +60,15 @@ return map; } + private final String boxedName; + private final String jni; private final String name; - private JPrimitiveType(String name, String jni) { + private JPrimitiveType(String name, String boxedName, String jni) { this.name = name; + this.boxedName = boxedName; this.jni = jni; } @@ -79,6 +82,10 @@ return jni; } + public String getQualifiedBoxedSourceName() { + return "java.lang." + boxedName; + } + @Override public String getQualifiedSourceName() { return name; @@ -143,7 +150,7 @@ public String toString() { return name; } - + @Override JPrimitiveType getSubstitutedType(JParameterizedType parameterizedType) { return this;
diff --git a/user/src/com/google/gwt/user/rebind/rpc/RemoteServiceAsyncValidator.java b/user/src/com/google/gwt/user/rebind/rpc/RemoteServiceAsyncValidator.java index 93f53c0..2fa9811 100644 --- a/user/src/com/google/gwt/user/rebind/rpc/RemoteServiceAsyncValidator.java +++ b/user/src/com/google/gwt/user/rebind/rpc/RemoteServiceAsyncValidator.java
@@ -115,8 +115,15 @@ sb.append(", "); } + JType returnType = method.getReturnType(); sb.append(AsyncCallback.class.getName()); - sb.append(" arg"); + sb.append("<"); + if (returnType instanceof JPrimitiveType) { + sb.append(((JPrimitiveType) returnType).getQualifiedBoxedSourceName()); + } else { + sb.append(returnType.getParameterizedQualifiedSourceName()); + } + sb.append("> arg"); sb.append(Integer.toString(params.length + 1)); sb.append(");\n"); }