Fix new instance on parenthesis
This commit is contained in:
parent
5e3208c262
commit
0111df23f5
3 changed files with 8 additions and 11 deletions
|
@ -30,12 +30,7 @@ public class JavaParser{
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
String variable = "Collection collection = new ArrayList<String>() {\r\n"
|
||||
+ " { add(\"1\");\r\n"
|
||||
+ " add(\"2\");\r\n"
|
||||
+ " add(\"3\");\r\n"
|
||||
+ " }\r\n"
|
||||
+ " };";
|
||||
String variable = "Future future = {new Runnable()};";
|
||||
|
||||
String clazz = "package test; public class Test{ "+variable+" }";
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File("/home/tmp.txt")));
|
||||
|
|
|
@ -93,8 +93,10 @@ public class Variable {
|
|||
private String generiqueTypes(String content, CleanerPool cleaner){
|
||||
System.out.println("generic "+content);
|
||||
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);
|
||||
unzip = UNZIP_STICK.matcher(unzip).replaceAll("${e}");
|
||||
unzip = UNZIP_MAJ.matcher(unzip).replaceAll("> ${e}");
|
||||
|
|
|
@ -210,7 +210,7 @@ class VariableTest{
|
|||
assertEquals(0, variable.getModifier());
|
||||
assertEquals("java.util.function.Function<Integer,Integer>", variable.getType());
|
||||
assertEquals("j", variable.getName());
|
||||
assertEquals("((i)-> {return 4;})", ((Value)variable.getValue()).value());
|
||||
assertEquals("((i) -> {return 4;})", ((Value)variable.getValue()).value());
|
||||
}catch(Exception e){
|
||||
fail(e);
|
||||
}
|
||||
|
@ -263,13 +263,13 @@ class VariableTest{
|
|||
assertEquals(JavaParser.getModifier("private"), variable.getModifier());
|
||||
assertEquals("java.util.function.Function<Integer,Integer>", variable.getType());
|
||||
assertEquals("j", variable.getName());
|
||||
assertEquals("((i)-> {return 4;})", ((Value)variable.getValue()).value());
|
||||
assertEquals("((i) -> {return 4;})", ((Value)variable.getValue()).value());
|
||||
|
||||
variable = vars.get(1);
|
||||
assertEquals(JavaParser.getModifier("private"), variable.getModifier());
|
||||
assertEquals("java.util.function.Function<Integer,Integer>", variable.getType());
|
||||
assertEquals("k", variable.getName());
|
||||
assertEquals("((i)->4)", ((Value)variable.getValue()).value());
|
||||
assertEquals("((i) -> 4)", ((Value)variable.getValue()).value());
|
||||
}catch(Exception e){
|
||||
fail(e);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue