diff options
author | acolyer <acolyer> | 2005-06-02 11:32:17 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-06-02 11:32:17 +0000 |
commit | bedcb3ea08173f4b4ed837822e917e8dba6837d9 (patch) | |
tree | c501cd4a57f65db8b6ecc531fadcaa481d9b0000 /ajdoc/src | |
parent | 3508c1bb7e5f6eab1ba7d35c8700f83f4f24d777 (diff) | |
download | aspectj-bedcb3ea08173f4b4ed837822e917e8dba6837d9.tar.gz aspectj-bedcb3ea08173f4b4ed837822e917e8dba6837d9.zip |
Andrew Huff's patch fixing miscellaneous ajdoc NPEs....
Diffstat (limited to 'ajdoc/src')
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/Config.java | 5 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/DocException.java | 20 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/Main.java | 25 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java | 36 |
4 files changed, 66 insertions, 20 deletions
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Config.java b/ajdoc/src/org/aspectj/tools/ajdoc/Config.java index 04f740d76..c9c6f121c 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Config.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Config.java @@ -33,9 +33,10 @@ interface Config { " -classpath <pathlist> Specify where to find user class files\n" + " -bootclasspath <pathlist> Override location of class files loaded\n" + " -d <directory> Destination directory for output files\n" + - " -argfile <file> Build config file (wildcards not supported\n" + + " -argfile <file> Build config file (wildcards not supported)\n" + " -verbose Output messages about what Javadoc is doing\n" + - " -v Print out the version of ajdoc" + + " -v Print out the version of ajdoc\n" + + " -source <version> set source level (1.3, 1.4 or 1.5)" + "\n"+ "If an argument is of the form @<filename>, the file will be interpreted as\n"+ "a line delimited set of arguments to insert into the argument list."; diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/DocException.java b/ajdoc/src/org/aspectj/tools/ajdoc/DocException.java new file mode 100644 index 000000000..1333661ba --- /dev/null +++ b/ajdoc/src/org/aspectj/tools/ajdoc/DocException.java @@ -0,0 +1,20 @@ +/* ******************************************************************* + * Copyright (c) 2005 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Andrew Huff initial implementation + * ******************************************************************/ +package org.aspectj.tools.ajdoc; + +class DocException extends Exception { + private static final long serialVersionUID = 3257284725490857778L; + + DocException(String message){ + super(message); + } +} diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java index 4eb2875e9..ed5b04339 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java @@ -153,7 +153,13 @@ public class Main implements Config { // PHASE 1: generate Signature files (Java with DeclIDs and no bodies). System.out.println( "> Building signature files..." ); + try{ StubFileGenerator.doFiles(declIDTable, symbolManager, inputFiles, signatureFiles); + } catch (DocException d){ + System.err.println(d.getMessage()); + // d.printStackTrace(); + return; + } // PHASE 2: let Javadoc generate HTML (with DeclIDs) System.out.println( "> Calling javadoc..." ); @@ -223,7 +229,12 @@ public class Main implements Config { "package-summary.html", true); } } else { - File[] files = FileUtil.listFiles(rootDir, new FileFilter() { + File[] files = rootDir.listFiles(); + if (files == null){ + System.err.println("Destination directory is not a directory: " + rootDir.toString()); + return; + } + files = FileUtil.listFiles(rootDir, new FileFilter() { public boolean accept(File f) { return f.getName().equals("package-summary.html"); } @@ -678,10 +689,14 @@ public class Main implements Config { static void displayHelpAndExit(String message) { - if (message != null) System.err.println(message); - System.err.println(); - System.err.println(Config.USAGE); - exit(0); + if (message != null) { + System.err.println(message); + System.err.println(); + System.err.println(Config.USAGE); + } else { + System.out.println(Config.USAGE); + exit(0); + } } static protected void exit(int value) { diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java index 88f61117c..9843a2b94 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java @@ -25,21 +25,22 @@ import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten */ -class StubFileGenerator { +class StubFileGenerator{ static Hashtable declIDTable = null; - static void doFiles(Hashtable table, + static void doFiles (Hashtable table, SymbolManager symbolManager, File[] inputFiles, - File[] signatureFiles) { + File[] signatureFiles) throws DocException { declIDTable = table; for (int i = 0; i < inputFiles.length; i++) { processFile(symbolManager, inputFiles[i], signatureFiles[i]); } } + - static void processFile(SymbolManager symbolManager, File inputFile, File signatureFile) { + static void processFile(SymbolManager symbolManager, File inputFile, File signatureFile) throws DocException { try { String path = StructureUtil.translateAjPathName(signatureFile.getCanonicalPath()); PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(path))); @@ -56,7 +57,11 @@ class StubFileGenerator { if (node.getKind().equals(IProgramElement.Kind.IMPORT_REFERENCE)) { processImportDeclaration(node, writer); } else { - processTypeDeclaration(node, writer); + try { + processTypeDeclaration(node, writer); + } catch (DocException d){ + throw new DocException("File name invalid: " + inputFile.toString()); + } } } @@ -78,12 +83,15 @@ class StubFileGenerator { } } - private static void processTypeDeclaration(IProgramElement classNode, PrintWriter writer) throws IOException { + private static void processTypeDeclaration(IProgramElement classNode, PrintWriter writer) throws DocException { String formalComment = addDeclID(classNode, classNode.getFormalComment()); writer.println(formalComment); String signature = genSourceSignature(classNode);// StructureUtil.genSignature(classNode); + if (signature == null){ + throw new DocException("The java file is invalid"); + } // System.err.println("######" + signature + ", " + classNode.getName()); if (!StructureUtil.isAnonymous(classNode) && !classNode.getName().equals("<undefined>")) { @@ -94,7 +102,7 @@ class StubFileGenerator { } } - private static void processMembers(List/*IProgramElement*/ members, PrintWriter writer, boolean declaringTypeIsInterface) throws IOException { + private static void processMembers(List/*IProgramElement*/ members, PrintWriter writer, boolean declaringTypeIsInterface) throws DocException { for (Iterator it = members.iterator(); it.hasNext();) { IProgramElement member = (IProgramElement) it.next(); @@ -155,12 +163,14 @@ class StubFileGenerator { */ private static String genSourceSignature(IProgramElement classNode) { String signature = classNode.getSourceSignature(); - int index = signature.indexOf("aspect"); - if (index != -1 && signature.charAt(index-1) != '.') { - signature = signature.substring(0, index) + - "class " + - signature.substring(index + 6, signature.length()); - } + if (signature != null){ + int index = signature.indexOf("aspect"); + if (index != -1 && signature.charAt(index-1) != '.') { + signature = signature.substring(0, index) + + "class " + + signature.substring(index + 6, signature.length()); + } + } return signature; } |