From aab4cd5fd8d42f350ee1472bec4c37f4b14a9d2e Mon Sep 17 00:00:00 2001 From: jeffcheasey88 <66554203+jeffcheasey88@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:22:46 +0200 Subject: [PATCH] Refractor Annotation buffer --- .../peeratcode/parser/java/Annotation.java | 7 ++- .../peeratcode/parser/java/Class.java | 30 +++++++---- .../peeratcode/parser/java/Function.java | 24 ++++----- .../peeratcode/parser/java/JavaFile.java | 17 ++++++- .../peeratcode/parser/java/JavaParser.java | 51 ++++++++++++++----- .../peeratcode/parser/java/Variable.java | 18 +++---- .../parser/java/AnnotationTests.java | 7 ++- .../peeratcode/parser/java/ClassTests.java | 7 +-- .../peeratcode/parser/java/FunctionTests.java | 5 +- .../peeratcode/parser/java/VariableTests.java | 5 +- 10 files changed, 105 insertions(+), 66 deletions(-) diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Annotation.java b/src/be/jeffcheasey88/peeratcode/parser/java/Annotation.java index a35d5f2..960212b 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Annotation.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Annotation.java @@ -1,5 +1,6 @@ package be.jeffcheasey88.peeratcode.parser.java; +import java.util.List; import java.util.Map; import java.util.function.Function; @@ -7,9 +8,11 @@ import be.jeffcheasey88.peeratcode.parser.Token; public class Annotation extends JavaElement{ - public static interface Annotable{ + public static interface AnnotableBuffer{ - void addAnnotation(Annotation annotation); + void addAnnotationBuffer(Annotation annotation); + + List getAnnotationBuffer(); } diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Class.java b/src/be/jeffcheasey88/peeratcode/parser/java/Class.java index c9354df..176c7f8 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Class.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Class.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; import be.jeffcheasey88.peeratcode.parser.Token; -import be.jeffcheasey88.peeratcode.parser.java.Annotation.Annotable; +import be.jeffcheasey88.peeratcode.parser.java.Annotation.AnnotableBuffer; import be.jeffcheasey88.peeratcode.parser.java.Function.FunctionContainer; import be.jeffcheasey88.peeratcode.parser.java.Variable.VariableContainer; @@ -14,8 +14,9 @@ interface ClassContainer{ } -public class Class extends JavaElement implements Annotable, ClassContainer, FunctionContainer, VariableContainer{ +public class Class extends JavaElement implements AnnotableBuffer, ClassContainer, FunctionContainer, VariableContainer{ + private List annotationBuffer; private List annotations; @@ -25,14 +26,14 @@ public class Class extends JavaElement implements Annotable, ClassContainer, Fun private List elements; - public Class(Token name){ + public Class(List annotations, Token name){ + this.annotations = annotations; this.name = name; - this.annotations = new ArrayList<>(); this.elements = new ArrayList<>(); } - public Class(Token name, Token extend, Token implement){ - this(name); + public Class(List annotations, Token name, Token extend, Token implement){ + this(annotations, name); this.extend = extend; this.implement = implement; } @@ -42,11 +43,6 @@ public class Class extends JavaElement implements Annotable, ClassContainer, Fun this.elements.add(function); } - @Override - public void addAnnotation(Annotation annotation) { - this.annotations.add(annotation); - } - @Override public void addVariable(Variable variable) { this.elements.add(variable); @@ -67,6 +63,18 @@ public class Class extends JavaElement implements Annotable, ClassContainer, Fun } return null; } + + @Override + public void addAnnotationBuffer(Annotation annotation){ + if(annotationBuffer == null) annotationBuffer = new ArrayList<>(); + annotationBuffer.add(annotation); + } + + public List getAnnotationBuffer(){ + List list = this.annotationBuffer; + this.annotationBuffer = null; + return list; + } } diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Function.java b/src/be/jeffcheasey88/peeratcode/parser/java/Function.java index 9a84030..b170191 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Function.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Function.java @@ -4,11 +4,10 @@ import java.util.ArrayList; import java.util.List; import be.jeffcheasey88.peeratcode.parser.Token; -import be.jeffcheasey88.peeratcode.parser.java.Annotation.Annotable; import be.jeffcheasey88.peeratcode.parser.java.Operation.OperationContainer; import be.jeffcheasey88.peeratcode.parser.java.Variable.VariableContainer; -public class Function extends JavaElement implements Annotable, VariableContainer, OperationContainer{ +public class Function extends JavaElement implements VariableContainer, OperationContainer{ public static interface FunctionContainer{ @@ -27,34 +26,29 @@ public class Function extends JavaElement implements Annotable, VariableContaine private List elements; - public Function(int mod, Token type, Token name){ + public Function(List annotations, int mod, Token type, Token name){ + this.annotations = annotations; this.mod = mod; this.type = type; this.name = name; - this.annotations = new ArrayList<>(); this.elements = new ArrayList<>(); } - public Function(int mod, Token generic, Token type, Token name){ - this(mod, type, name); + public Function(List annotations, int mod, Token generic, Token type, Token name){ + this(annotations, mod, type, name); this.generic = generic; } - public Function(int mod, Token generic, Token type, Token name, List parameters){ - this(mod, generic, type, name); + public Function(List annotations, int mod, Token generic, Token type, Token name, List parameters){ + this(annotations, mod, generic, type, name); this.parameters = parameters; } - public Function(int mod, Token generic, Token type, Token name, List parameters, List throwables){ - this(mod, generic, type, name, parameters); + public Function(List annotations, int mod, Token generic, Token type, Token name, List parameters, List throwables){ + this(annotations, mod, generic, type, name, parameters); this.throwables = throwables; } - @Override - public void addAnnotation(Annotation annotation) { - this.annotations.add(annotation); - } - @Override public void addVariable(Variable variable) { this.elements.add(variable); diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/JavaFile.java b/src/be/jeffcheasey88/peeratcode/parser/java/JavaFile.java index 219fb60..047e340 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/JavaFile.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/JavaFile.java @@ -6,8 +6,11 @@ import java.util.function.Function; import be.jeffcheasey88.peeratcode.parser.Bag; import be.jeffcheasey88.peeratcode.parser.Token; +import be.jeffcheasey88.peeratcode.parser.java.Annotation.AnnotableBuffer; -public class JavaFile extends JavaElement implements ClassContainer{ +public class JavaFile extends JavaElement implements ClassContainer, AnnotableBuffer{ + + private List annotationBuffer; private List pack; private List> imports; @@ -51,4 +54,16 @@ public class JavaFile extends JavaElement implements ClassContainer{ } return null; } + + @Override + public void addAnnotationBuffer(Annotation annotation){ + if(annotationBuffer == null) annotationBuffer = new ArrayList<>(); + annotationBuffer.add(annotation); + } + + public List getAnnotationBuffer(){ + List list = this.annotationBuffer; + this.annotationBuffer = null; + return list; + } } diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java b/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java index 0fe36e6..4099640 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java @@ -21,7 +21,7 @@ import be.jeffcheasey88.peeratcode.parser.Token; import be.jeffcheasey88.peeratcode.parser.TokenType; import be.jeffcheasey88.peeratcode.parser.TokenValidator; import be.jeffcheasey88.peeratcode.parser.Tokenizer; -import be.jeffcheasey88.peeratcode.parser.java.Annotation.Annotable; +import be.jeffcheasey88.peeratcode.parser.java.Annotation.AnnotableBuffer; import be.jeffcheasey88.peeratcode.parser.java.Function.FunctionContainer; import be.jeffcheasey88.peeratcode.parser.java.Variable.VariableContainer; import be.jeffcheasey88.peeratcode.parser.state.BuilderStateTree; @@ -450,7 +450,7 @@ public class JavaParser extends Parser { annotation_name.end((parent, bag) -> { Annotation result = new Annotation(bag.get("name")); bag.set(result); - if(parent instanceof Annotable) ((Annotable)parent).addAnnotation(result); + if(parent instanceof AnnotableBuffer) ((AnnotableBuffer)parent).addAnnotationBuffer(result); return null; }); StateTree annotation_begin = annotation_name.then((validator) -> validator.validate((token) -> token.getValue().equals("("))); @@ -458,7 +458,7 @@ public class JavaParser extends Parser { annotation_end.end((parent, bag) -> { Annotation result = new Annotation(bag.get("name"), bag.get("values")); bag.set(result); - if(parent instanceof Annotable) ((Annotable)parent).addAnnotation(result); + if(parent instanceof AnnotableBuffer) ((AnnotableBuffer)parent).addAnnotationBuffer(result); return null; }); StateTree annotation_var = annotation_begin.then((validator) -> validator.validate( @@ -490,7 +490,9 @@ public class JavaParser extends Parser { Token vtype = bag.get("type"); Map map = bag.get("vars"); for(Entry vars : map.entrySet()){ - Variable result = new Variable(mod == null ? 0 : mod, vtype, vars.getKey(), false, vars.getValue()); + List annotations = null; + if(parent instanceof AnnotableBuffer) annotations = (((AnnotableBuffer)parent).getAnnotationBuffer()); + Variable result = new Variable(annotations, mod == null ? 0 : mod, vtype, vars.getKey(), false, vars.getValue()); bag.set(result); if(parent instanceof VariableContainer) ((VariableContainer)parent).addVariable(result); } @@ -731,7 +733,7 @@ public class JavaParser extends Parser { BiFunction function_builder = (parent, bag) -> { buildVariable(bag); Integer mod = bag.get("mod"); - Function function = new Function(mod == null ? 0 : mod, bag.get("generic"), bag.get("type"), bag.get("name"), bag.get("param"), bag.get("throws")); + Function function = new Function((((AnnotableBuffer)parent).getAnnotationBuffer()), mod == null ? 0 : mod, bag.get("generic"), bag.get("type"), bag.get("name"), bag.get("param"), bag.get("throws")); if(parent instanceof FunctionContainer) ((FunctionContainer)parent).addFunction(function); return function; }; @@ -739,7 +741,7 @@ public class JavaParser extends Parser { InitialStateTree function = new InitialStateTree<>(); function.multiple(annotation); BuilderStateTree function_static = function.then((validator) -> validator.validate((token) -> token.getValue().equals("static")) && validator.validate((token) -> token.getValue().equals("{"))).end((parent, bag) -> { - Function build = new Function(Modifier.STATIC, null, null); + Function build = new Function((((AnnotableBuffer)parent).getAnnotationBuffer()), Modifier.STATIC, null, null); if(parent instanceof FunctionContainer) ((FunctionContainer)parent).addFunction(build); return build; }); @@ -828,27 +830,40 @@ public class JavaParser extends Parser { StateTree clazz_base = clazz.then((validator) -> validator.validate((token) -> token.getValue().equals("class"))) .then(new RedirectStateTree<>(type, (global, local) -> global.set("name", local.get()))); clazz_base.then((validator) -> validator.validate((token) -> token.getValue().equals("{"))) - .end((JavaElement, bag) -> null) + .end((parent, bag) -> { + Class current = new Class((((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); StateTree clazz_implement = clazz_base.then((validator) -> validator.validate((token) -> token.getValue().equals("implements"))); StateTree clazz_implement_name = clazz_implement.then(new RedirectStateTree<>(type, (global, local) -> { Token token = global.get("implement"); -// if(token == null) token = local.get(); -// else token = token.concat(local.get()); - global.set("implement", token); + if(token == null) global.set("implement", local.get()); + else global.set("implement", token.concat(local.get())); })); - clazz_implement_name.then((validator) -> validator.validate((token) -> token.getValue().equals(","))).then(clazz_implement_name); + clazz_implement_name.then((validator) -> validator.validate( + (token) -> token.getValue().equals(","), + (bag, token) -> bag.set("implement", bag.get("implement").concat(token)))).then(clazz_implement_name); clazz_implement_name.then((validator) -> validator.validate((token) -> token.getValue().equals("{"))) - .end((JavaElement, bag) -> null) + .end((parent, bag) -> { + Class current = new Class((((AnnotableBuffer)parent).getAnnotationBuffer()), bag.get("name"), bag.get("extend"), bag.get("implements")); + 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); StateTree clazz_extend = clazz_base.then((validator) -> validator.validate((token) -> token.getValue().equals("extends"))) .then(new RedirectStateTree<>(type, (global, local) -> global.set("extend", local.get()))); clazz_extend.then((validator) -> validator.validate((token) -> token.getValue().equals("{"))) - .end((JavaElement, bag) -> null) + .end((parent, bag) -> { + Class current = new Class((((AnnotableBuffer)parent).getAnnotationBuffer()), bag.get("name"), bag.get("extend"), bag.get("implements")); + 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); @@ -982,6 +997,7 @@ public class JavaParser extends Parser { System.out.println("init"); } + //TAKE ANNOTATIONS ??????? private static void buildVariable(Bag bag){ if(!bag.has("arg_name")) return; @@ -993,7 +1009,7 @@ public class JavaParser extends Parser { Integer mod = bag.get("arg_mod"); - Variable variable = new Variable(mod == null ? 0 : mod, bag.get("arg_type"), bag.get("arg_name"), bag.get("arg_elips") == Boolean.TRUE); + Variable variable = new Variable(null, mod == null ? 0 : mod, bag.get("arg_type"), bag.get("arg_name"), bag.get("arg_elips") == Boolean.TRUE); bag.remove("arg_name"); bag.remove("arg_mod"); bag.remove("arg_type"); @@ -1032,6 +1048,13 @@ public class JavaParser extends Parser { Parser parser = new JavaParser(); JavaFile jFile = new JavaFile(); parser.parse(reader, jFile); + + System.out.println(); + + jFile.find((e) -> { + System.out.println(e); + return false; + }); System.out.println((System.currentTimeMillis()-time)+"ms"); diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Variable.java b/src/be/jeffcheasey88/peeratcode/parser/java/Variable.java index b85d25c..ccd062b 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Variable.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Variable.java @@ -5,9 +5,8 @@ import java.util.List; import java.util.function.Function; import be.jeffcheasey88.peeratcode.parser.Token; -import be.jeffcheasey88.peeratcode.parser.java.Annotation.Annotable; -public class Variable extends JavaElement implements Annotable{ +public class Variable extends JavaElement{ public static interface VariableContainer{ @@ -23,20 +22,20 @@ public class Variable extends JavaElement implements Annotable{ private boolean elips; private Value value; - public Variable(int mod, Token type, Token name){ + public Variable(List annotations, int mod, Token type, Token name){ this.mod = mod; this.type = type; this.name = name; this.annotations = new ArrayList<>(); } - public Variable(int mod, Token type, Token name, boolean elips){ - this(mod, type, name); + public Variable(List annotations, int mod, Token type, Token name, boolean elips){ + this(annotations, mod, type, name); this.elips = elips; } - public Variable(int mod, Token type, Token name, boolean elips, Value value){ - this(mod, type, name, elips); + public Variable(List annotations, int mod, Token type, Token name, boolean elips, Value value){ + this(annotations, mod, type, name, elips); this.value = value; } @@ -45,11 +44,6 @@ public class Variable extends JavaElement implements Annotable{ return "Variable[mod="+mod+", type="+type+", name="+name+", elips="+elips+", value="+value+"]"; } - @Override - public void addAnnotation(Annotation annotation){ - this.annotations.add(annotation); - } - @Override public E find(Function finder){ for(Annotation annotation : this.annotations){ diff --git a/test/be/jeffcheasey88/peeratcode/parser/java/AnnotationTests.java b/test/be/jeffcheasey88/peeratcode/parser/java/AnnotationTests.java index 0f0d7dc..f43dc83 100644 --- a/test/be/jeffcheasey88/peeratcode/parser/java/AnnotationTests.java +++ b/test/be/jeffcheasey88/peeratcode/parser/java/AnnotationTests.java @@ -11,8 +11,7 @@ import be.jeffcheasey88.peeratcode.parser.Parser; import be.jeffcheasey88.peeratcode.parser.Token; import be.jeffcheasey88.peeratcode.parser.TokenType; import be.jeffcheasey88.peeratcode.parser.TokenValidator; -import be.jeffcheasey88.peeratcode.parser.java.Annotation.Annotable; -import be.jeffcheasey88.peeratcode.parser.java.Function.FunctionContainer; +import be.jeffcheasey88.peeratcode.parser.java.Annotation.AnnotableBuffer; import be.jeffcheasey88.peeratcode.parser.state.RedirectStateTree; import be.jeffcheasey88.peeratcode.parser.state.StateTree; @@ -41,7 +40,7 @@ public class AnnotationTests { annotation_name.end((parent, bag) -> { Annotation result = new Annotation(bag.get("name")); bag.set(result); - if(parent instanceof Annotable) ((Annotable)parent).addAnnotation(result); + if(parent instanceof AnnotableBuffer) ((AnnotableBuffer)parent).addAnnotationBuffer(result); return null; }); StateTree annotation_begin = annotation_name.then((validator) -> validator.validate((token) -> token.getValue().equals("("))); @@ -49,7 +48,7 @@ public class AnnotationTests { annotation_end.end((parent, bag) -> { Annotation result = new Annotation(bag.get("name"), bag.get("values")); bag.set(result); - if(parent instanceof Annotable) ((Annotable)parent).addAnnotation(result); + if(parent instanceof AnnotableBuffer) ((AnnotableBuffer)parent).addAnnotationBuffer(result); return null; }); StateTree annotation_var = annotation_begin.then((validator) -> validator.validate( diff --git a/test/be/jeffcheasey88/peeratcode/parser/java/ClassTests.java b/test/be/jeffcheasey88/peeratcode/parser/java/ClassTests.java index 0608208..f8e5d03 100644 --- a/test/be/jeffcheasey88/peeratcode/parser/java/ClassTests.java +++ b/test/be/jeffcheasey88/peeratcode/parser/java/ClassTests.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test; import be.jeffcheasey88.peeratcode.parser.Parser; import be.jeffcheasey88.peeratcode.parser.Token; import be.jeffcheasey88.peeratcode.parser.TokenValidator; +import be.jeffcheasey88.peeratcode.parser.java.Annotation.AnnotableBuffer; import be.jeffcheasey88.peeratcode.parser.state.RedirectStateTree; import be.jeffcheasey88.peeratcode.parser.state.StateTree; @@ -22,7 +23,7 @@ public class ClassTests{ .then(new RedirectStateTree<>(TypeTests.get(), (global, local) -> global.set("name", local.get()))); clazz_base.then((validator) -> validator.validate((token) -> token.getValue().equals("{"))) .end((parent, bag) -> { - Class current = new Class(bag.get("name")); + Class current = new Class((((AnnotableBuffer)parent).getAnnotationBuffer()), bag.get("name")); if(parent instanceof ClassContainer) ((ClassContainer)parent).addClass(current); return current; }) @@ -40,7 +41,7 @@ public class ClassTests{ (bag, token) -> bag.set("implement", bag.get("implement").concat(token)))).then(clazz_implement_name); clazz_implement_name.then((validator) -> validator.validate((token) -> token.getValue().equals("{"))) .end((parent, bag) -> { - Class current = new Class(bag.get("name"), bag.get("extend"), bag.get("implements")); + Class current = new Class((((AnnotableBuffer)parent).getAnnotationBuffer()),bag.get("name"), bag.get("extend"), bag.get("implements")); if(parent instanceof ClassContainer) ((ClassContainer)parent).addClass(current); return current; }) @@ -51,7 +52,7 @@ public class ClassTests{ .then(new RedirectStateTree<>(TypeTests.get(), (global, local) -> global.set("extend", local.get()))); clazz_extend.then((validator) -> validator.validate((token) -> token.getValue().equals("{"))) .end((parent, bag) -> { - Class current = new Class(bag.get("name"), bag.get("extend"), bag.get("implements")); + Class current = new Class((((AnnotableBuffer)parent).getAnnotationBuffer()), bag.get("name"), bag.get("extend"), bag.get("implements")); if(parent instanceof ClassContainer) ((ClassContainer)parent).addClass(current); return current; }) diff --git a/test/be/jeffcheasey88/peeratcode/parser/java/FunctionTests.java b/test/be/jeffcheasey88/peeratcode/parser/java/FunctionTests.java index c373015..a502667 100644 --- a/test/be/jeffcheasey88/peeratcode/parser/java/FunctionTests.java +++ b/test/be/jeffcheasey88/peeratcode/parser/java/FunctionTests.java @@ -13,6 +13,7 @@ import be.jeffcheasey88.peeratcode.parser.Parser; import be.jeffcheasey88.peeratcode.parser.Token; import be.jeffcheasey88.peeratcode.parser.TokenType; import be.jeffcheasey88.peeratcode.parser.TokenValidator; +import be.jeffcheasey88.peeratcode.parser.java.Annotation.AnnotableBuffer; import be.jeffcheasey88.peeratcode.parser.java.Function.FunctionContainer; import be.jeffcheasey88.peeratcode.parser.state.BuilderStateTree; import be.jeffcheasey88.peeratcode.parser.state.InitialStateTree; @@ -26,7 +27,7 @@ public class FunctionTests { BiFunction function_builder = (parent, bag) -> { buildVariable(bag); Integer mod = bag.get("mod"); - Function function = new Function(mod == null ? 0 : mod, bag.get("generic"), bag.get("type"), bag.get("name"), bag.get("param"), bag.get("throws")); + Function function = new Function((((AnnotableBuffer)parent).getAnnotationBuffer()), mod == null ? 0 : mod, bag.get("generic"), bag.get("type"), bag.get("name"), bag.get("param"), bag.get("throws")); if(parent instanceof FunctionContainer) ((FunctionContainer)parent).addFunction(function); return function; }; @@ -114,7 +115,7 @@ public class FunctionTests { Integer mod = bag.get("arg_mod"); - Variable variable = new Variable(mod == null ? 0 : mod, bag.get("arg_type"), bag.get("arg_name"), bag.get("arg_elips") == Boolean.TRUE); + Variable variable = new Variable(null, mod == null ? 0 : mod, bag.get("arg_type"), bag.get("arg_name"), bag.get("arg_elips") == Boolean.TRUE); bag.remove("arg_name"); bag.remove("arg_mod"); bag.remove("arg_type"); diff --git a/test/be/jeffcheasey88/peeratcode/parser/java/VariableTests.java b/test/be/jeffcheasey88/peeratcode/parser/java/VariableTests.java index a4d85e2..6e6928e 100644 --- a/test/be/jeffcheasey88/peeratcode/parser/java/VariableTests.java +++ b/test/be/jeffcheasey88/peeratcode/parser/java/VariableTests.java @@ -14,6 +14,7 @@ import be.jeffcheasey88.peeratcode.parser.Parser; import be.jeffcheasey88.peeratcode.parser.Token; import be.jeffcheasey88.peeratcode.parser.TokenType; import be.jeffcheasey88.peeratcode.parser.TokenValidator; +import be.jeffcheasey88.peeratcode.parser.java.Annotation.AnnotableBuffer; import be.jeffcheasey88.peeratcode.parser.java.Variable.VariableContainer; import be.jeffcheasey88.peeratcode.parser.state.InitialStateTree; import be.jeffcheasey88.peeratcode.parser.state.RedirectStateTree; @@ -27,7 +28,7 @@ public class VariableTests{ Token type = bag.get("type"); Map map = bag.get("vars"); for(Entry vars : map.entrySet()){ - Variable result = new Variable(mod == null ? 0 : mod, type, vars.getKey(), false, vars.getValue()); + Variable result = new Variable((((AnnotableBuffer)parent).getAnnotationBuffer()), mod == null ? 0 : mod, type, vars.getKey(), false, vars.getValue()); bag.set(result); if(parent instanceof VariableContainer) ((VariableContainer)parent).addVariable(result); } @@ -79,7 +80,7 @@ public class VariableTests{ TokenValidator.TOKENS = 0; TokenValidator.MAX_VALIDATE = 0; - JavaElement result = new Class(new Token(0, 0, "Test", TokenType.NAME)); + JavaElement result = new Class(null, new Token(0, 0, "Test", TokenType.NAME)); parser.parse(value, result);