package org.aspectj.tools.ajdoc;
-import java.io.*;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IProgramElement;
*/
class HtmlDecorator {
- static List visibleFileList = new ArrayList();
+ private static final String POINTCUT_DETAIL = "Pointcut Detail";
+ private static final String ADVICE_DETAIL = "Advice Detail";
+ private static final String DECLARE_DETAIL = "Declare Detail";
+ private static final String ADVICE_SUMMARY = "Advice Summary";
+ private static final String POINTCUT_SUMMARY = "Pointcut Summary";
+ private static final String DECLARE_SUMMARY = "Declare Summary";
+ static List visibleFileList = new ArrayList();
static Hashtable declIDTable = null;
static SymbolManager symbolManager = null;
static File rootDir = null;
// Change "Class" to "Aspect"
// HACK: depends on matching presence of advice or pointcut summary
int classStartIndex = fileContents.toString().indexOf("<BR>\nClass ");
- int pointcutSummaryIndex = fileContents.toString().indexOf("Pointcut Summary");
- int adviceSummaryIndex = fileContents.toString().indexOf("Advice Summary");
+ int pointcutSummaryIndex = fileContents.toString().indexOf(POINTCUT_SUMMARY);
+ int adviceSummaryIndex = fileContents.toString().indexOf(ADVICE_SUMMARY);
if (classStartIndex != -1 &&
(adviceSummaryIndex != -1 || pointcutSummaryIndex != -1)) {
int classEndIndex = fileContents.toString().indexOf("</H2>", classStartIndex);
static void addAspectDocumentation(IProgramElement node, StringBuffer fileBuffer, int index ) {
List pointcuts = new ArrayList();
List advice = new ArrayList();
+ List declares = new ArrayList();
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
IProgramElement member = (IProgramElement)it.next();
if (member.getKind().equals(IProgramElement.Kind.POINTCUT)) {
pointcuts.add(member);
} else if (member.getKind().equals(IProgramElement.Kind.ADVICE)) {
advice.add(member);
+ } else if (member.getKind().isDeclare() || member.getKind().isInterTypeMember()) {
+ declares.add(member);
}
}
+ if (declares.size() > 0) {
+ insertDeclarationsDetails(fileBuffer, declares, DECLARE_DETAIL, index);
+ insertDeclarationsSummary(fileBuffer, declares, DECLARE_SUMMARY, index);
+ }
if (pointcuts.size() > 0) {
- insertDeclarationsSummary(fileBuffer, pointcuts, "Pointcut Summary", index);
- insertDeclarationsDetails(fileBuffer, pointcuts, "Pointcut Detail", index);
+ insertDeclarationsSummary(fileBuffer, pointcuts, POINTCUT_SUMMARY, index);
+ insertDeclarationsDetails(fileBuffer, pointcuts, POINTCUT_DETAIL, index);
}
if (advice.size() > 0) {
- insertDeclarationsSummary(fileBuffer, advice, "Advice Summary", index);
- insertDeclarationsDetails(fileBuffer, advice, "Advice Detail", index);
+ insertDeclarationsSummary(fileBuffer, advice, ADVICE_SUMMARY, index);
+ insertDeclarationsDetails(fileBuffer, advice, ADVICE_DETAIL, index);
}
}
// insert the table row accordingly
String comment = generateSummaryComment(decl);
String entry = "";
- if ( kind.equals( "Advice Summary" ) ) {
+ if ( kind.equals( ADVICE_SUMMARY ) ) {
entry +=
"<TR><TD>" +
"<A HREF=\"#" + generateHREFName(decl) + "\">" +
generateAffects(decl, false) + "</TD>" +
"</TR><TD>\n";
}
- else if ( kind.equals( "Pointcut Summary" ) ) {
+ else if ( kind.equals( POINTCUT_SUMMARY ) ) {
entry +=
"<TR><TD WIDTH=\"1%\">" +
"<FONT SIZE=-1><TT>" + genAccessibility(decl) + "</TT></FONT>" +
entry +=
"</TR></TD>\n";
}
- else if ( kind.equals( "Introduction Summary" ) ) {
+ else if ( kind.equals( DECLARE_SUMMARY ) ) {
entry +=
"<TR><TD WIDTH=\"1%\">" +
"<FONT SIZE=-1><TT>" + decl.getModifiers() + "</TT></FONT>" +
"</TD>" +
"<TD>" +
"<A HREF=\"#" + generateHREFName(decl) + "\">" +
- "<TT>introduction " + decl.toLabelString() + "</TT></A><P>" +
- generateIntroductionSignatures(decl, false) +
+ "<TT>" + decl.toLabelString() + "</TT></A><P>" +
+ generateIntroductionSignatures(decl, true) +
generateAffects(decl, true);
}
// insert the table row accordingly
entry += "<A NAME=\"" + generateHREFName(decl) + "\"><!-- --></A>\n";
- if ( kind.equals( "Advice Detail" ) ) {
+ if ( kind.equals( ADVICE_DETAIL ) ) {
entry += "<H3>" + decl.getName() + "</H3><P>";
entry +=
"<TT>" +
generateDetailsComment(decl) + "<P>" +
generateAffects(decl, false);
}
- else if (kind.equals("Pointcut Detail")) {
+ else if (kind.equals(POINTCUT_DETAIL)) {
entry +=
"<H3>" +
decl.toLabelString() +
"</H3><P>" +
generateDetailsComment(decl);
}
- else if (kind.equals("Introduction Detail")) {
- entry += "<H3>introduction " + decl.toLabelString() + "</H3><P>";
+ else if (kind.equals(DECLARE_DETAIL)) {
+ entry += "<H3>declare " + decl.toLabelString() + "</H3><P>";
entry +=
generateIntroductionSignatures(decl, true) +
generateAffects(decl, true) +
StringBuffer fileContentsBuffer,
int index ) {
List targets = StructureUtil.getTargets(node, IRelationship.Kind.ADVICE);
- if (targets != null && !targets.isEmpty()) {
- String prevName = "";
-
+ if (targets != null && !targets.isEmpty()) {
String adviceDoc
= "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>" +
"<TD width=\"15%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000> Advised by:</font></b></td><td>";
* TODO: probably want to make this the same for intros and advice.
*/
static String generateAffects(IProgramElement decl, boolean isIntroduction) {
-
- List targets = StructureUtil.getTargets(decl, IRelationship.Kind.ADVICE);
- if (targets == null) return null;
- List packageList = new ArrayList();
- String entry
- = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>" +
- "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000> Advises:</b></font></td><td>";
-
+ List targets = null;
+ if (isIntroduction) {
+ targets = StructureUtil.getDeclareTargets(decl);
+ } else {
+ targets = StructureUtil.getTargets(decl, IRelationship.Kind.ADVICE);
+ }
+ if (targets == null) return "";
+ String entry = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>";
+ if (!isIntroduction) {
+ entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000> Advises:</b></font></td><td>";
+ } else {
+ entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000> Affects:</b></font></td><td>";
+ }
+
String relativePackagePath =
getRelativePathFromHere(
decl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR);
}
static String generateHREFName(IProgramElement decl) {
- String hrefLink = decl.toLabelString(); // !!!
+ String hrefLink = decl.toLabelString().replace("\"", "quot;"); // !!!
return hrefLink;
}
*/
public class CoverageTestCase extends TestCase {
- protected File file0 = new File("testdata/coverage/InDefaultPackage.java");
- protected File file1 = new File("testdata/coverage/foo/ClassA.java");
- protected File aspect1 = new File("testdata/coverage/foo/UseThisAspectForLinkCheck.aj");
- protected File file2 = new File("testdata/coverage/foo/InterfaceI.java");
- protected File file3 = new File("testdata/coverage/foo/PlainJava.java");
- protected File file4 = new File("testdata/coverage/foo/ModelCoverage.java");
- protected File file5 = new File("testdata/coverage/fluffy/Fluffy.java");
- protected File file6 = new File("testdata/coverage/fluffy/bunny/Bunny.java");
- protected File file7 = new File("testdata/coverage/fluffy/bunny/rocks/Rocks.java");
- protected File file8 = new File("testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java");
- protected File file9 = new File("testdata/coverage/foo/PkgVisibleClass.java");
- protected File file10 = new File("testdata/coverage/foo/NoMembers.java");
+ protected File file0 = new File("../ajdoc/testdata/coverage/InDefaultPackage.java");
+ protected File file1 = new File("../ajdoc/testdata/coverage/foo/ClassA.java");
+ protected File aspect1 = new File("../ajdoc/testdata/coverage/foo/UseThisAspectForLinkCheck.aj");
+ protected File file2 = new File("../ajdoc/testdata/coverage/foo/InterfaceI.java");
+ protected File file3 = new File("../ajdoc/testdata/coverage/foo/PlainJava.java");
+ protected File file4 = new File("../ajdoc/testdata/coverage/foo/ModelCoverage.java");
+ protected File file5 = new File("../ajdoc/testdata/coverage/fluffy/Fluffy.java");
+ protected File file6 = new File("../ajdoc/testdata/coverage/fluffy/bunny/Bunny.java");
+ protected File file7 = new File("../ajdoc/testdata/coverage/fluffy/bunny/rocks/Rocks.java");
+ protected File file8 = new File("../ajdoc/testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java");
+ protected File file9 = new File("../ajdoc/testdata/coverage/foo/PkgVisibleClass.java");
+ protected File file10 = new File("../ajdoc/testdata/coverage/foo/NoMembers.java");
protected File outdir = new File("testdata/coverage/doc");