forked from JavaTX/JavaCompilerCore
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 inMethod = false;
|
||||||
boolean inLocalOrParamOrReturn = false;
|
boolean inLocalOrParamOrReturn = false;
|
||||||
|
Boolean inLambdaExpression = false;
|
||||||
|
|
||||||
public final ArrayList<MethodAndTPH> ListOfMethodsAndTph = new ArrayList<>();
|
public final ArrayList<MethodAndTPH> ListOfMethodsAndTph = new ArrayList<>();
|
||||||
final ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> allPairs = new ArrayList<>();
|
final ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> allPairs = new ArrayList<>();
|
||||||
@ -255,11 +256,18 @@ public class TPHExtractor extends AbstractASTWalker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public void visit(LambdaExpression lambdaExpression) {
|
||||||
|
inLambdaExpression = true;
|
||||||
|
super.visit(lambdaExpression);
|
||||||
|
inLambdaExpression = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(Assign assign) {
|
public void visit(Assign assign) {
|
||||||
super.visit(assign);
|
super.visit(assign);
|
||||||
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(assign.rightSide.getType()).resolvedType;
|
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(assign.rightSide.getType()).resolvedType;
|
||||||
RefTypeOrTPHOrWildcardOrGeneric right = resultSet.resolveType(assign.lefSide.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) {
|
if (right instanceof TypePlaceholder) {
|
||||||
methodAndTph.addPair(allPairs.stream().filter(
|
methodAndTph.addPair(allPairs.stream().filter(
|
||||||
p -> (p.getLeft() instanceof TypePlaceholder &&
|
p -> (p.getLeft() instanceof TypePlaceholder &&
|
||||||
@ -292,6 +300,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
|||||||
|| (((ExpressionReceiver)methodCall.receiver).expr instanceof LocalVar) &&
|
|| (((ExpressionReceiver)methodCall.receiver).expr instanceof LocalVar) &&
|
||||||
nameToField.keySet().contains(fieldOrMethName = ((LocalVar)((ExpressionReceiver)methodCall.receiver).expr).name)
|
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 -> {
|
.forEach(x -> {
|
||||||
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(x.getType()).resolvedType;
|
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(x.getType()).resolvedType;
|
||||||
RefTypeOrTPHOrWildcardOrGeneric right = resultSet.resolveType(paraIt.next()).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) {
|
if (right instanceof TypePlaceholder) {
|
||||||
methodAndTph.addPair(allPairs.stream().filter(
|
methodAndTph.addPair(allPairs.stream().filter(
|
||||||
p -> (p.getLeft() instanceof TypePlaceholder &&
|
p -> (p.getLeft() instanceof TypePlaceholder &&
|
||||||
@ -327,9 +336,10 @@ public class TPHExtractor extends AbstractASTWalker {
|
|||||||
@Override
|
@Override
|
||||||
public void visit(Return aReturn) {
|
public void visit(Return aReturn) {
|
||||||
super.visit(aReturn);
|
super.visit(aReturn);
|
||||||
|
if (!inLambdaExpression) {
|
||||||
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(aReturn.retexpr.getType()).resolvedType;
|
RefTypeOrTPHOrWildcardOrGeneric left = resultSet.resolveType(aReturn.retexpr.getType()).resolvedType;
|
||||||
RefTypeOrTPHOrWildcardOrGeneric right = resultSet.resolveType(methodAndTph.getReturnType()).resolvedType;
|
RefTypeOrTPHOrWildcardOrGeneric right = resultSet.resolveType(methodAndTph.getReturnType()).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) {
|
if (right instanceof TypePlaceholder) {
|
||||||
methodAndTph.addPair(allPairs.stream().filter(
|
methodAndTph.addPair(allPairs.stream().filter(
|
||||||
p -> (p.getLeft() instanceof TypePlaceholder &&
|
p -> (p.getLeft() instanceof TypePlaceholder &&
|
||||||
@ -341,6 +351,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,9 +69,9 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> methodConstraints1Pairs,
|
ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> methodConstraints1Pairs,
|
||||||
List<MethodAndTPH> listOfMethodsAndTph) {
|
List<MethodAndTPH> listOfMethodsAndTph) {
|
||||||
List<MethodConstraint> cs_m = new ArrayList<>();
|
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()
|
methodConstraints1Pairs.stream()
|
||||||
.map(p -> new MethodConstraint(p.getLeft().getName(), p.getRight().getName(), Relation.EXTENDS))
|
.map(p -> new MethodConstraint(p.getLeft().getName(), p.getRight().getName(), Relation.EXTENDS))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
Loading…
Reference in New Issue
Block a user