diff --git a/src/de/dhbwstuttgart/core/MyCompiler.java b/src/de/dhbwstuttgart/core/MyCompiler.java index e1b624cf..bd7fe90d 100755 --- a/src/de/dhbwstuttgart/core/MyCompiler.java +++ b/src/de/dhbwstuttgart/core/MyCompiler.java @@ -11,9 +11,10 @@ import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.io.StringReader; -import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.LoggerConfiguration; import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.myexception.CTypeReconstructionException; @@ -116,10 +117,11 @@ public class MyCompiler implements MyCompilerAPI */ // ino.end // ino.method.getAPI.21286.definition - public static MyCompilerAPI getAPI() + public static MyCompilerAPI getAPI(LoggerConfiguration loggerConfig) // ino.end // ino.method.getAPI.21286.body { + Logger.setStandardConfiguration(loggerConfig); return new MyCompiler(); } // ino.end @@ -591,7 +593,7 @@ public class MyCompiler implements MyCompilerAPI // ino.end // ino.method.main.21313.body { - MyCompilerAPI compiler = MyCompiler.getAPI(); + MyCompilerAPI compiler = MyCompiler.getAPI(new LoggerConfiguration()); // Hier koennten ggf. Aenderungen der Ausgabeeinstellungen // (Debuginfos) vorgenommen werden -> LOG4J diff --git a/src/de/dhbwstuttgart/logger/Logger.java b/src/de/dhbwstuttgart/logger/Logger.java index 1af96f70..983369bb 100755 --- a/src/de/dhbwstuttgart/logger/Logger.java +++ b/src/de/dhbwstuttgart/logger/Logger.java @@ -8,7 +8,7 @@ import java.util.logging.LogRecord; public class Logger { - private static LoggerConfiguration standardConfiguration = new LoggerConfiguration(); + private static LoggerConfiguration standardConfiguration = null; private static final HashMap LOGGER_DIRECTORY = new HashMap<>(); private String name; @@ -17,17 +17,21 @@ public class Logger { protected Logger(String name, LoggerConfiguration config) { this.name = name; this.logger = new HashMap<>(); - config.forEach((s,o)->{ - java.util.logging.Logger log = java.util.logging.Logger.getLogger( name ); - log.setLevel(Level.FINE); - log.addHandler(new OutputHandler(o)); - logger.put(s, log); - }); + if(config != null){ + config.forEach((s,o)->{ + java.util.logging.Logger log = java.util.logging.Logger.getLogger( name ); + log.setLevel(Level.FINE); + log.addHandler(new OutputHandler(o)); + logger.put(s, log); + }); + } } + /* public static LoggerConfiguration getConfiguration(){ return Logger.standardConfiguration; } + */ /** * Logt eine Debug Message, welche zusätzlich einer bestimmten Section zugewiesen wird. diff --git a/src/de/dhbwstuttgart/logger/LoggerConfiguration.java b/src/de/dhbwstuttgart/logger/LoggerConfiguration.java index d9ae2c0e..56d57d99 100644 --- a/src/de/dhbwstuttgart/logger/LoggerConfiguration.java +++ b/src/de/dhbwstuttgart/logger/LoggerConfiguration.java @@ -3,23 +3,42 @@ package de.dhbwstuttgart.logger; import java.io.PrintStream; import java.util.HashMap; +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.exceptions.DebugException; public class LoggerConfiguration{ - private final HashMap outputs = new HashMap<>(Section.values().length); + private final HashMap> outputs = new HashMap<>(Section.values().length); public LoggerConfiguration setOutput(Section forSection, PrintStream output){ if(outputs.containsKey(forSection)){ - throw new DebugException("Eine outputStream für Section "+forSection+" ist bereits vorhanden"); + //throw new DebugException("Eine outputStream für Section "+forSection+" ist bereits vorhanden"); + if(outputs.get(forSection).equals(output)){ + //do nothing + }else{ + outputs.get(forSection).add(output); + } + }else{ + Menge outMenge = new Menge<>(); + outMenge.add(output); + outputs.put(forSection, outMenge); } - outputs.put(forSection, output); return this; } public void forEach(ConfigurationEvaluater action){ for(Section key : outputs.keySet()){ - action.apply(key, outputs.get(key)); + for(PrintStream out : outputs.get(key)){ + action.apply(key, out); + } + } + } + + public void mergeConfiguration(LoggerConfiguration config){ + for(Section key : config.outputs.keySet()){ + for(PrintStream out : config.outputs.get(key)){ + this.setOutput(key, out); + } } } } diff --git a/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java b/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java index e31ddfa7..49a0f5f8 100755 --- a/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java +++ b/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java @@ -1,11 +1,12 @@ package de.dhbwstuttgart.typeinference; import java.util.Iterator; + import de.dhbwstuttgart.typeinference.Menge; -import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.*; import de.dhbwstuttgart.typeinference.unify.Unifier; + public class ConstraintsSet extends UndMenge{ private static final Logger log = Logger.getLogger(ConstraintsSet.class.getName()); @@ -60,7 +61,21 @@ public class ConstraintsSet extends UndMenge{ } */ - public void filterWrongConstraints(Unifier unify) {/* + public void filterWrongConstraints(Unifier unify) { + Menge> newSet = new Menge>(); + for(OderMenge orSet : this.getOrSets()){ + Menge> res = unify.apply(orSet.getItems()); + if(res.size()>0){ + newSet.add(orSet); + }else{ + Logger.getLogger("Filter").debug("Ausgesondertes Constraint: "+orSet, Section.TYPEINFERENCE); + } + } + for(KomplexeMenge i : set){ + newSet.addAll(i.getAndSets()); + } + this.set = newSet; + /* for(OderConstraint constraint : this){ constraint.filterWrongConstraints(unify); } diff --git a/src/de/dhbwstuttgart/typeinference/Menge.java b/src/de/dhbwstuttgart/typeinference/Menge.java new file mode 100644 index 00000000..0a727c61 --- /dev/null +++ b/src/de/dhbwstuttgart/typeinference/Menge.java @@ -0,0 +1,7 @@ +package de.dhbwstuttgart.typeinference; + +import java.util.Vector; + +public class Menge extends Vector{ + +} diff --git a/src/de/dhbwstuttgart/typeinference/OderMenge.java b/src/de/dhbwstuttgart/typeinference/OderMenge.java new file mode 100644 index 00000000..0d17bf09 --- /dev/null +++ b/src/de/dhbwstuttgart/typeinference/OderMenge.java @@ -0,0 +1,78 @@ +package de.dhbwstuttgart.typeinference; + +import java.util.Collection; +import java.util.Iterator; + +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.syntaxtree.type.RefType; +import de.dhbwstuttgart.syntaxtree.type.Type; +import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; +import de.dhbwstuttgart.typeinference.unify.Unifier; + +/* + * KomplexeMenge + * OderMenge + * Menge + * Item + */ + +interface KomplexeMenge{ + void addItems(KomplexeMenge item); + void addItem(A item); + Menge> cartesianProduct(); + Menge getItems(); + Menge> getOrSets(); + Menge> getAndSets(); +} + +public class OderMenge implements KomplexeMenge{ + Menge> set = new Menge<>(); + + @Override + public void addItems(KomplexeMenge item) { + set.add(item); + } + + public Menge getItems(){ + Menge ret = new Menge<>(); + for(KomplexeMenge i : set){ + ret.addAll(i.getItems()); + } + return ret; + } + + @Override + public void addItem(A item) { + set.add(new EinzelElement(item)); + } + + @Override + public Menge> cartesianProduct() { + Menge> ret = new Menge<>(); + for(KomplexeMenge km : this.set){ + ret.addAll(km.cartesianProduct()); + } + return ret; + } + + @Override + public Menge> getOrSets() { + Menge> ret = new Menge<>(); + ret.add(this); + for(KomplexeMenge i : set){ + ret.addAll(i.getOrSets()); + } + return ret; + } + + @Override + public Menge> getAndSets() { + Menge> ret = new Menge<>(); + for(KomplexeMenge i : set){ + ret.addAll(i.getAndSets()); + } + return ret; + } +} diff --git a/src/de/dhbwstuttgart/typeinference/UndConstraint.java b/src/de/dhbwstuttgart/typeinference/UndConstraint.java index d2f6694a..55d3e67c 100755 --- a/src/de/dhbwstuttgart/typeinference/UndConstraint.java +++ b/src/de/dhbwstuttgart/typeinference/UndConstraint.java @@ -62,4 +62,8 @@ public class UndConstraint extends UndMenge implements Iterable{ public void addConstraint(ConstraintType type, ConstraintType type2) { this.addItem(new ConstraintPair(type,type2).getPair()); } + + public void addConstraint(ConstraintPair constraintPair) { + this.addItem(constraintPair.getPair()); + } } diff --git a/src/de/dhbwstuttgart/typeinference/UndMenge.java b/src/de/dhbwstuttgart/typeinference/UndMenge.java new file mode 100644 index 00000000..49087949 --- /dev/null +++ b/src/de/dhbwstuttgart/typeinference/UndMenge.java @@ -0,0 +1,116 @@ +package de.dhbwstuttgart.typeinference; + +import java.util.Collection; +import java.util.Iterator; + +import com.rits.cloning.Cloner; + +public class UndMenge implements KomplexeMenge{ + Menge> set = new Menge<>(); + + @Override + public void addItems(KomplexeMenge item) { + set.add(item); + } + + public void addItem(A item){ + set.add(new EinzelElement(item)); + } + + public Menge getItems(){ + Menge ret = new Menge<>(); + for(KomplexeMenge i : set){ + ret.addAll(i.getItems()); + } + return ret; + } + + @Override + public Menge> cartesianProduct() { + Menge> ret = null; + Cloner cloner = new Cloner(); + for(KomplexeMenge km : this.set){ + if(ret == null){ + ret = km.cartesianProduct(); + }else{ + Menge> cartesianProduct = new Menge<>(); + for(Menge r : ret)for(Menge m : km.cartesianProduct()){ //Für jedes Element aus dem Karthesischen Produkt: + Menge undElement = new Menge(); + undElement.addAll(cloner.deepClone(r)); + undElement.addAll(m); + cartesianProduct.add(undElement); + } + ret = cartesianProduct; + } + } + return ret; + } + + @Override + public Menge> getOrSets() { + Menge> ret = new Menge<>(); + for(KomplexeMenge i : set){ + ret.addAll(i.getOrSets()); + } + return ret; + } + + @Override + public Menge> getAndSets() { + Menge> ret = new Menge<>(); + ret.add(this); + for(KomplexeMenge i : set){ + ret.addAll(i.getAndSets()); + } + return ret; + } +} + + +class EinzelElement implements KomplexeMenge{ + private A item; + + public EinzelElement(A element){ + item = element; + } + + @Override + public void addItems(KomplexeMenge item) { + + } + + @Override + public Menge getItems() { + Menge ret = new Menge<>(); + ret.add(item); + return ret; + } + + @Override + public void addItem(A item) { + + } + + @Override + public Menge> cartesianProduct() { + Cloner cloner = new Cloner(); + Menge> ret = new Menge<>(); + Menge i = new Menge(); + i.add(cloner.deepClone(item)); + ret.add(i); + return ret; + } + + @Override + public Menge> getOrSets() { + Menge> ret = new Menge<>(); + return ret; + } + + @Override + public Menge> getAndSets() { + Menge> ret = new Menge<>(); + return ret; + } + +} \ No newline at end of file diff --git a/src/de/dhbwstuttgart/typeinference/unify/ParallelUnify.java b/src/de/dhbwstuttgart/typeinference/unify/ParallelUnify.java index 5f852819..fffceb53 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/ParallelUnify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/ParallelUnify.java @@ -9,7 +9,7 @@ import de.dhbwstuttgart.typeinference.Pair; public class ParallelUnify { public ParallelUnify(ConstraintsSet constraints){ - constraints.getConstraints(); + //constraints.getConstraints(); } private CartesianProduct parallelCartProd(){ diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index b5489102..37e1857e 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -6,7 +6,9 @@ package de.dhbwstuttgart.typeinference.unify; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; + import de.dhbwstuttgart.typeinference.Menge; + import java.util.stream.Stream; import de.dhbwstuttgart.logger.Logger; @@ -33,6 +35,7 @@ import de.dhbwstuttgart.syntaxtree.type.ObjectType; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.WildcardType; import de.dhbwstuttgart.typeinference.ConstraintPair; +import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.typeinference.OderConstraint; import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.Pair.PairOperator; @@ -115,8 +118,13 @@ public class Unify * oder [] = fail * Für den Argumenttype FunN<...> in Typ A ...> werden keine ? extends-, ? super-Typen erzeugt */ - //public static Menge> unifyWC (Menge E, FC_TTO fc_tto) public static Menge> unify (Menge E, FC_TTO fc_tto) + { + return unifyFiltered(E, fc_tto,true); + } + + //public static Menge> unifyWC (Menge E, FC_TTO fc_tto) + public static Menge> unifyFiltered (Menge E, FC_TTO fc_tto, boolean filter) { //Schritt 1: Aufrufen der Regeln durch sub_unify. Menge Eq = sub_unify(E,fc_tto); @@ -625,6 +633,28 @@ 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(); + for (Menge> vecvecpair : cartProduktSets){ + OderConstraint orConstraints = new OderConstraint(); + for(Menge pairs : vecvecpair){ + UndConstraint uCons = new UndConstraint(); + for(Pair p : pairs){ + uCons.addItem(p); + } + orConstraints.addItems(uCons); + } + cSet.addItems(orConstraints); + } + if(filter){ + Unifier filterUnify = (pairs)->{ + Menge> retValue = new Menge<>(); + retValue = Unify.unifyFiltered(pairs,fc_tto,false); + //Unify.unify(pairs, fc_tto, (i)->{}); + return retValue;}; + + cSet.filterWrongConstraints(filterUnify); + } + /* for (Menge> vecvecpair : cartProduktSets){ OderConstraint orConstraints = new OderConstraint(); diff --git a/test/KomplexeMenge/KarthesischesProduktTest.java b/test/KomplexeMenge/KarthesischesProduktTest.java new file mode 100644 index 00000000..327c37ea --- /dev/null +++ b/test/KomplexeMenge/KarthesischesProduktTest.java @@ -0,0 +1,81 @@ +package KomplexeMenge; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.OderMenge; +import de.dhbwstuttgart.typeinference.UndMenge; + +public class KarthesischesProduktTest { + + @Test + public void test() { + OderMenge oM1 = new OderMenge<>(); + OderMenge oM2 = new OderMenge<>(); + UndMenge oM3 = new UndMenge<>(); + oM1.addItem("Menge 1, Item 1"); + oM1.addItem("Menge 1, Item 2"); + oM2.addItem("Menge 2, Item 1"); + oM2.addItem("Menge 2, Item 2"); + oM3.addItems(oM1); + oM3.addItems(oM2); + System.out.println(oM3.cartesianProduct()); + assertTrue(oM3.cartesianProduct().size()==4); + } + + @Test + public void test2(){ + UndMenge oM1 = new UndMenge<>(); + UndMenge oM2 = new UndMenge<>(); + UndMenge oM3 = new UndMenge<>(); + oM1.addItem("Menge 1, Item 1"); + oM1.addItem("Menge 1, Item 2"); + oM2.addItem("Menge 2, Item 1"); + oM2.addItem("Menge 2, Item 2"); + oM3.addItems(oM1); + oM3.addItems(oM2); + System.out.println("undMenge:"+oM3.cartesianProduct()); + assertTrue(oM3.cartesianProduct().size()==1); + } + + @Test + public void test3(){ + OderMenge oM1 = new OderMenge<>(); + UndMenge oM2 = new UndMenge<>(); + UndMenge oM3 = new UndMenge<>(); + oM1.addItem("Menge 1, Item 1"); + oM1.addItem("Menge 1, Item 2"); + oM2.addItem("Menge 2, Item 1"); + oM2.addItem("Menge 2, Item 2"); + oM3.addItems(oM1); + oM3.addItems(oM2); + //System.out.println("undMenge:"+oM3.cartesianProduct()); + assertTrue(oM3.cartesianProduct().size()==2); + } + + @Test + public void test4(){ + OderMenge oM1 = new OderMenge<>(); + UndMenge oM2 = new UndMenge<>(); + UndMenge oM3 = new UndMenge<>(); + oM2.addItem("Menge 2, Item 1"); + oM2.addItem("Menge 2, Item 2"); + oM3.addItems(oM1); + oM3.addItems(oM2); + //System.out.println("undMenge:"+oM3.cartesianProduct()); + assertTrue(oM3.cartesianProduct().size()==0); + } + + @Test + public void test5(){ + OderMenge oM1 = new OderMenge<>(); + UndMenge oM2 = new UndMenge<>(); + UndMenge oM3 = new UndMenge<>(); + oM3.addItems(oM1); + oM3.addItems(oM2); + //System.out.println("undMenge:"+oM3.cartesianProduct()); + assertTrue(oM3.cartesianProduct().size()==0); + } +} diff --git a/test/KomplexeMenge/KeineDoppeltenVerweise.java b/test/KomplexeMenge/KeineDoppeltenVerweise.java new file mode 100644 index 00000000..d7c3f431 --- /dev/null +++ b/test/KomplexeMenge/KeineDoppeltenVerweise.java @@ -0,0 +1,66 @@ +package KomplexeMenge; + +import static org.junit.Assert.*; + +import java.util.Vector; + +import org.junit.Test; + +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.OderMenge; +import de.dhbwstuttgart.typeinference.UndMenge; + +class TestKlasse { + static int identifier = 0; + public String name; + int id; + + TestKlasse(String name){ + this.name = name; + id = 0; + } + + public String toString(){ + return name+" #"+id; + } +} + +public class KeineDoppeltenVerweise { + + @Test + public void test() { + OderMenge oM1 = new OderMenge<>(); + OderMenge oM2 = new OderMenge<>(); + UndMenge oM3 = new UndMenge<>(); + oM1.addItem(new TestKlasse("Menge 1, Item 1")); + oM1.addItem(new TestKlasse("Menge 1, Item 2")); + oM2.addItem(new TestKlasse("Menge 2, Item 1")); + oM2.addItem(new TestKlasse("Menge 2, Item 2")); + oM3.addItems(oM1); + oM3.addItems(oM2); + Menge> cP = oM3.cartesianProduct(); + System.out.println(cP); + cP.firstElement().firstElement().name="neu"; + System.out.println(cP); + check(cP); + } + + private void check(Menge> cP){ + Menge allElements = new Menge<>(); + for(Vector v : cP)for(A i : v){ + Object o = containsRef(allElements, i); + if(o!=null){ + fail("Ein Verweis ist im Karthesischen Produkt doppelt vorhanden: "+o+" == "+i); + }else{ + allElements.add(i); + } + } + } + + private Object containsRef(Menge v, Object i){ + for(Object o : v){ + if(i == o)return o; + } + return null; + } +} diff --git a/test/plugindevelopment/TypeInsertTester.java b/test/plugindevelopment/TypeInsertTester.java index d8e36e1f..27154bb2 100755 --- a/test/plugindevelopment/TypeInsertTester.java +++ b/test/plugindevelopment/TypeInsertTester.java @@ -24,10 +24,11 @@ import junit.framework.TestCase; public class TypeInsertTester{ - private static Logger inferencelog = Logger.getLogger(TypeInsertTester.class.getName()); + //private static Logger inferencelog = Logger.getLogger(TypeInsertTester.class.getName()); + private static LoggerConfiguration logConfig = new LoggerConfiguration(); static{ { - Logger.getConfiguration().setOutput(Section.TYPEINFERENCE, System.out); + logConfig.setOutput(Section.TYPEINFERENCE, System.out); /* // Ausgabeoptionen fuer die Logger ConsoleAppender logAppender = new ConsoleAppender(new SimpleLayout()); @@ -41,7 +42,7 @@ public class TypeInsertTester{ public static void test(String sourceFileToInfere, String solutionFile){ String inferedSource = ""; - MyCompilerAPI compiler = MyCompiler.getAPI(); + MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { compiler.parse(new File(rootDirectory + sourceFileToInfere)); Menge results = compiler.typeReconstruction(); diff --git a/test/plugindevelopment/TypeInsertTests/Add.jav b/test/plugindevelopment/TypeInsertTests/Add.jav index 720aa04a..4e7599b3 100644 --- a/test/plugindevelopment/TypeInsertTests/Add.jav +++ b/test/plugindevelopment/TypeInsertTests/Add.jav @@ -1,8 +1,8 @@ -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Vector; -class Matrix extends Menge> { +class Matrix extends Vector> { - mvmul(Menge v) { + mvmul(Vector v) { return v.size() + 5; } } diff --git a/test/plugindevelopment/TypeInsertTests/ConstructorTest.jav b/test/plugindevelopment/TypeInsertTests/ConstructorTest.jav index a3aa400e..b92a7a3b 100644 --- a/test/plugindevelopment/TypeInsertTests/ConstructorTest.jav +++ b/test/plugindevelopment/TypeInsertTests/ConstructorTest.jav @@ -1,4 +1,4 @@ -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Vector; class Matrix{ diff --git a/test/plugindevelopment/TypeInsertTests/GenericVarTest.jav b/test/plugindevelopment/TypeInsertTests/GenericVarTest.jav index b6cfbec7..1f3d9f46 100644 --- a/test/plugindevelopment/TypeInsertTests/GenericVarTest.jav +++ b/test/plugindevelopment/TypeInsertTests/GenericVarTest.jav @@ -1,5 +1,5 @@ -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Vector; -class WildcardTest extends Menge{ +class WildcardTest extends Vector{ Fun1> op = (f) -> f.apply(this); } \ No newline at end of file diff --git a/test/plugindevelopment/TypeInsertTests/ImportSubClassTest.jav b/test/plugindevelopment/TypeInsertTests/ImportSubClassTest.jav new file mode 100644 index 00000000..92ee5482 --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/ImportSubClassTest.jav @@ -0,0 +1,13 @@ +import java.util.ArrayList; +import java.util.List; +import de.dhbwstuttgart.typeinference.Menge; + +class ImportSubClassTest{ +methode(){ +Menge var1; +ArrayList var2; +var3; +var3 = var1; +var3 = var2; +} +} \ No newline at end of file diff --git a/test/plugindevelopment/TypeInsertTests/ImportSubClassTest.java b/test/plugindevelopment/TypeInsertTests/ImportSubClassTest.java new file mode 100644 index 00000000..f33f3160 --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/ImportSubClassTest.java @@ -0,0 +1,16 @@ +package plugindevelopment.TypeInsertTests; + +import de.dhbwstuttgart.typeinference.Menge; + +import org.junit.Test; + +public class ImportSubClassTest { + private static final String TEST_FILE = "ImportSubClassTest.jav"; + + @Test + public void run(){ + Menge mustContain = new Menge(); + //mustContain.add("TestIfStmt var"); + MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain); + } +} diff --git a/test/plugindevelopment/TypeInsertTests/ImportTest.jav b/test/plugindevelopment/TypeInsertTests/ImportTest.jav index 465ee6dd..7e761863 100755 --- a/test/plugindevelopment/TypeInsertTests/ImportTest.jav +++ b/test/plugindevelopment/TypeInsertTests/ImportTest.jav @@ -1,7 +1,7 @@ -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Vector; class ImportTest{ -Menge var; +Vector var; methode(var2){ var.add(var2); diff --git a/test/plugindevelopment/TypeInsertTests/ImportTest2.jav b/test/plugindevelopment/TypeInsertTests/ImportTest2.jav index 45a7e159..10075ef9 100755 --- a/test/plugindevelopment/TypeInsertTests/ImportTest2.jav +++ b/test/plugindevelopment/TypeInsertTests/ImportTest2.jav @@ -1,4 +1,4 @@ -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Vector; class ImportTest{ diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest2.java b/test/plugindevelopment/TypeInsertTests/LambdaTest2.java index dce2a469..c1c11870 100755 --- a/test/plugindevelopment/TypeInsertTests/LambdaTest2.java +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest2.java @@ -14,10 +14,10 @@ public class LambdaTest2 { @Test public void run(){ - Logger.getConfiguration().setOutput(Section.ASSUMPTIONS, System.out); Menge mustContain = new Menge(); //mustContain.add("S m"); - MultipleTypesInsertTester.test(this.TEST_FILE, mustContain); + MultipleTypesInsertTester.test(this.TEST_FILE, mustContain, + new LoggerConfiguration().setOutput(Section.ASSUMPTIONS, System.out)); } } diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest23.jav b/test/plugindevelopment/TypeInsertTests/LambdaTest23.jav index 6e8887c3..cd4550ba 100644 --- a/test/plugindevelopment/TypeInsertTests/LambdaTest23.jav +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest23.jav @@ -1,6 +1,6 @@ -import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.Vector; -class Matrix extends Menge> { +class Matrix extends Vector> { void mul(m){ v1; diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest25.jav b/test/plugindevelopment/TypeInsertTests/LambdaTest25.jav index 6a9130f5..a499b2bd 100644 --- a/test/plugindevelopment/TypeInsertTests/LambdaTest25.jav +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest25.jav @@ -1,4 +1,4 @@ -import de.dhbwstuttgart.typeinference.Vector; +import java.util.Vector; class ImportGeneric { diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest25.java b/test/plugindevelopment/TypeInsertTests/LambdaTest25.java index ef845f8b..8dbeb3fb 100644 --- a/test/plugindevelopment/TypeInsertTests/LambdaTest25.java +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest25.java @@ -1,5 +1,7 @@ package plugindevelopment.TypeInsertTests; +import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.typeinference.Menge; import org.junit.Test; @@ -9,6 +11,7 @@ public class LambdaTest25 { @Test public void run(){ + //de.dhbwstuttgart.logger.Logger.setStandardConfiguration(Logger.getConfiguration().setOutput(Section.TYPEINFERENCE, System.out)); Menge mustContain = new Menge(); mustContain.add("Integer m"); MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain); diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest2_2.java b/test/plugindevelopment/TypeInsertTests/LambdaTest2_2.java index 481ec5e0..5503c7fe 100644 --- a/test/plugindevelopment/TypeInsertTests/LambdaTest2_2.java +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest2_2.java @@ -14,10 +14,12 @@ public class LambdaTest2_2 { @Test public void run(){ - Logger.getConfiguration().setOutput(Section.ASSUMPTIONS, System.out); + //Logger.getConfiguration().setOutput(Section.ASSUMPTIONS, System.out); + LoggerConfiguration logConfig = new LoggerConfiguration(); + logConfig.setOutput(Section.ASSUMPTIONS, System.out); Menge mustContain = new Menge(); //mustContain.add("S m"); - MultipleTypesInsertTester.test(this.TEST_FILE, mustContain); + MultipleTypesInsertTester.test(this.TEST_FILE, mustContain, logConfig); } } diff --git a/test/plugindevelopment/TypeInsertTests/Matrix.jav b/test/plugindevelopment/TypeInsertTests/Matrix.jav index d30e2a07..b71f5c1f 100644 --- a/test/plugindevelopment/TypeInsertTests/Matrix.jav +++ b/test/plugindevelopment/TypeInsertTests/Matrix.jav @@ -1,6 +1,6 @@ -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Vector; -class Matrix extends Menge> { +class Matrix extends Vector> { mul(m){ ret; diff --git a/test/plugindevelopment/TypeInsertTests/Matrix_simple.jav b/test/plugindevelopment/TypeInsertTests/Matrix_simple.jav index 50bad19a..5aa6ee45 100644 --- a/test/plugindevelopment/TypeInsertTests/Matrix_simple.jav +++ b/test/plugindevelopment/TypeInsertTests/Matrix_simple.jav @@ -1,8 +1,8 @@ -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Vector; -class Matrix extends Menge> { +class Matrix extends Vector> { - mvmul(Menge v) { + mvmul(Vector v) { i; ele; v.add(1); diff --git a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java index 66e4a8d8..79dce804 100755 --- a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java +++ b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java @@ -20,15 +20,25 @@ public class MultipleTypesInsertTester extends TypeInsertTester{ public final static String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/TypeInsertTests/"; + static LoggerConfiguration logConfig = new LoggerConfiguration(); + static{ + logConfig.setOutput(Section.TYPEINFERENCE, System.out); + } + public MultipleTypesInsertTester(){ //Output von TYPEINFERENCE auf die Console setzen: - Logger.getConfiguration().setOutput(Section.TYPEINFERENCE, System.out); + //Logger.getConfiguration().setOutput(Section.TYPEINFERENCE, System.out); + } + + public static void test(String sourceFileToInfere, Menge mustContain, LoggerConfiguration additionalConfig){ + logConfig.mergeConfiguration(additionalConfig); + MultipleTypesInsertTester.test(sourceFileToInfere, mustContain); } public static void test(String sourceFileToInfere, Menge mustContain){ String gesamterSrc = ""; String inferedSource = ""; - MyCompilerAPI compiler = MyCompiler.getAPI(); + MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { compiler.parse(new File(rootDirectory + sourceFileToInfere)); Menge results = compiler.typeReconstruction(); @@ -59,7 +69,7 @@ public class MultipleTypesInsertTester extends TypeInsertTester{ public static void testSingleInsert(String sourceFileToInfere, Menge mustContain){ String gesamterSrc = ""; String inferedSource = ""; - MyCompilerAPI compiler = MyCompiler.getAPI(); + MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { compiler.parse(new File(rootDirectory + sourceFileToInfere)); Menge results = compiler.typeReconstruction(); diff --git a/test/syntaxTree/NodeEqualTest.java b/test/syntaxTree/NodeEqualTest.java index 010cdf8c..1082379d 100644 --- a/test/syntaxTree/NodeEqualTest.java +++ b/test/syntaxTree/NodeEqualTest.java @@ -8,6 +8,8 @@ import org.junit.Test; import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.parser.JavaParser.yyException; import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; @@ -19,8 +21,10 @@ public class NodeEqualTest extends TestCase{ @Test public void test(){ - MyCompilerAPI compiler = MyCompiler.getAPI(); - MyCompilerAPI compiler2 = MyCompiler.getAPI(); + LoggerConfiguration logConfig = new LoggerConfiguration(); + logConfig.setOutput(Section.TYPEINFERENCE, System.out); + MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); + MyCompilerAPI compiler2 = MyCompiler.getAPI(logConfig); SourceFile tree = null; SourceFile tree2 = null; try {