Browse Source

Added ANTLR#setGlib(File)

Marked ANTLR#setGlib(String) as deprecated, and make it call
the new setGlib(File)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274717 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 22 years ago
parent
commit
26f6bfe2be
1 changed files with 20 additions and 7 deletions
  1. +20
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java

+ 20
- 7
src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java View File

@@ -73,6 +73,7 @@ import org.apache.tools.ant.types.Path;
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 @@ public class ANTLR extends Task {
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 @@ public class ANTLR extends Task {
/** 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 @@ public class ANTLR extends Task {

/**
* 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 @@ public class ANTLR extends Task {
{
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 class ANTLR extends Task {

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 @@ public class ANTLR extends Task {
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");


Loading…
Cancel
Save