Merge branch 'antlr' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into antlr

This commit is contained in:
JanUlrich 2017-02-10 17:37:56 +01:00
commit 5c36e68825
2 changed files with 7 additions and 5 deletions

View File

@ -28,7 +28,7 @@ public class RunParser{
SyntaxTreeGenerator generator = new SyntaxTreeGenerator(new JavaClassRegistry(new ArrayList<>()));
SourceFile f = generator.convert((Java8Parser.CompilationUnitContext) tree);
String pkgName = f.getPkgName();
System.out.println(pkgName);
System.out.println("package: " + pkgName);
System.out.println("classes:");
for(ClassOrInterface c : f.KlassenVektor){
for(Modifier mod : c.getModifiers().getModifierList()){

View File

@ -36,11 +36,12 @@ public class SyntaxTreeGenerator{
}
public void getNames(Java8Parser.CompilationUnitContext ctx){
if(this.pkgName == "") this.setPackageName(ctx);
String nameString = "";
for (Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
if(typeDecl.interfaceDeclaration() != null){
if(typeDecl.interfaceDeclaration().normalInterfaceDeclaration() != null){
if(this.pkgName != null){
if(this.pkgName != ""){
nameString = this.pkgName + "." + typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
}
else{
@ -130,9 +131,9 @@ public class SyntaxTreeGenerator{
private List<Field> convertFields(Java8Parser.ClassBodyContext classBodyContext) {
List<Field> ret = new ArrayList<>();
for(Java8Parser.ClassBodyDeclarationContext classMember : classBodyContext.classBodyDeclaration()){
if(classMember.classMemberDeclaration()!= null){
if(classMember.classMemberDeclaration() != null){
Java8Parser.ClassMemberDeclarationContext classMemberDeclarationContext = classMember.classMemberDeclaration();
if(classMemberDeclarationContext.fieldDeclaration()!=null){
if(classMemberDeclarationContext.fieldDeclaration() != null){
ret.addAll(convert(classMember.classMemberDeclaration().fieldDeclaration()));
}else if(classMemberDeclarationContext.methodDeclaration()!= null){
ret.add(convert(classMemberDeclarationContext.methodDeclaration()));
@ -148,8 +149,9 @@ public class SyntaxTreeGenerator{
RefTypeOrTPH retType;
if(header.result() != null){
if(header.result().unannType() != null)
if(header.result().unannType() != null){
retType = convert(header.result().unannType());
}
else retType = new de.dhbwstuttgart.syntaxtree.type.Void(header.result().getStart());
}else{
retType = TypePlaceholder.fresh(header.getStart());