diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/CleanerPool.java b/src/be/jeffcheasey88/peeratcode/parser/java/CleanerPool.java index c2bbbfa..19f5cc2 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/CleanerPool.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/CleanerPool.java @@ -34,6 +34,8 @@ public class CleanerPool{ if(matcher.matches()){ String key = matcher.group(2); String zip = cleaner.getConstant(key); + String modified = modifier.apply(zip, cleaner.getPattern()); + if(modified == null) continue; map.put(key, cleaner.open+zip+cleaner.close); tmp = matcher.group(1)+cleaner.open+zip+cleaner.close+matcher.group(3); edited = true; @@ -57,7 +59,7 @@ public class CleanerPool{ String key = matcher.group(2); String zip = cleaner.getConstant(key); String modified = modifier.apply(zip, cleaner.getPattern()); - if(modified == null) modified = zip; + if(modified == null) continue; value = matcher.group(1)+cleaner.open+modified+cleaner.close+matcher.group(3); edited = true; } diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/operations/OperationFactory.java b/src/be/jeffcheasey88/peeratcode/parser/java/operations/OperationFactory.java index 9eca205..c485474 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/operations/OperationFactory.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/operations/OperationFactory.java @@ -42,9 +42,9 @@ public class OperationFactory{ * variable OK * assignation OK * exec method OK - * for + * for OK * do while - * while + * while OK * if OK * switch case * return OK @@ -70,8 +70,9 @@ public class OperationFactory{ new Cleaner("GENERIC_ARRAY",'[',']'), new Cleaner("GENERIC_TYPE_",'<','>')); content = generic.clean(content); - generiqueTypes(content, generic); + content = generiqueTypes(content, generic); + System.out.println("look for "+content); for(Entry> entries : this.patterns.entrySet()){ if(entries.getKey().matcher(content).matches()) return entries.getValue().newInstance(); } @@ -86,16 +87,25 @@ public class OperationFactory{ private static Pattern UNZIP_EQUALS_RIGHT = Pattern.compile("=(?[^=\\s])"); private String generiqueTypes(String content, CleanerPool cleaner){ + System.out.println("base on "+content); String unzip = cleaner.unzip(content, (value, pattern) -> { + System.out.println("unzip pattern "+pattern); if(pattern.equals("^GENERIC_FUNCTION")) return null; - if(pattern.equals("^GENERIC_PARENTHESIS")) return value.replace("\\s+", " "); + if(pattern.equals("^GENERIC_PARENTHESIS")) return null; + System.out.println("let pass "+pattern); return value.replaceAll("\\s+", ""); }); + System.out.println("generiqueTypes on "+unzip); unzip = UNZIP_STICK.matcher(unzip).replaceAll("${e}"); + System.out.println("g => "+unzip); unzip = UNZIP_MAJ.matcher(unzip).replaceAll("> ${e}"); + System.out.println("g => "+unzip); unzip = UNZIP_ARRAY.matcher(unzip).replaceAll("] ${e}"); + System.out.println("g => "+unzip); unzip = UNZIP_EQUALS_LEFT.matcher(unzip).replaceAll("${e} ="); + System.out.println("g => "+unzip); unzip = UNZIP_EQUALS_RIGHT.matcher(unzip).replaceAll("= ${e}"); + System.out.println("g => "+unzip); return unzip; } }