modified: src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java

modified:   src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
This commit is contained in:
AluAli 2021-01-22 15:07:03 +01:00
parent c15953bbac
commit 1a135ebe5c
2 changed files with 32 additions and 11 deletions

View File

@ -35,12 +35,26 @@ public class FamilyOfGeneratedGenerics {
cs_cl.add(cons);
}
}
List<ClassConstraint> classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher
boolean equalsConstraintsList = false;
List<ClassConstraint> tempList = new ArrayList<>();
do {
List<ClassConstraint> classConstraints2 = new ArrayList<>();
classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher
if (classConstraints2 == tempList) {
equalsConstraintsList = true;
}
for (ClassConstraint cons: classConstraints2) {
if (!checkForDuplicates(cons, cs_cl)) {
cs_cl.add(cons);
}
}
tempList = new ArrayList<>(classConstraints2);
for (ClassConstraint cc : tempList) {
classConstraints2.remove(cc);
System.out.println(classConstraints2);
}
}while(!equalsConstraintsList);
List<ClassConstraint> classConstraints3 = hasNoSupertypeForClassTypes(cs, cs_cl, posOfTphs);
for (ClassConstraint cons: classConstraints3) {
if (!checkForDuplicates(cons, cs_cl)) {
@ -138,14 +152,18 @@ public class FamilyOfGeneratedGenerics {
*/
public static List<ClassConstraint> transitiveSubtypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl) {
List<ClassConstraint> tempCC = new ArrayList<>();
ClassConstraint consToAdd;
for(ClassConstraint cCons: cs_cl) {
if(cCons.getLeft() != null && cCons.getRel()==Relation.EXTENDS) {
for(TPHConstraint allCons: allConstraints) {
if(cCons.getRight() == allCons.getLeft() && allCons.getRight() != null && allCons.getRel()==Relation.EXTENDS){
ClassConstraint consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel());
consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel());
if (!checkForDuplicates(consToAdd, tempCC)) {
tempCC.add(consToAdd);
}
// if (tempCC != null) {
// transitiveSubtypeForClassTypes(allConstraints, tempCC);
// }
}
}
}
@ -279,12 +297,15 @@ public class FamilyOfGeneratedGenerics {
* nimm die Menge cs_cl aus cs_m raus
*/
public static List<MethodConstraint> methodTypesWithoutClassTypes(List<ClassConstraint> cs_cl, List<MethodConstraint> cs_m) {
//TODO:
// erstelle Kopie der Liste cs_cl
List<TPHConstraint> tempCC = new ArrayList<>();
for(ClassConstraint cc: cs_cl) {
TPHConstraint tphC = new TPHConstraint(cc.getLeft(), cc.getRight(), cc.getRel());
tempCC.add(tphC);
}
// Transitive Hülle von cs_cl
List<TPHConstraint> tcOfCsCl = buildTransitiveClosure(tempCC);
List<TPHConstraint> tempMC = new ArrayList<>();
for(MethodConstraint mc: cs_m) {
TPHConstraint tphC = new TPHConstraint(mc.getLeft(), mc.getRight(), mc.getRel());
@ -294,7 +315,7 @@ public class FamilyOfGeneratedGenerics {
tempMC2.addAll(tempMC);
List<MethodConstraint> tempMCToReturn = new ArrayList<>();
for(TPHConstraint cc: tempCC) {
for(TPHConstraint cc: tcOfCsCl) {
for(TPHConstraint mc: tempMC) {
if(cc.getLeft().equals(mc.getLeft()) && cc.getRight().equals(mc.getRight())) {
tempMC2.remove(mc);