54 lines
1.6 KiB
Java
54 lines
1.6 KiB
Java
package be.jeffcheasey88.peeratcode.parser.java.operations;
|
|
|
|
import java.io.BufferedWriter;
|
|
import java.util.List;
|
|
import java.util.function.BiFunction;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
import be.jeffcheasey88.peeratcode.parser.java.ArrayBuffer;
|
|
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*([^\\^\\s]+\\^GENERIC_PARENTHESIS\\d+);).*$");
|
|
|
|
private String value;
|
|
|
|
public MethodCallOperation(){}
|
|
|
|
@Override
|
|
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
|
content = local.clean(content);
|
|
|
|
Matcher matcher = PATTERN.matcher(content);
|
|
matcher.matches();
|
|
|
|
this.value = local.unzip(matcher.group(2), (s,p) -> s);
|
|
|
|
return matcher.group(1).length();
|
|
}
|
|
|
|
public String getValue(){
|
|
return this.value;
|
|
}
|
|
|
|
@Override
|
|
public void build(ArrayBuffer<String> buffer, int tab) throws Exception{
|
|
super.build(buffer, tab);
|
|
buffer.append((s) -> s+=value+";");
|
|
buffer.add("");
|
|
}
|
|
|
|
@Override
|
|
public <E extends JavaElement> E find(java.util.function.Function<JavaElement, Boolean> search, java.util.function.Function<List<JavaElement>, Boolean> deep, List<JavaElement> trace){
|
|
return search.apply(this) ? (E)this : null;
|
|
}
|
|
|
|
@Override
|
|
public <E extends JavaElement> E find(BiFunction<JavaElement, List<JavaElement>, Boolean> search, List<JavaElement> trace){
|
|
trace.add(this);
|
|
return search.apply(this, trace) || trace.remove(trace.size()-1) == null ? (E)this : null;
|
|
}
|
|
}
|