diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index dc9a1127..cb39277d 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -27,7 +27,7 @@ import java.util.*; public class JavaTXCompiler { - private List sourceFiles = new ArrayList<>(); + protected List sourceFiles = new ArrayList<>(); public List getTypeInserts(File forFile){ ResultSet result = typeInference(); diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index b3273f9d..58eb92de 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -819,7 +819,7 @@ public class StatementGenerator { funNParams.add(TypePlaceholder.fresh(expression.getStart()))); RefTypeOrTPHOrWildcardOrGeneric lambdaType = TypePlaceholder.fresh(expression.getStart()); //RefType lambdaType = new RefType(reg.getName("Fun"+params.getFormalparalist().size()), - //funNParams, expression.getStart()); + //funNParams, name.getStart()); return new LambdaExpression(lambdaType, params, block, expression.getStart()); } } diff --git a/src/de/dhbwstuttgart/parser/antlr/Java8Parser.java b/src/de/dhbwstuttgart/parser/antlr/Java8Parser.java index 851e7ead..1af14046 100644 --- a/src/de/dhbwstuttgart/parser/antlr/Java8Parser.java +++ b/src/de/dhbwstuttgart/parser/antlr/Java8Parser.java @@ -180,7 +180,7 @@ public class Java8Parser extends Parser { "methodInvocation_lf_primary", "methodInvocation_lfno_primary", "argumentList", "methodReference", "methodReference_lf_primary", "methodReference_lfno_primary", "arrayCreationExpression", "dimExprs", "dimExpr", "constantExpression", - "expression", "lambdaExpression", "lambdaParameters", "inferredFormalParameterList", + "name", "lambdaExpression", "lambdaParameters", "inferredFormalParameterList", "lambdaBody", "assignmentExpression", "assignment", "leftHandSide", "assignmentOperator", "conditionalExpression", "conditionalOrExpression", "conditionalAndExpression", "inclusiveOrExpression", "exclusiveOrExpression", "andExpression", "equalityExpression", diff --git a/src/de/dhbwstuttgart/syntaxtree/ASTVisitor.java b/src/de/dhbwstuttgart/syntaxtree/ASTVisitor.java index 8372dca8..d7527634 100644 --- a/src/de/dhbwstuttgart/syntaxtree/ASTVisitor.java +++ b/src/de/dhbwstuttgart/syntaxtree/ASTVisitor.java @@ -3,7 +3,7 @@ package de.dhbwstuttgart.syntaxtree; import de.dhbwstuttgart.syntaxtree.statement.*; import de.dhbwstuttgart.syntaxtree.statement.literal.Literal; import de.dhbwstuttgart.syntaxtree.statement.literal.Null; -import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; +import de.dhbwstuttgart.syntaxtree.type.*; public interface ASTVisitor extends StatementVisitor{ @@ -11,8 +11,6 @@ public interface ASTVisitor extends StatementVisitor{ void visit(ArgumentList argumentList); - void visit(RefTypeOrTPHOrWildcardOrGeneric refTypeOrTPHOrWildcardOrGeneric); - void visit(GenericTypeVar genericTypeVar); void visit(FormalParameter formalParameter); @@ -21,5 +19,19 @@ public interface ASTVisitor extends StatementVisitor{ void visit(Field field); + void visit(Method field); + void visit(ParameterList formalParameters); + + void visit(ClassOrInterface classOrInterface); + + void visit(RefType refType); + + void visit(SuperWildcardType superWildcardType); + + void visit(TypePlaceholder typePlaceholder); + + void visit(ExtendsWildcardType extendsWildcardType); + + void visit(GenericRefType genericRefType); } diff --git a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java index 79098e4d..1604c8c5 100755 --- a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java +++ b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.syntaxtree; import de.dhbwstuttgart.core.IItemWithOffset; import de.dhbwstuttgart.syntaxtree.type.RefType; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; import de.dhbwstuttgart.typecheck.JavaClassName; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.constraints.Constraint; @@ -15,13 +16,12 @@ import java.util.List; /** * Stellt jede Art von Klasse dar. Auch abstrakte Klassen und Interfaces */ -public class ClassOrInterface implements IItemWithOffset{ +public class ClassOrInterface extends SyntaxTreeNode { protected int modifiers; protected JavaClassName name; private List fields = new ArrayList<>(); private List methods = new ArrayList<>(); private GenericDeclarationList genericClassParameters; - private Token offset; private RefTypeOrTPHOrWildcardOrGeneric superClass; protected boolean isInterface; private List implementedInterfaces; @@ -29,12 +29,11 @@ public class ClassOrInterface implements IItemWithOffset{ public ClassOrInterface(int modifiers, JavaClassName name, List fielddecl, List methods, List constructors, GenericDeclarationList genericClassParameters, RefTypeOrTPHOrWildcardOrGeneric superClass, Boolean isInterface, List implementedInterfaces, Token offset){ - this.offset = offset; + super(offset); this.modifiers = modifiers; this.name = name; this.fields = fielddecl; this.genericClassParameters = genericClassParameters; - this.offset = offset; this.superClass = superClass; this.isInterface = isInterface; this.implementedInterfaces = implementedInterfaces; @@ -88,7 +87,7 @@ public class ClassOrInterface implements IItemWithOffset{ } @Override - public Token getOffset() { - return offset; + public void accept(ASTVisitor visitor) { + visitor.visit(this); } } diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java index 350d8b15..065945ee 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/syntaxtree/Method.java @@ -23,7 +23,7 @@ import de.dhbwstuttgart.syntaxtree.statement.Block; */ public class Method extends Field implements IItemWithOffset, TypeScope { - private Block block; + public final Block block; private ParameterList parameterlist = new ParameterList(new ArrayList<>(), new NullToken()); private ExceptionList exceptionlist; private GenericDeclarationList generics; @@ -56,4 +56,9 @@ public class Method extends Field implements IItemWithOffset, TypeScope public RefTypeOrTPHOrWildcardOrGeneric getReturnType() { return this.getType(); } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/ParameterList.java b/src/de/dhbwstuttgart/syntaxtree/ParameterList.java index 1d8ff055..2540f907 100755 --- a/src/de/dhbwstuttgart/syntaxtree/ParameterList.java +++ b/src/de/dhbwstuttgart/syntaxtree/ParameterList.java @@ -32,7 +32,7 @@ public class ParameterList extends SyntaxTreeNode implements Iterable iterator() { - return null; + return formalparameter.iterator(); } @Override diff --git a/src/de/dhbwstuttgart/syntaxtree/StatementVisitor.java b/src/de/dhbwstuttgart/syntaxtree/StatementVisitor.java index eddaeece..39db3ef0 100644 --- a/src/de/dhbwstuttgart/syntaxtree/StatementVisitor.java +++ b/src/de/dhbwstuttgart/syntaxtree/StatementVisitor.java @@ -27,8 +27,6 @@ public interface StatementVisitor { void visit(InstanceOf instanceOf); - void visit(InstVar instVar); - void visit(LocalVar localVar); void visit(LocalVarDecl localVarDecl); diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java deleted file mode 100755 index 021b5039..00000000 --- a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.statement; - -import de.dhbwstuttgart.exceptions.NotImplementedException; -import de.dhbwstuttgart.syntaxtree.StatementVisitor; -import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; -import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; -import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; -import org.antlr.v4.runtime.Token; - - -public class InstVar extends Expression -{ - private Expression expr; - public InstVar(Expression instanz, String name, Token offset) - { - super(instanz.getType(),offset); - expr = instanz; - } - - @Override - public void accept(StatementVisitor visitor) { - visitor.visit(this); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVar.java index 3c703a6f..91094a7a 100644 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVar.java @@ -1,28 +1,23 @@ package de.dhbwstuttgart.syntaxtree.statement; -import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; -import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; -import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; -import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; -import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; import org.antlr.v4.runtime.Token; public class LocalVar extends Statement{ - protected final String expression; + public final String name; public LocalVar(String n, RefTypeOrTPHOrWildcardOrGeneric type, Token offset) { super(type,offset); - this.expression = n; + this.name = n; } public LocalVar(Expression e1, RefTypeOrTPHOrWildcardOrGeneric type, String access) { super(type,e1.getOffset()); - this.expression = access; + this.name = access; } @Override diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java index ecbc79d7..0767c59d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.ASTVisitor; import org.antlr.v4.runtime.Token; /** @@ -33,4 +34,8 @@ public class ExtendsWildcardType extends WildcardType{ } + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java b/src/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java index 8a50c726..ebb28946 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.ASTVisitor; import de.dhbwstuttgart.typecheck.GenericTypeName; import de.dhbwstuttgart.typecheck.JavaClassName; import org.antlr.v4.runtime.Token; @@ -20,5 +21,10 @@ public class GenericRefType extends RefTypeOrTPHOrWildcardOrGeneric public String getUniqueIdentifier(){ return name.toString(); } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index bd370c3f..e8030403 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.ASTVisitor; import de.dhbwstuttgart.typecheck.JavaClassName; import org.antlr.v4.runtime.Token; @@ -100,5 +101,9 @@ public class RefType extends RefTypeOrTPHOrWildcardOrGeneric } + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java b/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java index 640e80c7..20bc5b45 100644 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java @@ -4,13 +4,11 @@ import de.dhbwstuttgart.syntaxtree.ASTVisitor; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import org.antlr.v4.runtime.Token; -public class RefTypeOrTPHOrWildcardOrGeneric extends SyntaxTreeNode{ +public abstract class RefTypeOrTPHOrWildcardOrGeneric extends SyntaxTreeNode{ public RefTypeOrTPHOrWildcardOrGeneric(Token offset) { super(offset); } @Override - public void accept(ASTVisitor visitor) { - visitor.visit(this); - } + public abstract void accept(ASTVisitor visitor); } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java index babc0a31..4cbee79e 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.ASTVisitor; import org.antlr.v4.runtime.Token; /** @@ -42,4 +43,9 @@ public class SuperWildcardType extends WildcardType{ public boolean isSuper() { return true; } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java index 82f7e298..97845545 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.type; import java.util.Hashtable; +import de.dhbwstuttgart.syntaxtree.ASTVisitor; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.factory.NameGenerator; import org.antlr.v4.runtime.Token; @@ -65,4 +66,9 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric public String getName() { return name; } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/visual/ASTPrinter.java b/src/de/dhbwstuttgart/syntaxtree/visual/ASTPrinter.java index bf8c1f87..22413346 100644 --- a/src/de/dhbwstuttgart/syntaxtree/visual/ASTPrinter.java +++ b/src/de/dhbwstuttgart/syntaxtree/visual/ASTPrinter.java @@ -1,5 +1,298 @@ package de.dhbwstuttgart.syntaxtree.visual; +import de.dhbwstuttgart.syntaxtree.*; +import de.dhbwstuttgart.syntaxtree.statement.*; +import de.dhbwstuttgart.syntaxtree.statement.literal.Literal; +import de.dhbwstuttgart.syntaxtree.statement.literal.Null; +import de.dhbwstuttgart.syntaxtree.type.*; + +import java.lang.reflect.Modifier; +import java.util.Iterator; + public class ASTPrinter { + + public static String print(SourceFile toPrint){ + StringBuilder output = new StringBuilder(); + new OutputGenerator(output).visit(toPrint); + return output.toString(); + } + + private static class OutputGenerator implements ASTVisitor{ + + private final StringBuilder out; + + OutputGenerator(StringBuilder out){ + this.out = out; + } + + @Override + public void visit(SourceFile sourceFile) { + for(ClassOrInterface cl : sourceFile.getClasses()){ + cl.accept(this); + } + } + + @Override + public void visit(ArgumentList argumentList) { + out.append("("); + Iterator expressionIterator = argumentList.getArguments().iterator(); + while(expressionIterator.hasNext()){ + expressionIterator.next().accept(this); + if(expressionIterator.hasNext())out.append(", "); + } + out.append(")"); + } + + @Override + public void visit(GenericTypeVar genericTypeVar) { + out.append(genericTypeVar.getName()); + } + + @Override + public void visit(FormalParameter formalParameter) { + formalParameter.getType().accept(this); + out.append(" "); + out.append(formalParameter.getName()); + } + + @Override + public void visit(GenericDeclarationList genericTypeVars) { + Iterator genericIterator = genericTypeVars.iterator(); + if(genericIterator.hasNext()){ + out.append("<"); + while(genericIterator.hasNext()){ + genericIterator.next().accept(this); + if(genericIterator.hasNext())out.append(", "); + } + out.append(">"); + } + } + + @Override + public void visit(Field field) { + field.getType().accept(this); + out.append(" "); + out.append(field.getName()); + out.append(";"); + } + + @Override + public void visit(Method method) { + method.getType().accept(this); + out.append(" " + method.getName()); + method.getParameterList().accept(this); + method.block.accept(this); + } + + @Override + public void visit(ParameterList formalParameters) { + out.append("("); + Iterator genericIterator = formalParameters.getFormalparalist().iterator(); + if(genericIterator.hasNext()){ + while(genericIterator.hasNext()){ + genericIterator.next().accept(this); + if(genericIterator.hasNext())out.append(", "); + } + } + out.append(")"); + } + + @Override + public void visit(ClassOrInterface classOrInterface) { + if((Modifier.INTERFACE & classOrInterface.getModifiers()) == 1){ + out.append("interface "); + }else{ + out.append("class "); + } + out.append(classOrInterface.getClassName()); + classOrInterface.getGenerics().accept(this); + out.append(" {\n"); + for(Field f : classOrInterface.getFieldDecl()){ + f.accept(this); + out.append("\n"); + } + for(Method m : classOrInterface.getMethods()){ + m.accept(this); + out.append("\n"); + } + } + + @Override + public void visit(RefType refType) { + out.append(refType.getName()); + Iterator genericIterator = refType.getParaList().iterator(); + if(genericIterator.hasNext()){ + out.append("<"); + while(genericIterator.hasNext()){ + genericIterator.next().accept(this); + if(genericIterator.hasNext())out.append(", "); + } + out.append(">"); + } + } + + @Override + public void visit(SuperWildcardType superWildcardType) { + out.append("? super "); + superWildcardType.getInnerType().accept(this); + } + + @Override + public void visit(TypePlaceholder typePlaceholder) { + out.append("TPH "+ typePlaceholder.getName()); + } + + @Override + public void visit(ExtendsWildcardType extendsWildcardType) { + out.append("? extends "); + extendsWildcardType.getInnerType().accept(this); + } + + @Override + public void visit(GenericRefType genericRefType) { + out.append(genericRefType.getName()); + } + + @Override + public void visit(LambdaExpression lambdaExpression) { + lambdaExpression.params.accept(this); + out.append(" -> "); + lambdaExpression.methodBody.accept(this); + } + + @Override + public void visit(Assign assign) { + assign.lefSide.accept(this); + out.append(" = "); + assign.rightSide.accept(this); + } + + @Override + public void visit(Binary binary) { + + } + + @Override + public void visit(Block block) { + out.append("{\n"); + for(Statement stmt : block.getStatements()){ + stmt.accept(this); + out.append(";\n"); + } + out.append("}"); + } + + @Override + public void visit(CastExpr castExpr) { + + } + + @Override + public void visit(EmptyStmt emptyStmt) { + + } + + @Override + public void visit(FieldVar fieldVar) { + fieldVar.receiver.accept(this); + out.append("." + fieldVar.fieldVarName); + } + + @Override + public void visit(ForStmt forStmt) { + + } + + @Override + public void visit(IfStmt ifStmt) { + + } + + @Override + public void visit(InstanceOf instanceOf) { + + } + + @Override + public void visit(LocalVar localVar) { + out.append(localVar.name); + } + + @Override + public void visit(LocalVarDecl localVarDecl) { + localVarDecl.getType().accept(this); + out.append(" " + localVarDecl.getName()); + } + + @Override + public void visit(MethodCall methodCall) { + methodCall.receiver.accept(this); + out.append("."+methodCall.name); + methodCall.getArgumentList().accept(this); + } + + @Override + public void visit(NewClass methodCall) { + out.append("new "); + visit((MethodCall) methodCall); + } + + @Override + public void visit(NewArray newArray) { + + } + + @Override + public void visit(Receiver receiver) { + receiver.expr.accept(this); + } + + @Override + public void visit(Return aReturn) { + out.append("return "); + aReturn.retexpr.accept(this); + } + + @Override + public void visit(ReturnVoid aReturn) { + out.append("return"); + } + + @Override + public void visit(StaticClassName staticClassName) { + + } + + @Override + public void visit(Super aSuper) { + + } + + @Override + public void visit(This aThis) { + out.append("this"); + } + + @Override + public void visit(UnaryPlus unaryPlus) { + + } + + @Override + public void visit(WhileStmt whileStmt) { + + } + + @Override + public void visit(Null aNull) { + + } + + @Override + public void visit(Literal literal) { + + } + } + } diff --git a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java index 6d76a462..a799d8e2 100644 --- a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java +++ b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java @@ -118,11 +118,6 @@ public class TYPE implements StatementVisitor{ throw new NotImplementedException(); } - @Override - public void visit(InstVar instVar) { - throw new NotImplementedException(); - } - @Override public void visit(LocalVar localVar) { // Es werden nur bei Feldvariablen Constraints generiert. Lokale Variablen sind eindeutig diff --git a/test/typeinference/JavaTXCompilerTest.java b/test/typeinference/JavaTXCompilerTest.java index 96dc1d40..8053d80c 100644 --- a/test/typeinference/JavaTXCompilerTest.java +++ b/test/typeinference/JavaTXCompilerTest.java @@ -3,6 +3,7 @@ package typeinference; import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.parser.ClassNotFoundException; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; import de.dhbwstuttgart.typedeployment.TypeInsert; import de.dhbwstuttgart.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.ResultSet; @@ -19,7 +20,7 @@ import java.util.List; import static org.junit.Assert.*; -public class JavaTXCompilerTest { +public class JavaTXCompilerTest extends JavaTXCompiler { private static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/"; private static final List filesToTest = new ArrayList<>(); @@ -35,10 +36,10 @@ public class JavaTXCompilerTest { //filesToTest.add(new File(rootDirectory+"Generics.jav")); //filesToTest.add(new File(rootDirectory+"MethodsEasy.jav")); //filesToTest.add(new File(rootDirectory+"Matrix.jav")); - JavaTXCompiler compiler = new JavaTXCompiler(); for(File f : filesToTest){ - compiler.parse(f); - List result = compiler.getTypeInserts(f); + this.parse(f); + System.out.println(ASTPrinter.print(this.sourceFiles.get(sourceFiles.size()-1))); + List result = this.getTypeInserts(f); String content = readFile(f.getPath(), StandardCharsets.UTF_8); for(TypeInsert tip : result){ System.out.println(tip.insert(content));