Merge
This commit is contained in:
parent
af894ebfe4
commit
f18083ba06
@ -51,15 +51,15 @@ public class ASTFactory {
|
||||
java.lang.Class superjreClass = jreClass.getSuperclass();
|
||||
RefType superClass;
|
||||
if(parameterSuperClass != null){
|
||||
superClass = (RefType) convertType(parameterSuperClass);
|
||||
superClass = (RefType) createType(parameterSuperClass);
|
||||
}else if(superjreClass != null){
|
||||
superClass = (RefType) convertType(superjreClass);
|
||||
superClass = (RefType) createType(superjreClass);
|
||||
}else{//Jede Klasse und jedes Interface erbt von Object: (auch Object selbst!)
|
||||
superClass = (RefType) createType(java.lang.Object.class, name, "");
|
||||
superClass = (RefType) createType(java.lang.Object.class);
|
||||
}
|
||||
List<RefType> implementedInterfaces = new ArrayList<>();
|
||||
for(Type jreInterface : jreClass.getGenericInterfaces()){
|
||||
implementedInterfaces.add((RefType) createType(jreInterface, name, ""));
|
||||
implementedInterfaces.add((RefType) createType(jreInterface));
|
||||
}
|
||||
GenericDeclarationList genericDeclarationList = createGenerics(jreClass.getTypeParameters(), jreClass, null);
|
||||
|
||||
@ -68,29 +68,8 @@ public class ASTFactory {
|
||||
return new ClassOrInterface(modifier, name, felder, methoden, konstruktoren, genericDeclarationList, superClass,isInterface, implementedInterfaces, offset);
|
||||
}
|
||||
|
||||
private static RefTypeOrTPHOrWildcardOrGeneric convertType(Type type){
|
||||
if(type instanceof ParameterizedType){
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
for(Type paramType : ((ParameterizedType)type).getActualTypeArguments()){
|
||||
params.add(convertType(paramType));
|
||||
}
|
||||
JavaClassName name = new JavaClassName(((ParameterizedType) type).getRawType().getTypeName());
|
||||
return new RefType(name, params, new NullToken());
|
||||
}else if(type instanceof TypeVariable){
|
||||
return new GenericRefType(((TypeVariable) type).getName(), new NullToken());
|
||||
}else if(type instanceof Class){
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
Class paramClass = (Class) type;
|
||||
for(TypeVariable tv : paramClass.getTypeParameters()){
|
||||
params.add(new GenericRefType(tv.getName(), new NullToken()));
|
||||
}
|
||||
JavaClassName name = new JavaClassName(paramClass.getName());
|
||||
return new RefType(name, params, new NullToken());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static Field createField(java.lang.reflect.Field field, JavaClassName jreClass) {
|
||||
return new Field(field.getName(), createType(field.getGenericType(), jreClass, null), field.getModifiers(), new NullToken());
|
||||
return new Field(field.getName(), createType(field.getType()), field.getModifiers(), new NullToken());
|
||||
}
|
||||
|
||||
//private static RefType createType(Class classType) {
|
||||
@ -99,13 +78,13 @@ public class ASTFactory {
|
||||
|
||||
private static de.dhbwstuttgart.syntaxtree.Constructor createConstructor(Constructor constructor, Class inClass) {
|
||||
String name = constructor.getName();
|
||||
RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass, new JavaClassName(inClass.getName()), name);
|
||||
RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass);
|
||||
Parameter[] jreParams = constructor.getParameters();
|
||||
Type[] jreGenericParams = constructor.getGenericParameterTypes();
|
||||
List<FormalParameter> params = new ArrayList<>();
|
||||
int i = 0;
|
||||
for(Type jreParam : jreGenericParams){
|
||||
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam,new JavaClassName(inClass.getName()), name);
|
||||
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam);
|
||||
params.add(new FormalParameter(jreParams[i].getName(),paramType, new NullToken()));
|
||||
i++;
|
||||
}
|
||||
@ -131,13 +110,13 @@ public class ASTFactory {
|
||||
}else{
|
||||
jreRetType = jreMethod.getReturnType();
|
||||
}
|
||||
returnType = createType(jreRetType,new JavaClassName(inClass.getName()), name);
|
||||
returnType = createType(jreRetType);
|
||||
Parameter[] jreParams = jreMethod.getParameters();
|
||||
Type[] jreGenericParams = jreMethod.getGenericParameterTypes();
|
||||
List<FormalParameter> params = new ArrayList<>();
|
||||
int i = 0;
|
||||
for(Type jreParam : jreGenericParams){
|
||||
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam,new JavaClassName(inClass.getName()), name);
|
||||
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam);
|
||||
params.add(new FormalParameter(jreParams[i].getName(),paramType, new NullToken()));
|
||||
i++;
|
||||
}
|
||||
@ -158,18 +137,7 @@ public class ASTFactory {
|
||||
return new GenericDeclarationList(gtvs,new NullToken());
|
||||
}
|
||||
|
||||
/*
|
||||
public RefType createType(java.lang.Class jreClass){
|
||||
List<RefTypeOrTPH> params = new ArrayList<>();
|
||||
for(TypeVariable jreTV : jreClass.getTypeParameters()){
|
||||
RefType gtv = createType(jreTV);
|
||||
params.add(gtv);
|
||||
}
|
||||
return new RefType(names.getName(jreClass.getName()), params, new NullToken());
|
||||
}
|
||||
*/
|
||||
|
||||
private static RefTypeOrTPHOrWildcardOrGeneric createType(java.lang.reflect.Type type, JavaClassName parentClass, String parentMethod){
|
||||
private static RefTypeOrTPHOrWildcardOrGeneric createType(java.lang.reflect.Type type){
|
||||
if(type.getTypeName().equals("void")){
|
||||
return new Void(new NullToken());
|
||||
}else if(type.getTypeName().equals("int")){
|
||||
@ -194,7 +162,7 @@ public class ASTFactory {
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
if(type instanceof ParameterizedType){
|
||||
for(Type t : ((ParameterizedType)type).getActualTypeArguments()){
|
||||
params.add(createType(t, parentClass, parentMethod));
|
||||
params.add(createType(t));
|
||||
}
|
||||
}
|
||||
String name = type.getTypeName();
|
||||
@ -205,9 +173,9 @@ public class ASTFactory {
|
||||
if(type instanceof java.lang.reflect.WildcardType){
|
||||
java.lang.reflect.WildcardType wildcardType = (java.lang.reflect.WildcardType) type;
|
||||
if(wildcardType.getLowerBounds().length > 0){
|
||||
return new SuperWildcardType(convertType(wildcardType.getLowerBounds()[0]), new NullToken());
|
||||
return new SuperWildcardType(createType(wildcardType.getLowerBounds()[0]), new NullToken());
|
||||
}else if(wildcardType.getUpperBounds().length > 0){
|
||||
return new ExtendsWildcardType(convertType(wildcardType.getUpperBounds()[0]), new NullToken());
|
||||
return new ExtendsWildcardType(createType(wildcardType.getUpperBounds()[0]), new NullToken());
|
||||
}else{//Es handelt sich um den '?'-Typ:
|
||||
return new ExtendsWildcardType(createObjectType(), new NullToken());
|
||||
}
|
||||
@ -224,7 +192,7 @@ public class ASTFactory {
|
||||
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
|
||||
if(bounds.length > 0){
|
||||
for(java.lang.reflect.Type bound : bounds){
|
||||
genericBounds.add((RefType) createType(bound, parentClass, parentMethod));
|
||||
genericBounds.add((RefType) createType(bound));
|
||||
}
|
||||
}
|
||||
return new de.dhbwstuttgart.syntaxtree.GenericTypeVar(jreTVName, genericBounds, new NullToken(), new NullToken());
|
||||
|
@ -45,9 +45,7 @@ public class MethodAssumption extends Assumption{
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgTypes(GenericsResolver resolver) {
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> ret = new ArrayList<>();
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric param : params){
|
||||
if(param instanceof GenericRefType){ //Generics in den Assumptions müssen umgewandelt werden.
|
||||
param = resolver.resolve((GenericRefType) param);
|
||||
}
|
||||
param = resolver.resolve(param);
|
||||
ret.add(param);
|
||||
}
|
||||
return ret;
|
||||
|
@ -60,8 +60,7 @@ public class TYPE {
|
||||
|
||||
return new TypeInferenceInformation(classes);
|
||||
}
|
||||
|
||||
*/
|
||||
*/
|
||||
private ConstraintSet getConstraintsMethod(Method m, TypeInferenceInformation info, ClassOrInterface currentClass) {
|
||||
if(m.block == null)return new ConstraintSet(); //Abstrakte Methoden generieren keine Constraints
|
||||
TypeInferenceBlockInformation blockInfo = new TypeInferenceBlockInformation(info.getAvailableClasses(), currentClass, m);
|
||||
|
Loading…
Reference in New Issue
Block a user