modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java

This commit is contained in:
AluAli 2021-03-12 17:08:40 +01:00
parent 6862c91b73
commit 4acb820202

View File

@ -543,6 +543,7 @@ public class FamilyOfGeneratedGenerics {
oldConsListConverted.add(new TPHConstraint(((TypePlaceholder) pair.TA1).getName(), ((TypePlaceholder) pair.TA2).getName(), r));
}
List<TPHConstraint> tcOfoldCons = buildTransitiveClosure(oldConsListConverted);
Set<Pair> tcOfoldConsSet = buildTransitiveClosureForCP(oldCons);
for(int i=0; i<orConsListConverted.size(); i++) {
List<TPHConstraint> extendsList = orConsListConverted.get(i).get(Relation.EXTENDS);
@ -563,6 +564,38 @@ public class FamilyOfGeneratedGenerics {
return tempMC;
}
public static Set<Pair> buildTransitiveClosureForCP(Set constraint) {
Set<Pair> iterSet = new HashSet<>(constraint);
Set<Pair> runSet = new HashSet<>(constraint);
Set<Pair> tcSet = new HashSet<>(constraint);
boolean addedConToList = false;
// for (TPHConstraint cons: iterList) {
Iterator<Pair> itIterSet = iterSet.iterator();
while(itIterSet.hasNext()) {
Pair pairIterSet = itIterSet.next();
// for (TPHConstraint cons2: runList) {
Iterator<Pair> itRunSet = runSet.iterator();
while (itRunSet.hasNext()) {
Pair pairRunSet = itRunSet.next();
// if(cons.getRight() == cons2.getLeft()) {
if(pairIterSet.TA2 == pairRunSet.TA1) {
// TPHConstraint consToAdd = new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS);
Pair p = new Pair(pairIterSet.TA1, pairRunSet.TA2);
// if (!checkForDuplicates(consToAdd,tcList)) {
if(!tcSet.contains(p)) {
// tcList.add(consToAdd);
tcSet.add(p);
addedConToList = true;
if (addedConToList) {
return buildTransitiveClosureForCP(tcSet);
}
}
}
}
}
return tcSet;
}
public static HashMap<String, List<MethodConstraint>> getMethodConstraintsWithPositionNew(List<TPHConstraint> cs, List<ClassConstraint> cs_cl, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, List<MethodAndTPH> listOfMethodsAndTph, ResultSet resSet, Set<Pair> oldCons) {
HashMap<String, List<MethodConstraint>> tempMethodConstraintsWithPosition = new HashMap<>();
List<MethodConstraint> newMCList = new ArrayList<>();