square/javawriter — pull request #22 by sgdheeban (2013-08-23 06:02:47+00:00)
Title: Suggestion: Minor Change to TYPE_PATTERN regex to accomodate .* type imports

Just a humble suggestion --

Currently, the TYPE_PATTERN uses a short name of * of types import xxx.yyy.* (Meaning, it assumes, full name is always used in imports)

- private static final Pattern TYPE_PATTERN = Pattern.compile("(?:[\\w$]+\\.)*([\\w\\.*$]+)");
+ private static final Pattern TYPE_PATTERN = Pattern.compile("(?:[\\w$]+\\.)*([\\w]+)(?:[\\.\\*$]*)");

So, I have modified the Pattern, so that, when we give xxx.yyy.*..it takes yyy as the base .. have also added unit tests....also, wrote a function to expose get short name as a utility to outside world..(in the future, we can collect many such utilities separately.)