Reviewers: rjrjr,

Message:
On 2011/09/27 21:34:03, rjrjr wrote:
Thomas, if you still want this in can you make the me reviewer?

Well, your comment was enough to add you as a reviewer (and it removed
BobV at the same time).
I'll go through my other open reviews previously assigned to Bob, to
assign them to you.

Description:
See http://code.google.com/p/google-web-toolkit/issues/detail?id=6016

Please review this at http://gwt-code-reviews.appspot.com/1352806/

Affected files:
  M user/src/com/google/gwt/editor/rebind/AbstractEditorDriverGenerator.java
  M user/test/com/google/gwt/editor/client/SimpleBeanEditorTest.java


Index: user/src/com/google/gwt/editor/rebind/AbstractEditorDriverGenerator.java diff --git a/user/src/com/google/gwt/editor/rebind/AbstractEditorDriverGenerator.java b/user/src/com/google/gwt/editor/rebind/AbstractEditorDriverGenerator.java index e0c8b23e8a10c0b6d871af50cf134c9a260b86f0..4039f3cf8da5a608c944523b316cdd7389684f3c 100644 --- a/user/src/com/google/gwt/editor/rebind/AbstractEditorDriverGenerator.java +++ b/user/src/com/google/gwt/editor/rebind/AbstractEditorDriverGenerator.java @@ -94,22 +94,9 @@ public abstract class AbstractEditorDriverGenerator extends Generator { Map<EditorData, String> delegateFields = new IdentityHashMap<EditorData, String>();
     NameFactory nameFactory = new NameFactory();

-    /*
-     * The paramaterization of the editor type is included to ensure that a
-     * correct specialization of a CompositeEditor will be generated. For
-     * example, a ListEditor<Person, APersonEditor> would need a different
-     * delegate from a ListEditor<Person, AnotherPersonEditor>.
-     */
-    StringBuilder maybeParameterizedName = new StringBuilder(
-        BinaryName.getClassName(editor.getQualifiedBinaryName()));
-    if (editor.isParameterized() != null) {
-      for (JClassType type : editor.isParameterized().getTypeArgs()) {
- maybeParameterizedName.append("$").append(type.getQualifiedBinaryName());
-      }
-    }
     String delegateSimpleName = String.format(
         "%s_%s",
-        escapedBinaryName(maybeParameterizedName.toString()),
+        escapedMaybeParameterizedBinaryName(editor),
BinaryName.getShortClassName(Name.getBinaryNameForClass(getEditorDelegateType())));

     String packageName = editor.getPackage().getName();
@@ -230,8 +217,25 @@ public abstract class AbstractEditorDriverGenerator extends Generator { return binaryName.replace("_", "_1").replace('$', '_').replace('.', '_');
   }

+  private String escapedMaybeParameterizedBinaryName(JClassType editor) {
+    /*
+     * The parameterization of the editor type is included to ensure that a
+     * correct specialization of a CompositeEditor will be generated. For
+     * example, a ListEditor<Person, APersonEditor> would need a different
+     * delegate from a ListEditor<Person, AnotherPersonEditor>.
+     */
+    StringBuilder maybeParameterizedName = new StringBuilder(
+        BinaryName.getClassName(editor.getQualifiedBinaryName()));
+    if (editor.isParameterized() != null) {
+      for (JClassType type : editor.isParameterized().getTypeArgs()) {
+ maybeParameterizedName.append("$").append(type.getQualifiedBinaryName());
+      }
+    }
+    return escapedBinaryName(maybeParameterizedName.toString());
+  }
+
   /**
-   * Create an EditorContext implementation that will provide acess to
+   * Create an EditorContext implementation that will provide access to
* {@link data} owned by {@link parent}. In other words, given the EditorData * for a {@code PersonEditor} and the EditorData for a {@code AddressEditor}
    * nested in the {@code PersonEditor}, create an EditorContext that will
@@ -242,7 +246,8 @@ public abstract class AbstractEditorDriverGenerator extends Generator {
   private String getEditorContext(EditorData parent, EditorData data) {
     String pkg = parent.getEditorType().getPackage().getName();
     // PersonEditor_manager_name_Context
-    String simpleName = escapedBinaryName(parent.getEditorType().getName())
+    String simpleName =
+        escapedMaybeParameterizedBinaryName(parent.getEditorType())
         + "_" + data.getDeclaredPath().replace("_", "_1").replace(".", "_")
         + "_Context";

Index: user/test/com/google/gwt/editor/client/SimpleBeanEditorTest.java
diff --git a/user/test/com/google/gwt/editor/client/SimpleBeanEditorTest.java b/user/test/com/google/gwt/editor/client/SimpleBeanEditorTest.java index b6cd3cb9f7e4575e6e78d1d57bdbd9fe9192ec37..c03c60f875671f624e93c4fbe6ff31caf12b9385 100644
--- a/user/test/com/google/gwt/editor/client/SimpleBeanEditorTest.java
+++ b/user/test/com/google/gwt/editor/client/SimpleBeanEditorTest.java
@@ -57,6 +57,36 @@ public class SimpleBeanEditorTest extends GWTTestCase {
     }
   }

+  /**
+   * See <a
+ * href="http://code.google.com/p/google-web-toolkit/issues/detail?id=6016";
+   * >issue 6016</a>
+   */
+  static class EditorWithGenericSubEditors implements
+      Editor<EditorWithGenericSubEditors.HasPersons> {
+    interface Driver
+        extends
+        SimpleBeanEditorDriver<EditorWithGenericSubEditors.HasPersons,
+            EditorWithGenericSubEditors> {
+    }
+
+    static class SubPerson1 extends Person {
+    }
+    static class SubPerson2 extends Person {
+    }
+    static class HasPersons {
+      public SubPerson1 getPerson1() { return null; }
+      public SubPerson2 getPerson2() { return null; }
+    }
+    static class PersonEditor<T extends Person> implements Editor<T> {
+      SimpleEditor<String> name = SimpleEditor.of(UNINITIALIZED);
+    }
+
+    PersonEditor<SubPerson1> person1;
+
+    PersonEditor<SubPerson2> person2;
+  }
+
class LeafAddressEditor extends AddressEditor implements LeafValueEditor<Address> {
     /*
* These two fields are used to ensure that getValue() and setValue() aren't
@@ -348,6 +378,16 @@ public class SimpleBeanEditorTest extends GWTTestCase {
     assertEquals("manager.name", editor.managerName.delegate.getPath());
   }

+  /**
+   * See <a
+ * href="http://code.google.com/p/google-web-toolkit/issues/detail?id=6016";
+   * >issue 6016</a>
+   */
+  public void testEditorWithGenericSubEditors() {
+    EditorWithGenericSubEditors.Driver driver =
+        GWT.create(EditorWithGenericSubEditors.Driver.class);
+  }
+
   public void testEditorWithNullSubEditor() {
     PersonEditor editor = new PersonEditor();
     editor.addressEditor = null;


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to