From 72f27fab7a8ca4bb430a17c2ffcadbca669da948 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 22 Mar 2018 11:17:51 +0100 Subject: [PATCH] Fehler in ASTFactory Generierung von Superinterfaces beheben --- src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java | 9 +++++++-- test/finiteClosure/SuperInterfacesTest.java | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java index c438bc67..67e1b14c 100644 --- a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java +++ b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java @@ -59,7 +59,7 @@ public class ASTFactory { superClass = (RefType) createType(java.lang.Object.class, name, ""); } List implementedInterfaces = new ArrayList<>(); - for(java.lang.Class jreInterface : jreClass.getInterfaces()){ + for(Type jreInterface : jreClass.getGenericInterfaces()){ implementedInterfaces.add((RefType) createType(jreInterface, name, "")); } GenericDeclarationList genericDeclarationList = createGenerics(jreClass.getTypeParameters(), jreClass, null); @@ -193,7 +193,12 @@ public class ASTFactory { params.add(createType(t, parentClass, parentMethod)); } } - RefType ret = new RefType(new JavaClassName(type.getTypeName()), params, new NullToken()); + String name = type.getTypeName(); + if(name.contains("<")){ //Komischer fix. Type von Generischen Typen kann die Generics im Namen enthalten Type + //Diese entfernen: + name = name.split("<")[0]; + } + RefType ret = new RefType(new JavaClassName(name), params, new NullToken()); return ret; } } diff --git a/test/finiteClosure/SuperInterfacesTest.java b/test/finiteClosure/SuperInterfacesTest.java index d96e5ecc..0e1368c3 100644 --- a/test/finiteClosure/SuperInterfacesTest.java +++ b/test/finiteClosure/SuperInterfacesTest.java @@ -21,7 +21,6 @@ public class SuperInterfacesTest { public void testGeneric() throws ClassNotFoundException { Collection classes = new ArrayList<>(); classes.add(ASTFactory.createClass(TestClassGeneric.class)); - //TODO: Die ASTFactory generiert hier den Supertyp falsch. Es fehlt die Parameterliste System.out.println(FCGenerator.toFC(classes)); } }