}
private static void processEnum(List<String> lines, String indent, int startIndex, String qualifiedName, String simpleName)
{
String newIndent = indent + " ";
Pattern enumEntry = Pattern.compile(newIndent + ENUM_ENTRY_REGEX);
Pattern constructor = Pattern.compile(newIndent + String.format(CONSTRUCTOR_REGEX, simpleName));
Pattern constructorCall = Pattern.compile(newIndent + " " + CONSTRUCTOR_CALL_REGEX);
String formatted = newIndent + String.format(VALUE_FIELD_REGEX, qualifiedName, qualifiedName);
Pattern valueField = Pattern.compile(formatted);
String newLine;
boolean prevSynthetic = false;
for (int i = startIndex; i < lines.size(); i++)
{
newLine = null;
String line = lines.get(i);
// find and replace enum entries
Matcher matcher = enumEntry.matcher(line);
if (matcher.find())
{
String body = matcher.group("body");
newLine = newIndent + matcher.group("name");
if (!Strings.isNullOrEmpty(body))
{
String[] args = body.split(", ");
if (line.endsWith("{"))
{
if (args[args.length - 1].equals("null"))
{
args = Arrays.copyOf(args, args.length - 1);
}
}
body = Joiner.on(", ").join(args);
}
if (Strings.isNullOrEmpty(body))
newLine += matcher.group("end");
else
newLine += "(" + body + ")" + matcher.group("end");
}
// find and replace constructor
matcher = constructor.matcher(line);
if (matcher.find())
{
StringBuilder tmp = new StringBuilder();
tmp.append(newIndent).append(matcher.group("modifiers")).append(simpleName).append("(");
String[] args = matcher.group("parameters").split(", ");
for(int x = 2; x < args.length; x++)
tmp.append(args[x]).append(x < args.length - 1 ? ", " : "");
tmp.append(")");
tmp.append(matcher.group("end"));
newLine = tmp.toString();
if (args.length <= 2 && newLine.endsWith("}"))
newLine = "";
}
// find constructor calls...
matcher = constructorCall.matcher(line);
if (matcher.find())
{
String body = matcher.group("body");
if (!Strings.isNullOrEmpty(body))
{
String[] args = body.split(", ");
args = Arrays.copyOfRange(args, 2, args.length);
body = Joiner.on(", ").join(args);
}
newLine = newIndent + " " + matcher.group("name") + "(" + body + ")" + matcher.group("end");
}
if (prevSynthetic)
{
matcher = valueField.matcher(line);
if (matcher.find())
newLine = "";
}
if (line.contains("// $FF: synthetic field"))