Fix new instance on parenthesis

This commit is contained in:
jeffcheasey88 2023-05-10 08:39:01 +02:00
parent 5e3208c262
commit 0111df23f5
3 changed files with 8 additions and 11 deletions

View file

@ -30,12 +30,7 @@ public class JavaParser{
} }
public static void main(String[] args) throws Exception{ public static void main(String[] args) throws Exception{
String variable = "Collection collection = new ArrayList<String>() {\r\n" String variable = "Future future = {new Runnable()};";
+ " { add(\"1\");\r\n"
+ " add(\"2\");\r\n"
+ " add(\"3\");\r\n"
+ " }\r\n"
+ " };";
String clazz = "package test; public class Test{ "+variable+" }"; String clazz = "package test; public class Test{ "+variable+" }";
BufferedWriter writer = new BufferedWriter(new FileWriter(new File("/home/tmp.txt"))); BufferedWriter writer = new BufferedWriter(new FileWriter(new File("/home/tmp.txt")));

View file

@ -93,7 +93,9 @@ public class Variable {
private String generiqueTypes(String content, CleanerPool cleaner){ private String generiqueTypes(String content, CleanerPool cleaner){
System.out.println("generic "+content); System.out.println("generic "+content);
String unzip = cleaner.unzip(content, (value, pattern) -> { String unzip = cleaner.unzip(content, (value, pattern) -> {
return (pattern.equals("^GENERIC_FUNCTION")) ? null : value.replaceAll("\\s+", ""); if(pattern.equals("^GENERIC_FUNCTION")) return null;
if(pattern.equals("^GENERIC_PARENTHESIS")) return value.replace("\\s+", " ");
return value.replaceAll("\\s+", "");
}); });
System.out.println("unzip "+unzip); System.out.println("unzip "+unzip);
unzip = UNZIP_STICK.matcher(unzip).replaceAll("${e}"); unzip = UNZIP_STICK.matcher(unzip).replaceAll("${e}");