diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index 05685b986..0d659d63b 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -14,6 +14,7 @@ import de.dhbwstuttgart.typecheck.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.lang.ClassNotFoundException; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.TerminalNode; @@ -82,6 +83,30 @@ public class SyntaxTreeGenerator{ return this.reg; } + // Converts type name to String. + public String convertTypeName(Java8Parser.TypeNameContext ctx){ + String ret; + if(ctx.packageOrTypeName() == null){ + ret = ctx.Identifier().toString(); + } + else{ + ret = convertPackageOrTypeName(ctx.packageOrTypeName()) + "." + ctx.Identifier().toString(); + } + return ret; + } + + // Converts PackageOrTypeName to String. + public String convertPackageOrTypeName(Java8Parser.PackageOrTypeNameContext ctx){ + String ret; + if(ctx.packageOrTypeName() == null){ + ret = ctx.Identifier().toString(); + } + else{ + ret = convertPackageOrTypeName(ctx.packageOrTypeName()) + "." + ctx.Identifier().toString(); + } + return ret; + } + public SourceFile convert(Java8Parser.CompilationUnitContext ctx){ List classes = new ArrayList<>(); this.getNames(ctx);