modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
This commit is contained in:
parent
ba8df8b376
commit
d08e598649
@ -513,8 +513,10 @@ public class FamilyOfGeneratedGenerics {
|
||||
|
||||
public static List<MethodConstraint> secondLineMethodDefinition(List<TPHConstraint> allConstraints, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, MethodAndTPH methodAndTPH, ResultSet resSet, Set<Pair> oldCons) {
|
||||
List<MethodConstraint> tempMC = new ArrayList<>(); //für Ergebnisse basierend auf der neuen Datenstruktur (Ali)
|
||||
Set<Pair> tempSet = new HashSet<>(); //für Ergebnisse basierend auf der alten Datenstruktur
|
||||
Set<Pair> tempSet = new HashSet<>(); //für Ergebnisse des ersten Teils basierend auf der alten Datenstruktur
|
||||
Set<Pair> tempSet2 = new HashSet<>(); //für Ergebnisse des zweiten Teils basierend auf der alten Datenstruktur
|
||||
Set<Pair> tcOfoldConsSet = buildTransitiveClosureForCP(oldCons, resSet);
|
||||
List<TPHConstraint> tcOfCs = buildTransitiveClosure(allConstraints);
|
||||
MethodAndTPH methAndTphs = methodAndTPH;
|
||||
List<Set<Constraint<Pair>>> orCons = methAndTphs.constraints.getOderConstraints();
|
||||
List<HashMap<Relation, List<TPHConstraint>>> orConsListConverted = new ArrayList<>();
|
||||
@ -531,10 +533,10 @@ public class FamilyOfGeneratedGenerics {
|
||||
if(p.GetOperator() == PairOperator.SMALLERDOT) {
|
||||
r = Relation.EXTENDS;
|
||||
orConsWithEXTENDS.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r));
|
||||
MethodConstraint mc = new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r);
|
||||
/*MethodConstraint mc = new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r);
|
||||
if(!checkForDuplicates(mc, tempMC)) {
|
||||
tempMC.add(mc);
|
||||
}
|
||||
}*/
|
||||
} else if(p.GetOperator() == PairOperator.EQUALSDOT) {
|
||||
r = Relation.EQUAL;
|
||||
orConsWithEQUAL.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r));
|
||||
@ -566,11 +568,13 @@ public class FamilyOfGeneratedGenerics {
|
||||
|
||||
// dies ist das "R" aus dem ersten Teil, wird im zweiten Teil gebraucht
|
||||
TypePlaceholder tphR = null;
|
||||
Constraint<Pair> extendsSetAllOfOr = new Constraint<Pair>();
|
||||
Constraint<Pair> equalSetAllOfOr = new Constraint<Pair>();
|
||||
|
||||
// Berechnung des ersten Teils der Regel
|
||||
Constraint<Pair> extendsSet = new Constraint<Pair>();
|
||||
Constraint<Pair> equalSet = new Constraint<Pair>();
|
||||
for(int i=0; i<orCons.size(); i++) {
|
||||
Constraint<Pair> extendsSet = new Constraint<Pair>();
|
||||
Constraint<Pair> equalSet = new Constraint<Pair>();
|
||||
//für jede einzelne OrConstraint-Menge gehe durch
|
||||
for(Constraint con: orCons.get(i)) {
|
||||
Iterator<Pair> it = con.iterator();
|
||||
@ -579,8 +583,10 @@ public class FamilyOfGeneratedGenerics {
|
||||
Pair p = it.next();
|
||||
if (p.OperatorSmallerDot()) {
|
||||
extendsSet.add(p);
|
||||
extendsSetAllOfOr.add(p);
|
||||
} else if (p.OperatorEqual()) {
|
||||
equalSet.add(p);
|
||||
equalSetAllOfOr.add(p);
|
||||
}
|
||||
}
|
||||
Iterator<Pair> itExtends = extendsSet.iterator();
|
||||
@ -605,28 +611,52 @@ public class FamilyOfGeneratedGenerics {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Berechnung des zweiten Teils der Regel
|
||||
|
||||
|
||||
/*// Berechnung des zweiten Teils der Regel
|
||||
Iterator<Pair> itEqual = equalSet.iterator();
|
||||
while(itEqual.hasNext()) {
|
||||
Pair pairEqual = itEqual.next();
|
||||
// prüfe, ob das "R" von vorhin in einem EqualConstraint links auftaucht
|
||||
if(tphR == pairEqual.TA1) {
|
||||
tempSet.add();
|
||||
}
|
||||
}
|
||||
Iterator<Pair> itExtends = equalSet.iterator();
|
||||
while(itExtends.hasNext()) {
|
||||
Pair pairExtends = itExtends.next();
|
||||
// prüfe, ob das "R" von vorhin in einem EqualConstraint links auftaucht
|
||||
if(tphR == pairExtends.TA1) {
|
||||
tempSet.add();
|
||||
}
|
||||
Iterator<Pair> itExtends = equalSet.iterator();
|
||||
while(itExtends.hasNext()) {
|
||||
Pair pairExtends = itExtends.next();
|
||||
Pair newPair = new Pair(resSet.resolveType((TypePlaceholder)(pairExtends.TA2)).resolvedType, resSet.resolveType((TypePlaceholder)(pairEqual.TA1)).resolvedType, PairOperator.SMALLERDOT);
|
||||
Iterator<Pair> itTC = tcOfoldConsSet.iterator();
|
||||
while(itTC.hasNext()) {
|
||||
Pair pairTC = itTC.next();
|
||||
|
||||
}
|
||||
// prüfe, ob das "R" von vorhin in einem EqualConstraint links auftaucht
|
||||
if(tphR == pairEqual.TA1) {
|
||||
// tempSet.add();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
// Berechnung des zweiten Teils der Regel
|
||||
Iterator<Pair> itExtends2 = extendsSetAllOfOr.iterator();
|
||||
while(itExtends2.hasNext()) {
|
||||
Pair pairExtends2 = itExtends2.next();
|
||||
Iterator<Pair> itEqual2 = equalSetAllOfOr.iterator();
|
||||
while (itEqual2.hasNext()) {
|
||||
Pair pairEqual2 = itEqual2.next();
|
||||
Pair newPair2 = new Pair(resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, resSet.resolveType((TypePlaceholder) (pairEqual2.TA1)).resolvedType, PairOperator.SMALLERDOT);
|
||||
boolean rEqRtilde = (tphR == pairEqual2.TA1 && checkForDuplicatesForSets(new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairEqual2.TA2)).resolvedType, PairOperator.EQUALSDOT), equalSetAllOfOr));
|
||||
boolean rExRtilde = (tphR == pairExtends2.TA1 && checkForDuplicatesForSets(new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, PairOperator.SMALLERDOT), extendsSetAllOfOr));
|
||||
Pair rExRtildePair = new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, PairOperator.SMALLERDOT);
|
||||
boolean isPairInTExTapostrophe = checkForDuplicatesForSets(rExRtildePair, extendsSetAllOfOr);
|
||||
if (rEqRtilde || rExRtilde || !isPairInTExTapostrophe) {
|
||||
if (newPair2.TA1 != newPair2.TA2) { //eliminieren der Fälle wie AA<.AA
|
||||
if (!checkForDuplicatesForSets(newPair2, tempSet2)) {
|
||||
tempSet2.add(newPair2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// aus der alten Datenstruktur in die neue Datenstruktur (von Ali)
|
||||
// aus der alten Datenstruktur in die neue Datenstruktur (von Ali) für ersten Teil
|
||||
Iterator<Pair> itTemp = tempSet.iterator();
|
||||
while(itTemp.hasNext()) {
|
||||
Pair p = itTemp.next();
|
||||
@ -639,13 +669,35 @@ public class FamilyOfGeneratedGenerics {
|
||||
r = Relation.EQUAL;
|
||||
}
|
||||
MethodConstraint mc = new MethodConstraint(ta1, ta2, r);
|
||||
if(mc.getRel() != Relation.EQUAL) {
|
||||
if(mc.getRel() == Relation.EXTENDS) {
|
||||
if(!checkForDuplicates(mc, tempMC)) {
|
||||
tempMC.add(mc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// aus der alten Datenstruktur in die neue Datenstruktur (von Ali) für zweiten Teil
|
||||
Iterator<Pair> itTemp2 = tempSet2.iterator();
|
||||
while(itTemp2.hasNext()) {
|
||||
Pair p = itTemp2.next();
|
||||
String ta1 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName();
|
||||
String ta2 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName();
|
||||
Relation r = null;
|
||||
if (p.GetOperator() == PairOperator.SMALLERDOT) {
|
||||
r = Relation.EXTENDS;
|
||||
} else if (p.GetOperator() == PairOperator.EQUALSDOT) {
|
||||
r = Relation.EQUAL;
|
||||
}
|
||||
for(TPHConstraint tphCons: tcOfCs) {
|
||||
if(ta1 == tphCons.getLeft() && ta2 == tphCons.getRight() && r==Relation.EXTENDS) {
|
||||
MethodConstraint mc = new MethodConstraint(ta1, ta2, r);
|
||||
if(!checkForDuplicates(mc, tempMC)) {
|
||||
tempMC.add(mc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tempMC;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user