forked from JavaTX/JavaCompilerCore
Start rewriting converters to simplify readability etc.
This commit is contained in:
parent
9ef41280ca
commit
5814cac83f
@ -53,48 +53,23 @@ public class SyntaxTreeGenerator{
|
|||||||
List<ClassOrInterface> classes = new ArrayList<>();
|
List<ClassOrInterface> classes = new ArrayList<>();
|
||||||
this.getNames(ctx);
|
this.getNames(ctx);
|
||||||
for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
|
for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
|
||||||
ClassOrInterface newClass = convert(typeDecl);
|
ClassOrInterface newClass = null;
|
||||||
|
if(typeDecl.classDeclaration() != null){
|
||||||
|
newClass = convertCl(typeDecl.classDeclaration());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
newClass = convertIf(typeDecl.interfaceDeclaration());
|
||||||
|
}
|
||||||
classes.add(newClass);
|
classes.add(newClass);
|
||||||
}
|
}
|
||||||
return new SourceFile(this.pkgName, classes, this.imports);
|
return new SourceFile(this.pkgName, classes, this.imports);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassOrInterface convert(Java8Parser.TypeDeclarationContext ctx) {
|
private ClassOrInterface convertCl(Java8Parser.ClassDeclarationContext ctx) {
|
||||||
Java8Parser.ClassDeclarationContext cl = ctx.classDeclaration();
|
|
||||||
Java8Parser.InterfaceDeclarationContext id = ctx.interfaceDeclaration();
|
|
||||||
if(cl != null){
|
|
||||||
Java8Parser.NormalClassDeclarationContext nc = cl.normalClassDeclaration();
|
|
||||||
if(nc != null){
|
|
||||||
Modifiers modifiers = null;
|
|
||||||
if(nc.classModifier() != null){
|
|
||||||
List<Modifier> modList = new ArrayList();
|
|
||||||
for(Java8Parser.ClassModifierContext mod : nc.classModifier()){
|
|
||||||
Modifier m = convert(mod);
|
|
||||||
modList.add(m);
|
|
||||||
}
|
|
||||||
modifiers = new Modifiers(modList);
|
|
||||||
}
|
|
||||||
JavaClassName name = null;
|
|
||||||
if(this.pkgName != null){
|
|
||||||
name = new JavaClassName(this.pkgName +"."+ nc.Identifier().toString());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
name = new JavaClassName(nc.Identifier().toString());
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Modifier convert(Java8Parser.ClassModifierContext ctx){
|
private ClassOrInterface convertIf(Java8Parser.InterfaceDeclarationContext ctx){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user