diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index ede2b1b6..097185e0 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -812,6 +812,36 @@ public class FamilyOfGeneratedGenerics { return tempMC; } + + + public static List methodTypesWithoutClassTypesNEW(String tphToCompute, List cs_m, HashMap>> posOfTphs) { + List tempMC = new ArrayList<>(cs_m); + if(tphToCompute==null || tphToCompute.isEmpty()) { + for(TPHConstraint tphCons: tempMC) { + for(String tph: posOfTphs.keySet()){ + for(PairTphMethod p: posOfTphs.get(tph)) { + if(p.fst == PositionFinder.Position.FIELD && tphCons.getLeft() == tph) { + String rightTPH = tphCons.getRight(); + tempMC.remove(tphCons); + methodTypesWithoutClassTypesNEW(rightTPH,tempMC,posOfTphs); + } + } + } + } + } else { + for(TPHConstraint tphCons: tempMC) { + if(tphCons.getLeft() == tphToCompute) { + String newRightTPH = tphCons.getRight(); + tempMC.remove(tphCons); + methodTypesWithoutClassTypesNEW(newRightTPH,tempMC,posOfTphs); + } + } + } + return tempMC; + } + + + public static HashMap> getMethodConstraintsWithPositionNew(List cs, List cs_cl, HashMap>> posOfTphs, List listOfMethodsAndTph, ResultSet resSet, Set oldCons) { HashMap> tempMethodConstraintsWithPosition = new HashMap<>(); List newMCList = new ArrayList<>(); @@ -857,7 +887,8 @@ public class FamilyOfGeneratedGenerics { } } - mcWithoutCc = methodTypesWithoutClassTypes(cs_cl, listToAdd); +// mcWithoutCc = methodTypesWithoutClassTypes(cs_cl, listToAdd); + mcWithoutCc = methodTypesWithoutClassTypesNEW(null, listToAdd, posOfTphs); tempMethodConstraintsWithPosition.put(currentMethod, mcWithoutCc); } diff --git a/src/test/java/insertGenerics/TestTPHsAndGenerics.java b/src/test/java/insertGenerics/TestTPHsAndGenerics.java index 3bf3dee2..387204c2 100644 --- a/src/test/java/insertGenerics/TestTPHsAndGenerics.java +++ b/src/test/java/insertGenerics/TestTPHsAndGenerics.java @@ -100,9 +100,9 @@ public class TestTPHsAndGenerics { methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc); } else { if (fogg.allConstraints.contains((new MethodConstraint("EIM", "FEA", Relation.EXTENDS)))) { - classConstraintsTest.add(new ClassConstraint("ETW", "DZP", Relation.EXTENDS)); - classConstraintsTest.add(new ClassConstraint("DZP", "U", Relation.EXTENDS)); - classConstraintsTest.add(new ClassConstraint("ETW", "java/lang/Object", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("VK", "EIM", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("EIM", "FEA", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("FEA", "java/lang/Object", Relation.EXTENDS)); lmc.add(new MethodConstraint("AI", "AE", Relation.EXTENDS)); lmc.add(new MethodConstraint("AD", "AI", Relation.EXTENDS)); @@ -112,9 +112,10 @@ public class TestTPHsAndGenerics { methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc); lmc = new HashSet<>(); lmc.add(new MethodConstraint("V", "VK", Relation.EXTENDS)); - methodConstraintsWithPositionTest.put("TPH ETWid2(TPH V)", lmc); + methodConstraintsWithPositionTest.put("TPH FEAid2(TPH V)", lmc); lmc = new HashSet<>(); lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AI", "java/lang/Object", Relation.EXTENDS)); methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc); } }