diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 0bea77178..e881614ea 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.bytecode.insertGenerics; +import de.dhbwstuttgart.bytecode.TPHExtractor; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; @@ -8,6 +9,12 @@ import java.util.HashMap; import java.util.List; public class FamilyOfGeneratedGenerics { + public List allConstraints = new ArrayList<>(); + public HashMap posOfTPHs = new HashMap<>(); + public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) { + this.allConstraints = tphExtractor.allCons; +// this.posOfTPHs = tphExtractor. + } public static List getClassConstraints(List cs, HashMap posOfTphs) { //Inputparameter List constraintsSet weg List cs_cl = new ArrayList<>(); diff --git a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java index 162b4b236..cf15c5748 100644 --- a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java +++ b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java @@ -91,7 +91,6 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { inputConstraints.add(new TPHConstraint("A", "E", TPHConstraint.Relation.EXTENDS)); inputConstraints.add(new TPHConstraint("E", "D", TPHConstraint.Relation.EXTENDS)); - HashMap tphPositions = new HashMap<>(); tphPositions.put("A", PositionFinder.Position.FIELD); tphPositions.put("B", PositionFinder.Position.FIELD); @@ -107,5 +106,52 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } + public void testTPHsAndGenerics() { + /* + class TPHsAndGenerics { + Fun1 id = x -> x; + C id2 (D x) { + return id.apply(x); + } + E m(F a, G b){ + var c = m2(a,b); + return a; + } + H m2(I a, J b){ + return b; + } + } + */ + + List inputConstraints = new ArrayList<>(); + inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("B","C", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("D","A", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("F","E", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("F","I", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("G","J", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("J","H", TPHConstraint.Relation.EXTENDS)); + + HashMap tphPositions = new HashMap<>(); + tphPositions.put("A", PositionFinder.Position.FIELD); + tphPositions.put("B", PositionFinder.Position.FIELD); + tphPositions.put("C", PositionFinder.Position.METHOD); + tphPositions.put("D", PositionFinder.Position.METHOD); + tphPositions.put("E", PositionFinder.Position.METHOD); + tphPositions.put("F", PositionFinder.Position.METHOD); + tphPositions.put("G", PositionFinder.Position.METHOD); + tphPositions.put("H", PositionFinder.Position.METHOD); + tphPositions.put("I", PositionFinder.Position.METHOD); + tphPositions.put("J", PositionFinder.Position.METHOD); + + List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); + System.out.println(classConstraints); + + assertFalse(classConstraints.isEmpty()); + assertTrue(classConstraints.size() == 3); + } + + + } \ No newline at end of file