Browse Source

fix name-hiding and style by Kev Jackson

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277734 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
323c0a1252
3 changed files with 39 additions and 38 deletions
  1. +10
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java
  2. +27
    -29
      src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java
  3. +2
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java

+ 10
- 6
src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2004 The Apache Software Foundation
* Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -95,6 +96,9 @@ public class JJDoc extends Task {
this.javaccHome = javaccHome;
}

/**
* Constructor
*/
public JJDoc() {
cmdl.setVm(JavaEnvUtils.getJreExecutable("java"));
}
@@ -161,12 +165,12 @@ public class JJDoc extends Task {
}
}

private String createOutputFileName(File targetFile, String optionalOutputFile,
boolean plainText) {
private String createOutputFileName(File destFile, String optionalOutputFile,
boolean plain) {
String suffix = DEFAULT_SUFFIX_HTML;
String javaccFile = targetFile.getAbsolutePath().replace('\\', '/');
String javaccFile = destFile.getAbsolutePath().replace('\\', '/');

if (plainText) {
if (plain) {
suffix = DEFAULT_SUFFIX_TEXT;
}

@@ -198,4 +202,4 @@ public class JJDoc extends Task {
return (getProject().getBaseDir() + "/" + optionalOutputFile)
.replace('\\', '/');
}
}
}

+ 27
- 29
src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2004 The Apache Software Foundation
* Copyright 2000-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -175,6 +176,9 @@ public class JJTree extends Task {
this.javaccHome = javaccHome;
}

/**
* Constructor
*/
public JJTree() {
cmdl.setVm(JavaEnvUtils.getJreExecutable("java"));
}
@@ -264,11 +268,11 @@ public class JJTree extends Task {
}
}

private String createOutputFileName(File targetFile, String optionalOutputFile,
String outputDirectory) {
private String createOutputFileName(File destFile, String optionalOutputFile,
String outputDir) {
optionalOutputFile = validateOutputFile(optionalOutputFile,
outputDirectory);
String jjtreeFile = targetFile.getAbsolutePath().replace('\\', '/');
outputDir);
String jjtreeFile = destFile.getAbsolutePath().replace('\\', '/');

if ((optionalOutputFile == null) || optionalOutputFile.equals("")) {
int filePos = jjtreeFile.lastIndexOf("/");
@@ -293,57 +297,51 @@ public class JJTree extends Task {
}
}

if ((outputDirectory == null) || outputDirectory.equals("")) {
outputDirectory = getDefaultOutputDirectory();
if ((outputDir == null) || outputDir.equals("")) {
outputDir = getDefaultOutputDirectory();
}

return (outputDirectory + "/" + optionalOutputFile).replace('\\', '/');
return (outputDir + "/" + optionalOutputFile).replace('\\', '/');
}

/*
* Not used anymore
private boolean isAbsolute(String fileName) {
return (fileName.startsWith("/") || (new File(fileName).isAbsolute()));
}
*/
/**
* When running JJTree from an Ant taskdesk the -OUTPUT_DIRECTORY must
* always be set. But when -OUTPUT_DIRECTORY is set, -OUTPUT_FILE is
* handled as if relative of this -OUTPUT_DIRECTORY. Thus when the
* -OUTPUT_FILE is absolute or contains a drive letter we have a problem.
*
* @param outputFile
* @param outputDirectory
* @param destFile
* @param outputDir
* @return
* @throws BuildException
*/
private String validateOutputFile(String outputFile,
String outputDirectory)
private String validateOutputFile(String destFile,
String outputDir)
throws BuildException {
if (outputFile == null) {
if (destFile == null) {
return null;
}

if ((outputDirectory == null)
&& (outputFile.startsWith("/") || outputFile.startsWith("\\"))) {
String relativeOutputFile = makeOutputFileRelative(outputFile);
if ((outputDir == null)
&& (destFile.startsWith("/") || destFile.startsWith("\\"))) {
String relativeOutputFile = makeOutputFileRelative(destFile);
setOutputfile(relativeOutputFile);

return relativeOutputFile;
}

String root = getRoot(new File(outputFile)).getAbsolutePath();
String root = getRoot(new File(destFile)).getAbsolutePath();

if ((root.length() > 1)
&& outputFile.startsWith(root.substring(0, root.length() - 1))) {
&& destFile.startsWith(root.substring(0, root.length() - 1))) {
throw new BuildException("Drive letter in 'outputfile' not "
+ "supported: " + outputFile);
+ "supported: " + destFile);
}

return outputFile;
return destFile;
}

private String makeOutputFileRelative(String outputFile) {
private String makeOutputFileRelative(String destFile) {
StringBuffer relativePath = new StringBuffer();
String defaultOutputDirectory = getDefaultOutputDirectory();
int nextPos = defaultOutputDirectory.indexOf('/');
@@ -360,7 +358,7 @@ public class JJTree extends Task {
}
}

relativePath.append(outputFile);
relativePath.append(destFile);

return relativePath.toString();
}
@@ -384,4 +382,4 @@ public class JJTree extends Task {

return root;
}
}
}

+ 2
- 3
src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2004 The Apache Software Foundation
* Copyright 2000-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +19,9 @@ package org.apache.tools.ant.taskdefs.optional.javacc;

import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.zip.ZipFile;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;


Loading…
Cancel
Save