diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java index 5718e72d..871dd300 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java @@ -151,7 +151,7 @@ public class GeneratedGenericsFinder implements ASTVisitor { if(ggResult != null) generatedGenericsForSF.addGenericGeneratorResultClass(ggResult); - + System.out.println("ddd"); } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 4f7d25ed..50170cdf 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; @@ -11,13 +12,16 @@ import java.util.List; public class FamilyOfGeneratedGenerics { public List allConstraints = new ArrayList<>(); + // 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 @@ -43,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<>(); @@ -165,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; } /** @@ -175,9 +197,22 @@ 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_cl, List cs_m, HashMap> posOfTphs) { //TODO: - return null; + List tempCC= new ArrayList<>(); + List tcOfCs = buildTransitiveClosure(allConstraints); + for(ClassConstraint cC : cs_cl) { + for(MethodConstraint mC : cs_m) { + String rightSide = mC.getRight(); + String leftSide = cC.getLeft(); + for(TPHConstraint tphC : tcOfCs) { + if(tphC.getLeft().equals(leftSide)&&tphC.getRight().equals(rightSide)) { + tempCC.add((MethodConstraint) tphC); + } + } + } + } + return tempCC; } /** 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