diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 05d7b3d7..71b4886b 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -3,6 +3,7 @@ package de.dhbwstuttgart.bytecode.insertGenerics; import de.dhbwstuttgart.bytecode.TPHExtractor; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult; import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; import java.util.ArrayList; @@ -14,11 +15,13 @@ public class FamilyOfGeneratedGenerics { // HashMap speichert ob TPH in einer Methode oder in der Klasse ist; und wenn es in der Methode ist, in welcher Methode public HashMap> posOfTPHs = new HashMap<>(); public List classConstraints = new ArrayList<>(); + public List methodConstraints = new ArrayList<>(); public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) { this.allConstraints = tphExtractor.allCons; this.posOfTPHs = positionConverter(tphExtractor.allTPHS, tphExtractor.ListOfMethodsAndTph); this.classConstraints = getClassConstraints(allConstraints,posOfTPHs); +// this.methodConstraints = } public static List getClassConstraints(List cs, HashMap> posOfTphs) { //Inputparameter List constraintsSet weg @@ -44,6 +47,11 @@ public class FamilyOfGeneratedGenerics { return cs_cl; } + public static List getMethodConstraintsAlternative() { + List ggRes = GenericsGeneratorResult. + return null; + } + public static List getMethodConstraints(List cs, HashMap> posOfTphs) { //TODO: Regeln List cs_m = new ArrayList<>(); @@ -166,9 +174,22 @@ public class FamilyOfGeneratedGenerics { * {R' <. S | (R <. R'), (S <. S') \in cs_m and (R',S) is in the transitive closure of cs} */ - public static List firstTransitiveSubtypeForMethodTypes() { //transitive closure of cs + public static List firstTransitiveSubtypeForMethodTypes(List allConstraints, List cs_m, HashMap> posOfTphs) { //transitive closure of cs //TODO: - return null; + List tempCC= new ArrayList<>(); + List tcOfCs = buildTransitiveClosure(allConstraints); + for(MethodConstraint mC1 : cs_m) { + for(MethodConstraint mC2 : cs_m) { + String rightSide = mC1.getRight(); + String leftSide = mC2.getLeft(); + for(TPHConstraint tphC : tcOfCs) { + if(tphC.getLeft().equals(leftSide)&&tphC.getRight().equals(rightSide)) { + tempCC.add((MethodConstraint) tphC); + } + } + } + } + return tempCC; } /** @@ -176,8 +197,20 @@ public class FamilyOfGeneratedGenerics { * {R' <. S | (R <. R') \in cs_m, (S <. S') \in cs_cl and (R',S) is in the transitive closure of cs} */ - public static List secondTransitiveSubtypeForMethodTypes() { + public static List secondTransitiveSubtypeForMethodTypes(List allConstraints, List cs_m, HashMap> posOfTphs) { //TODO: + List tempCC= new ArrayList<>(); + List tcOfCs = buildTransitiveClosure(allConstraints); + for(MethodConstraint mC1 : cs_m) { + for(MethodConstraint mC2 : cs_m) { + String rightSide = mC1.getRight(); + String leftSide = mC2.getLeft(); + for(TPHConstraint tphC : tcOfCs) { + + } + } + } + return null; return null; } diff --git a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java index b6eb41ce..cb3f6840 100644 --- a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java +++ b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java @@ -199,4 +199,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } + public void testFirstTransitiveSubtypeForMethodTypes(){ + + } + } \ No newline at end of file