modified: ../../../../main/java/de/dhbwstuttgart/bytecode/TPHExtractor.java
modified: ../../../../main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
This commit is contained in:
parent
5fb2d57d3b
commit
905dfd8a27
@ -69,6 +69,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
|
||||
Boolean inMethod = false;
|
||||
boolean inLocalOrParamOrReturn = false;
|
||||
Boolean inLambdaExpression = false;
|
||||
|
||||
public final ArrayList<MethodAndTPH> ListOfMethodsAndTph = new ArrayList<>();
|
||||
final ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> allPairs = new ArrayList<>();
|
||||
@ -254,12 +255,19 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
inMethod = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
inLambdaExpression = true;
|
||||
super.visit(lambdaExpression);
|
||||
inLambdaExpression = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Assign assign) {
|
||||
super.visit(assign);
|
||||
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(assign.rightSide.getType()).resolvedType;
|
||||
RefTypeOrTPHOrWildcardOrGeneric right = resultSet.resolveType(assign.lefSide.getType()).resolvedType;
|
||||
if (left instanceof TypePlaceholder && methodAndTph.getTphs().contains(((TypePlaceholder)left).getName())) {
|
||||
if (left instanceof TypePlaceholder && methodAndTph.getLocalTphs().contains(((TypePlaceholder)left).getName())) {
|
||||
if (right instanceof TypePlaceholder) {
|
||||
methodAndTph.addPair(allPairs.stream().filter(
|
||||
p -> (p.getLeft() instanceof TypePlaceholder &&
|
||||
@ -292,6 +300,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
|| (((ExpressionReceiver)methodCall.receiver).expr instanceof LocalVar) &&
|
||||
nameToField.keySet().contains(fieldOrMethName = ((LocalVar)((ExpressionReceiver)methodCall.receiver).expr).name)
|
||||
)
|
||||
//LOKALE VARIABLEN MUESSE NOCH IN nameToField EINGETRAGEN WERDEN
|
||||
)
|
||||
)
|
||||
{
|
||||
@ -309,7 +318,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
.forEach(x -> {
|
||||
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(x.getType()).resolvedType;
|
||||
RefTypeOrTPHOrWildcardOrGeneric right = resultSet.resolveType(paraIt.next()).resolvedType;
|
||||
if (left instanceof TypePlaceholder && methodAndTph.getTphs().contains(((TypePlaceholder)left).getName())) {
|
||||
if (left instanceof TypePlaceholder && methodAndTph.getLocalTphs().contains(((TypePlaceholder)left).getName())) {
|
||||
if (right instanceof TypePlaceholder) {
|
||||
methodAndTph.addPair(allPairs.stream().filter(
|
||||
p -> (p.getLeft() instanceof TypePlaceholder &&
|
||||
@ -327,19 +336,21 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
@Override
|
||||
public void visit(Return aReturn) {
|
||||
super.visit(aReturn);
|
||||
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(aReturn.retexpr.getType()).resolvedType;
|
||||
RefTypeOrTPHOrWildcardOrGeneric right = resultSet.resolveType(methodAndTph.getReturnType()).resolvedType;
|
||||
if (left instanceof TypePlaceholder && methodAndTph.getTphs().contains(((TypePlaceholder)left).getName())) {
|
||||
if (right instanceof TypePlaceholder) {
|
||||
methodAndTph.addPair(allPairs.stream().filter(
|
||||
if (!inLambdaExpression) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(aReturn.retexpr.getType()).resolvedType;
|
||||
RefTypeOrTPHOrWildcardOrGeneric right = resultSet.resolveType(methodAndTph.getReturnType()).resolvedType;
|
||||
if (left instanceof TypePlaceholder && methodAndTph.getLocalTphs().contains(((TypePlaceholder)left).getName())) {
|
||||
if (right instanceof TypePlaceholder) {
|
||||
methodAndTph.addPair(allPairs.stream().filter(
|
||||
p -> (p.getLeft() instanceof TypePlaceholder &&
|
||||
p.getRight() instanceof TypePlaceholder) &&
|
||||
((TypePlaceholder)p.getLeft()).getName().equals(((TypePlaceholder)left).getName()) &&
|
||||
((TypePlaceholder)p.getRight()).getName().equals(((TypePlaceholder)right).getName())
|
||||
).findFirst()
|
||||
.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,9 +69,9 @@ public class FamilyOfGeneratedGenerics {
|
||||
ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> methodConstraints1Pairs,
|
||||
List<MethodAndTPH> listOfMethodsAndTph) {
|
||||
List<MethodConstraint> cs_m = new ArrayList<>();
|
||||
List<MethodConstraint> methodConstraints1 = typeOfTheMethodInClSigma(cs, posOfTphs);
|
||||
//List<MethodConstraint> methodConstraints1 = typeOfTheMethodInClSigma(cs, posOfTphs);
|
||||
|
||||
List<MethodConstraint> methodConstraints1prime =
|
||||
List<MethodConstraint> methodConstraints1 =
|
||||
methodConstraints1Pairs.stream()
|
||||
.map(p -> new MethodConstraint(p.getLeft().getName(), p.getRight().getName(), Relation.EXTENDS))
|
||||
.collect(Collectors.toList());
|
||||
|
Loading…
Reference in New Issue
Block a user