Reviewers: jat,
Please review this at http://gwt-code-reviews.appspot.com/33838 Affected files: user/src/com/google/gwt/i18n/client/Dictionary.java user/test/com/google/gwt/i18n/client/I18NTest.java Index: user/src/com/google/gwt/i18n/client/Dictionary.java --- user/src/com/google/gwt/i18n/client/Dictionary.java (revision 1403) +++ user/src/com/google/gwt/i18n/client/Dictionary.java (working copy) @@ -102,6 +102,7 @@ public final class Dictionary { null, name); } + private JavaScriptObject accessedKeys; private JavaScriptObject dict; private String label; @@ -123,8 +124,13 @@ public final class Dictionary { "Cannot find JavaScript object with the name '" + name + "'", name, null); } + createAccessedKeysArray(); } + private native void createAccessedKeysArray() /*-{ + [email protected]::accessedKeys = new Array(); + }-*/; + /** * Get the value associated with the given Dictionary key. * @@ -138,6 +144,7 @@ public final class Dictionary { */ public native String get(String key) /*-{ var value = [email protected]::dict[key]; + [email protected]::accessedKeys.push(key); if (value == null || !Object.prototype.hasOwnProperty.call( [email protected]::dict, key)) { @@ -179,6 +186,7 @@ public final class Dictionary { if (s.size() < MAX_KEYS_TO_SHOW) { error += "\n keys found: " + s; } + error += "\n accessed keys: " + accessedKeys; throw new MissingResourceException(error, this.toString(), key); } Index: user/test/com/google/gwt/i18n/client/I18NTest.java --- user/test/com/google/gwt/i18n/client/I18NTest.java (revision 4905) +++ user/test/com/google/gwt/i18n/client/I18NTest.java (working copy) @@ -421,6 +421,13 @@ public class I18NTest extends GWTTestCase { assertTrue(s.contains("a")); assertTrue(s.contains("b")); assertFalse(s.contains("c")); + try { + d.get("nonExistentKey"); + fail("should have thrown a MissingResourceException"); + } catch (MissingResourceException ex) { + assertTrue(ex.getMessage(), ex.getMessage().indexOf( + "accessed keys: formattedMessage,d,nonExistentKey") != -1); + } Collection<String> s2 = d.values(); assertTrue(s2.contains("A")); assertTrue(s2.contains("B")); --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
