Operation -> Method Call

This commit is contained in:
jeffcheasey88 2023-05-30 21:46:40 +02:00
parent be289b8d7f
commit ad430cb659
4 changed files with 20 additions and 5 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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