add replacement of param types with tph and generate consolidated

constraints
This commit is contained in:
Till Schnell 2021-04-06 18:44:30 +02:00
parent b59aabeea5
commit 98b3ad1517
2 changed files with 14 additions and 5 deletions

View File

@ -1,7 +1,7 @@
package de.dhbwstuttgart.inferWildcards; package de.dhbwstuttgart.inferWildcards;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.NullToken;
@ -24,10 +24,18 @@ public class ReplaceTypeparamVisitor
public void visit (RefType refType) { public void visit (RefType refType) {
if (!refType.getParaList().isEmpty()) { if (!refType.getParaList().isEmpty()) {
System.out.println("Type: " + refType); System.out.println("Type: " + refType);
List<RefTypeOrTPHOrWildcardOrGeneric> paraList = refType.getParaList();
paraList.stream().filter(e -> e instanceof RefType).map(RefType.class::cast)
.forEach(this::generateTypePlaceholder);
for (ListIterator<RefTypeOrTPHOrWildcardOrGeneric> listIterator = refType.getParaList()
.listIterator(); listIterator
.hasNext();) {
RefTypeOrTPHOrWildcardOrGeneric next = listIterator.next();
if (next instanceof RefType) {
RefType nextRefType = (RefType) next;
TypePlaceholder tph = generateTypePlaceholder(nextRefType);
listIterator.set(tph);
}
}
} }
super.visit(refType); super.visit(refType);
} }

View File

@ -52,8 +52,9 @@ public class TestInferWildcardsJavaTx
// Constraints // Constraints
ConstraintSet<Pair> constraints = javaTXCompiler.getConstraints(); ConstraintSet<Pair> constraints = javaTXCompiler.getConstraints();
constraints.addAll(generatedConstraints);
// System.out.println(constraints); System.out.println(constraints);
} }
} }