Compare commits
No commits in common. "3a2e39f223368420ef717069b1dca4c4d9e2e37d" and "f4ff094554fa35e9b826754306e9357061dda2fa" have entirely different histories.
3a2e39f223
...
f4ff094554
11 changed files with 13 additions and 350 deletions
|
@ -89,10 +89,6 @@ public class Class extends JavaElement{
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JavaElement> getChilds(){
|
|
||||||
return this.childs;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public List<Variable> getVariables(){
|
// public List<Variable> getVariables(){
|
||||||
// return this.vars;
|
// return this.vars;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -41,8 +41,13 @@ public class Function extends OperationContainer{
|
||||||
String body = local.unzipOne(zip, (s,p) -> s);
|
String body = local.unzipOne(zip, (s,p) -> s);
|
||||||
String unzip = body.substring(1, body.indexOf('}'));
|
String unzip = body.substring(1, body.indexOf('}'));
|
||||||
|
|
||||||
|
System.out.println("----------before----------");
|
||||||
|
show(0);
|
||||||
|
|
||||||
super.parse(local.clean(unzip), global, local);
|
super.parse(local.clean(unzip), global, local);
|
||||||
|
|
||||||
|
System.out.println("----------After----------");
|
||||||
|
show(0);
|
||||||
|
|
||||||
return matcher.group(1).length()+local.unzip(unzip, ((s,p) -> s)).length()+1;
|
return matcher.group(1).length()+local.unzip(unzip, ((s,p) -> s)).length()+1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import be.jeffcheasey88.peeratcode.parser.java.CleanerPool.Cleaner;
|
||||||
public class JavaParser{
|
public class JavaParser{
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\src\\be\\jeffcheasey88\\peeratcode\\parser\\java\\Class.java");
|
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\src\\be\\jeffcheasey88\\peeratcode\\parser\\java\\ExampleClass.java");
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||||
|
|
||||||
JavaParser parser = new JavaParser(reader);
|
JavaParser parser = new JavaParser(reader);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
|
||||||
public class ConditionalOperation extends OperationContainer{
|
public class ConditionalOperation extends OperationContainer{
|
||||||
|
|
||||||
private static Pattern PATTERN = Pattern.compile("^(\\^GENERIC_FUNCTION\\d+).*$");
|
private static Pattern PATTERN = Pattern.compile("^(\\^GENERIC_FUNCTION\\d+).*$");
|
||||||
private static Pattern PATTERN_SPACE = Pattern.compile("^(\\s+).*$");
|
|
||||||
|
|
||||||
private Pattern pattern;
|
private Pattern pattern;
|
||||||
private String condition;
|
private String condition;
|
||||||
|
@ -24,16 +23,9 @@ public class ConditionalOperation extends OperationContainer{
|
||||||
matcher.matches();
|
matcher.matches();
|
||||||
|
|
||||||
this.condition = local.unzipOne(matcher.group(2), (s,p) -> s);
|
this.condition = local.unzipOne(matcher.group(2), (s,p) -> s);
|
||||||
System.out.println("CONDITION "+condition);
|
|
||||||
|
|
||||||
int index = matcher.group(1).length();
|
int index = matcher.group(1).length();
|
||||||
content = content.substring(index);
|
content = content.substring(index);
|
||||||
|
|
||||||
matcher = PATTERN_SPACE.matcher(content);
|
|
||||||
if(matcher.matches()){
|
|
||||||
index+=matcher.group(1).length();
|
|
||||||
content = content.substring(matcher.group(1).length());
|
|
||||||
}
|
|
||||||
|
|
||||||
int bodysize;
|
int bodysize;
|
||||||
if(content.startsWith("^")){
|
if(content.startsWith("^")){
|
||||||
|
@ -47,8 +39,6 @@ public class ConditionalOperation extends OperationContainer{
|
||||||
content = content.substring(1, content.length()-1);
|
content = content.substring(1, content.length()-1);
|
||||||
content = local.clean(content);
|
content = local.clean(content);
|
||||||
super.parse(content, global, local);
|
super.parse(content, global, local);
|
||||||
}else if(content.startsWith(";")){
|
|
||||||
bodysize=1;
|
|
||||||
}else{
|
}else{
|
||||||
bodysize = parseOne(content, global, local);
|
bodysize = parseOne(content, global, local);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
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 DoOperation extends OperationContainer{
|
|
||||||
|
|
||||||
private static Pattern PATTERN = Pattern.compile("^(\\s*do\\s*).*$");
|
|
||||||
private static Pattern PATTERN_CLEANER = Pattern.compile("^(\\^GENERIC_FUNCTION\\d+).*$");
|
|
||||||
|
|
||||||
public DoOperation(){}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
|
||||||
Matcher matcher = PATTERN.matcher(content);
|
|
||||||
matcher.matches();
|
|
||||||
|
|
||||||
int index = matcher.group(1).length();
|
|
||||||
content = content.substring(index);
|
|
||||||
|
|
||||||
matcher = PATTERN_CLEANER.matcher(content);
|
|
||||||
matcher.matches();
|
|
||||||
|
|
||||||
content = matcher.group(1);
|
|
||||||
|
|
||||||
index += content.length();
|
|
||||||
content = local.unzipOne(content, (s,p) -> s);
|
|
||||||
content = content.substring(1, content.length()-1);
|
|
||||||
content = local.clean(content);
|
|
||||||
super.parse(content, global, local);
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(int tab) {
|
|
||||||
String start = "";
|
|
||||||
for(int i = 0; i < tab; i++) start+="\t";
|
|
||||||
System.out.println(start+"do{");
|
|
||||||
for(JavaElement child : getChilds()) child.show(tab+1);
|
|
||||||
System.out.println(start+"}");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
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 LoopAffectOperation extends JavaElement{
|
|
||||||
|
|
||||||
private Pattern pattern;
|
|
||||||
|
|
||||||
public LoopAffectOperation(Pattern pattern){
|
|
||||||
this.pattern = pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
|
||||||
Matcher matcher = this.pattern.matcher(content);
|
|
||||||
matcher.matches();
|
|
||||||
|
|
||||||
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+"loop affect??;");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ContinueOperation extends LoopAffectOperation{
|
|
||||||
|
|
||||||
private static Pattern PATTERN = Pattern.compile("^(\\s*continue\\s*;).*$");
|
|
||||||
|
|
||||||
public ContinueOperation(){
|
|
||||||
super(PATTERN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(int tab){
|
|
||||||
String start = "";
|
|
||||||
for(int i = 0; i < tab; i++) start+="\t";
|
|
||||||
System.out.println(start+"continue;");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class BreakOperation extends LoopAffectOperation{
|
|
||||||
|
|
||||||
private static Pattern PATTERN = Pattern.compile("^(\\s*break\\s*;).*$");
|
|
||||||
|
|
||||||
public BreakOperation(){
|
|
||||||
super(PATTERN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(int tab){
|
|
||||||
String start = "";
|
|
||||||
for(int i = 0; i < tab; i++) start+="\t";
|
|
||||||
System.out.println(start+"break;");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,6 +16,7 @@ public class MethodCallOperation extends JavaElement{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
||||||
|
System.out.println("MethodCallOperation.parse -> "+content);
|
||||||
content = local.clean(content);
|
content = local.clean(content);
|
||||||
|
|
||||||
Matcher matcher = PATTERN.matcher(content);
|
Matcher matcher = PATTERN.matcher(content);
|
||||||
|
|
|
@ -40,6 +40,8 @@ public abstract class OperationContainer extends JavaElement{
|
||||||
|
|
||||||
System.out.println(operation.getClass().getSimpleName()+" operation = FACTORY.buildOperation();");
|
System.out.println(operation.getClass().getSimpleName()+" operation = FACTORY.buildOperation();");
|
||||||
int index = operation.parse(content, global, local);
|
int index = operation.parse(content, global, local);
|
||||||
|
operation.show(0);
|
||||||
|
System.out.println();
|
||||||
content = content.substring(index);
|
content = content.substring(index);
|
||||||
if(operation instanceof Variable){
|
if(operation instanceof Variable){
|
||||||
if(content.startsWith(",")){
|
if(content.startsWith(",")){
|
||||||
|
|
|
@ -12,8 +12,6 @@ import be.jeffcheasey88.peeratcode.parser.java.Variable;
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.ConditionalOperation.ForOperation;
|
import be.jeffcheasey88.peeratcode.parser.java.operations.ConditionalOperation.ForOperation;
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.ConditionalOperation.IfOperation;
|
import be.jeffcheasey88.peeratcode.parser.java.operations.ConditionalOperation.IfOperation;
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.ConditionalOperation.WhileOperation;
|
import be.jeffcheasey88.peeratcode.parser.java.operations.ConditionalOperation.WhileOperation;
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.LoopAffectOperation.BreakOperation;
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.LoopAffectOperation.ContinueOperation;
|
|
||||||
|
|
||||||
public class OperationFactory{
|
public class OperationFactory{
|
||||||
|
|
||||||
|
@ -33,12 +31,6 @@ public class OperationFactory{
|
||||||
this.patterns.put(Pattern.compile("^\\s*for\\s*\\^GENERIC_PARENTHESIS\\d+.*$"), ForOperation.class);
|
this.patterns.put(Pattern.compile("^\\s*for\\s*\\^GENERIC_PARENTHESIS\\d+.*$"), ForOperation.class);
|
||||||
this.patterns.put(Pattern.compile("^\\s*while\\s*\\^GENERIC_PARENTHESIS\\d+.*$"), WhileOperation.class);
|
this.patterns.put(Pattern.compile("^\\s*while\\s*\\^GENERIC_PARENTHESIS\\d+.*$"), WhileOperation.class);
|
||||||
this.patterns.put(Pattern.compile("^\\s*else\\s*.*$"), ElseOperation.class);
|
this.patterns.put(Pattern.compile("^\\s*else\\s*.*$"), ElseOperation.class);
|
||||||
this.patterns.put(Pattern.compile("^\\s*do\\s*\\^GENERIC_FUNCTION\\d+.*$"), DoOperation.class);
|
|
||||||
|
|
||||||
this.patterns.put(Pattern.compile("^\\s*synchronized\\s*\\^GENERIC_PARENTHESIS\\d+.*$"), SynchronizedOperation.class);
|
|
||||||
|
|
||||||
this.patterns.put(Pattern.compile("^\\s*continue\\s*;.*$"), ContinueOperation.class);
|
|
||||||
this.patterns.put(Pattern.compile("^\\s*break\\s*;.*$"), BreakOperation.class);
|
|
||||||
|
|
||||||
this.patterns.put(Pattern.compile("^\\s*[^\\^\\s]+\\^GENERIC_PARENTHESIS\\d+;.*$"), MethodCallOperation.class);
|
this.patterns.put(Pattern.compile("^\\s*[^\\^\\s]+\\^GENERIC_PARENTHESIS\\d+;.*$"), MethodCallOperation.class);
|
||||||
|
|
||||||
|
@ -52,17 +44,17 @@ public class OperationFactory{
|
||||||
* assignation OK
|
* assignation OK
|
||||||
* exec method OK
|
* exec method OK
|
||||||
* for OK
|
* for OK
|
||||||
* do while OK
|
* do while
|
||||||
* while OK
|
* while OK
|
||||||
* if OK
|
* if OK
|
||||||
* switch case
|
* switch case
|
||||||
* return OK
|
* return OK
|
||||||
* continue OK
|
* continue
|
||||||
* break OK
|
* break
|
||||||
* try catch finally
|
* try catch finally
|
||||||
* throw
|
* throw
|
||||||
* else OK
|
* else OK
|
||||||
* synchronized OK
|
* synchronized
|
||||||
* instance of
|
* instance of
|
||||||
*
|
*
|
||||||
* native operation style i++
|
* native operation style i++
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
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 SynchronizedOperation extends OperationContainer{
|
|
||||||
|
|
||||||
private static Pattern PATTERN = Pattern.compile("^(\\s*synchronized\\s*)(\\^GENERIC_PARENTHESIS\\d+)(\\s*).*$");
|
|
||||||
private static Pattern PATTERN_CLEANER = Pattern.compile("^(\\^GENERIC_FUNCTION\\d+).*$");
|
|
||||||
|
|
||||||
private String include;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
|
||||||
Matcher matcher = PATTERN.matcher(content);
|
|
||||||
matcher.matches();
|
|
||||||
|
|
||||||
this.include = local.unzip(matcher.group(2), (s,p) -> s);
|
|
||||||
|
|
||||||
int index = matcher.group(1).length()+matcher.group(2).length()+matcher.group(3).length();
|
|
||||||
content = content.substring(index);
|
|
||||||
|
|
||||||
matcher = PATTERN_CLEANER.matcher(content);
|
|
||||||
matcher.matches();
|
|
||||||
|
|
||||||
content = matcher.group(1);
|
|
||||||
|
|
||||||
index += content.length();
|
|
||||||
content = local.unzipOne(content, (s,p) -> s);
|
|
||||||
content = content.substring(1, content.length()-1);
|
|
||||||
content = local.clean(content);
|
|
||||||
super.parse(content, global, local);
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(int tab){
|
|
||||||
String start = "";
|
|
||||||
for(int i = 0; i < tab; i++) start+="\t";
|
|
||||||
System.out.println(start+"synchronized"+this.include+"{");
|
|
||||||
for(JavaElement child : getChilds()) child.show(tab+1);
|
|
||||||
System.out.println(start+"}");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,163 +0,0 @@
|
||||||
package be.jeffcheasey88.peeratcode.parser.java;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestInstance;
|
|
||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
|
||||||
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.ConditionalOperation.ForOperation;
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.ConditionalOperation.WhileOperation;
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.DoOperation;
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.LoopAffectOperation.BreakOperation;
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.LoopAffectOperation.ContinueOperation;
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.MethodCallOperation;
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.operations.SynchronizedOperation;
|
|
||||||
|
|
||||||
@TestInstance(Lifecycle.PER_CLASS)
|
|
||||||
class OperationTest{
|
|
||||||
|
|
||||||
JavaParser parse(String code) throws Exception{
|
|
||||||
BufferedReader reader = new BufferedReader(new Reader(){public int read(char[] cbuf, int off, int len) throws IOException{return 0;}public void close() throws IOException {}}) {
|
|
||||||
private boolean read = false;
|
|
||||||
@Override
|
|
||||||
public String readLine() throws IOException{
|
|
||||||
if(read) return null;
|
|
||||||
read = true;
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
JavaParser parser = new JavaParser(reader);
|
|
||||||
parser.parse();
|
|
||||||
return parser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void ifOperation(){
|
|
||||||
try {
|
|
||||||
JavaParser parser = parse("package be.jeffcheasey88.peeratcode.parser.java; class Test{ void function(){ int i = 0; if(i == 0) { return i; } return i; } }");
|
|
||||||
Class clazz = parser.getClazz();
|
|
||||||
|
|
||||||
clazz.show(0);
|
|
||||||
|
|
||||||
assertEquals(1, clazz.getChilds().size());
|
|
||||||
Function function = (Function) clazz.getChilds().get(0);
|
|
||||||
assertEquals(3, function.getChilds().size());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void ifWithNoneOperation(){
|
|
||||||
try {
|
|
||||||
JavaParser parser = parse("package be.jeffcheasey88.peeratcode.parser.java; class Test{ void function(){ int i = 0; if(i == 0); return i; } }");
|
|
||||||
Class clazz = parser.getClazz();
|
|
||||||
|
|
||||||
clazz.show(0);
|
|
||||||
|
|
||||||
assertEquals(1, clazz.getChilds().size());
|
|
||||||
Function function = (Function) clazz.getChilds().get(0);
|
|
||||||
assertEquals(3, function.getChilds().size());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void doWhileOperation(){
|
|
||||||
try {
|
|
||||||
JavaParser parser = parse("package be.jeffcheasey88.peeratcode.parser.java; class Test{ void function(){ int i = 0; do{ System.out.println(\"Hello\"); }while(i == 0); return i; } }");
|
|
||||||
Class clazz = parser.getClazz();
|
|
||||||
|
|
||||||
clazz.show(0);
|
|
||||||
|
|
||||||
assertEquals(1, clazz.getChilds().size());
|
|
||||||
Function function = (Function) clazz.getChilds().get(0);
|
|
||||||
assertEquals(4, function.getChilds().size());
|
|
||||||
|
|
||||||
assertEquals(DoOperation.class, function.getChilds().get(1).getClass());
|
|
||||||
DoOperation doOp = (DoOperation)function.getChilds().get(1);
|
|
||||||
assertEquals(1, doOp.getChilds().size());
|
|
||||||
assertEquals(MethodCallOperation.class, doOp.getChilds().get(0).getClass());
|
|
||||||
|
|
||||||
assertEquals(WhileOperation.class, function.getChilds().get(2).getClass());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void continueOperation(){
|
|
||||||
try {
|
|
||||||
JavaParser parser = parse("package be.jeffcheasey88.peeratcode.parser.java; class Test{ void function(){ for(int i = 0; i < 1; i++) continue; } }");
|
|
||||||
Class clazz = parser.getClazz();
|
|
||||||
|
|
||||||
clazz.show(0);
|
|
||||||
|
|
||||||
assertEquals(1, clazz.getChilds().size());
|
|
||||||
Function function = (Function) clazz.getChilds().get(0);
|
|
||||||
assertEquals(1, function.getChilds().size());
|
|
||||||
|
|
||||||
assertEquals(ForOperation.class, function.getChilds().get(0).getClass());
|
|
||||||
ForOperation f = (ForOperation)function.getChilds().get(0);
|
|
||||||
assertEquals(1, f.getChilds().size());
|
|
||||||
assertEquals(ContinueOperation.class, f.getChilds().get(0).getClass());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void breakOperation(){
|
|
||||||
try {
|
|
||||||
JavaParser parser = parse("package be.jeffcheasey88.peeratcode.parser.java; class Test{ void function(){ for(int i = 0; i < 1; i++) break ; } }");
|
|
||||||
Class clazz = parser.getClazz();
|
|
||||||
|
|
||||||
clazz.show(0);
|
|
||||||
|
|
||||||
assertEquals(1, clazz.getChilds().size());
|
|
||||||
Function function = (Function) clazz.getChilds().get(0);
|
|
||||||
assertEquals(1, function.getChilds().size());
|
|
||||||
|
|
||||||
assertEquals(ForOperation.class, function.getChilds().get(0).getClass());
|
|
||||||
ForOperation f = (ForOperation)function.getChilds().get(0);
|
|
||||||
assertEquals(1, f.getChilds().size());
|
|
||||||
assertEquals(BreakOperation.class, f.getChilds().get(0).getClass());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void synchronizedOperation(){
|
|
||||||
try {
|
|
||||||
JavaParser parser = parse("package be.jeffcheasey88.peeratcode.parser.java; class Test{ void function(){ synchronized(this) { this.none(); } } }");
|
|
||||||
Class clazz = parser.getClazz();
|
|
||||||
|
|
||||||
clazz.show(0);
|
|
||||||
|
|
||||||
assertEquals(1, clazz.getChilds().size());
|
|
||||||
Function function = (Function) clazz.getChilds().get(0);
|
|
||||||
assertEquals(1, function.getChilds().size());
|
|
||||||
|
|
||||||
assertEquals(SynchronizedOperation.class, function.getChilds().get(0).getClass());
|
|
||||||
SynchronizedOperation sync = (SynchronizedOperation)function.getChilds().get(0);
|
|
||||||
assertEquals(1, sync.getChilds().size());
|
|
||||||
assertEquals(MethodCallOperation.class, sync.getChilds().get(0).getClass());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue