Reviewers: pdr,

Description:
Fix a codegen bug for use of {0,localtime,predef:FOO}
format in Messages.

Patch by: jat
Review by: pdr


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

Affected files:
  M user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java
  M user/test/com/google/gwt/i18n/client/I18N2Test.java
  M user/test/com/google/gwt/i18n/client/TestAnnotatedMessages.java


Index: user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java
===================================================================
--- user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java (revision 9778) +++ user/src/com/google/gwt/i18n/rebind/MessagesMethodCreator.java (working copy)
@@ -433,7 +433,8 @@
           return true;
         }
         out.appendStringValuedExpression(
- dtFormatClassName + ".getFormat(" + PredefinedFormat.class.getName() + "."
+            dtFormatClassName + ".getFormat("
+                + PredefinedFormat.class.getCanonicalName() + "."
+ predef.toString() + ").format(" + argName + tzParam + ")");
         return false;
       }
Index: user/test/com/google/gwt/i18n/client/I18N2Test.java
===================================================================
--- user/test/com/google/gwt/i18n/client/I18N2Test.java (revision 9778)
+++ user/test/com/google/gwt/i18n/client/I18N2Test.java (working copy)
@@ -454,6 +454,13 @@
     assertEquals("nested underscore b", m.nestedUnderscore());
   }

+  @SuppressWarnings("deprecation")
+  public void testPredefDateFormat() {
+    TestAnnotatedMessages m = GWT.create(TestAnnotatedMessages.class);
+    Date date = new Date(Date.UTC(2010 - 1900, 1, 2, 3, 4, 5));
+    assertEquals("Short: 2010-02-01", m.predef(date));
+  }
+
   public void testSpecialPlurals() {
     TestAnnotatedMessages m = GWT.create(TestAnnotatedMessages.class);
     assertEquals("No widgets", m.specialPlurals(0));
Index: user/test/com/google/gwt/i18n/client/TestAnnotatedMessages.java
===================================================================
--- user/test/com/google/gwt/i18n/client/TestAnnotatedMessages.java (revision 9778) +++ user/test/com/google/gwt/i18n/client/TestAnnotatedMessages.java (working copy)
@@ -98,6 +98,9 @@

   @DefaultMessage("in timezone: {0,localdatetime:tz=$tz,yMd hms}")
   SafeHtml inTimezoneAsSafeHtml(Date date, @Optional TimeZone tz);
+
+  @DefaultMessage("Short: {0,localdatetime,predef:DATE_SHORT}")
+  String predef(Date date);

   @DefaultMessage("Once more, with meaning")
   @Meaning("Mangled quote")


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

Reply via email to