diff --git a/.classpath b/.classpath
index 1a1e4004..cf0244b5 100755
--- a/.classpath
+++ b/.classpath
@@ -7,6 +7,6 @@
+
-
diff --git a/bin/log4j.xml b/bin/log4j.xml
index f36fb342..64e7c5db 100755
--- a/bin/log4j.xml
+++ b/bin/log4j.xml
@@ -1,35 +1,35 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bin/log4jTesting.xml b/bin/log4jTesting.xml
index ef849218..dc30c245 100755
--- a/bin/log4jTesting.xml
+++ b/bin/log4jTesting.xml
@@ -1,24 +1,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/guava-10.0.1.jar b/lib/guava-10.0.1.jar
new file mode 100644
index 00000000..d107c0f3
Binary files /dev/null and b/lib/guava-10.0.1.jar differ
diff --git a/src/de/dhbwstuttgart/typeinference/Menge.java b/src/de/dhbwstuttgart/typeinference/Menge.java
index 0a727c61..10df5235 100644
--- a/src/de/dhbwstuttgart/typeinference/Menge.java
+++ b/src/de/dhbwstuttgart/typeinference/Menge.java
@@ -1,7 +1,8 @@
package de.dhbwstuttgart.typeinference;
+import java.util.Set;
import java.util.Vector;
-public class Menge extends Vector{
+public class Menge extends Vector implements Set{
}
diff --git a/src/de/dhbwstuttgart/typeinference/typedeployment/TypeInsertSet.java b/src/de/dhbwstuttgart/typeinference/typedeployment/TypeInsertSet.java
index 6510d90e..2e02352f 100644
--- a/src/de/dhbwstuttgart/typeinference/typedeployment/TypeInsertSet.java
+++ b/src/de/dhbwstuttgart/typeinference/typedeployment/TypeInsertSet.java
@@ -224,3 +224,41 @@ class TypePatchJob{
return fileContent;
}
}
+
+class TypedJavaSource{
+ public TypedJavaSource(String source, int offset){
+
+ }
+
+ public void addInsert(GenericVarInsert genericVar, int offset){
+
+ }
+
+ public void addInsert(VarInsert var, int offset){
+
+ }
+}
+
+class VarInsert{
+ public VarInsert(String var){
+
+ }
+}
+
+class GenericVarInsert{
+ public GenericVarInsert(String varName){
+
+ }
+}
+
+class GenericVarExtendsInsert extends GenericVarInsert{
+ public GenericVarExtendsInsert(String varName, String extendsVarName){
+ super(varName);
+ }
+}
+
+class GenericVarSuperInsert extends GenericVarInsert{
+ public GenericVarSuperInsert(String varName, String superVarName){
+ super(varName);
+ }
+}
diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java
index 240a127e..4a4dd4fa 100755
--- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java
+++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java
@@ -6,11 +6,17 @@ package de.dhbwstuttgart.typeinference.unify;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import de.dhbwstuttgart.typeinference.Menge;
import java.util.stream.Stream;
+import com.google.common.collect.Sets;
+import com.google.common.collect.Sets.SetView;
+import com.rits.cloning.Cloner;
+
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.logger.SectionLogger;
@@ -630,7 +636,7 @@ public class Unify
}
//Schritt 4, Teil 2: Kartesisches Produkt bilden.
- ///*
+ /*
//TODO: Vor der Bildung des Karthesischen Produkts unmögliche Kombinationen ausfiltern
//cartProduktSets kontrollieren:
ConstraintsSet cSet = new ConstraintsSet();
@@ -651,10 +657,43 @@ public class Unify
cSet.add(orConstraints);
}
+ Menge> bigCartProductErg3 = cSet.cartesianProduct();
+ if(filter)log.debug("Karthesisches Produkt nach Filterung: "+bigCartProductErg3);
+ Sets.cartesianProduct(bigCartProductErg3);
+ */
SectionLogger log = Logger.getSectionLogger(Unify.class.getName(), Section.UNIFY);
- if(filter && false){
- Unifier filterUnify = (pairs)->{
+ if(filter){
+ Cloner cloner = new Cloner();
+ Menge>> temp = new Menge<>();
+ Menge undMenge = new Menge(); //Die Menge von Pairs, welche in jedem Kartesischen Produkt enthalten sind.
+ undMenge.addAll(cloner.deepClone(Eq1));
+ for (Menge> vecvecpair : cartProduktSets){
+ Menge> temp2 = new Menge<>();
+ if(vecvecpair.size() == 1){//gibt es nur eine UndMenge in diesem Set, dann kommt diese in jedem Karthesischen Produkt vor:
+ undMenge.addAll(cloner.deepClone(vecvecpair.firstElement()));
+ temp2 = vecvecpair;
+ }else{//gibt es mehrere Mengen, kann gefiltert werden:
+ for(Menge pairs : vecvecpair){
+ Menge testMenge = new Menge();
+ testMenge.addAll(cloner.deepClone(undMenge));
+ testMenge.addAll(cloner.deepClone(pairs));
+ Menge> test = Unify.unifyFiltered(testMenge, fc_tto, false);
+ if(test.size()>0){
+ temp2.add(pairs);
+ }
+ else{
+ log.debug("Ausgesondertes Constraint: "+pairs);
+ }
+ }
+ }
+ temp.add(temp2);
+ }
+ SetView>> difference = Sets.difference(cartProduktSets, temp);
+ log.debug("Ausgelöschte Constraints: "+difference.toString());
+ //cartProduktSets = temp;
+ /*
+ Unifier filterUnify = (pairs)->{
String pairsString = pairs.toString();
Menge> retValue = new Menge<>();
retValue = Unify.unifyFiltered(pairs,fc_tto,false);
@@ -666,11 +705,9 @@ public class Unify
log.debug("Filtere mithilfe von 'filterWrongConstraints': "+cSet);
cSet.filterWrongConstraints(filterUnify);
+ */
}
-
- Menge> bigCartProductErg3 = cSet.cartesianProduct();
- if(filter)log.debug("Karthesisches Produkt nach Filterung: "+bigCartProductErg3);
//*/
///* Altes Karthesisches Produkt: Auskommentiert durch Andreas Stadelmeier
@@ -693,22 +730,30 @@ public class Unify
}
}
}
- //*/
-
+
+ /*
if(! bigCartProductErg.equals(bigCartProductErg3)){
for(int i = 0; i> changedSets = new Menge>();
Menge> notChangedSets = new Menge>();
+ int counter = 0;
for(Menge vecpair : bigCartProductErg)
{
+ counter++;
+ if(counter > 1000){
+ System.out.println(counter + " von "+bigCartProductErg.size());
+ }
boolean change = false; //eingefuegt PL 13-05-22
Pair substPair = null;
do
diff --git a/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest2.java b/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest2.java
index 810219c2..10aad9ab 100644
--- a/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest2.java
+++ b/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest2.java
@@ -1,5 +1,11 @@
package plugindevelopment.TypeInsertTests;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.typeinference.Menge;
import org.junit.Test;
@@ -7,11 +13,17 @@ import org.junit.Test;
public class GenericTypeVarTest2 {
private static final String TEST_FILE2 = "GenericTypeVarTest2.jav";
+ private static final String LOGFILE = "GenericTypeVarTest2.log";
+
@Test
- public void run2(){
+ public void run2() throws FileNotFoundException{
Menge mustContain = new Menge();
mustContain.add("String var2");
- MultipleTypesInsertTester.test(TEST_FILE2, mustContain);
+ File logFile = new File(MultipleTypesInsertTester.rootDirectory+this.LOGFILE);
+ LoggerConfiguration lConf = new LoggerConfiguration();
+
+ lConf.setOutput(Section.TYPEINFERENCE, new PrintStream(logFile));
+ MultipleTypesInsertTester.test(TEST_FILE2, mustContain, lConf);
}
}
diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest26.java b/test/plugindevelopment/TypeInsertTests/LambdaTest26.java
index 183dd938..fdca0e67 100644
--- a/test/plugindevelopment/TypeInsertTests/LambdaTest26.java
+++ b/test/plugindevelopment/TypeInsertTests/LambdaTest26.java
@@ -1,13 +1,20 @@
package plugindevelopment.TypeInsertTests;
+import java.io.File;
+import java.io.IOException;
+
+import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.typeinference.Menge;
import org.junit.Test;
+import com.google.common.io.Files;
+
public class LambdaTest26 {
private static final String TEST_FILE = "LambdaTest26.jav";
+
@Test
public void run(){
Menge mustContain = new Menge();
diff --git a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java
index 29331173..1dca7ed6 100755
--- a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java
+++ b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java
@@ -2,13 +2,16 @@ package plugindevelopment.TypeInsertTests;
import java.io.File;
import java.io.IOException;
-import de.dhbwstuttgart.typeinference.Menge;
+import com.google.common.io.Files;
+
+import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.core.MyCompilerAPI;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.LoggerConfiguration;
import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.logger.SectionLogger;
import de.dhbwstuttgart.parser.JavaParser.yyException;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
@@ -38,6 +41,8 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
public static void test(String sourceFileToInfere, Menge mustContain){
String gesamterSrc = "";
String inferedSource = "";
+ SectionLogger log = Logger.getSectionLogger(MultipleTypesInsertTester.class.getName(), Section.TYPEINFERENCE);
+
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + sourceFileToInfere));
@@ -51,7 +56,7 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
//TestCase.assertTrue("Es muss mindestens ein TypeInsertPoint vorhanden sein", point.points.size()>0);
if(point.points.size()>0){
inferedSource = point.insertAllTypes(TypeInsertTester.getFileContent(rootDirectory + sourceFileToInfere));
- System.out.println(inferedSource);
+ log.debug(inferedSource);
gesamterSrc += inferedSource;
}
@@ -64,6 +69,12 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
for(String containString : mustContain){
TestCase.assertTrue("\""+containString+"\" muss in den inferierten Lösungen vorkommen",gesamterSrc.contains(containString));
}
+ try {
+ Files.write(Logger.getWholeLog().getBytes(),new File(rootDirectory+sourceFileToInfere+".log"));
+ } catch (IOException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
}
public static void testSingleInsert(String sourceFileToInfere, Menge mustContain){
diff --git a/test/plugindevelopment/TypeInsertTests/OverloadingInMethod2.java b/test/plugindevelopment/TypeInsertTests/OverloadingInMethod2.java
index 1db86fb9..dc911c2b 100644
--- a/test/plugindevelopment/TypeInsertTests/OverloadingInMethod2.java
+++ b/test/plugindevelopment/TypeInsertTests/OverloadingInMethod2.java
@@ -1,5 +1,7 @@
package plugindevelopment.TypeInsertTests;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.typeinference.Menge;
import org.junit.Test;
@@ -13,7 +15,7 @@ public class OverloadingInMethod2 {
Menge mustContain = new Menge();
//mustContain.add("Fun0>> op");
- MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
+ MultipleTypesInsertTester.test(this.TEST_FILE, mustContain, new LoggerConfiguration().setOutput(Section.UNIFY, System.out));
}
}
diff --git a/test/plugindevelopment/TypeInsertTests/ThisTest.java b/test/plugindevelopment/TypeInsertTests/ThisTest.java
index 2ebe429a..5a64a069 100644
--- a/test/plugindevelopment/TypeInsertTests/ThisTest.java
+++ b/test/plugindevelopment/TypeInsertTests/ThisTest.java
@@ -1,5 +1,7 @@
package plugindevelopment.TypeInsertTests;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.typeinference.Menge;
import org.junit.Test;
@@ -12,7 +14,7 @@ public class ThisTest {
public void run(){
Menge mustContain = new Menge();
- MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
+ MultipleTypesInsertTester.test(this.TEST_FILE, mustContain, new LoggerConfiguration().setOutput(Section.UNIFY, System.out));
}
}