diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java index 00b182732..d59f4c01d 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Optional; import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass; import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.MethodAndConstraints; diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/ClassConstraint.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java similarity index 88% rename from src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/ClassConstraint.java rename to src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java index fd5ffcaed..3f1d19d2b 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/ClassConstraint.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java @@ -1,4 +1,4 @@ -package de.dhbwstuttgart.bytecode.gGenericsAli; +package de.dhbwstuttgart.bytecode.insertGenerics; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java similarity index 92% rename from src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java rename to src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index c9a458ac4..8683cc60c 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -1,11 +1,7 @@ -package de.dhbwstuttgart.bytecode.gGenericsAli; +package de.dhbwstuttgart.bytecode.insertGenerics; -import de.dhbwstuttgart.bytecode.TPHExtractor; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.syntaxtree.AbstractASTWalker; -import de.dhbwstuttgart.syntaxtree.SourceFile; -import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import java.util.ArrayList; import java.util.HashMap; @@ -189,8 +185,7 @@ public class FamilyOfGeneratedGenerics { for (TPHConstraint tphC: tempList) { hasSame = constraint.getLeft() == tphC.getLeft() && constraint.getRight() == tphC.getRight() && - constraint.getRel() == tphC.getRel(); //constraint already in ArrayList if -// System.out.println(hasSame); + constraint.getRel() == tphC.getRel(); //constraint already in ArrayList if true if (hasSame) return true; } @@ -198,22 +193,19 @@ public class FamilyOfGeneratedGenerics { } public static List buildTransitiveClosure(List list) { - List iterList = list; - List runList = list; - List tcList = list; + List iterList = new ArrayList<>(list); + List runList = new ArrayList<>(list); + List tcList = new ArrayList<>(list); boolean addedConToList = false; for (TPHConstraint cons: iterList) { for (TPHConstraint cons2: runList) { if(cons.getRight() == cons2.getLeft()) { TPHConstraint consToAdd = new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS); -// System.out.println(consToAdd); -// System.out.println(tcList); -// System.out.println(checkForDuplicates(consToAdd,tcList)); if (!checkForDuplicates(consToAdd,tcList)) { - tcList.add(consToAdd); //Duplikate? dürfte nicht sein -> checken + tcList.add(consToAdd); addedConToList = true; if (addedConToList) { - buildTransitiveClosure(tcList); + return buildTransitiveClosure(tcList); } } //TODO: über aktualisierte Liste laufen wegen Updates -> Rekursion? diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/GGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/GGenerics.java similarity index 100% rename from src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/GGenerics.java rename to src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/GGenerics.java diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/MethodConstraint.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java similarity index 81% rename from src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/MethodConstraint.java rename to src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java index 9b2282584..d68f7d3f6 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/MethodConstraint.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java @@ -1,4 +1,4 @@ -package de.dhbwstuttgart.bytecode.gGenericsAli; +package de.dhbwstuttgart.bytecode.insertGenerics; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/PositionFinder.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/PositionFinder.java similarity index 95% rename from src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/PositionFinder.java rename to src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/PositionFinder.java index ba9585f07..c5638360d 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/PositionFinder.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/PositionFinder.java @@ -1,6 +1,5 @@ -package de.dhbwstuttgart.bytecode.gGenericsAli; +package de.dhbwstuttgart.bytecode.insertGenerics; -import de.dhbwstuttgart.bytecode.TPHExtractor; import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/preGGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/preGGenerics.java similarity index 76% rename from src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/preGGenerics.java rename to src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/preGGenerics.java index 781e3d76b..088a435b7 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/preGGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/preGGenerics.java @@ -1,4 +1,4 @@ -package de.dhbwstuttgart.bytecode.gGenericsAli; +package de.dhbwstuttgart.bytecode.insertGenerics; import de.dhbwstuttgart.typeinference.result.ResultSet; diff --git a/src/test/java/constraintSimplify/FamilyOfGenerics.java b/src/test/java/constraintSimplify/FamilyOfGenerics.java index 835614503..e5c9ad131 100644 --- a/src/test/java/constraintSimplify/FamilyOfGenerics.java +++ b/src/test/java/constraintSimplify/FamilyOfGenerics.java @@ -1,27 +1,18 @@ package constraintSimplify; import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics; -import de.dhbwstuttgart.bytecode.gGenericsAli.PositionFinder; +import de.dhbwstuttgart.bytecode.insertGenerics.PositionFinder; import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder; -import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.statement.Block; import de.dhbwstuttgart.syntaxtree.type.RefType; -import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.result.ResultSet; -import org.antlr.v4.runtime.Token; -import org.junit.Assert; import org.junit.Test; -import java.io.File; import java.lang.reflect.Modifier; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.NotLinkException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; diff --git a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java index c4cbeb93a..d0a2712fc 100644 --- a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java +++ b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java @@ -1,10 +1,10 @@ package insertGenerics; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; -import de.dhbwstuttgart.bytecode.gGenericsAli.ClassConstraint; -import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics; -import de.dhbwstuttgart.bytecode.gGenericsAli.MethodConstraint; -import de.dhbwstuttgart.bytecode.gGenericsAli.PositionFinder; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.PositionFinder; import junit.framework.TestCase; import java.util.ArrayList; @@ -47,7 +47,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { return f; } } - gives constraint: A <. B, which is a method constraint + gives constraint: A <. B, which is a class constraint */ List inputConstraints = new ArrayList<>(); diff --git a/src/test/java/insertGenerics/TestExample42.java b/src/test/java/insertGenerics/TestExample42.java index 219e3fffa..130706d7b 100644 --- a/src/test/java/insertGenerics/TestExample42.java +++ b/src/test/java/insertGenerics/TestExample42.java @@ -2,10 +2,10 @@ package insertGenerics; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.gGenericsAli.ClassConstraint; -import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics; -import de.dhbwstuttgart.bytecode.gGenericsAli.MethodConstraint; -import de.dhbwstuttgart.bytecode.gGenericsAli.PositionFinder; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.PositionFinder; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/insertGenerics/TestTransitiveClosure.java b/src/test/java/insertGenerics/TestTransitiveClosure.java index e1bc022b1..95c6a0e23 100644 --- a/src/test/java/insertGenerics/TestTransitiveClosure.java +++ b/src/test/java/insertGenerics/TestTransitiveClosure.java @@ -2,15 +2,11 @@ package insertGenerics; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.gGenericsAli.ClassConstraint; -import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics; -import de.dhbwstuttgart.bytecode.gGenericsAli.MethodConstraint; -import de.dhbwstuttgart.bytecode.gGenericsAli.PositionFinder; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; import org.junit.Test; import static org.junit.Assert.assertEquals; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; public class TestTransitiveClosure {