More converters & cleanup.

This commit is contained in:
Jakob Herrmann 2017-01-17 20:59:42 +01:00
parent 5814cac83f
commit fbfa407c26

View File

@ -55,21 +55,59 @@ public class SyntaxTreeGenerator{
for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
ClassOrInterface newClass = null;
if(typeDecl.classDeclaration() != null){
newClass = convertCl(typeDecl.classDeclaration());
newClass = convertClass(typeDecl.classDeclaration());
}
else{
newClass = convertIf(typeDecl.interfaceDeclaration());
newClass = convertInterface(typeDecl.interfaceDeclaration());
}
classes.add(newClass);
}
return new SourceFile(this.pkgName, classes, this.imports);
}
private ClassOrInterface convertCl(Java8Parser.ClassDeclarationContext ctx) {
private ClassOrInterface convertClass(Java8Parser.ClassDeclarationContext ctx) {
ClassOrInterface newClass = null;
if(ctx.normalClassDeclaration() != null){
newClass = convertNormal(ctx.normalClassDeclaration());
}
else{
newClass = convertEnum(ctx.enumDeclaration());
}
return newClass;
}
private ClassOrInterface convertNormal(Java8Parser.NormalClassDeclarationContext ctx){
Modifiers modifiers = null;
JavaClassName name = convert(ctx.Identifier());
Block class_block = null;
List<Field> fielddecl = null;
GenericDeclarationList genericClassParameters = null;
int offset = 0;
RefType superClass = null;
Boolean isInterface = false;
List<RefType> implementedInterfaces = null;
return new ClassOrInterface(modifiers, name, class_block, fielddecl, genericClassParameters, offset, superClass, isInterface, implementedInterfaces);
}
/**
Converts a TerminalNode to JavaClassName. If pkgName is set, it will be included like expected.
**/
private JavaClassName convert(TerminalNode t){
String name = "";
if(this.pkgName != null){
name = this.pkgName + "." + t.toString();
}
else{
name = t.toString();
}
return new JavaClassName(name);
}
private ClassOrInterface convertEnum(Java8Parser.EnumDeclarationContext ctx){
return null;
}
private ClassOrInterface convertIf(Java8Parser.InterfaceDeclarationContext ctx){
private ClassOrInterface convertInterface(Java8Parser.InterfaceDeclarationContext ctx){
return null;
}
}