diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/CleanerPool.java b/src/be/jeffcheasey88/peeratcode/parser/java/CleanerPool.java index 888677d..0712dbf 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/CleanerPool.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/CleanerPool.java @@ -17,6 +17,14 @@ public class CleanerPool{ public CleanerPool(Cleaner... cleaners){ this.cleaners = Arrays.asList(cleaners); } + + @Override + public String toString(){ + String s = "CleanerPool[\n"; + for(Cleaner cleaner : cleaners) s+=cleaner.pattern+"['"+cleaner.open+"' -> '"+cleaner.close+"']\n"; + s+="\n]"; + return s; + } public String clean(String value){ for(Cleaner cleaner : this.cleaners) value = cleaner.clean(value); diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Function.java b/src/be/jeffcheasey88/peeratcode/parser/java/Function.java index ae5bb5f..aae8a26 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Function.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Function.java @@ -35,7 +35,9 @@ public class Function extends OperationContainer{ this.exceptions = matcher.group(4).trim(); System.out.println("body IS {"+matcher.group(5)); - CleanerPool generic = new CleanerPool(new Cleaner("GENERIC_FUNCTION", '{', '}')); + CleanerPool generic = new CleanerPool( + new Cleaner("GENERIC_FUNCTION", '{', '}'), + new Cleaner("GENERIC_PARENTHESIS", '(', ')')); String zip = generic.clean("{"+matcher.group(5)); System.out.println("clean it "+zip); String body = generic.unzipOne(zip, (s,p) -> s); diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java b/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java index 224dd4f..cd5ee83 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java @@ -14,7 +14,7 @@ import be.jeffcheasey88.peeratcode.parser.java.CleanerPool.Cleaner; public class JavaParser{ 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\\Variable.java"); + File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\src\\be\\jeffcheasey88\\peeratcode\\parser\\java\\Class.java"); BufferedReader reader = new BufferedReader(new FileReader(file)); JavaParser parser = new JavaParser(reader); diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/operations/MethodCallOperation.java b/src/be/jeffcheasey88/peeratcode/parser/java/operations/MethodCallOperation.java index c474c6d..0ca2395 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/operations/MethodCallOperation.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/operations/MethodCallOperation.java @@ -8,7 +8,7 @@ import be.jeffcheasey88.peeratcode.parser.java.JavaElement; public class MethodCallOperation extends JavaElement{ - private static Pattern PATTERN = Pattern.compile("^(\\s*([^\\(]*\\([^\\)]*\\));).*$"); + private static Pattern PATTERN = Pattern.compile("^(\\s*([^\\^\\s]+\\^GENERIC_PARENTHESIS\\d+);).*$"); private String value; @@ -16,12 +16,17 @@ public class MethodCallOperation extends JavaElement{ @Override public int parse(String content, CleanerPool cleaner) throws Exception{ + System.out.println("method call "+cleaner); + System.out.println("parse method "+content); + content = cleaner.clean(content); + Matcher matcher = PATTERN.matcher(content); matcher.matches(); + System.out.println("method call "+content); - this.value = matcher.group(2); + this.value = cleaner.unzip(matcher.group(2), (s,p) -> s); - return matcher.group(1).length(); + return cleaner.unzip(matcher.group(1), (s,p) -> s).length(); } @Override