Fix bug in InterfaceGenerator. If a constant name contains words starting with a numeral (e.g DEF_1), the InterfaceGenerator generates a method with the constant name in camel lower case to access the constant (def1()) The CssRessourceGenerator is not able to match the method with the constant afterwards. Change-Id: I6469b793cc6372b7e0e2dfa2441c1d8779bbb567 Bug-Link: https://github.com/gwtproject/gwt/issues/9401
diff --git a/user/src/com/google/gwt/resources/css/InterfaceGenerator.java b/user/src/com/google/gwt/resources/css/InterfaceGenerator.java index 434cdb3..9e1fa9f 100644 --- a/user/src/com/google/gwt/resources/css/InterfaceGenerator.java +++ b/user/src/com/google/gwt/resources/css/InterfaceGenerator.java
@@ -306,7 +306,21 @@ return Lists.newArrayList(Iterables.transform(constantsNames, new Function<String, String>() { @Override public String apply(String constantName) { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, constantName); + String lowerCase = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, constantName); + + // If we cannot revert the method name to the original constant name, use the + // original constant name. + // This case happens when number are used after an underscore: + // CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "DEF_1") returns def1 + // but CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, "def1") returns DEF1 and the + // GssResourceGenerator is not able to match the name of the method with the name of the + // constant . + if (!constantName.equals(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, + lowerCase))) { + return constantName; + } + + return lowerCase; } })); }