Logger angepasst. MyCompiler.getAPI erfordert nun einen Logger als Parameter. Filterung im Unify eingefügt.

This commit is contained in:
JanUlrich 2015-05-07 01:01:39 +02:00
parent 1cb335b46b
commit d343c27edb
29 changed files with 518 additions and 47 deletions

View File

@ -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

View File

@ -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<String, Logger> LOGGER_DIRECTORY = new HashMap<>();
private String name;
@ -17,6 +17,7 @@ public class Logger {
protected Logger(String name, LoggerConfiguration config) {
this.name = name;
this.logger = new HashMap<>();
if(config != null){
config.forEach((s,o)->{
java.util.logging.Logger log = java.util.logging.Logger.getLogger( name );
log.setLevel(Level.FINE);
@ -24,10 +25,13 @@ public class Logger {
logger.put(s, log);
});
}
}
/*
public static LoggerConfiguration getConfiguration(){
return Logger.standardConfiguration;
}
*/
/**
* Logt eine Debug Message, welche zusätzlich einer bestimmten Section zugewiesen wird.

View File

@ -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<Section,PrintStream> outputs = new HashMap<>(Section.values().length);
private final HashMap<Section,Menge<PrintStream>> 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<PrintStream> 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);
}
}
}
}

View File

@ -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<Pair>{
private static final Logger log = Logger.getLogger(ConstraintsSet.class.getName());
@ -60,7 +61,21 @@ public class ConstraintsSet extends UndMenge<Pair>{
}
*/
public void filterWrongConstraints(Unifier unify) {/*
public void filterWrongConstraints(Unifier unify) {
Menge<KomplexeMenge<Pair>> newSet = new Menge<KomplexeMenge<Pair>>();
for(OderMenge<Pair> orSet : this.getOrSets()){
Menge<Menge<Pair>> res = unify.apply(orSet.getItems());
if(res.size()>0){
newSet.add(orSet);
}else{
Logger.getLogger("Filter").debug("Ausgesondertes Constraint: "+orSet, Section.TYPEINFERENCE);
}
}
for(KomplexeMenge<Pair> i : set){
newSet.addAll(i.getAndSets());
}
this.set = newSet;
/*
for(OderConstraint constraint : this){
constraint.filterWrongConstraints(unify);
}

View File

@ -0,0 +1,7 @@
package de.dhbwstuttgart.typeinference;
import java.util.Vector;
public class Menge<A> extends Vector<A>{
}

View File

@ -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<A>{
void addItems(KomplexeMenge<A> item);
void addItem(A item);
Menge<Menge<A>> cartesianProduct();
Menge<A> getItems();
Menge<OderMenge<A>> getOrSets();
Menge<UndMenge<A>> getAndSets();
}
public class OderMenge<A> implements KomplexeMenge<A>{
Menge<KomplexeMenge<A>> set = new Menge<>();
@Override
public void addItems(KomplexeMenge<A> item) {
set.add(item);
}
public Menge<A> getItems(){
Menge<A> ret = new Menge<>();
for(KomplexeMenge<A> i : set){
ret.addAll(i.getItems());
}
return ret;
}
@Override
public void addItem(A item) {
set.add(new EinzelElement<A>(item));
}
@Override
public Menge<Menge<A>> cartesianProduct() {
Menge<Menge<A>> ret = new Menge<>();
for(KomplexeMenge<A> km : this.set){
ret.addAll(km.cartesianProduct());
}
return ret;
}
@Override
public Menge<OderMenge<A>> getOrSets() {
Menge<OderMenge<A>> ret = new Menge<>();
ret.add(this);
for(KomplexeMenge<A> i : set){
ret.addAll(i.getOrSets());
}
return ret;
}
@Override
public Menge<UndMenge<A>> getAndSets() {
Menge<UndMenge<A>> ret = new Menge<>();
for(KomplexeMenge<A> i : set){
ret.addAll(i.getAndSets());
}
return ret;
}
}

View File

@ -62,4 +62,8 @@ public class UndConstraint extends UndMenge<Pair> implements Iterable<Pair>{
public void addConstraint(ConstraintType type, ConstraintType type2) {
this.addItem(new ConstraintPair(type,type2).getPair());
}
public void addConstraint(ConstraintPair constraintPair) {
this.addItem(constraintPair.getPair());
}
}

View File

@ -0,0 +1,116 @@
package de.dhbwstuttgart.typeinference;
import java.util.Collection;
import java.util.Iterator;
import com.rits.cloning.Cloner;
public class UndMenge<A> implements KomplexeMenge<A>{
Menge<KomplexeMenge<A>> set = new Menge<>();
@Override
public void addItems(KomplexeMenge<A> item) {
set.add(item);
}
public void addItem(A item){
set.add(new EinzelElement<A>(item));
}
public Menge<A> getItems(){
Menge<A> ret = new Menge<>();
for(KomplexeMenge<A> i : set){
ret.addAll(i.getItems());
}
return ret;
}
@Override
public Menge<Menge<A>> cartesianProduct() {
Menge<Menge<A>> ret = null;
Cloner cloner = new Cloner();
for(KomplexeMenge<A> km : this.set){
if(ret == null){
ret = km.cartesianProduct();
}else{
Menge<Menge<A>> cartesianProduct = new Menge<>();
for(Menge<A> r : ret)for(Menge<A> m : km.cartesianProduct()){ //Für jedes Element aus dem Karthesischen Produkt:
Menge<A> undElement = new Menge<A>();
undElement.addAll(cloner.deepClone(r));
undElement.addAll(m);
cartesianProduct.add(undElement);
}
ret = cartesianProduct;
}
}
return ret;
}
@Override
public Menge<OderMenge<A>> getOrSets() {
Menge<OderMenge<A>> ret = new Menge<>();
for(KomplexeMenge<A> i : set){
ret.addAll(i.getOrSets());
}
return ret;
}
@Override
public Menge<UndMenge<A>> getAndSets() {
Menge<UndMenge<A>> ret = new Menge<>();
ret.add(this);
for(KomplexeMenge<A> i : set){
ret.addAll(i.getAndSets());
}
return ret;
}
}
class EinzelElement<A> implements KomplexeMenge<A>{
private A item;
public EinzelElement(A element){
item = element;
}
@Override
public void addItems(KomplexeMenge<A> item) {
}
@Override
public Menge<A> getItems() {
Menge<A> ret = new Menge<>();
ret.add(item);
return ret;
}
@Override
public void addItem(A item) {
}
@Override
public Menge<Menge<A>> cartesianProduct() {
Cloner cloner = new Cloner();
Menge<Menge<A>> ret = new Menge<>();
Menge<A> i = new Menge<A>();
i.add(cloner.deepClone(item));
ret.add(i);
return ret;
}
@Override
public Menge<OderMenge<A>> getOrSets() {
Menge<OderMenge<A>> ret = new Menge<>();
return ret;
}
@Override
public Menge<UndMenge<A>> getAndSets() {
Menge<UndMenge<A>> ret = new Menge<>();
return ret;
}
}

View File

@ -9,7 +9,7 @@ import de.dhbwstuttgart.typeinference.Pair;
public class ParallelUnify {
public ParallelUnify(ConstraintsSet constraints){
constraints.getConstraints();
//constraints.getConstraints();
}
private CartesianProduct parallelCartProd(){

View File

@ -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<FunN<...> ...> werden keine ? extends-, ? super-Typen erzeugt
*/
//public static Menge<Menge<Pair>> unifyWC (Menge<Pair> E, FC_TTO fc_tto)
public static Menge<Menge<Pair>> unify (Menge<Pair> E, FC_TTO fc_tto)
{
return unifyFiltered(E, fc_tto,true);
}
//public static Menge<Menge<Pair>> unifyWC (Menge<Pair> E, FC_TTO fc_tto)
public static Menge<Menge<Pair>> unifyFiltered (Menge<Pair> E, FC_TTO fc_tto, boolean filter)
{
//Schritt 1: Aufrufen der Regeln durch sub_unify.
Menge<Pair> 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<Menge<Pair>> vecvecpair : cartProduktSets){
OderConstraint orConstraints = new OderConstraint();
for(Menge<Pair> 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<Menge<Pair>> retValue = new Menge<>();
retValue = Unify.unifyFiltered(pairs,fc_tto,false);
//Unify.unify(pairs, fc_tto, (i)->{});
return retValue;};
cSet.filterWrongConstraints(filterUnify);
}
/*
for (Menge<Menge<Pair>> vecvecpair : cartProduktSets){
OderConstraint orConstraints = new OderConstraint();

View File

@ -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<String> oM1 = new OderMenge<>();
OderMenge<String> oM2 = new OderMenge<>();
UndMenge<String> 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<String> oM1 = new UndMenge<>();
UndMenge<String> oM2 = new UndMenge<>();
UndMenge<String> 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<String> oM1 = new OderMenge<>();
UndMenge<String> oM2 = new UndMenge<>();
UndMenge<String> 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<String> oM1 = new OderMenge<>();
UndMenge<String> oM2 = new UndMenge<>();
UndMenge<String> 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<String> oM1 = new OderMenge<>();
UndMenge<String> oM2 = new UndMenge<>();
UndMenge<String> oM3 = new UndMenge<>();
oM3.addItems(oM1);
oM3.addItems(oM2);
//System.out.println("undMenge:"+oM3.cartesianProduct());
assertTrue(oM3.cartesianProduct().size()==0);
}
}

View File

@ -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<TestKlasse> oM1 = new OderMenge<>();
OderMenge<TestKlasse> oM2 = new OderMenge<>();
UndMenge<TestKlasse> 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<Menge<TestKlasse>> cP = oM3.cartesianProduct();
System.out.println(cP);
cP.firstElement().firstElement().name="neu";
System.out.println(cP);
check(cP);
}
private <A> void check(Menge<Menge<A>> cP){
Menge<A> allElements = new Menge<>();
for(Vector<A> 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;
}
}

View File

@ -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<TypeinferenceResultSet> results = compiler.typeReconstruction();

View File

@ -1,8 +1,8 @@
import de.dhbwstuttgart.typeinference.Menge;
import java.util.Vector;
class Matrix extends Menge<Menge<Integer>> {
class Matrix extends Vector<Vector<Integer>> {
mvmul(Menge<Integer> v) {
mvmul(Vector<Integer> v) {
return v.size() + 5;
}
}

View File

@ -1,4 +1,4 @@
import de.dhbwstuttgart.typeinference.Menge;
import java.util.Vector;
class Matrix{

View File

@ -1,5 +1,5 @@
import de.dhbwstuttgart.typeinference.Menge;
import java.util.Vector;
class WildcardTest extends Menge<Integer>{
class WildcardTest extends Vector<Integer>{
<HZQ, HZP extends HZQ, R1247600089 extends HZP> Fun1<? extends HZQ, ? super Fun1<R1247600089, WildcardTest>> op = (f) -> f.apply(this);
}

View File

@ -0,0 +1,13 @@
import java.util.ArrayList;
import java.util.List;
import de.dhbwstuttgart.typeinference.Menge;
class ImportSubClassTest{
methode(){
Menge<String> var1;
ArrayList<String> var2;
var3;
var3 = var1;
var3 = var2;
}
}

View File

@ -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<String> mustContain = new Menge<String>();
//mustContain.add("TestIfStmt var");
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
}
}

View File

@ -1,7 +1,7 @@
import de.dhbwstuttgart.typeinference.Menge;
import java.util.Vector;
class ImportTest{
Menge<String> var;
Vector<String> var;
methode(var2){
var.add(var2);

View File

@ -1,4 +1,4 @@
import de.dhbwstuttgart.typeinference.Menge;
import java.util.Vector;
class ImportTest{

View File

@ -14,10 +14,10 @@ public class LambdaTest2 {
@Test
public void run(){
Logger.getConfiguration().setOutput(Section.ASSUMPTIONS, System.out);
Menge<String> mustContain = new Menge<String>();
//mustContain.add("S m");
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain,
new LoggerConfiguration().setOutput(Section.ASSUMPTIONS, System.out));
}
}

View File

@ -1,6 +1,6 @@
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.Vector;
class Matrix extends Menge<Menge<Integer>> {
class Matrix extends Vector<Vector<Integer>> {
void mul(m){
v1;

View File

@ -1,4 +1,4 @@
import de.dhbwstuttgart.typeinference.Vector;
import java.util.Vector;
class ImportGeneric {

View File

@ -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<String> mustContain = new Menge<String>();
mustContain.add("Integer m");
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);

View File

@ -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<String> mustContain = new Menge<String>();
//mustContain.add("S m");
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain, logConfig);
}
}

View File

@ -1,6 +1,6 @@
import de.dhbwstuttgart.typeinference.Menge;
import java.util.Vector;
class Matrix extends Menge<Menge<Integer>> {
class Matrix extends Vector<Vector<Integer>> {
mul(m){
ret;

View File

@ -1,8 +1,8 @@
import de.dhbwstuttgart.typeinference.Menge;
import java.util.Vector;
class Matrix extends Menge<Menge<Integer>> {
class Matrix extends Vector<Vector<Integer>> {
mvmul(Menge<Integer> v) {
mvmul(Vector<Integer> v) {
i;
ele;
v.add(1);

View File

@ -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<String> mustContain, LoggerConfiguration additionalConfig){
logConfig.mergeConfiguration(additionalConfig);
MultipleTypesInsertTester.test(sourceFileToInfere, mustContain);
}
public static void test(String sourceFileToInfere, Menge<String> mustContain){
String gesamterSrc = "";
String inferedSource = "";
MyCompilerAPI compiler = MyCompiler.getAPI();
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + sourceFileToInfere));
Menge<TypeinferenceResultSet> results = compiler.typeReconstruction();
@ -59,7 +69,7 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
public static void testSingleInsert(String sourceFileToInfere, Menge<String> mustContain){
String gesamterSrc = "";
String inferedSource = "";
MyCompilerAPI compiler = MyCompiler.getAPI();
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + sourceFileToInfere));
Menge<TypeinferenceResultSet> results = compiler.typeReconstruction();

View File

@ -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 {