forked from JavaTX/JavaCompilerCore
Merge branch 'bigRefactoring' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into bigRefactoring
This commit is contained in:
commit
c7042d185f
@ -1,5 +1,6 @@
|
||||
package de.dhbwstuttgart.syntaxtree;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Mod;
|
||||
import de.dhbwstuttgart.core.IItemWithOffset;
|
||||
import de.dhbwstuttgart.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
@ -12,6 +13,7 @@ import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -33,6 +35,7 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope{
|
||||
public ClassOrInterface(int modifiers, JavaClassName name, List<Field> fielddecl, List<Method> methods, List<Constructor> constructors, GenericDeclarationList genericClassParameters,
|
||||
RefType superClass, Boolean isInterface, List<RefType> implementedInterfaces, Token offset){
|
||||
super(offset);
|
||||
if(isInterface && !Modifier.isInterface(modifiers))modifiers += Modifier.INTERFACE;
|
||||
this.modifiers = modifiers;
|
||||
this.name = name;
|
||||
this.fields = fielddecl;
|
||||
|
@ -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