* Copyright (C) 2010 Robert Futrell
* robert_futrell at users.sourceforge.net
* http://fifesoft.com/rsyntaxtextarea
* This library is distributed under a modified BSD license. See the included
* RSTALanguageSupport.License.txt file for details.
package org.fife.rsta.ac.java.rjc.parser;
import java.util.ArrayList;
import org.fife.rsta.ac.java.rjc.lexer.*;
* Test application for the Java scanner.
* If this system property is set to "<code>true</code>",
* output will not be written to stdout for each file.
public static final String PROPERTY_NO_OUTPUT = "no.output";
private static final boolean LOG = !"true".equals(
System.getProperty(PROPERTY_NO_OUTPUT));
private static void log(Object text) {
System.out.println(text);
* @param args Command line arguments.
* @throws IOException If an IO error occurs.
public static void main(String[] args) throws IOException {
PrintStream oldOut = System.out;
PrintStream oldErr = System.err;
//PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream("C:/temp/rofutr.out")));
ASTFactory fact = new ASTFactory();
//CompilationUnit cu = null;
List toDo = new ArrayList();
toDo.add(new File(args[0]));
//toDo.add(new File("C:\\java\\32\\jdk1.6.0_16\\src\\java\\util\\concurrent\\TimeUnit.java"));
File rootDir = new File("C:/java/32/jdk1.6.0_16/src/");
//rootDir = new File("C:/dev/rsta/JavaAst/src");
//rootDir = new File("C:/dev/rjava/Common/src");
File[] files = rootDir.listFiles();
for (int i=0; i<files.length; i++) {
int annotationTypeDecCount = 0;
long entireStart = System.currentTimeMillis();
for (int i=0; i<toDo.size(); i++) {
File file = (File)toDo.get(i);
if (file.isDirectory()) {
File[] contents = file.listFiles();
for (int j=0; j<contents.length; j++) {
else if (!file.getName().endsWith(".java")) {
BufferedReader r = new BufferedReader(new FileReader(file));
Scanner scanner = new Scanner(r);
long start = System.currentTimeMillis();
/*cu = */fact.getCompilationUnit(file.getName(), scanner);
long time = System.currentTimeMillis() - start;
log(file.getAbsolutePath() + " (" + file.length() + "): " + time + " ms");
} catch (InternalError ie) {
System.err.println(file.getAbsolutePath());
} catch (IOException ioe) {
String msg = ioe.getMessage();
if (msg.startsWith("TypeParameters")) {
log(file.getName() + ": ****** TYPEPARAMETERS ******");
else if (msg.startsWith("AnnotationTypeDeclaration")) {
log(file.getName() + ": ****** AnnotationTypeDeclaration ******");
annotationTypeDecCount++;
System.err.println(file.getAbsolutePath());
long entireTime = System.currentTimeMillis() - entireStart;
log(count + " files parsed");
log("TypeParameter errors: " + typeParamCount);
log("AnnotationTypeDeclaration errors: " + annotationTypeDecCount);