MethodCall with generic type

This commit is contained in:
jeffcheasey88 2023-11-08 22:55:35 +01:00
parent 9b87621a35
commit b78ef3213e

View file

@ -178,8 +178,8 @@ public class JavaParser extends Parser<JavaElement> {
StateTree<JavaElement> type = new StateTree<JavaElement>(); StateTree<JavaElement> type = new StateTree<JavaElement>();
StateTree<JavaElement> type_ = type.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME),concat)); StateTree<JavaElement> type_ = type.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME),concat));
type_.then((validator) -> validator.validate((token) -> token.getValue().equals("."), concat)) // type_.then((validator) -> validator.validate((token) -> token.getValue().equals("."), concat)) //only dot?
.then(type_); // .then(type_);
StateTree<JavaElement> gen = new StateTree<>(); StateTree<JavaElement> gen = new StateTree<>();
type_.then(gen); type_.then(gen);
StateTree<JavaElement> type_begin = gen.then((validator) -> validator.validate((token) -> token.getValue().equals("<"), concat)); StateTree<JavaElement> type_begin = gen.then((validator) -> validator.validate((token) -> token.getValue().equals("<"), concat));
@ -291,7 +291,10 @@ public class JavaParser extends Parser<JavaElement> {
.end((a,b) -> a) .end((a,b) -> a)
.multiple(braces_container) .multiple(braces_container)
.unique((validator) -> validator.validate((token) -> token.getValue().equals("}"))).end((a,b) -> a); .unique((validator) -> validator.validate((token) -> token.getValue().equals("}"))).end((a,b) -> a);
value_name = value_name.then(new RedirectStateTree<>(type, (global, local) -> global.set(local.get()))); value_name = value_name.then(new RedirectStateTree<>(type, (global, local) -> {
if(global.get() == null) global.set(local.get());
else global.set(global.<Token>get().concat(local.get()));
}));
value_name.end((parent,bag) -> { value_name.end((parent,bag) -> {
Value result = new Value(bag.<Token>get()); Value result = new Value(bag.<Token>get());
bag.set(result); bag.set(result);
@ -302,8 +305,11 @@ public class JavaParser extends Parser<JavaElement> {
.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME))) .then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)))
.end((a,b) -> a); .end((a,b) -> a);
StateTree<JavaElement> value_call = value_name.then((validator) -> validator.validate((token) -> token.getValue().equals("."))); StateTree<JavaElement> value_call = value_name.then((validator) -> validator.validate(
(token) -> token.getValue().equals("."),
(bag, token) -> bag.set(bag.<Token>get().concat(token))));
value_call.end((a,b) -> a); value_call.end((a,b) -> a);
value_call.then(new RedirectStateTree<>(gen, (global, local) -> global.set(global.<Token>get().concat(local.get())))).then(value_name);
value_call.then(value_name); value_call.then(value_name);
StateTree<JavaElement> value_array_begin = value_name.then((validator) -> validator.validate((token) -> token.getValue().equals("["))); StateTree<JavaElement> value_array_begin = value_name.then((validator) -> validator.validate((token) -> token.getValue().equals("[")));
StateTree<JavaElement> value_array_end = value_array_begin.then((validator) -> validator.validate((token) -> token.getValue().equals("]"))); StateTree<JavaElement> value_array_end = value_array_begin.then((validator) -> validator.validate((token) -> token.getValue().equals("]")));
@ -1161,7 +1167,7 @@ public class JavaParser extends Parser<JavaElement> {
} }
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\\dev\\peerat\\backend\\routes\\users\\Register.java"); File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\");
BufferedReader reader = new BufferedReader(new FileReader(file)); BufferedReader reader = new BufferedReader(new FileReader(file));