From 146a9b0509bb65079402b4b622252fa43b7a5a9e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 13 Feb 2012 16:32:42 -0600 Subject: [PATCH] Fix unit test placing output files like "null.java" in the project directory --- tool/src/org/antlr/v4/codegen/CodeGenerator.java | 2 ++ tool/test/org/antlr/v4/test/TestCompositeGrammars.java | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tool/src/org/antlr/v4/codegen/CodeGenerator.java b/tool/src/org/antlr/v4/codegen/CodeGenerator.java index 69f642105..7c84cbe28 100644 --- a/tool/src/org/antlr/v4/codegen/CodeGenerator.java +++ b/tool/src/org/antlr/v4/codegen/CodeGenerator.java @@ -303,6 +303,7 @@ public class CodeGenerator { * TListener.java, if we're using the Java target. */ public String getListenerFileName() { + assert g.name != null; ST extST = templates.getInstanceOf("codeFileExtension"); String listenerName = g.name + "Listener"; return listenerName+extST.render(); @@ -312,6 +313,7 @@ public class CodeGenerator { * such as BlankTListener.java, if we're using the Java target. */ public String getBlankListenerFileName() { + assert g.name != null; ST extST = templates.getInstanceOf("codeFileExtension"); String listenerName = "Blank" + g.name + "Listener"; return listenerName+extST.render(); diff --git a/tool/test/org/antlr/v4/test/TestCompositeGrammars.java b/tool/test/org/antlr/v4/test/TestCompositeGrammars.java index c291ed4a1..ad83dc641 100644 --- a/tool/test/org/antlr/v4/test/TestCompositeGrammars.java +++ b/tool/test/org/antlr/v4/test/TestCompositeGrammars.java @@ -42,10 +42,14 @@ public class TestCompositeGrammars extends BaseTest { String grammar = "parser grammar S;\n" + "a : B . C ;\n"; // not qualified ID - Grammar g = new Grammar(grammar); + mkdir(tmpdir); + Grammar g = new Grammar(tmpdir + "/S.g", grammar); + g.name = "S"; ErrorQueue equeue = new ErrorQueue(); - Tool antlr = new Tool(); + Tool antlr = g.tool; + antlr.outputDirectory = tmpdir; + antlr.libDirectory = tmpdir; antlr.addListener(equeue); antlr.process(g,true);