From 98b3ad15175e3e313372d473251d4bf611c8cad5 Mon Sep 17 00:00:00 2001 From: Till Schnell Date: Tue, 6 Apr 2021 18:44:30 +0200 Subject: [PATCH] add replacement of param types with tph and generate consolidated constraints --- .../inferWildcards/ReplaceTypeparamVisitor.java | 16 ++++++++++++---- .../inferWildcards/TestInferWildcardsJavaTx.java | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/inferWildcards/ReplaceTypeparamVisitor.java b/src/main/java/de/dhbwstuttgart/inferWildcards/ReplaceTypeparamVisitor.java index 43e3a75b..6e40ba37 100644 --- a/src/main/java/de/dhbwstuttgart/inferWildcards/ReplaceTypeparamVisitor.java +++ b/src/main/java/de/dhbwstuttgart/inferWildcards/ReplaceTypeparamVisitor.java @@ -1,7 +1,7 @@ package de.dhbwstuttgart.inferWildcards; import java.util.HashMap; -import java.util.List; +import java.util.ListIterator; import java.util.Map; import de.dhbwstuttgart.parser.NullToken; @@ -24,10 +24,18 @@ public class ReplaceTypeparamVisitor public void visit (RefType refType) { if (!refType.getParaList().isEmpty()) { System.out.println("Type: " + refType); - List paraList = refType.getParaList(); - paraList.stream().filter(e -> e instanceof RefType).map(RefType.class::cast) - .forEach(this::generateTypePlaceholder); + for (ListIterator 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); } diff --git a/src/test/java/inferWildcards/TestInferWildcardsJavaTx.java b/src/test/java/inferWildcards/TestInferWildcardsJavaTx.java index bf631082..3a132881 100644 --- a/src/test/java/inferWildcards/TestInferWildcardsJavaTx.java +++ b/src/test/java/inferWildcards/TestInferWildcardsJavaTx.java @@ -52,8 +52,9 @@ public class TestInferWildcardsJavaTx // Constraints ConstraintSet constraints = javaTXCompiler.getConstraints(); + constraints.addAll(generatedConstraints); - // System.out.println(constraints); + System.out.println(constraints); } }