diff --git a/src/main/java/de/dhbwstuttgart/parser/JavaTXParser.java b/src/main/java/de/dhbwstuttgart/parser/JavaTXParser.java index aad0a575..07f79998 100644 --- a/src/main/java/de/dhbwstuttgart/parser/JavaTXParser.java +++ b/src/main/java/de/dhbwstuttgart/parser/JavaTXParser.java @@ -7,7 +7,8 @@ import de.dhbwstuttgart.parser.antlr.Java8Parser; import de.dhbwstuttgart.parser.scope.JavaClassRegistry; import de.dhbwstuttgart.syntaxtree.SourceFile; -import org.antlr.v4.runtime.ANTLRInputStream; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; import java.io.*; @@ -18,7 +19,8 @@ import java.util.List; public class JavaTXParser { public static Java8Parser.CompilationUnitContext parse(File source) throws IOException, java.lang.ClassNotFoundException { InputStream stream = new FileInputStream(source); - ANTLRInputStream input = new ANTLRInputStream(stream); + //DEPRECATED: ANTLRInputStream input = new ANTLRInputStream(stream); + CharStream input = CharStreams.fromStream(stream); Java8Lexer lexer = new Java8Lexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); Java8Parser parser = new Java8Parser(tokens); diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index bcc4f841..cdfce63c 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -818,7 +818,7 @@ public class StatementGenerator { private Expression convert(Java8Parser.PrimaryNoNewArray_lfno_primaryContext expression) { if(expression.literal() != null){ return convert(expression.literal()); - }else if(expression.parExpression().expression()!=null){ + }else if(expression.parExpression()!=null){ return convert(expression.parExpression().expression()); }else if(expression.methodInvocation_lfno_primary() != null){ return convert(expression.methodInvocation_lfno_primary()); diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java index 33559a8e..8ebeea11 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java @@ -204,8 +204,7 @@ public class SyntaxTreeGenerator{ List methods = new ArrayList<>(); List konstruktoren = new ArrayList<>(); //int noOfMethods = methods.size(); - for(int i = 0; i < methodsAndConstructors.size(); i++){ - Method m = methodsAndConstructors.get(i); + for(Method m : methodsAndConstructors){ if(m instanceof Constructor){ konstruktoren.add((Constructor) m); } diff --git a/src/test/java/parser/GeneralParserTest.java b/src/test/java/parser/GeneralParserTest.java index 4e7d9868..b4328147 100644 --- a/src/test/java/parser/GeneralParserTest.java +++ b/src/test/java/parser/GeneralParserTest.java @@ -20,7 +20,7 @@ import org.junit.Test; * */ public class GeneralParserTest{ - private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/"; + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/java/parser/"; @Test public void run(){ diff --git a/src/test/java/typeinference/JavaTXCompilerTest.java b/src/test/java/typeinference/JavaTXCompilerTest.java index 63570d95..c0e69e28 100644 --- a/src/test/java/typeinference/JavaTXCompilerTest.java +++ b/src/test/java/typeinference/JavaTXCompilerTest.java @@ -132,9 +132,9 @@ public class JavaTXCompilerTest { //filesToTest.add(new File(rootDirectory+"MethodsEasy.jav")); //filesToTest.add(new File(rootDirectory+"Matrix.jav")); //filesToTest.add(new File(rootDirectory+"Import.jav")); - // //filesToTest.add(new File(rootDirectory+"Faculty.jav")); - // //filesToTest.add(new File(rootDirectory+"mathStruc.jav")); - // //filesToTest.add(new File(rootDirectory+"test.jav")); + //filesToTest.add(new File(rootDirectory+"Faculty.jav")); + //filesToTest.add(new File(rootDirectory+"mathStruc.jav")); + //filesToTest.add(new File(rootDirectory+"test.jav")); JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); for(File f : compiler.sourceFiles.keySet()){ SourceFile sf = compiler.sourceFiles.get(f);