forked from JavaTX/JavaCompilerCore
Fehler in ASTFactory mit Generischen FEldern beheben
This commit is contained in:
parent
c8728bab10
commit
35d5fb2f03
@ -37,7 +37,7 @@ public class ASTFactory {
|
||||
methoden.add(createMethod(method, jreClass));
|
||||
}
|
||||
List<Field> felder = new ArrayList<>();
|
||||
for(java.lang.reflect.Field field : jreClass.getFields()){
|
||||
for(java.lang.reflect.Field field : jreClass.getDeclaredFields()){
|
||||
felder.add(createField(field, name));
|
||||
}
|
||||
int modifier = jreClass.getModifiers();
|
||||
@ -89,7 +89,7 @@ public class ASTFactory {
|
||||
}
|
||||
|
||||
private static Field createField(java.lang.reflect.Field field, JavaClassName jreClass) {
|
||||
return new Field(field.getName(), createType(field.getType(), jreClass, null), field.getModifiers(), new NullToken());
|
||||
return new Field(field.getName(), createType(field.getGenericType(), jreClass, null), field.getModifiers(), new NullToken());
|
||||
}
|
||||
|
||||
//private static RefType createType(Class classType) {
|
||||
|
@ -1,6 +1,9 @@
|
||||
package astfactory;
|
||||
|
||||
//import javafx.collections.ObservableList;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
@ -19,4 +22,13 @@ public class ASTFactoryTest<A> extends HashMap<String, A>{
|
||||
System.out.println(Arrays.toString(arguments));
|
||||
System.out.println(((TypeVariable)arguments[1]).getGenericDeclaration());
|
||||
}
|
||||
|
||||
public static class GenericFieldTest<G>{
|
||||
public G testField;
|
||||
}
|
||||
@Test
|
||||
public void genericFieldTest(){
|
||||
ClassOrInterface test = ASTFactory.createClass(GenericFieldTest.class);
|
||||
assertTrue(test.getFieldDecl().get(0).getType() instanceof GenericRefType);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user