Fehler in ASTFactory Generierung von Superinterfaces beheben

This commit is contained in:
JanUlrich 2018-03-22 11:17:51 +01:00
parent 06bb978cf6
commit 72f27fab7a
2 changed files with 7 additions and 3 deletions

View File

@ -59,7 +59,7 @@ public class ASTFactory {
superClass = (RefType) createType(java.lang.Object.class, name, "");
}
List<RefType> 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<A>
//Diese entfernen:
name = name.split("<")[0];
}
RefType ret = new RefType(new JavaClassName(name), params, new NullToken());
return ret;
}
}

View File

@ -21,7 +21,6 @@ public class SuperInterfacesTest {
public void testGeneric() throws ClassNotFoundException {
Collection<ClassOrInterface> 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));
}
}