Bug in ASTFactory beseitigen

This commit is contained in:
JanUlrich 2018-03-13 01:57:21 +01:00
parent 725b071d28
commit bb5945898a
3 changed files with 31 additions and 17 deletions

View File

@ -42,6 +42,12 @@
<artifactId>asm-all</artifactId>
<version>[4.0.0,)</version>
</dependency>
<!--
<dependency>
<groupId>org.bitbucket.mstrobel</groupId>
<artifactId>procyon-reflection</artifactId>
<version>[0.5.32,)</version>
</dependency> -->
</dependencies>
<build>

View File

@ -89,14 +89,21 @@ public class ASTFactory {
return new Field(field.getName(), createType(field.getType(), jreClass, null), field.getModifiers(), new NullToken());
}
//private static RefType createType(Class classType) {
// return createClass(classType).getType();
//}
private static de.dhbwstuttgart.syntaxtree.Constructor createConstructor(Constructor constructor, Class inClass) {
String name = constructor.getName();
RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass, new JavaClassName(inClass.getName()), name);
Parameter[] jreParams = constructor.getParameters();
Type[] jreGenericParams = constructor.getGenericParameterTypes();
List<FormalParameter> params = new ArrayList<>();
for(Parameter jreParam : jreParams){
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam.getType(),new JavaClassName(inClass.getName()), name);
params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken()));
int i = 0;
for(Type jreParam : jreGenericParams){
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam,new JavaClassName(inClass.getName()), name);
params.add(new FormalParameter(jreParams[i].getName(),paramType, new NullToken()));
i++;
}
ParameterList parameterList = new ParameterList(params, new NullToken());
Block block = new Block(new ArrayList<Statement>(), new NullToken());
@ -111,19 +118,24 @@ public class ASTFactory {
return new de.dhbwstuttgart.syntaxtree.Constructor(modifier, name,returnType, parameterList, block, gtvDeclarations, offset, new ArrayList<>());
}
//private static RefType createType(Class classType) {
// return createClass(classType).getType();
//}
public static Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName();
RefTypeOrTPHOrWildcardOrGeneric returnType;
returnType = createType(jreMethod.getReturnType(),new JavaClassName(inClass.getName()), name);
Type jreRetType;
if(jreMethod.getGenericReturnType()!=null){
jreRetType = jreMethod.getGenericReturnType();
}else{
jreRetType = jreMethod.getReturnType();
}
returnType = createType(jreRetType,new JavaClassName(inClass.getName()), name);
Parameter[] jreParams = jreMethod.getParameters();
Type[] jreGenericParams = jreMethod.getGenericParameterTypes();
List<FormalParameter> params = new ArrayList<>();
for(Parameter jreParam : jreParams){
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam.getType(),new JavaClassName(inClass.getName()), name);
params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken()));
int i = 0;
for(Type jreParam : jreGenericParams){
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam,new JavaClassName(inClass.getName()), name);
params.add(new FormalParameter(jreParams[i].getName(),paramType, new NullToken()));
i++;
}
ParameterList parameterList = new ParameterList(params, new NullToken());
Block block = new Block(new ArrayList<Statement>(), new NullToken());

View File

@ -3,10 +3,6 @@ import java.util.Vector;
class MyVector{
id(x){
return id2(x);
}
id2(x){
return id(x);
return (x.elementAt(0));
}
}