Base AST for enumeration & annotation class + findAll method for AST
This commit is contained in:
parent
4a8588968c
commit
33cb38b9ba
19 changed files with 386 additions and 19 deletions
|
@ -39,6 +39,7 @@ public class Annotation extends JavaElement{
|
|||
|
||||
@Override
|
||||
public void build(Builder builder) throws Exception{
|
||||
System.out.println("build annotation "+name+" | "+values);
|
||||
builder.append(name);
|
||||
if(values != null && values.size() > 0){
|
||||
builder.append("(");
|
||||
|
@ -62,4 +63,10 @@ public class Annotation extends JavaElement{
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
for(Value value : this.values.values()){
|
||||
if(finder.apply(value)) list.add((E)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
106
src/dev/peerat/parser/java/AnnotationClass.java
Normal file
106
src/dev/peerat/parser/java/AnnotationClass.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package dev.peerat.parser.java;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.peerat.parser.Token;
|
||||
|
||||
public class AnnotationClass extends ClassBase{
|
||||
|
||||
private List<Annotation> annotations;
|
||||
|
||||
//where mod ????
|
||||
private Token name;
|
||||
private Token extend;
|
||||
|
||||
private List<JavaElement> elements;
|
||||
|
||||
public AnnotationClass(List<Annotation> annotations, Token name){
|
||||
this.annotations = annotations;
|
||||
this.name = name;
|
||||
this.elements = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunction(Function function) {
|
||||
this.elements.add(function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariable(Variable variable) {
|
||||
this.elements.add(variable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClass(ClassBase clazz){
|
||||
this.elements.add(clazz);
|
||||
}
|
||||
|
||||
public List<Annotation> getAnnotations(){
|
||||
return this.annotations;
|
||||
}
|
||||
|
||||
public Token getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Token getExtension(){
|
||||
return this.extend;
|
||||
}
|
||||
|
||||
public List<JavaElement> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Builder builder) throws Exception{
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
annotation.build(builder);
|
||||
}
|
||||
}
|
||||
|
||||
builder.append("@interface");
|
||||
builder.append(name);
|
||||
if(extend != null){
|
||||
builder.append(" extends ");
|
||||
builder.append(extend);
|
||||
}
|
||||
builder.append("{");
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
element.build(builder);
|
||||
}
|
||||
}
|
||||
builder.append("}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> E find(java.util.function.Function<JavaElement, Boolean> finder){
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
if(finder.apply(annotation)) return (E) annotation;
|
||||
}
|
||||
}
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
if(finder.apply(element)) return (E) element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(java.util.function.Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
if(finder.apply(annotation)) list.add((E) annotation);
|
||||
}
|
||||
}
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
if(finder.apply(element)) list.add((E) element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -105,5 +105,17 @@ public class Class extends ClassBase{
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(java.util.function.Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
if(finder.apply(annotation)) list.add((E) annotation);
|
||||
}
|
||||
}
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
if(finder.apply(element)) list.add((E) element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
112
src/dev/peerat/parser/java/Enumeration.java
Normal file
112
src/dev/peerat/parser/java/Enumeration.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
package dev.peerat.parser.java;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.peerat.parser.Token;
|
||||
|
||||
public class Enumeration extends ClassBase{
|
||||
|
||||
private List<Annotation> annotations;
|
||||
|
||||
//where mod ????
|
||||
private Token name;
|
||||
private Token extend;
|
||||
|
||||
private List<JavaElement> elements;
|
||||
|
||||
public Enumeration(List<Annotation> annotations, Token name){
|
||||
this.annotations = annotations;
|
||||
this.name = name;
|
||||
this.elements = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Enumeration(List<Annotation> annotations, Token name, Token extend){
|
||||
this(annotations, name);
|
||||
this.extend = extend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunction(Function function) {
|
||||
this.elements.add(function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariable(Variable variable) {
|
||||
this.elements.add(variable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClass(ClassBase clazz){
|
||||
this.elements.add(clazz);
|
||||
}
|
||||
|
||||
public List<Annotation> getAnnotations(){
|
||||
return this.annotations;
|
||||
}
|
||||
|
||||
public Token getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Token getExtension(){
|
||||
return this.extend;
|
||||
}
|
||||
|
||||
public List<JavaElement> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Builder builder) throws Exception{
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
annotation.build(builder);
|
||||
}
|
||||
}
|
||||
|
||||
builder.append("enum");
|
||||
builder.append(name);
|
||||
if(extend != null){
|
||||
builder.append(" extends ");
|
||||
builder.append(extend);
|
||||
}
|
||||
builder.append("{");
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
element.build(builder);
|
||||
}
|
||||
}
|
||||
builder.append("}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> E find(java.util.function.Function<JavaElement, Boolean> finder){
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
if(finder.apply(annotation)) return (E) annotation;
|
||||
}
|
||||
}
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
if(finder.apply(element)) return (E) element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(java.util.function.Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
if(finder.apply(annotation)) list.add((E) annotation);
|
||||
}
|
||||
}
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
if(finder.apply(element)) list.add((E) element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -147,4 +147,22 @@ public class Function extends JavaElement implements VariableContainer, Operatio
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(java.util.function.Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
if(finder.apply(annotation)) list.add((E) annotation);
|
||||
}
|
||||
}
|
||||
if(parameters != null){
|
||||
for(Variable param : this.parameters){
|
||||
if(finder.apply(param)) list.add((E) param);
|
||||
}
|
||||
}
|
||||
if(elements != null){
|
||||
for(JavaElement content : this.elements){
|
||||
if(finder.apply(content)) list.add((E) content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,5 +95,17 @@ public class Interface extends ClassBase{
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(java.util.function.Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
if(finder.apply(annotation)) list.add((E) annotation);
|
||||
}
|
||||
}
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
if(finder.apply(element)) list.add((E) element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.peerat.parser.java;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import dev.peerat.parser.Bag;
|
||||
|
@ -12,5 +13,5 @@ public abstract class JavaElement implements ElementBuilder{
|
|||
|
||||
public abstract <E extends JavaElement> E find(Function<JavaElement, Boolean> finder);
|
||||
|
||||
|
||||
public abstract <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list);
|
||||
}
|
||||
|
|
|
@ -93,4 +93,11 @@ public class JavaFile extends JavaElement implements ClassContainer, AnnotableBu
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(finder.apply(mainClazz)) list.add((E) mainClazz);
|
||||
for(ClassBase clazz : subClazz){
|
||||
if(finder.apply(clazz)) list.add((E) clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.io.FileWriter;
|
|||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -16,6 +15,7 @@ import java.util.function.BiConsumer;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
import dev.peerat.parser.Bag;
|
||||
import dev.peerat.parser.ElementBuilder.Builder;
|
||||
import dev.peerat.parser.Parser;
|
||||
import dev.peerat.parser.Token;
|
||||
import dev.peerat.parser.TokenType;
|
||||
|
@ -247,10 +247,10 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
return false;
|
||||
}).end();
|
||||
|
||||
value.then((validator) -> validator.validate((token) -> {
|
||||
System.out.println("string? "+token);
|
||||
return token.getType().equals(TokenType.STRING);
|
||||
})).end((parent,bag) -> {
|
||||
value.then((validator) -> validator.validate(
|
||||
(token) -> token.getType().equals(TokenType.STRING),
|
||||
(bag, token) -> bag.set(token)))
|
||||
.end((parent,bag) -> {
|
||||
bag.set(new Value(bag.<Token>get()));
|
||||
return null;
|
||||
});
|
||||
|
@ -879,9 +879,15 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
//INTERFACE
|
||||
StateTree<JavaElement> interfaces = new StateTree<>();
|
||||
StateTree<JavaElement> interface_base = interfaces.then((validator) -> validator.validate((token) -> token.getValue().equals("interface")))
|
||||
.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)));
|
||||
.then((validator) -> validator.validate(
|
||||
(token) -> token.getType().equals(TokenType.NAME),
|
||||
(bag, token) -> bag.set("name", token)));
|
||||
StateTree<JavaElement> interface_start = interface_base.then((validator) -> validator.validate((token) -> token.getValue().equals("{")));
|
||||
interface_start.end((a,b) -> a)
|
||||
interface_start.<JavaElement>end((parent,bag) -> {
|
||||
Interface current = new Interface((((AnnotableBuffer)parent).getAnnotationBuffer()), bag.get("name"));
|
||||
if(parent instanceof ClassContainer) ((ClassContainer)parent).addClass(current);
|
||||
return current;
|
||||
})
|
||||
.multiple(clazz_container)
|
||||
.unique((validator) -> validator.validate((token) -> token.getValue().equals("}"))).end((a,b) -> a);
|
||||
|
||||
|
@ -900,10 +906,16 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
//ENUM
|
||||
StateTree<JavaElement> enums = new StateTree<>();
|
||||
StateTree<JavaElement> enum_base = enums.then((validator) -> validator.validate((token) -> token.getValue().equals("enum")))
|
||||
.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)));
|
||||
.then((validator) -> validator.validate(
|
||||
(token) -> token.getType().equals(TokenType.NAME),
|
||||
(bag,token) -> bag.set("name", token)));
|
||||
|
||||
StateTree<JavaElement> enum_start = enum_base.then((validator) -> validator.validate((token) -> token.getValue().equals("{")));
|
||||
enum_start.end((a,b) -> a)
|
||||
enum_start.<JavaElement>end((parent,bag) -> {
|
||||
Enumeration current = new Enumeration((((AnnotableBuffer)parent).getAnnotationBuffer()), bag.get("name"));
|
||||
if(parent instanceof ClassContainer) ((ClassContainer)parent).addClass(current);
|
||||
return current;
|
||||
})
|
||||
.unique(enum_value)
|
||||
.unique(mult_clazz_container)
|
||||
.unique((validator) -> validator.validate((token) -> token.getValue().equals("}"))).end((a,b) -> a);
|
||||
|
@ -931,9 +943,15 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
StateTree<JavaElement> def_anno_base = def_annos.then((validator) ->
|
||||
validator.validate((token) -> token.getValue().equals("@")) &&
|
||||
validator.validate((token) -> token.getValue().equals("interface")))
|
||||
.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)));
|
||||
.then((validator) -> validator.validate(
|
||||
(token) -> token.getType().equals(TokenType.NAME),
|
||||
(bag, token) -> bag.set("name", token)));
|
||||
def_anno_base.then((validator) -> validator.validate((token) -> token.getValue().equals("{")))
|
||||
.end((a,b) -> a)
|
||||
.<JavaElement>end((parent,bag) -> {
|
||||
AnnotationClass current = new AnnotationClass((((AnnotableBuffer)parent).getAnnotationBuffer()), bag.get("name"));
|
||||
if(parent instanceof ClassContainer) ((ClassContainer)parent).addClass(current);
|
||||
return current;
|
||||
})
|
||||
.multiple(clazz_container)
|
||||
.unique((validator) -> validator.validate((token) -> token.getValue().equals("}"))).end((a,b) -> a);
|
||||
|
||||
|
@ -1047,7 +1065,7 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\test\\dev\\peerat\\backend\\routes\\PlayerDetailsTests.java");
|
||||
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\src\\dev\\peerat\\backend\\routes\\users\\Register.java");
|
||||
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
|
||||
|
@ -1068,6 +1086,9 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
|
||||
System.out.println(TokenValidator.MAX_VALIDATE+" / "+TokenValidator.TOKENS);
|
||||
|
||||
parser.build(new BufferedWriter(new FileWriter(new File("/home/ParserV2.txt"))));
|
||||
// parser.build(new BufferedWriter(new FileWriter(new File("/home/ParserV2.txt"))));
|
||||
Builder builder = new Builder();
|
||||
jFile.build(builder);
|
||||
builder.build(new BufferedWriter(new FileWriter(new File("/home/ParserV2.txt"))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.peerat.parser.java;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import dev.peerat.parser.Token;
|
||||
|
@ -46,6 +47,11 @@ public class Value extends JavaElement{
|
|||
return content != null ? finder.apply(content) ? (E) content : null : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list) {
|
||||
if(content != null && finder.apply(content)) list.add((E) content);
|
||||
}
|
||||
|
||||
public static class BiValue extends Value{
|
||||
|
||||
private Value left;
|
||||
|
@ -86,6 +92,12 @@ public class Value extends JavaElement{
|
|||
public <E extends JavaElement> E find(Function<JavaElement, Boolean> finder){
|
||||
return finder.apply(left) ? (E) left : finder.apply(right) ? (E) right : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(finder.apply(left)) list.add((E)left);
|
||||
if(finder.apply(right)) list.add((E)right);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TriValue extends Value{
|
||||
|
@ -121,6 +133,13 @@ public class Value extends JavaElement{
|
|||
public <E extends JavaElement> E find(Function<JavaElement, Boolean> finder){
|
||||
return finder.apply(check) ? (E) check : finder.apply(success) ? (E) success : finder.apply(fail) ? (E) fail : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(finder.apply(check)) list.add((E)check);
|
||||
if(finder.apply(success)) list.add((E)success);
|
||||
if(finder.apply(fail)) list.add((E)fail);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,4 +98,13 @@ public class Variable extends JavaElement{
|
|||
return value != null ? finder.apply(value) ? (E)value : null : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(annotations != null){
|
||||
for(Annotation annotation : this.annotations){
|
||||
if(finder.apply(annotation)) list.add((E)annotation);
|
||||
}
|
||||
}
|
||||
if(value != null && finder.apply(value)) list.add((E)value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.peerat.parser.java.operation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import dev.peerat.parser.java.JavaElement;
|
||||
|
@ -36,4 +37,9 @@ public class AssignOperation extends Operation{
|
|||
return finder.apply(left) ? (E)left : finder.apply(right) ? (E)right : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(finder.apply(left)) list.add((E) left);
|
||||
if(finder.apply(right)) list.add((E) right);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.peerat.parser.java.operation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import dev.peerat.parser.java.JavaElement;
|
||||
|
@ -19,4 +20,7 @@ public class BreakOperation extends Operation{
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.peerat.parser.java.operation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import dev.peerat.parser.java.JavaElement;
|
||||
|
@ -17,4 +18,6 @@ public class ContinueOperation extends Operation{
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){}
|
||||
}
|
||||
|
|
|
@ -54,4 +54,12 @@ public class MethodCallOperation extends Operation{
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(finder.apply(start)) list.add((E)start);
|
||||
if(previous != null) if(finder.apply(previous)) list.add((E) previous);
|
||||
for(Value param : this.parameters){
|
||||
if(finder.apply(param)) list.add((E)param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,15 @@ public class OperationBag extends Operation implements VariableContainer, Operat
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(elements != null){
|
||||
for(JavaElement element : this.elements){
|
||||
if(finder.apply(element)) list.add((E)element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Builder builder) throws Exception {
|
||||
//todo and super on child
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.peerat.parser.java.operation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import dev.peerat.parser.java.JavaElement;
|
||||
|
@ -24,9 +25,12 @@ public class ReturnOperation extends Operation{
|
|||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> E find(Function<JavaElement, Boolean> finder) {
|
||||
public <E extends JavaElement> E find(Function<JavaElement, Boolean> finder){
|
||||
return value != null ? finder.apply(value) ? (E)value : null : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(value != null && finder.apply(value)) list.add((E) value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.peerat.parser.java.operation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import dev.peerat.parser.java.JavaElement;
|
||||
|
@ -16,4 +17,6 @@ public class SwitchOperation extends Operation{
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.peerat.parser.java.operation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import dev.peerat.parser.java.JavaElement;
|
||||
|
@ -29,4 +30,9 @@ public class ThrowOperation extends Operation{
|
|||
return finder.apply(value) ? (E)value : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
||||
if(finder.apply(value)) list.add((E) value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue