Helper methods to convert type names.

This commit is contained in:
Jakob Herrmann 2017-02-22 13:14:32 +01:00
parent 15f8a1b99d
commit d63fe45d08

View File

@ -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<ClassOrInterface> classes = new ArrayList<>();
this.getNames(ctx);