diff options
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/CompilerWrapper.java | 32 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/Config.java | 2 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java (renamed from ajdoc/src/org/aspectj/tools/ajdoc/Phase3.java) | 217 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/JavadocExecutor.java (renamed from ajdoc/src/org/aspectj/tools/ajdoc/Phase2.java) | 2 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/Main.java | 103 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java (renamed from ajdoc/src/org/aspectj/tools/ajdoc/Phase1.java) | 54 | ||||
-rw-r--r-- | ajdoc/testdata/failing-build/Fail.java | 5 | ||||
-rw-r--r-- | ajdoc/testdata/simple/foo/ClassA.java | 23 | ||||
-rw-r--r-- | ajdoc/testdata/simple/foo/InterfaceI.java | 6 | ||||
-rw-r--r-- | ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocModuleTests.java | 29 | ||||
-rw-r--r-- | ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java | 50 | ||||
-rw-r--r-- | ajdoc/testsrc/org/aspectj/tools/ajdoc/MainTestCase.java (renamed from ajdoc/testsrc/org/aspectj/tools/ajdoc/MainTest.java) | 13 |
12 files changed, 328 insertions, 208 deletions
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/CompilerWrapper.java b/ajdoc/src/org/aspectj/tools/ajdoc/CompilerWrapper.java new file mode 100644 index 000000000..05a1c405e --- /dev/null +++ b/ajdoc/src/org/aspectj/tools/ajdoc/CompilerWrapper.java @@ -0,0 +1,32 @@ +/* ******************************************************************* + * Copyright (c) 2003 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: + * Mik Kersten initial implementation + * ******************************************************************/ + package org.aspectj.tools.ajdoc; + +/** + * Wrapper for ajdoc's use of the AspectJ compiler. + * + * @author Mik Kersten + */ +public class CompilerWrapper extends org.aspectj.tools.ajc.Main { + + private static CompilerWrapper INSTANCE = null; + + public static void main(String[] args) { + INSTANCE = new CompilerWrapper(); + INSTANCE.runMain(args, true); + + } + + public static boolean hasErrors() { + return INSTANCE.ourHandler.getErrors().length > 0; + } +} diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Config.java b/ajdoc/src/org/aspectj/tools/ajdoc/Config.java index 4224ed783..990568fff 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Config.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Config.java @@ -15,11 +15,11 @@ package org.aspectj.tools.ajdoc; interface Config { + static final String DECL_ID_STRING = "__AJDECLID:"; static final String DECL_ID_TERMINATOR = ":__"; static final String WORKING_DIR = "ajdocworkingdir"; static final String DIR_SEP_CHAR = "/"; - static final String VERSION = "ajdoc version 0.8beta4"; static final String USAGE = "Usage: ajdoc <options> <source files>\n" + "\n" + diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Phase3.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java index 09d3e95c2..7bfa544d9 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Phase3.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -14,19 +14,14 @@ package org.aspectj.tools.ajdoc; -import java.io.File; -import java.io.FileOutputStream; -import java.io.BufferedWriter; -import java.io.PrintWriter; -import java.io.IOException; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.StringReader; - +import java.io.*; import java.util.*; -class Phase3 { +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; + +class HtmlDecorator { static List visibleFileList = new ArrayList(); static Hashtable declIDTable = null; @@ -99,7 +94,7 @@ class Phase3 { newBase = base.substring(0, base.lastIndexOf(Config.DIR_SEP_CHAR)); } filename = newBase + Config.DIR_SEP_CHAR + packageName + - Config.DIR_SEP_CHAR + currFileClass + "." + + Config.DIR_SEP_CHAR + currFileClass + //"." + getName(decl) + ".html"; nestedClass = true; } @@ -138,7 +133,7 @@ class Phase3 { boolean isSecond = false; int index = 0; - Declaration decl; + IProgramElement decl; while ( true ) { //---this next part is an inlined procedure that returns two values--- @@ -153,19 +148,22 @@ class Phase3 { throw new Error("Malformed DeclID."); else { String tid = contents.substring(start + Config.DECL_ID_STRING.length(), end); - decl = (Declaration)declIDTable.get(tid); + decl = (IProgramElement)declIDTable.get(tid); index = start; } //--- --- - //--- --- + //--- --- if ( decl == null ) break; fileContents.delete(start, end + Config.DECL_ID_TERMINATOR.length()); - if ( decl.isType() ) { + if ( decl.getKind().isTypeKind() ) { isSecond = true; - goAddIntroductions(decl, fileContents, index); - goAddAdvice(decl, fileContents, index); - goAddCrosscuts(decl, fileContents, index); +// addIntroductionDocumentation(decl, fileContents, index); +// addAdviceDocumentation(decl, fileContents, index); +// addPointcutDocumentation(decl, fileContents, index); + addAspectDocumentation(decl, fileContents, index); + + } else { decorateMemberDocumentation(decl, fileContents, index); @@ -189,37 +187,49 @@ class Phase3 { fos.write( fileContents.toString().getBytes() ); } - static void goAddCrosscuts(Declaration decl, StringBuffer fileBuffer, int index ) { - Declaration[] crosscuts = decl.getCrosscutDeclarations(); - if ( crosscuts.length > 0 ) { - insertDeclarationsSummary(fileBuffer, crosscuts, "Pointcut Summary", index); - insertDeclarationsDetails(fileBuffer, crosscuts, "Pointcut Detail", index); - } - } - - static void goAddAdvice(Declaration decl, StringBuffer fileBuffer, int index ) { - Declaration[] advice = decl.getAdviceDeclarations(); - if ( advice.length > 0 ) { - insertDeclarationsSummary(fileBuffer, advice, "Advice Summary", index); - insertDeclarationsDetails(fileBuffer, advice, "Advice Detail", index); - } - } - - static void goAddIntroductions(Declaration decl, - StringBuffer fileBuffer, - int index ) { - Declaration[] introductions = decl.getIntroductionDeclarations(); - if ( introductions.length > 0 ) { - insertDeclarationsSummary(fileBuffer, - introductions, - "Introduction Summary", - index); - insertDeclarationsDetails(fileBuffer, - introductions, - "Introduction Detail", - index); - } + static void addAspectDocumentation(IProgramElement node, StringBuffer fileBuffer, int index ) { + List relations = AsmManager.getDefault().getRelationshipMap().get(node); + System.err.println("> relations: " + relations); + +// if ( crosscuts.length > 0 ) { +// insertDeclarationsSummary(fileBuffer, crosscuts, "Pointcut Summary", index); +// insertDeclarationsDetails(fileBuffer, crosscuts, "Pointcut Detail", index); +// } } + + +// static void addPointcutDocumentation(IProgramElement decl, StringBuffer fileBuffer, int index ) { +// List AsmManager.getDefault().getRelationshipMap().get() +// Declaration[] crosscuts = decl.getCrosscutDeclarations(); +// if ( crosscuts.length > 0 ) { +// insertDeclarationsSummary(fileBuffer, crosscuts, "Pointcut Summary", index); +// insertDeclarationsDetails(fileBuffer, crosscuts, "Pointcut Detail", index); +// } +// } +// +// static void addAdviceDocumentation(IProgramElement decl, StringBuffer fileBuffer, int index ) { +// Declaration[] advice = decl.getAdviceDeclarations(); +// if ( advice.length > 0 ) { +// insertDeclarationsSummary(fileBuffer, advice, "Advice Summary", index); +// insertDeclarationsDetails(fileBuffer, advice, "Advice Detail", index); +// } +// } +// +// static void addIntroductionDocumentation(IProgramElement decl, +// StringBuffer fileBuffer, +// int index ) { +// Declaration[] introductions = decl.getIntroductionDeclarations(); +// if ( introductions.length > 0 ) { +// insertDeclarationsSummary(fileBuffer, +// introductions, +// "Introduction Summary", +// index); +// insertDeclarationsDetails(fileBuffer, +// introductions, +// "Introduction Detail", +// index); +// } +// } static void insertDeclarationsSummary(StringBuffer fileBuffer, Declaration[] decls, @@ -406,66 +416,65 @@ class Phase3 { } } - static void decorateMemberDocumentation( Declaration decl, + static void decorateMemberDocumentation(IProgramElement node, StringBuffer fileContentsBuffer, int index ) { - if (decl.isIntroduced()) { - // !!! HACK, THIS HAS TO BE CHANGED WITH THE SYMBOL MANAGER - String fname = decl.getFilename(); - int index1 = fname.lastIndexOf('\\'); - int index2 = fname.lastIndexOf(".java"); - String introducingType = fname; - if (index1 != -1 && index2 != -1) { - introducingType = fname.substring(index1+1, index2); - } - //System.out.println( "decl: " + decl.getSignature() + ", ptb: " + decl.getFilename()); - String hrefName = ""; - if (decl.getPackageName() != null ) { - hrefName = decl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR + - introducingType; - } - else { - hrefName = introducingType; - } - String hrefLink = generateAffectsHREFLink( hrefName ); - fileContentsBuffer.insert( index, - "<BR><B><FONT COLOR=CC6699>Introduced by: </FONT></B>" + - "<A HREF=\"" + hrefLink + "\">" + - hrefName.replace('/', '.') + "</A>" ); // !!! don't replace - return; - } - Declaration[] ptb = decl.getPointedToBy(); - if ( ptb.length > 0 ) { +// if (decl.isIntroduced()) { +// // !!! HACK, THIS HAS TO BE CHANGED WITH THE SYMBOL MANAGER +// String fname = decl.getFilename(); +// int index1 = fname.lastIndexOf('\\'); +// int index2 = fname.lastIndexOf(".java"); +// String introducingType = fname; +// if (index1 != -1 && index2 != -1) { +// introducingType = fname.substring(index1+1, index2); +// } +// //System.out.println( "decl: " + decl.getSignature() + ", ptb: " + decl.getFilename()); +// String hrefName = ""; +// if (decl.getPackageName() != null ) { +// hrefName = decl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR + +// introducingType; +// } +// else { +// hrefName = introducingType; +// } +// String hrefLink = generateAffectsHREFLink( hrefName ); +// fileContentsBuffer.insert( index, +// "<BR><B><FONT COLOR=CC6699>Introduced by: </FONT></B>" + +// "<A HREF=\"" + hrefLink + "\">" + +// hrefName.replace('/', '.') + "</A>" ); // !!! don't replace +// return; +// } + + List relations = AsmManager.getDefault().getRelationshipMap().get(node); + +// Declaration[] ptb = decl.getPointedToBy(); + if (relations != null && !relations.isEmpty()) { String prevName = ""; String adviceDoc = "<BR><B><FONT COLOR=CC6699>Advised by: </FONT></B>"; - for ( int i = 0; i < ptb.length; i++ ) { - Declaration currDecl = ptb[i]; + for (Iterator it = relations.iterator(); it.hasNext(); ) { +// for ( int i = 0; i < ptb.length; i++ ) { + IRelationship curr = (IRelationship)it.next(); +// Declaration currDecl = ptb[i]; String hrefName = ""; - if (currDecl.getPackageName() != null ) { - hrefName = currDecl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR + - currDecl.getDeclaringType(); - } - else { - hrefName = currDecl.getDeclaringType(); - } - String hrefLink = generateAffectsHREFLink( hrefName ); - if (!hrefName.equals(prevName)) { // !!! eliminates dupilcates since it's ordered - //if ( currDecl.getKind().equals( "introduction" ) ) { - // fileContentsBuffer.insert( index, - // "<BR><B><FONT COLOR=CC6699>Introduced by: </FONT></B>" + - // "<A HREF=\"" + hrefLink + "\">" + - // hrefName.replace('/', '.') + "</A>" ); // !!! don't replace - // return; - //} - if ( currDecl.getKind().equals( "advice" ) ) { - if ( i > 0 ) { - adviceDoc = adviceDoc + ", "; - } - adviceDoc = adviceDoc + - "<A HREF=\"" + hrefLink + "\">" - + hrefName.replace('/', '.') + "</A>"; // !!! don't replace - } - } + +// if (currDecl.getPackageName() != null ) { +// hrefName = currDecl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR + +// currDecl.getDeclaringType(); +// } +// else { +// hrefName = currDecl.getDeclaringType(); +// } +// String hrefLink = generateAffectsHREFLink( hrefName ); +// if (!hrefName.equals(prevName)) { // !!! eliminates dupilcates since it's ordered +// if ( currDecl.getKind().equals( "advice" ) ) { +// if ( i > 0 ) { +// adviceDoc = adviceDoc + ", "; +// } +// adviceDoc = adviceDoc + +// "<A HREF=\"" + hrefLink + "\">" +// + hrefName.replace('/', '.') + "</A>"; // !!! don't replace +// } +// } prevName = hrefName; } //adviceDoc += "<BR> "; diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Phase2.java b/ajdoc/src/org/aspectj/tools/ajdoc/JavadocExecutor.java index 303b74cc4..bc59f3511 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Phase2.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/JavadocExecutor.java @@ -26,7 +26,7 @@ import java.io.StringReader; import java.util.*; -class Phase2 { +class JavadocExecutor { static void callJavadoc( String[] javadocargs ) { final SecurityManager defaultSecurityManager = System.getSecurityManager(); diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java index 558430543..34f4bb433 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java @@ -17,8 +17,7 @@ package org.aspectj.tools.ajdoc; import java.io.*; import java.util.*; -import org.aspectj.asm.AsmManager; -import org.aspectj.asm.IProgramElement; +import org.aspectj.bridge.Version; /** * This is an old implementation of ajdoc that does not use an OO style. However, it @@ -29,6 +28,8 @@ import org.aspectj.asm.IProgramElement; */ public class Main implements Config { + private static final String FAIL_MESSAGE = "> compile failed, exiting ajdoc"; + static SymbolManager symbolManager = null; /** Command line options. */ @@ -59,6 +60,8 @@ public class Main implements Config { static Hashtable declIDTable = new Hashtable(); static String docDir = "."; + private static boolean aborted = false; + public static void clearState() { symbolManager = null; options = new Vector(); @@ -76,7 +79,8 @@ public class Main implements Config { } public static void main(String[] args) { - + aborted = false; + // STEP 1: parse the command line and do other global setup sourcepath.addElement("."); // add the current directory to the classapth parseCommandLine(args); @@ -113,19 +117,11 @@ public class Main implements Config { } System.out.println( "> calling ajc..." ); - - try { - (new org.aspectj.tools.ajc.Main() { - public void exit(int status) { - if (status != 0) { - System.out.println( "> compile failed, exiting ajdoc" ); - System.exit( -1 ); - } - } - }).main(argsToCompiler); - } - catch ( SecurityException se ) { - System.exit( -1 ); + CompilerWrapper.main(argsToCompiler); + if (CompilerWrapper.hasErrors()) { + System.out.println(FAIL_MESSAGE); + aborted = true; + return; } /* for (int ii = 0; ii < inputFiles.length; ii++) { @@ -143,7 +139,7 @@ public class Main implements Config { // PHASE 1: generate Signature files (Java with DeclIDs and no bodies). System.out.println( "> building signature files..." ); - Phase1.doFiles(declIDTable, symbolManager, inputFiles, signatureFiles); + StubFileGenerator.doFiles(declIDTable, symbolManager, inputFiles, signatureFiles); // PHASE 2: let Javadoc generate HTML (with DeclIDs) System.out.println( "> calling javadoc..." ); @@ -185,7 +181,7 @@ public class Main implements Config { } } - Phase2.callJavadoc(javadocargs); + JavadocExecutor.callJavadoc(javadocargs); //for ( int o = 0; o < inputFiles.length; o++ ) { // System.out.println( "file: " + inputFiles[o] ); //} @@ -196,19 +192,19 @@ public class Main implements Config { * into multiple .html files to handle inner classes or local classes. The html * file decorator picks that up. */ -// System.out.println( "> Decorating html files..." ); -// Phase3.decorateHTMLFromInputFiles(declIDTable, -// rootDir, -// symbolManager, -// inputFiles, -// docModifier); -// removeDeclIDsFromFile("index-all.html"); -// removeDeclIDsFromFile("serialized-form.html"); -// for (int p = 0; p < packageList.size(); p++) { -// removeDeclIDsFromFile(((String)packageList.elementAt(p)).replace('.','/') + -// Config.DIR_SEP_CHAR + -// "package-summary.html" ); -// } + System.out.println( "> Decorating html files..." ); + HtmlDecorator.decorateHTMLFromInputFiles(declIDTable, + rootDir, + symbolManager, + inputFiles, + docModifier); + removeDeclIDsFromFile("index-all.html"); + removeDeclIDsFromFile("serialized-form.html"); + for (int p = 0; p < packageList.size(); p++) { + removeDeclIDsFromFile(((String)packageList.elementAt(p)).replace('.','/') + + Config.DIR_SEP_CHAR + + "package-summary.html" ); + } } catch (Throwable e) { handleInternalError(e); exit(-2); @@ -242,40 +238,6 @@ public class Main implements Config { } } - static void callAJC( String[] ajcargs ) { - final SecurityManager defaultSecurityManager = System.getSecurityManager(); - - System.setSecurityManager( new SecurityManager() { - public void checkExit(int status) { - System.setSecurityManager( defaultSecurityManager ); - //throw new SecurityException( "status code: " + status ); - //System.exit( -1 ); - } - public void checkPermission( java.security.Permission permission ) { - if ( defaultSecurityManager != null ) - defaultSecurityManager.checkPermission( permission ); - } - public void checkPermission( java.security.Permission permission, - Object context ) { - if ( defaultSecurityManager != null ) - defaultSecurityManager.checkPermission( permission, context ); - } - } ); - - try { - org.aspectj.tools.ajc.Main.main( ajcargs ); - } - catch ( SecurityException se ) { - // Do nothing since we expect it to be thrown - //System.out.println( ">> se: " + se.getMessage() ); - } catch ( IOException ioe ) { - System.out.println( ">> io error: " + ioe.getMessage() ); - } - // Set the security manager back - System.setSecurityManager( defaultSecurityManager ); - } - - /** * If the file doesn't exist on the specified path look for it in all the other * paths specified by the "sourcepath" option. @@ -516,7 +478,7 @@ public class Main implements Config { versionStandardDocletSwitch = true; } else if ( arg.equals( "-v" ) ) { - printVersion(); + System.out.println(getVersion()); exit(0); } else if ( arg.equals( "-help" ) ) { @@ -678,10 +640,13 @@ public class Main implements Config { System.err.println(); } - static void printVersion() { - System.out.println( Config.VERSION ); + static String getVersion() { + return "ajdoc version " + Version.text; } - + + public static boolean hasAborted() { + return aborted; + } } diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Phase1.java b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java index ed79ec86c..3553b8702 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Phase1.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java @@ -22,7 +22,7 @@ import java.util.List; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IProgramElement; -class Phase1 { +class StubFileGenerator { static Hashtable declIDTable = null; @@ -51,7 +51,9 @@ class Phase1 { IProgramElement fileNode = (IProgramElement)AsmManager.getDefault().getHierarchy().findElementForSourceFile(inputFile.getAbsolutePath()); for (Iterator it = fileNode.getChildren().iterator(); it.hasNext(); ) { IProgramElement node = (IProgramElement)it.next(); - if (!node.getKind().equals(IProgramElement.Kind.IMPORT_REFERENCE)) { + if (node.getKind().equals(IProgramElement.Kind.IMPORT_REFERENCE)) { + processImportDeclaration(node, writer); + } else { processTypeDeclaration(node, writer); } } @@ -64,21 +66,16 @@ class Phase1 { } } -// static void processClassDeclarations(IProgramElement fileNode, -// PrintWriter writer, -// boolean declaringDeclIsInterface) throws IOException { -// for (Iterator it = fileNode.getChildren().iterator(); it.hasNext(); ) { -// IProgramElement node = (IProgramElement)it.next(); -// proc -// } -// for (int i = 0; i < decls.length; i++) { -// Declaration decl = decls[i]; -// -// //System.out.println( ">> sig: " + decl.getSignature() ); -// doDecl(decl, writer, declaringDeclIsInterface); -// } -// } - + private static void processImportDeclaration(IProgramElement node, PrintWriter writer) throws IOException { + List imports = node.getChildren(); + for (Iterator i = imports.iterator(); i.hasNext();) { + IProgramElement importNode = (IProgramElement) i.next(); + writer.print("import "); + writer.print(importNode.getName()); + writer.println(';'); + } + } + private static void processTypeDeclaration(IProgramElement classNode, PrintWriter writer) throws IOException { // String formalComment = classNode.getFormalComment(); @@ -89,7 +86,7 @@ class Phase1 { String formalComment = addDeclID(classNode, classNode.getFormalComment()); writer.println(formalComment); - String signature = StructureUtil.genSignature(classNode); + String signature = classNode.getSourceSignature();// StructureUtil.genSignature(classNode); writer.println(signature + " {" ); processMembers(classNode.getChildren(), writer, classNode.getKind().equals(IProgramElement.Kind.INTERFACE)); writer.println(); @@ -103,10 +100,9 @@ class Phase1 { if (member.getKind().isTypeKind()) { processTypeDeclaration(member, writer); } else { - - String formalComment = addDeclID(member, member.getFormalComment()); + String formalComment = addDeclID(member, member.getFormalComment());; writer.println(formalComment); - String signature = StructureUtil.genSignature(member); + String signature = member.getSourceSignature();//StructureUtil.genSignature(member); writer.print(signature); if (member.getKind().equals(IProgramElement.Kind.METHOD)) { @@ -118,6 +114,22 @@ class Phase1 { } } } + +// static void processClassDeclarations(IProgramElement fileNode, +// PrintWriter writer, +// boolean declaringDeclIsInterface) throws IOException { +//for (Iterator it = fileNode.getChildren().iterator(); it.hasNext(); ) { +//IProgramElement node = (IProgramElement)it.next(); +//proc +//} +//for (int i = 0; i < decls.length; i++) { +//Declaration decl = decls[i]; +// +////System.out.println( ">> sig: " + decl.getSignature() ); +//doDecl(decl, writer, declaringDeclIsInterface); +//} +//} + // // if (decl.hasSignature()) { diff --git a/ajdoc/testdata/failing-build/Fail.java b/ajdoc/testdata/failing-build/Fail.java new file mode 100644 index 000000000..63cba6e98 --- /dev/null +++ b/ajdoc/testdata/failing-build/Fail.java @@ -0,0 +1,5 @@ + +class Mumble { + + this fails +}
\ No newline at end of file diff --git a/ajdoc/testdata/simple/foo/ClassA.java b/ajdoc/testdata/simple/foo/ClassA.java index 458c76397..76bc4588e 100644 --- a/ajdoc/testdata/simple/foo/ClassA.java +++ b/ajdoc/testdata/simple/foo/ClassA.java @@ -1,14 +1,29 @@ package foo; -public class ClassA { +import java.io.IOException; + +/** + * Test class. This is a comment. + */ +public abstract class ClassA implements InterfaceI { public int pubfield; private int privfield; - void method1(int arg1) { + /** + * Mumbo. Jumbo. + * + * @param arg1 integer parameter + */ + void method1(int arg1) throws IOException { pubfield = arg1; } - + + public void foo() { } } -
\ No newline at end of file + +class SubClass extends ClassA { + + public void foo() { } +}
\ No newline at end of file diff --git a/ajdoc/testdata/simple/foo/InterfaceI.java b/ajdoc/testdata/simple/foo/InterfaceI.java new file mode 100644 index 000000000..55b018146 --- /dev/null +++ b/ajdoc/testdata/simple/foo/InterfaceI.java @@ -0,0 +1,6 @@ + +package foo; + +public interface InterfaceI { + void foo(); +}
\ No newline at end of file diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocModuleTests.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocModuleTests.java new file mode 100644 index 000000000..f1df75767 --- /dev/null +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocModuleTests.java @@ -0,0 +1,29 @@ +/* ******************************************************************* + * Copyright (c) 2003 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: + * Mik Kersten initial implementation + * ******************************************************************/ + package org.aspectj.tools.ajdoc; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author Mik Kersten + */ +public class AjdocModuleTests { + public static Test suite() { + TestSuite suite = new TestSuite("Test for org.aspectj.tools.ajdoc"); + //$JUnit-BEGIN$ + suite.addTestSuite(MainTestCase.class); + suite.addTestSuite(ExecutionTestCase.class); + //$JUnit-END$ + return suite; + } +} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java new file mode 100644 index 000000000..14ee913bf --- /dev/null +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java @@ -0,0 +1,50 @@ +/* ******************************************************************* + * Copyright (c) 2003 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: + * Mik Kersten initial implementation + * ******************************************************************/ + +package org.aspectj.tools.ajdoc; + +import java.io.File; +import java.io.PrintStream; +import java.io.PrintWriter; + +import junit.framework.TestCase; + +import org.aspectj.bridge.Version; +import org.aspectj.util.StreamPrintWriter; + +/** + * @author Mik Kersten + */ +public class ExecutionTestCase extends TestCase { + + public void testVersionMatch() { + String ajdocVersion = Main.getVersion(); + String compilerVersion = Version.text; + assertTrue("version check", ajdocVersion.endsWith(compilerVersion)); + } + + public void testFailingBuild() { + File file1 = new File("testdata/failing-build/Fail.java"); + String[] args = { file1.getAbsolutePath() }; + + org.aspectj.tools.ajdoc.Main.main(args); + assertTrue(Main.hasAborted()); + } + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } +} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/MainTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/MainTestCase.java index 6404ae25b..0863a04b0 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/MainTest.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/MainTestCase.java @@ -18,24 +18,21 @@ import junit.framework.TestCase; /** * @author Mik Kersten */ -public class MainTest extends TestCase { +public class MainTestCase extends TestCase { - - public void testRun() { + public void testSimpleExample() { // System.err.println(new File("testdata/figures-demo").exists()); - File sourcepath = new File("testdata/simple/foo/ClassA.java"); + File file1 = new File("testdata/simple/foo/ClassA.java"); + File file2 = new File("testdata/simple/foo/InterfaceI.java"); File outdir = new File("testdata/simple/doc"); - String[] args = { "-d", outdir.getAbsolutePath(), sourcepath.getAbsolutePath() }; - -// String[] args = { "-sourcepath", sourcepath.getAbsolutePath(), "figures" }; + String[] args = { "-d", outdir.getAbsolutePath(), file1.getAbsolutePath(), file2.getAbsolutePath() }; org.aspectj.tools.ajdoc.Main.main(args); assertTrue(true); } - protected void setUp() throws Exception { super.setUp(); } |