Start Operation (return & call method valid)

This commit is contained in:
jeffcheasey88 2023-05-29 21:41:17 +02:00
parent 86e326db87
commit 77f075abdc
6 changed files with 478 additions and 286 deletions

View file

@ -8,9 +8,13 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool.Cleaner; import be.jeffcheasey88.peeratcode.parser.java.CleanerPool.Cleaner;
import be.jeffcheasey88.peeratcode.parser.java.Variable.MultipleDeclaratedVariable;
import be.jeffcheasey88.peeratcode.parser.java.operations.OperationFactory;
public class Function extends JavaElement{ public class Function extends JavaElement{
private static OperationFactory FACTORY = new OperationFactory();
private static Pattern PATTERN = Pattern.compile("^(\\s*([^(]*)\\(([^)]*)\\)\\s*([^{]*)\\{)(.*)$"); private static Pattern PATTERN = Pattern.compile("^(\\s*([^(]*)\\(([^)]*)\\)\\s*([^{]*)\\{)(.*)$");
private int modifier; private int modifier;
@ -88,8 +92,40 @@ public class Function extends JavaElement{
}while(quote); }while(quote);
} }
private void body(String content, CleanerPool cleaner) throws Exception{ private void body(String content, CleanerPool cleaner) throws Exception{
System.out.println("BODY "+content); while(!(content.replaceAll("\\s+", "").isEmpty())){
System.out.println("BODY "+content);
JavaElement operation = FACTORY.buildOperation(content);
System.out.println("got "+operation.getClass().getSimpleName());
int index = operation.parse(content, cleaner);
content = content.substring(index);
if(operation instanceof Variable){
if(content.startsWith(",")){
Variable variable = (Variable)operation;
MultipleDeclaratedVariable multiple = new MultipleDeclaratedVariable(variable.getModifier(), variable.getType());
multiple.addVariable(variable.getName(), variable.getValue());
operation = multiple;
boolean quote;
do{
variable = new Variable(variable.getModifier(), variable.getType());
index = variable.parse(content, cleaner);
multiple.addVariable(variable.getName(), variable.getValue());
content = content.substring(index);
quote = content.startsWith(",");
content = content.substring(1);
}while(quote);
}else content = content.substring(1);
}
this.childs.add(operation);
}
} }
public void show(int tab){ public void show(int tab){
@ -99,6 +135,7 @@ public class Function extends JavaElement{
for(Variable v : this.parameters) param+=","+v.getType()+" "+v.getName()+""; for(Variable v : this.parameters) param+=","+v.getType()+" "+v.getName()+"";
if(!param.isEmpty()) param = param.substring(1); if(!param.isEmpty()) param = param.substring(1);
System.out.println(start+Modifier.toString(modifier)+" "+returnType+" "+name+"("+param+") "+exceptions+"{"); System.out.println(start+Modifier.toString(modifier)+" "+returnType+" "+name+"("+param+") "+exceptions+"{");
for(JavaElement child : this.childs) child.show(tab+1);
System.out.println(start+"}"); System.out.println(start+"}");
} }
} }

View file

@ -16,7 +16,7 @@ public class Variable extends JavaElement{
private int modifier; private int modifier;
private String name; private String name;
private String type; private String type;
private Variable value; private Variable value; //Change into operation
public Variable(){} public Variable(){}

View file

@ -0,0 +1,35 @@
package be.jeffcheasey88.peeratcode.parser.java.operations;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool;
import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
public class MethodCallOperation extends JavaElement{
private static Pattern PATTERN = Pattern.compile("^(\\s*([^\\(]*\\([^\\)]*\\));).*$");
private String value;
public MethodCallOperation(){}
@Override
public int parse(String content, CleanerPool cleaner) throws Exception{
Matcher matcher = PATTERN.matcher(content);
matcher.matches();
this.value = matcher.group(2);
return matcher.group(1).length();
}
@Override
public void show(int tab){
String start = "";
for(int i = 0; i < tab; i++) start+="\t";
System.out.println(start+value+";");
}
}

View file

@ -0,0 +1,86 @@
package be.jeffcheasey88.peeratcode.parser.java.operations;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool;
import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
import be.jeffcheasey88.peeratcode.parser.java.Variable;
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool.Cleaner;
public class OperationFactory{
private Map<Pattern, Class<? extends JavaElement>> patterns;
public OperationFactory(){
this.patterns = new LinkedHashMap<>();
this.patterns.put(Pattern.compile("^\\s*return\\s+[^;]*;.*$"), ReturnOperation.class);
this.patterns.put(Pattern.compile("^\\s*([^;=]*;).*$"), MethodCallOperation.class);
//if not types ??
this.patterns.put(Pattern.compile("^\\s*[^\\s]*\\s+[^\\s]*\\s+=\\s+[^\\s]*;.*$"), Variable.class);
}
/*
* variable
* assignation
* exec method
* for
* do while
* while
* if
* switch case
* return
* continue
* break
* try catch finally
* throw
* else
* synchronized
* instance of
*
* native operation style i++
*
* assert ??
* Goto ??
*/
public JavaElement buildOperation(String content) throws Exception{
CleanerPool generic = new CleanerPool(
new Cleaner("GENERIC_TYPE_",'<','>'),
new Cleaner("GENERIC_ARRAY",'[',']'),
new Cleaner("GENERIC_FUNCTION", '{','}'),
new Cleaner("GENERIC_PARENTHESIS",'(',')'));
content = generic.clean(content);
generiqueTypes(content, generic);
for(Entry<Pattern, Class<? extends JavaElement>> entries : this.patterns.entrySet()){
if(entries.getKey().matcher(content).matches()) return entries.getValue().newInstance();
}
return null;
}
private static Pattern UNZIP_STICK = Pattern.compile("\\s+(?<e>[<|(|\\[|\"|'])");
private static Pattern UNZIP_MAJ = Pattern.compile(">(?<e>[^>\\d,;(])");
private static Pattern UNZIP_ARRAY = Pattern.compile("](?<e>[^\\[\\d,;])");
private static Pattern UNZIP_EQUALS_LEFT = Pattern.compile("(?<e>[^=\\s])=");
private static Pattern UNZIP_EQUALS_RIGHT = Pattern.compile("=(?<e>[^=\\s])");
private String generiqueTypes(String content, CleanerPool cleaner){
String unzip = cleaner.unzip(content, (value, pattern) -> {
if(pattern.equals("^GENERIC_FUNCTION")) return null;
if(pattern.equals("^GENERIC_PARENTHESIS")) return value.replace("\\s+", " ");
return value.replaceAll("\\s+", "");
});
unzip = UNZIP_STICK.matcher(unzip).replaceAll("${e}");
unzip = UNZIP_MAJ.matcher(unzip).replaceAll("> ${e}");
unzip = UNZIP_ARRAY.matcher(unzip).replaceAll("] ${e}");
unzip = UNZIP_EQUALS_LEFT.matcher(unzip).replaceAll("${e} =");
unzip = UNZIP_EQUALS_RIGHT.matcher(unzip).replaceAll("= ${e}");
return unzip;
}
}

View file

@ -0,0 +1,34 @@
package be.jeffcheasey88.peeratcode.parser.java.operations;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool;
import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
public class ReturnOperation extends JavaElement{
private static Pattern PATTERN = Pattern.compile("^(\\s*return\\s+([^;]*);)\\s*$");
private String value;
public ReturnOperation(){}
@Override
public int parse(String content, CleanerPool cleaner) throws Exception{
Matcher matcher = PATTERN.matcher(content);
matcher.matches();
this.value = matcher.group(2);
return matcher.group(1).length();
}
@Override
public void show(int tab){
String start = "";
for(int i = 0; i < tab; i++) start+="\t";
System.out.println(start+"return "+value+";");
}
}

View file

@ -26,295 +26,295 @@ class VariableTest{
//Test<Test,K,L> j = new Test().schedule(p -> { return true;}); //Test<Test,K,L> j = new Test().schedule(p -> { return true;});
//int i =j=k=l=4; //int i =j=k=l=4;
private CleanerPool cleaner; // private CleanerPool cleaner;
//
@BeforeAll // @BeforeAll
void init(){ // void init(){
this.cleaner = new CleanerPool(); // this.cleaner = new CleanerPool();
} // }
//
@Test // @Test
void case1(){ // void case1(){
try { // try {
Variable variable = new Variable(); // Variable variable = new Variable();
variable.parse(cleaner.clean(" int i = 4 ; "), cleaner); // variable.parse(cleaner.clean(" int i = 4 ; "), cleaner);
//
assertEquals(0, variable.getModifier()); // assertEquals(0, variable.getModifier());
assertEquals("int", variable.getType()); // assertEquals("int", variable.getType());
assertEquals("i", variable.getName()); // assertEquals("i", variable.getName());
assertEquals("4", ((Value)variable.getValue()).value()); // assertEquals("4", ((Value)variable.getValue()).value());
}catch(Exception e){ // }catch(Exception e){
fail(e); // fail(e);
} // }
} // }
//
@Test // @Test
void case2(){ // void case2(){
try { // try {
Variable variable = new Variable(); // Variable variable = new Variable();
variable.parse(cleaner.clean("public static int l ; "), cleaner); // variable.parse(cleaner.clean("public static int l ; "), cleaner);
//
assertEquals(JavaParser.getModifier("public")+JavaParser.getModifier("static"), variable.getModifier()); // assertEquals(JavaParser.getModifier("public")+JavaParser.getModifier("static"), variable.getModifier());
assertEquals("int", variable.getType()); // assertEquals("int", variable.getType());
assertEquals("l", variable.getName()); // assertEquals("l", variable.getName());
assertNull(variable.getValue()); // assertNull(variable.getValue());
}catch(Exception e){ // }catch(Exception e){
fail(e); // fail(e);
} // }
} // }
//
@Test // @Test
void case3(){ // void case3(){
try { // try {
Variable variable = new Variable(); // Variable variable = new Variable();
variable.parse(cleaner.clean(" int lm ; "), cleaner); // variable.parse(cleaner.clean(" int lm ; "), cleaner);
//
assertEquals(0, variable.getModifier()); // assertEquals(0, variable.getModifier());
assertEquals("int", variable.getType()); // assertEquals("int", variable.getType());
assertEquals("lm", variable.getName()); // assertEquals("lm", variable.getName());
assertNull(variable.getValue()); // assertNull(variable.getValue());
}catch(Exception e){ // }catch(Exception e){
fail(e); // fail(e);
} // }
} // }
//
@Test // @Test
void case4(){ // void case4(){
try { // try {
Variable variable = new Variable(); // Variable variable = new Variable();
variable.parse(cleaner.clean("Test0< List< Map< Test1, List< Test2 >, Test3>> >t; "), cleaner); // variable.parse(cleaner.clean("Test0< List< Map< Test1, List< Test2 >, Test3>> >t; "), cleaner);
//
assertEquals(0, variable.getModifier()); // assertEquals(0, variable.getModifier());
assertEquals("Test0<List<Map<Test1,List<Test2>,Test3>>>", variable.getType()); // assertEquals("Test0<List<Map<Test1,List<Test2>,Test3>>>", variable.getType());
assertEquals("t", variable.getName()); // assertEquals("t", variable.getName());
assertNull(variable.getValue()); // assertNull(variable.getValue());
}catch(Exception e){ // }catch(Exception e){
fail(e); // fail(e);
} // }
} // }
//
@Test // @Test
void case5(){ // void case5(){
try { // try {
Variable variable = new Variable(); // Variable variable = new Variable();
variable.parse(cleaner.clean(" int i,j,k,l=1; "), cleaner); // variable.parse(cleaner.clean(" int i,j,k,l=1; "), cleaner);
//
assertEquals(0, variable.getModifier()); // assertEquals(0, variable.getModifier());
assertEquals("int", variable.getType()); // assertEquals("int", variable.getType());
assertEquals("i", variable.getName()); // assertEquals("i", variable.getName());
assertNull(variable.getValue()); // assertNull(variable.getValue());
}catch(Exception e){ // }catch(Exception e){
fail(e); // fail(e);
} // }
} // }
//
@Test // @Test
void case6(){ // void case6(){
try { // try {
Class clazz = new Class(); // Class clazz = new Class();
clazz.parse(cleaner.clean("public class Test{ int i ,j,k,l=1; } "), cleaner); // clazz.parse(cleaner.clean("public class Test{ int i ,j,k,l=1; } "), cleaner);
//
List<Variable> vars = clazz.getVariables(); // List<Variable> vars = clazz.getVariables();
assertEquals(1, vars.size()); // assertEquals(1, vars.size());
//
Variable v = vars.get(0); // Variable v = vars.get(0);
assertEquals(0, v.getModifier());
assertEquals("int", v.getType());
// for(int i = 0; i < 3; i++){
// Variable v = vars.get(i);
// assertEquals(0, v.getModifier());
// assertEquals("int", v.getType());
// assertEquals((char)('i'+i), v.getName().charAt(0));
// assertNull(v.getValue());
// }
// Variable v = vars.get(3);
// assertEquals(0, v.getModifier()); // assertEquals(0, v.getModifier());
// assertEquals("int", v.getType()); // assertEquals("int", v.getType());
// assertEquals('l', v.getName().charAt(0)); //// for(int i = 0; i < 3; i++){
// assertEquals("1", ((Value)v.getValue()).value()); //// Variable v = vars.get(i);
}catch(Exception e){ //// assertEquals(0, v.getModifier());
fail(e); //// assertEquals("int", v.getType());
} //// assertEquals((char)('i'+i), v.getName().charAt(0));
} //// assertNull(v.getValue());
//// }
@Test //// Variable v = vars.get(3);
void case7(){ //// assertEquals(0, v.getModifier());
try { //// assertEquals("int", v.getType());
Class clazz = new Class(); //// assertEquals('l', v.getName().charAt(0));
clazz.parse(cleaner.clean("public class Test{ int i ,j,k; int l=i=k=l=4; } "), new CleanerPool()); //// assertEquals("1", ((Value)v.getValue()).value());
// }catch(Exception e){
List<Variable> vars = clazz.getVariables(); // fail(e);
assertEquals(2, vars.size()); // }
Variable v = vars.get(0); // }
assertEquals(0, v.getModifier()); //
assertEquals("int", v.getType()); // @Test
// for(int i = 0; i < 4; i++){ // void case7(){
// Variable v = vars.get(i); // try {
// assertEquals(0, v.getModifier()); // Class clazz = new Class();
// assertEquals("int", v.getType()); // clazz.parse(cleaner.clean("public class Test{ int i ,j,k; int l=i=k=l=4; } "), new CleanerPool());
// assertEquals((char)('i'+i), v.getName().charAt(0)); //
// } // List<Variable> vars = clazz.getVariables();
}catch(Exception e){ // assertEquals(2, vars.size());
fail(e); // Variable v = vars.get(0);
} // assertEquals(0, v.getModifier());
} // assertEquals("int", v.getType());
//// for(int i = 0; i < 4; i++){
@Test //// Variable v = vars.get(i);
void case8(){ //// assertEquals(0, v.getModifier());
try { //// assertEquals("int", v.getType());
Variable variable = new Variable(); //// assertEquals((char)('i'+i), v.getName().charAt(0));
variable.parse(cleaner.clean("int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]t; "), cleaner); //// }
// }catch(Exception e){
assertEquals(0, variable.getModifier()); // fail(e);
assertEquals("int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", variable.getType()); // }
assertEquals("t", variable.getName()); // }
assertNull(variable.getValue()); //
}catch(Exception e){ // @Test
fail(e); // void case8(){
} // try {
} // Variable variable = new Variable();
// variable.parse(cleaner.clean("int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]t; "), cleaner);
@Test //
void case9(){ // assertEquals(0, variable.getModifier());
try { // assertEquals("int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", variable.getType());
Class clazz = new Class(); // assertEquals("t", variable.getName());
clazz.parse(cleaner.clean("public class Test{ int i ,j,k,l; } "), cleaner); // assertNull(variable.getValue());
// }catch(Exception e){
List<Variable> vars = clazz.getVariables(); // fail(e);
assertEquals(1, vars.size()); // }
Variable v = vars.get(0); // }
assertEquals(0, v.getModifier()); //
assertEquals("int", v.getType()); // @Test
// for(int i = 0; i < 3; i++){ // void case9(){
// Variable v = vars.get(i); // try {
// assertEquals(0, v.getModifier()); // Class clazz = new Class();
// assertEquals("int", v.getType()); // clazz.parse(cleaner.clean("public class Test{ int i ,j,k,l; } "), cleaner);
// assertEquals((char)('i'+i), v.getName().charAt(0)); //
// assertNull(v.getValue()); // List<Variable> vars = clazz.getVariables();
// } // assertEquals(1, vars.size());
}catch(Exception e){ // Variable v = vars.get(0);
fail(e); // assertEquals(0, v.getModifier());
} // assertEquals("int", v.getType());
} //// for(int i = 0; i < 3; i++){
//// Variable v = vars.get(i);
@Test //// assertEquals(0, v.getModifier());
void case10(){ //// assertEquals("int", v.getType());
try { //// assertEquals((char)('i'+i), v.getName().charAt(0));
Variable variable = new Variable(); //// assertNull(v.getValue());
variable.parse(cleaner.clean(" boolean i = j << 3==0 ; "), cleaner); //// }
// }catch(Exception e){
assertEquals(0, variable.getModifier()); // fail(e);
assertEquals("boolean", variable.getType()); // }
assertEquals("i", variable.getName()); // }
assertEquals("j<< 3 == 0", ((Value)variable.getValue()).value()); //
}catch(Exception e){ // @Test
fail(e); // void case10(){
} // try {
} // Variable variable = new Variable();
// variable.parse(cleaner.clean(" boolean i = j << 3==0 ; "), cleaner);
@Test //
void case11(){ // assertEquals(0, variable.getModifier());
// assertEquals("boolean", variable.getType());
try { // assertEquals("i", variable.getName());
Variable variable = new Variable(); // assertEquals("j<< 3 == 0", ((Value)variable.getValue()).value());
variable.parse(cleaner.clean("java.util.function.Function<Integer, Integer> j = ((i) -> {return 4;});"), cleaner); // }catch(Exception e){
// fail(e);
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()); // @Test
}catch(Exception e){ // void case11(){
fail(e); //
} // try {
} // Variable variable = new Variable();
// variable.parse(cleaner.clean("java.util.function.Function<Integer, Integer> j = ((i) -> {return 4;});"), cleaner);
@Test //
void case12(){ // assertEquals(0, variable.getModifier());
// assertEquals("java.util.function.Function<Integer,Integer>", variable.getType());
try {
Variable variable = new Variable();
variable.parse(cleaner.clean(" public static final Locale FRENCH = createConstant(\"fr\", \"\");"), cleaner);
assertEquals(JavaParser.getModifier("public")+JavaParser.getModifier("static")+JavaParser.getModifier("final"), variable.getModifier());
assertEquals("Locale", variable.getType());
assertEquals("FRENCH", variable.getName());
assertEquals("createConstant(\"fr\",\"\")", ((Value)variable.getValue()).value());
}catch(Exception e){
fail(e);
}
}
@Test
void case13(){
try {
Variable variable = new Variable();
variable.parse(cleaner.clean("private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[] { new ObjectStreamField(\"language\", String.class), new ObjectStreamField(\"country\", String.class), new ObjectStreamField(\"variant\", String.class), new ObjectStreamField(\"hashcode\", int.class), new ObjectStreamField(\"script\", String.class), new ObjectStreamField(\"extensions\", String.class) };"), cleaner);
assertEquals(JavaParser.getModifier("private")+JavaParser.getModifier("static")+JavaParser.getModifier("final"), variable.getModifier());
assertEquals("ObjectStreamField[]", variable.getType());
assertEquals("serialPersistentFields", variable.getName());
assertEquals("new ObjectStreamField[] { new ObjectStreamField(\"language\", String.class), new ObjectStreamField(\"country\", String.class), new ObjectStreamField(\"variant\", String.class), new ObjectStreamField(\"hashcode\", int.class), new ObjectStreamField(\"script\", String.class), new ObjectStreamField(\"extensions\", String.class) }", ((Value)variable.getValue()).value());
}catch(Exception e){
fail(e);
}
}
@Test
void case14(){
try {
Class clazz = new Class();
clazz.parse(cleaner.clean("public class Test{ private java.util.function.Function<Integer, Integer> j = ((i) -> {return 4;}), k = ((i) -> 4); } "), cleaner);
List<Variable> vars = clazz.getVariables();
assertEquals(1, vars.size());
Variable variable;
variable = vars.get(0);
assertTrue(variable instanceof MultipleDeclaratedVariable);
assertEquals(JavaParser.getModifier("private"), variable.getModifier());
assertEquals("java.util.function.Function<Integer,Integer>", variable.getType());
// assertEquals("j", variable.getName()); // 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);
// }
// }
// //
// variable = vars.get(1); // @Test
// void case12(){
//
// try {
// Variable variable = new Variable();
// variable.parse(cleaner.clean(" public static final Locale FRENCH = createConstant(\"fr\", \"\");"), cleaner);
//
// assertEquals(JavaParser.getModifier("public")+JavaParser.getModifier("static")+JavaParser.getModifier("final"), variable.getModifier());
// assertEquals("Locale", variable.getType());
// assertEquals("FRENCH", variable.getName());
// assertEquals("createConstant(\"fr\",\"\")", ((Value)variable.getValue()).value());
// }catch(Exception e){
// fail(e);
// }
// }
//
// @Test
// void case13(){
//
// try {
// Variable variable = new Variable();
// variable.parse(cleaner.clean("private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[] { new ObjectStreamField(\"language\", String.class), new ObjectStreamField(\"country\", String.class), new ObjectStreamField(\"variant\", String.class), new ObjectStreamField(\"hashcode\", int.class), new ObjectStreamField(\"script\", String.class), new ObjectStreamField(\"extensions\", String.class) };"), cleaner);
//
// assertEquals(JavaParser.getModifier("private")+JavaParser.getModifier("static")+JavaParser.getModifier("final"), variable.getModifier());
// assertEquals("ObjectStreamField[]", variable.getType());
// assertEquals("serialPersistentFields", variable.getName());
// assertEquals("new ObjectStreamField[] { new ObjectStreamField(\"language\", String.class), new ObjectStreamField(\"country\", String.class), new ObjectStreamField(\"variant\", String.class), new ObjectStreamField(\"hashcode\", int.class), new ObjectStreamField(\"script\", String.class), new ObjectStreamField(\"extensions\", String.class) }", ((Value)variable.getValue()).value());
// }catch(Exception e){
// fail(e);
// }
// }
//
// @Test
// void case14(){
//
//
// try {
// Class clazz = new Class();
// clazz.parse(cleaner.clean("public class Test{ private java.util.function.Function<Integer, Integer> j = ((i) -> {return 4;}), k = ((i) -> 4); } "), cleaner);
//
// List<Variable> vars = clazz.getVariables();
// assertEquals(1, vars.size());
// Variable variable;
// variable = vars.get(0);
// assertTrue(variable instanceof MultipleDeclaratedVariable);
// assertEquals(JavaParser.getModifier("private"), variable.getModifier()); // assertEquals(JavaParser.getModifier("private"), variable.getModifier());
// assertEquals("java.util.function.Function<Integer,Integer>", variable.getType()); // assertEquals("java.util.function.Function<Integer,Integer>", variable.getType());
// assertEquals("k", variable.getName()); //// assertEquals("j", variable.getName());
// assertEquals("((i) -> 4)", ((Value)variable.getValue()).value()); //// assertEquals("((i) -> {return 4;})", ((Value)variable.getValue()).value());
}catch(Exception e){ ////
fail(e); //// variable = vars.get(1);
} //// assertEquals(JavaParser.getModifier("private"), variable.getModifier());
} //// assertEquals("java.util.function.Function<Integer,Integer>", variable.getType());
//// assertEquals("k", variable.getName());
@Test //// assertEquals("((i) -> 4)", ((Value)variable.getValue()).value());
void case15(){ // }catch(Exception e){
try { // fail(e);
Variable variable = new Variable(); // }
variable.parse(cleaner.clean(" List <String> list = new ArrayList <> () ; "), cleaner); // }
//
assertEquals(0, variable.getModifier()); // @Test
assertEquals("List<String>", variable.getType()); // void case15(){
assertEquals("list", variable.getName()); // try {
assertEquals("new ArrayList<>()", ((Value)variable.getValue()).value()); // Variable variable = new Variable();
}catch(Exception e){ // variable.parse(cleaner.clean(" List <String> list = new ArrayList <> () ; "), cleaner);
fail(e); //
} // assertEquals(0, variable.getModifier());
} // assertEquals("List<String>", variable.getType());
// assertEquals("list", variable.getName());
@Test // assertEquals("new ArrayList<>()", ((Value)variable.getValue()).value());
void case16(){ // }catch(Exception e){
try { // fail(e);
Variable variable = new Variable(); // }
variable.parse(cleaner.clean(" List <String> a [] = new ArrayList [ 0] ; "), cleaner); // }
//
assertEquals(0, variable.getModifier()); // @Test
assertEquals("List<String>", variable.getType()); // void case16(){
assertEquals("a[]", variable.getName()); // try {
assertEquals("new ArrayList[0]", ((Value)variable.getValue()).value()); // Variable variable = new Variable();
}catch(Exception e){ // variable.parse(cleaner.clean(" List <String> a [] = new ArrayList [ 0] ; "), cleaner);
fail(e); //
} // assertEquals(0, variable.getModifier());
} // assertEquals("List<String>", variable.getType());
// assertEquals("a[]", variable.getName());
// assertEquals("new ArrayList[0]", ((Value)variable.getValue()).value());
// }catch(Exception e){
// fail(e);
// }
// }
} }