diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index 8e01897e..ee07357e 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -10,18 +10,24 @@ import java.util.ArrayList; import java.util.List; import org.antlr.v4.runtime.tree.TerminalNode; public class SyntaxTreeGenerator{ - JavaClassRegistry reg = new JavaClassRegistry(); - String pkgName = null; - List imports = null; + private JavaClassRegistry reg; + private String pkgName = ""; + List imports = new ArrayList(); - public void getNames(Java8Parser.CompilationUnitContext ctx){ + public SyntaxTreeGenerator(JavaClassRegistry reg){ + this.reg = reg; + } + + public void setPackageName(Java8Parser.CompilationUnitContext ctx){ if(ctx.packageDeclaration() != null){ - this.pkgName = ""; for(TerminalNode t : ctx.packageDeclaration().Identifier()){ this.pkgName = this.pkgName + "." + t.toString(); } this.pkgName = this.pkgName.substring(1); } + } + + public void getNames(Java8Parser.CompilationUnitContext ctx){ String nameString = ""; for (Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){ if(typeDecl.interfaceDeclaration() != null){ @@ -48,6 +54,10 @@ public class SyntaxTreeGenerator{ } } } + + public JavaClassRegistry getReg{ + return this.reg; + } public SourceFile convert(Java8Parser.CompilationUnitContext ctx){ List classes = new ArrayList<>();