antoine 2003/06/25 13:17:45
Modified: src/main/org/apache/tools/ant/taskdefs/optional ANTLR.java
Log:
Added ANTLR#setGlib(File)
Marked ANTLR#setGlib(String) as deprecated, and make it call
the new setGlib(File)
Revision Changes Path
1.29 +20 -7
ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
Index: ANTLR.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- ANTLR.java 25 Jun 2003 18:35:28 -0000 1.28
+++ ANTLR.java 25 Jun 2003 20:17:45 -0000 1.29
@@ -73,6 +73,7 @@
import org.apache.tools.ant.util.JavaEnvUtils;
import org.apache.tools.ant.util.LoaderUtils;
import org.apache.tools.ant.util.TeeOutputStream;
+import org.apache.tools.ant.util.FileUtils;
/**
* Invokes the ANTLR Translator generator on a grammar file.
@@ -92,7 +93,7 @@
private File outputDirectory;
/** an optional super grammar file */
- private String superGrammar;
+ private File superGrammar;
/** optional flag to enable html output */
private boolean html;
@@ -121,9 +122,14 @@
/** The debug attribute */
private boolean debug;
+
+ /** Instance of a utility class to use for file operations. */
+ private FileUtils fileUtils;
+
public ANTLR() {
commandline.setVm(JavaEnvUtils.getJreExecutable("java"));
commandline.setClassname("antlr.Tool");
+ fileUtils = FileUtils.newFileUtils();
}
/**
@@ -144,7 +150,8 @@
/**
* Sets an optional super grammar file.
- * @TODO change the semantic from String to File
+ * Use setGlib(File superGrammar) instead.
+ * @deprecated since ant 1.6
*/
public void setGlib(String superGrammar) {
String sg = null;
@@ -155,9 +162,15 @@
{
sg = superGrammar;
}
- this.superGrammar = sg;
+ setGlib(fileUtils.resolveFile(getProject().getBaseDir(), sg));
+ }
+ /**
+ * Sets an optional super grammar file
+ * @since ant 1.6
+ */
+ public void setGlib(File superGrammar) {
+ this.superGrammar = superGrammar;
}
-
/**
* Sets a flag to enable ParseView debugging
*/
@@ -287,12 +300,12 @@
public void execute() throws BuildException {
validateAttributes();
- //TODO: use ANTLR to parse the grammer file to do this.
+ //TODO: use ANTLR to parse the grammar file to do this.
File generatedFile = getGeneratedFile();
boolean targetIsOutOfDate =
target.lastModified() > generatedFile.lastModified();
boolean superGrammarIsOutOfDate = superGrammar != null &&
- (new File(superGrammar).lastModified() >
generatedFile.lastModified());
+ (superGrammar.lastModified() > generatedFile.lastModified());
if (targetIsOutOfDate || superGrammarIsOutOfDate) {
if (targetIsOutOfDate) {
log("Compiling " + target + " as it is newer than "
@@ -330,7 +343,7 @@
commandline.createArgument().setValue(outputDirectory.toString());
if (superGrammar != null) {
commandline.createArgument().setValue("-glib");
- commandline.createArgument().setValue(superGrammar);
+ commandline.createArgument().setValue(superGrammar.toString());
}
if (html) {
commandline.createArgument().setValue("-html");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]