aboutsummaryrefslogtreecommitdiffstats
path: root/ajdoc/src
diff options
context:
space:
mode:
authormkersten <mkersten>2004-03-23 09:45:08 +0000
committermkersten <mkersten>2004-03-23 09:45:08 +0000
commitaa335f2a1986353cb757dbbcb6255bab448dc99f (patch)
tree74b0d8f08dace6d07406d737b9a27bfcb728d802 /ajdoc/src
parentc3f286ab51c94779820dcb529609142a846570be (diff)
downloadaspectj-aa335f2a1986353cb757dbbcb6255bab448dc99f.tar.gz
aspectj-aa335f2a1986353cb757dbbcb6255bab448dc99f.zip
Working ajdoc to that generates advice links, with tests
for generating spacewar documentation.
Diffstat (limited to 'ajdoc/src')
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java9
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java447
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/JavadocExecutor.java3
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/Main.java1
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/SourceLine.java54
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java19
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java154
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java120
8 files changed, 260 insertions, 547 deletions
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java b/ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java
index a68ad3be7..54f622654 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java
@@ -25,6 +25,11 @@ import java.util.*;
// This lets us generate serialized files which interoperate with other code better
import java.util.Vector;
+import org.aspectj.asm.IProgramElement;
+
+/**
+ * @author Mik Kersten
+ */
public class Declaration implements Serializable {
private int beginLine;
private int endLine;
@@ -246,7 +251,7 @@ public class Declaration implements Serializable {
public boolean isType() {
- return getKind().equals("interface") || getKind().equals("class");
+ return getKind().equals("interface") || getKind().equals("class") || getKind().equals("aspect");
}
public boolean hasBody() {
@@ -254,7 +259,7 @@ public class Declaration implements Serializable {
return kind.equals("class") || kind.endsWith("constructor") ||
(kind.endsWith("method") && getModifiers().indexOf("abstract") == -1 &&
getModifiers().indexOf("native") == -1);
- }
+ }
public boolean isIntroduced() {
return kind.startsWith("introduced-");
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
index 7bfa544d9..26eb12728 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
@@ -21,6 +21,9 @@ import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.IRelationship;
+/**
+ * @author Mik Kersten
+ */
class HtmlDecorator {
static List visibleFileList = new ArrayList();
@@ -37,6 +40,7 @@ class HtmlDecorator {
declIDTable = table;
symbolManager = sm;
for (int i = 0; i < inputFiles.length; i++) {
+
decorateHTMLFromDecls(symbolManager.getDeclarations(inputFiles[i].getCanonicalPath()),
rootDir.getCanonicalPath() + Config.DIR_SEP_CHAR,
docModifier,
@@ -75,10 +79,9 @@ class HtmlDecorator {
(docModifier.equals( "protected" ) && (decl.getModifiers().indexOf( "protected" ) != -1 ||
decl.getModifiers().indexOf( "public" ) != -1 )) ||
(docModifier.equals( "public" ) && decl.getModifiers().indexOf( "public" ) != -1) ) {
- visibleFileList.add( getName( decl ) );
+ visibleFileList.add(decl.getSignature());
String packageName = decl.getPackageName();
String filename = "";
- //System.out.println(">>>" + decl.getDeclaringType() + ", " + base);
if ( packageName != null ) {
int index1 = base.lastIndexOf(Config.DIR_SEP_CHAR);
int index2 = base.lastIndexOf(".");
@@ -95,27 +98,26 @@ class HtmlDecorator {
}
filename = newBase + Config.DIR_SEP_CHAR + packageName +
Config.DIR_SEP_CHAR + currFileClass + //"." +
- getName(decl) + ".html";
+ decl.getSignature() + ".html";
nestedClass = true;
- }
- else {
+ } else {
packageName = packageName.replace( '.','/' ); // !!!
- filename = base + packageName + Config.DIR_SEP_CHAR + getName(decl) + ".html";
+ filename = base + packageName + Config.DIR_SEP_CHAR + decl.getSignature() + ".html";
}
}
else {
- filename = base + getName(decl) + ".html";
+ filename = base + decl.getSignature() + ".html";
}
if (!exceededNestingLevel) {
decorateHTMLFile(new File(filename));
decorateHTMLFromDecls(decl.getDeclarations(),
- base + getName(decl) + ".",
+ base + decl.getSignature() + ".",
docModifier,
nestedClass);
}
else {
System.out.println("Warning: can not generate documentation for nested " +
- "inner class: " + getName(decl) );
+ "inner class: " + decl.getSignature() );
}
}
}
@@ -156,7 +158,7 @@ class HtmlDecorator {
if ( decl == null ) break;
fileContents.delete(start, end + Config.DECL_ID_TERMINATOR.length());
- if ( decl.getKind().isTypeKind() ) {
+ if ( decl.getKind().isType() ) {
isSecond = true;
// addIntroductionDocumentation(decl, fileContents, index);
// addAdviceDocumentation(decl, fileContents, index);
@@ -168,15 +170,16 @@ class HtmlDecorator {
else {
decorateMemberDocumentation(decl, fileContents, index);
}
- }
-
+ }
+
// Change "Class" to "Aspect", HACK: depends on "affects:"
- if (fileContents.toString().indexOf("affects: ") != -1) {
- int classStartIndex = fileContents.toString().indexOf("<BR>\nClass ");
+ int classStartIndex = fileContents.toString().indexOf("<BR>\nClass");
+ if (classStartIndex != -1 &&
+ fileContents.toString().indexOf("Advises:") != -1) {
int classEndIndex = fileContents.toString().indexOf("</H2>", classStartIndex);
- if (classStartIndex != -1 && classEndIndex != -1) {
+ if (classStartIndex != -1 && classEndIndex != -1) {
String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
- String aspectLine = "<BR>\n" + "Aspect" + classLine.substring(11, classLine.length());
+ String aspectLine = "<BR>\n" + "Aspect " + classLine.substring(11, classLine.length());
fileContents.delete(classStartIndex, classEndIndex);
fileContents.insert(classStartIndex, aspectLine);
}
@@ -188,33 +191,30 @@ class HtmlDecorator {
}
static void addAspectDocumentation(IProgramElement node, StringBuffer fileBuffer, int index ) {
- List relations = AsmManager.getDefault().getRelationshipMap().get(node);
- System.err.println("> relations: " + relations);
+// List relations = AsmManager.getDefault().getRelationshipMap().get(node);
+// System.err.println("> node: " + node + ", " + "relations: " + relations);
-// if ( crosscuts.length > 0 ) {
-// insertDeclarationsSummary(fileBuffer, crosscuts, "Pointcut Summary", index);
-// insertDeclarationsDetails(fileBuffer, crosscuts, "Pointcut Detail", index);
-// }
+
+ List pointcuts = new ArrayList();
+ List advice = 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);
+ }
+ }
+ if (pointcuts.size() > 0) {
+ 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);
+ }
}
-
-// 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 ) {
@@ -232,7 +232,7 @@ class HtmlDecorator {
// }
static void insertDeclarationsSummary(StringBuffer fileBuffer,
- Declaration[] decls,
+ List decls,
String kind,
int index) {
int insertIndex = findSummaryIndex(fileBuffer, index);
@@ -247,8 +247,8 @@ class HtmlDecorator {
insertIndex += tableHead.length();
// insert the body of the table
- for ( int i = 0; i < decls.length; i++ ) {
- Declaration decl = decls[i];
+ for ( int i = 0; i < decls.size(); i++ ) {
+ IProgramElement decl = (IProgramElement)decls.get(i);
// insert the table row accordingly
String comment = generateSummaryComment(decl);
@@ -257,8 +257,8 @@ class HtmlDecorator {
entry +=
"<TR><TD>" +
"<A HREF=\"#" + generateHREFName(decl) + "\">" +
- "<TT>advice " + decl.getCrosscutDesignator() + "</TT></A><BR><TT>" +
- generateAdviceSignatures(decl) + "</TT><BR>&nbsp;";
+ "<TT>" + generateAdviceSignatures(decl) +
+ "</TT></A><BR>&nbsp;";
if (!comment.equals("")) {
entry += comment + "<P>";
}
@@ -269,11 +269,11 @@ class HtmlDecorator {
else if ( kind.equals( "Pointcut Summary" ) ) {
entry +=
"<TR><TD WIDTH=\"1%\">" +
- "<FONT SIZE=-1><TT>" + decl.getModifiers() + "</TT></FONT>" +
+ "<FONT SIZE=-1><TT>" + genAccessibility(decl) + "</TT></FONT>" +
"</TD>\n" +
"<TD>" +
"<TT><A HREF=\"#" + generateHREFName(decl) + "\">" +
- decl.getSignature() + "</A></TT><BR>&nbsp;";
+ decl.toLabelString() + "</A></TT><BR>&nbsp;";
if (!comment.equals("")) {
entry += comment + "<P>";
}
@@ -287,7 +287,7 @@ class HtmlDecorator {
"</TD>" +
"<TD>" +
"<A HREF=\"#" + generateHREFName(decl) + "\">" +
- "<TT>introduction " + decl.getCrosscutDesignator() + "</TT></A><P>" +
+ "<TT>introduction " + decl.toLabelString() + "</TT></A><P>" +
generateIntroductionSignatures(decl, false) +
generateAffects(decl, true);
}
@@ -303,8 +303,16 @@ class HtmlDecorator {
insertIndex += tableTail.length();
}
- static void insertDeclarationsDetails(StringBuffer fileBuffer,
- Declaration[] decls,
+ private static String genAccessibility(IProgramElement decl) {
+ if (decl.getAccessibility().equals(IProgramElement.Accessibility.PACKAGE)) {
+ return "(package private)";
+ } else {
+ return decl.getAccessibility().toString();
+ }
+ }
+
+ static void insertDeclarationsDetails(StringBuffer fileBuffer,
+ List decls,
String kind,
int index) {
int insertIndex = findDetailsIndex(fileBuffer, index);
@@ -323,22 +331,14 @@ class HtmlDecorator {
insertIndex += detailsHeading.length();
// insert the details
- for ( int i = 0; i < decls.length; i++ ) {
- Declaration decl = decls[i];
+ for ( int i = 0; i < decls.size(); i++ ) {
+ IProgramElement decl = (IProgramElement)decls.get(i);
String entry = "";
// insert the table row accordingly
entry += "<A NAME=\"" + generateHREFName(decl) + "\"><!-- --></A>\n";
if ( kind.equals( "Advice Detail" ) ) {
- String designatorHREFLink = generateDesignatorHREFLink(decl);
- if (designatorHREFLink != null) {
- entry +=
- "<H3>advice " + designatorHREFLink + "</H3><P>";
- }
- else {
- entry +=
- "<H3>advice " + decl.getCrosscutDesignator() + "</H3><P>";
- }
+ entry += "<H3>" + decl.getName() + "</H3><P>";
entry +=
"<TT>" +
generateAdviceSignatures(decl) + "</TT>\n" + "<P>" +
@@ -348,20 +348,12 @@ class HtmlDecorator {
else if (kind.equals("Pointcut Detail")) {
entry +=
"<H3>" +
- decl.getSignature() +
+ decl.toLabelString() +
"</H3><P>" +
generateDetailsComment(decl);
}
else if (kind.equals("Introduction Detail")) {
- //String designatorHREFLink = generateDesignatorHREFLink(decl);
- //if (designatorHREFLink != null) {
- // entry +=
- // "<H3>introduction " + designatorHREFLink + "</H3><P>";
- //}
- //else {
- entry +=
- "<H3>introduction " + decl.getCrosscutDesignator() + "</H3><P>";
- //}
+ entry += "<H3>introduction " + decl.toLabelString() + "</H3><P>";
entry +=
generateIntroductionSignatures(decl, true) +
generateAffects(decl, true) +
@@ -369,7 +361,7 @@ class HtmlDecorator {
}
// insert the entry
- if (i != decls.length-1) {
+ if (i != decls.size()-1) {
entry += "<P><HR>\n";
}
else {
@@ -419,180 +411,122 @@ class HtmlDecorator {
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;
-// }
-
- List relations = AsmManager.getDefault().getRelationshipMap().get(node);
-
-// Declaration[] ptb = decl.getPointedToBy();
- if (relations != null && !relations.isEmpty()) {
+ List targets = StructureUtil.getTargets(node, IRelationship.Kind.ADVICE);
+ if (targets != null && !targets.isEmpty()) {
String prevName = "";
- String adviceDoc = "<BR><B><FONT COLOR=CC6699>Advised by: </FONT></B>";
- 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 = "";
+
+ String adviceDoc
+ = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>" +
+ "<TD width=\"15%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>&nbsp;Advised by:</font></b></td><td>";
+
+ for (Iterator it = targets.iterator(); it.hasNext(); ) {
+ String currHandle = (String)it.next();
+ IProgramElement currDecl = AsmManager.getDefault().getHierarchy().findElementForHandle(currHandle);
+
+ String hrefName = "";
+ String hrefLink = "";
+ if (currDecl.getPackageName() != null ) {
+ hrefName = currDecl.getPackageName().replace('.', '/');
+ hrefLink = "";//+ currDecl.getPackageName() + Config.DIR_SEP_CHAR;
+ }
+ hrefName += Config.DIR_SEP_CHAR +
+ currDecl.getParent().toLinkLabelString()
+ + "." + currDecl.getName();
+
+ hrefLink += currDecl.getParent().toLinkLabelString() + ".html"
+ + "#" + currDecl.toLabelString();
+
+ adviceDoc = adviceDoc +
+ "<A HREF=\"" + hrefLink + "\"><tt>"
+ + hrefName.replace('/', '.') + "</tt></A>";
-// 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;
+ if (it.hasNext()) adviceDoc += ", ";
}
- //adviceDoc += "<BR>&nbsp;";
+ adviceDoc += "</TR></TD></TABLE>\n";
fileContentsBuffer.insert( index, adviceDoc );
- //return lineHead + adviceDoc + lineTail;
- }
- else {
- ;// nop return lineHead + lineTail;
}
}
/**
* TODO: probably want to make this the same for intros and advice.
*/
- static String generateAffects( Declaration decl, boolean isIntroduction) {
- Declaration[] decls = null;
- if ( isIntroduction ) {
- decls = decl.getTargets(); // !!!
- }
- else {
- decls = decl.getPointsTo();
- }
- List addedDecls = new ArrayList();
- List packageList = new ArrayList();
- for ( int i = 0; i < decls.length; i++ ) {
- Declaration currDecl = decls[i];
- //if ( currDecl.getDeclaringType().equals( "not$found" ) ) {
- // System.out.println( "!!!!!! " + currDecl.getSignature() );
- //}
- if ( currDecl != null ) {
- String extendedName = "";
- String packageName = currDecl.getPackageName();
-
- // !!! HACK FOR INNER CLASSES, ONLY WORKS FOR 1 LEVEL OF NESTING !!!
- String declaringType = currDecl.getDeclaringType();
- if (packageName != null && !packageName.equals("")) {
- if (currDecl.isType() && declaringType != null && !declaringType.equals("not$found")) {
- extendedName = packageName.replace('.', '/') + Config.DIR_SEP_CHAR + declaringType + ".";
- }
- else {
- extendedName = packageName.replace('.', '/') + Config.DIR_SEP_CHAR;
- }
- }
-
- //System.out.println("extendedName: " + extendedName);
- if ( isIntroduction ) {
- if ( !addedDecls.contains(currDecl.getSignature() ) ) {
- //addedDecls.add(currDecl.getPackageName() + "." + currDecl.getSignature());
- addedDecls.add(extendedName + currDecl.getSignature());
- }
- }
- else if ( !addedDecls.contains(currDecl.getDeclaringType() ) ) {
- //addedDecls.add(currDecl.getPackageName() + "." + currDecl.getDeclaringType());
- addedDecls.add(extendedName + currDecl.getDeclaringType());
- }
- }
- }
- Collections.sort(addedDecls,
- new Comparator() {
- public int compare(Object o1, Object o2) {
- String s1 = (String)o1;
- String s2 = (String)o2;
- return s1.compareTo(s2);
- }
- }
- );
+ 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=\"20\">&nbsp;</TD>" +
- "<TD><FONT SIZE=-1>affects: ";
- String prevType = "";
- for ( int j = 0; j < addedDecls.size(); j++ ) {
- String currType = (String)addedDecls.get(j);
- // don't add duplicates
- if ( !currType.equals( prevType ) && currType.indexOf("not$found") == -1 ) { //!!!
- if ( j > 0 ) {
- entry += ", ";
- }
- if ( generateAffectsHREFLink(currType) != "" ) {
- entry += "<A HREF=\"" + generateAffectsHREFLink(currType) +
- "\">" + currType.replace('/', '.') + "</A>"; // !!! don't replace
- }
- else {
- entry += currType;
- }
+ = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>" +
+ "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>&nbsp;Advises:</b></font></td><td>";
+
+ for (Iterator it = targets.iterator(); it.hasNext(); ) {
+ String currHandle = (String)it.next();
+ IProgramElement currDecl = AsmManager.getDefault().getHierarchy().findElementForHandle(currHandle);
+ if (currDecl.getKind().equals(IProgramElement.Kind.CODE)) {
+ currDecl = currDecl.getParent(); // promote to enclosing
+ }
+ if (currDecl != null) {
+ String packagePath = "";
+ if (currDecl.getPackageName() != null && !currDecl.getPackageName().equals("")) {
+ packagePath = currDecl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR;
+ }
+ String linkRef = "";
+ String linkName = rootDir.getAbsolutePath() + "/";
+ if (currDecl.getKind().isType()) {
+ linkName = packagePath + currDecl.getName();
+ linkRef = currDecl.toLabelString() + ".html";
+ } else {
+
+ linkName = packagePath + currDecl.getParent().getName() + "." + currDecl.getName();
+ linkRef = currDecl.getParent().getName() + ".html" + "#" + currDecl.toLabelString();
+//
+ // XXX: only one level of nested classes
+ if (currDecl.getParent().getParent().getKind().isType()) {
+ linkRef = currDecl.getParent().getParent().getName() + "." + linkRef;
+ }
+ }
+ entry += "<A HREF=\"" + linkRef +
+ "\"><tt>" + linkName.replace('/', '.') + "</tt></A>"; // !!! don't replace
+ if (it.hasNext()) entry += ", ";
+// if ( isIntroduction ) {
+// if ( !addedDecls.contains(currDecl.getSourceSignature() ) ) {
+// //addedDecls.add(currDecl.getPackageName() + "." + currDecl.getSignature());
+// addedDecls.add(packageName + currDecl.getSourceSignature());
+// }
+// }
}
- prevType = currType;
}
- entry += "</FONT></TD></TR></TABLE>\n</TR></TD>\n";
+ entry += "</B></FONT></TD></TR></TABLE>\n</TR></TD>\n";
return entry;
}
- static String generateIntroductionSignatures(Declaration decl, boolean isDetails) {
- Declaration[] decls = decl.getDeclarations();
- String entry = "";
- for ( int j = 0; j < decls.length; j++ ) {
- Declaration currDecl = decls[j];
- if ( currDecl != null ) {
- entry +=
- "<TT><B>" +
- currDecl.getSignature() +
- "</B></TT><BR>";
- }
- if (isDetails) {
- entry += generateDetailsComment(currDecl) + "<P>";
- }
- else {
- entry += generateSummaryComment(currDecl) + "<P>";
- }
- }
- return entry;
+ static String generateIntroductionSignatures(IProgramElement decl, boolean isDetails) {
+ return "<not implemented>";
+ // Declaration[] decls = decl.getDeclarations();
+// String entry = "";
+// for ( int j = 0; j < decls.length; j++ ) {
+// Declaration currDecl = decls[j];
+// if ( currDecl != null ) {
+// entry +=
+// "<TT><B>" +
+// currDecl.getSignature() +
+// "</B></TT><BR>";
+// }
+// if (isDetails) {
+// entry += generateDetailsComment(currDecl) + "<P>";
+// }
+// else {
+// entry += generateSummaryComment(currDecl) + "<P>";
+// }
+// }
+// return entry;
}
- static String generateAdviceSignatures( Declaration decl ) {
- return "<B>" + decl.getSignature() + "</B>";
+ static String generateAdviceSignatures(IProgramElement decl ) {
+ return "<B>" + decl.toLabelString() + "</B>";
}
- static String generateSummaryComment(Declaration decl) {
+ static String generateSummaryComment(IProgramElement decl) {
String COMMENT_INDENT = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; // !!!
String formattedComment = getFormattedComment(decl);
int periodIndex = formattedComment.indexOf( '.' );
@@ -607,12 +541,12 @@ class HtmlDecorator {
}
}
- static String generateDetailsComment(Declaration decl) {
+ static String generateDetailsComment(IProgramElement decl) {
return getFormattedComment(decl);
}
- static String generateHREFName(Declaration decl) {
- String hrefLink = decl.getSignature(); // !!!
+ static String generateHREFName(IProgramElement decl) {
+ String hrefLink = decl.toLabelString(); // !!!
return hrefLink;
}
@@ -621,12 +555,11 @@ class HtmlDecorator {
* Figure out the link relative to the package.
*/
static String generateAffectsHREFLink(String declaringType) {
- //String offset = rootDir.getAbsolutePath() + "/" + declaringType.replace('.', '/') + ".html";
String link = rootDir.getAbsolutePath() + "/" + declaringType + ".html";
- //System.out.println(">>" + link);
return link;
}
+
/**
* This formats a comment according to the rules in the Java Langauge Spec:
* <I>The text of a docuemntation comment consists of the characters between
@@ -637,7 +570,7 @@ class HtmlDecorator {
*
* TODO: implement formatting or linking for tags.
*/
- static String getFormattedComment(Declaration decl) {
+ static String getFormattedComment(IProgramElement decl) {
String formattedComment = "";
// strip the comment markers
@@ -683,58 +616,8 @@ class HtmlDecorator {
}
} catch ( IOException ioe ) {
throw new Error( "Couldn't format comment for declaration: " +
- decl.getSignature() );
+ decl.getName() );
}
return formattedComment;
}
-
- static String generateDesignatorHREFLink(Declaration decl) {
- Declaration ccutDecl = decl.getCrosscutDeclaration();
- if (ccutDecl != null) {
- // !!! the following stuff should use ccutDecl
- return
- "<A HREF=" +
- ccutDecl.getDeclaringType() + ".html#" + generateHREFName(ccutDecl) + ">" +
- ccutDecl.getSignature() + "</A>";
- }
- else {
- //String link = decl.getCrosscutDesignator();
- //System.out.println(">> link: " + link);
- //return
- // "<A HREF=\"TransportAspect.html#" + generateHREFName( decl ) + "\">" +
- // decl.getCrosscutDesignator() + "</A>";
- //return null;
- return null;
- }
- }
-
-
- // *************************************************************************** //
- // ** This stuff should be in Declaration ** //
- // *************************************************************************** //
-
- static Declaration getCrosscutDeclaration(Declaration decl) {
- //String filename = "D:\\Projects\\AJDoc\\apples\\TransportAspect.java";
- //Declaration[] decls = symbolManager.getDeclarations(filename);
- //decls = decls[0].getDeclarations();
- //return decls[decls.length-2]; !!!
- return null;
- }
-
- static String getName(Declaration decl) {
- return decl.getSignature();
- }
}
-
-
- //
- // !!! this stub only guaranteed to work for classes or interfaces
- //
- /*
- static String getFullyQualifiedName(Declaration decl) {
- if ( decl.getDeclaringType() == null )
- return getName(decl);
- else
- return getFullyQualifiedName(decl.getDeclaringType()) + "$" + getName(decl);
- }
- */ \ No newline at end of file
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/JavadocExecutor.java b/ajdoc/src/org/aspectj/tools/ajdoc/JavadocExecutor.java
index bc59f3511..e654be7b0 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/JavadocExecutor.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/JavadocExecutor.java
@@ -26,6 +26,9 @@ import java.io.StringReader;
import java.util.*;
+/**
+ * @author Mik Kersten
+ */
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 34f4bb433..706b9c9be 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java
@@ -108,7 +108,6 @@ public class Main implements Config {
int i = 0;
for ( ; i < ajcOptions.size(); i++ ) {
argsToCompiler[i] = (String)ajcOptions.elementAt(i);
- //System.out.println(">>> ajc: " + argsToCompiler[i]);
}
for ( int j = 0; j < inputFiles.length; j++) {
argsToCompiler[i] = inputFiles[j].getAbsolutePath();
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/SourceLine.java b/ajdoc/src/org/aspectj/tools/ajdoc/SourceLine.java
deleted file mode 100644
index 76a11c585..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/SourceLine.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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:
- * Xerox/PARC initial implementation
- * Mik Kersten port to AspectJ 1.1+ code base
- * ******************************************************************/
-
-package org.aspectj.tools.ajdoc;
-import java.io.Serializable;
-import java.io.File;
-
-public class SourceLine implements Serializable {
- public int line;
- public String filename;
- //boolean hasBody;
-
- public SourceLine(String filename, int line) {
- this.line = line;
- this.filename = filename;
- }
-
- public String getDirectory() {
- return new File(filename).getParent();
- }
-
- public int hashCode() {
- return filename.hashCode() ^ line;
- }
-
- public boolean equals(Object other) {
- if (!(other instanceof SourceLine)) return false;
-
- SourceLine otherLine = (SourceLine)other;
-
- return otherLine.line == line && otherLine.filename.equals(filename);
- }
-
- public String toString() {
- return filename + "::" + line;
- }
-
- /**
- * @return true when the method has a corresponding signature in the source code
- * @return false otherwise
- */
- //public boolean hasBody() { return hasBody; }
-}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java b/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java
index ff46e3807..65b1e7d81 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java
@@ -13,14 +13,33 @@
import java.io.File;
import java.util.Iterator;
+import java.util.List;
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IProgramElement;
+import org.aspectj.asm.IRelationship;
/**
* @author Mik Kersten
*/
public class StructureUtil {
+
+
+ /**
+ * @return null if a relationship of that kind is not found
+ */
+ public static List/*IProgramElement*/ getTargets(IProgramElement node, IRelationship.Kind kind) {
+ List relations = AsmManager.getDefault().getRelationshipMap().get(node);
+ List targets = null;
+ if (relations == null) return null;
+ for (Iterator it = relations.iterator(); it.hasNext(); ) {
+ IRelationship rtn = (IRelationship)it.next();
+ if (rtn.getKind().equals(kind)) {
+ targets = rtn.getTargets();
+ }
+ }
+ return targets;
+ }
public static String getPackageDeclarationFromFile(File file) {
IProgramElement fileNode = (IProgramElement)AsmManager.getDefault().getHierarchy().findElementForSourceFile(file.getAbsolutePath());
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java
index 3553b8702..19302e5a7 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java
@@ -22,6 +22,9 @@ import java.util.List;
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IProgramElement;
+/**
+ * @author Mik Kersten
+ */
class StubFileGenerator {
static Hashtable declIDTable = null;
@@ -38,8 +41,6 @@ class StubFileGenerator {
static void processFile(SymbolManager symbolManager, File inputFile, File signatureFile) {
try {
- // Declaration[] decls = symbolManager.getDeclarations(inputFile.getCanonicalPath());
-
PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(signatureFile.getCanonicalPath())));
String packageName = StructureUtil.getPackageDeclarationFromFile(inputFile);
@@ -78,138 +79,65 @@ class StubFileGenerator {
private static void processTypeDeclaration(IProgramElement classNode, PrintWriter writer) throws IOException {
-// String formalComment = classNode.getFormalComment();
-// String fullSignature = classNode.getFullSignature();
-// Declaration[] ptbs = classNode.getPointedToBy();
-// Declaration[] subs = classNode.getDeclarations();
-
String formalComment = addDeclID(classNode, classNode.getFormalComment());
writer.println(formalComment);
- String signature = classNode.getSourceSignature();// StructureUtil.genSignature(classNode);
+ String signature = getnSourcesignature(classNode);// StructureUtil.genSignature(classNode);
+
writer.println(signature + " {" );
processMembers(classNode.getChildren(), writer, classNode.getKind().equals(IProgramElement.Kind.INTERFACE));
writer.println();
writer.println("}");
}
- private static void processMembers(List/*IProgramElement*/ members, PrintWriter writer, boolean declaringTypeIsInterface) throws IOException {
+ /**
+ * Translates "aspect" to "class"
+ */
+ private static String getnSourcesignature(IProgramElement classNode) {
+ String signature = classNode.getSourceSignature();
+ int index = signature.indexOf("aspect");
+ if (index != -1) {
+ signature = signature.substring(0, index) +
+ "class " +
+ signature.substring(index + 6, signature.length());
+ }
+ return signature;
+ }
+
+ private static void processMembers(List/*IProgramElement*/ members, PrintWriter writer, boolean declaringTypeIsInterface) throws IOException {
for (Iterator it = members.iterator(); it.hasNext();) {
IProgramElement member = (IProgramElement) it.next();
- if (member.getKind().isTypeKind()) {
+ if (member.getKind().isType()
+ && !member.getParent().getKind().equals(IProgramElement.Kind.METHOD)) {
processTypeDeclaration(member, writer);
} else {
String formalComment = addDeclID(member, member.getFormalComment());;
writer.println(formalComment);
- String signature = member.getSourceSignature();//StructureUtil.genSignature(member);
- writer.print(signature);
- if (member.getKind().equals(IProgramElement.Kind.METHOD)) {
+ String signature = "";
+ if (!member.getKind().equals(IProgramElement.Kind.POINTCUT)
+ && !member.getKind().equals(IProgramElement.Kind.ADVICE) ) {
+ signature = member.getSourceSignature();//StructureUtil.genSignature(member);
+ }
+ if (signature != null &&
+ !member.getKind().isInterTypeMember()) {
+ writer.print(signature);
+ } else {
+// System.err.println(">> skipping: " + member.getKind());
+ }
+
+ if (member.getKind().equals(IProgramElement.Kind.METHOD) ||
+ member.getKind().equals(IProgramElement.Kind.CONSTRUCTOR)) {
writer.println(" { }");
} else if (member.getKind().equals(IProgramElement.Kind.FIELD)) {
- writer.println(";");
+// writer.println(";");
}
}
}
}
-// 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()) {
-// formalComment = addDeclID(decl, formalComment);
-//
-// writer.println(formalComment);
-//
-// // HACK: this should be in Declaration
-// int implementsClauseIndex = fullSignature.indexOf(" implements");
-// if (implementsClauseIndex != -1) {
-// String newSignature = "";
-// StringTokenizer st = new StringTokenizer(fullSignature.substring(implementsClauseIndex, fullSignature.length()));
-// for (String element = (String)st.nextElement(); st.hasMoreElements(); element = (String)st.nextElement()) {
-// if (element.indexOf("$MightHaveAspect") != -1
-// && element.indexOf("implements") != -1) {
-// newSignature += element;
-// }
-// }
-// if (!newSignature.equals("")) {
-// writer.print(fullSignature.substring(0, implementsClauseIndex)
-// + " implements " + newSignature + " " );
-// } else {
-// writer.print(fullSignature.substring(0, implementsClauseIndex) + " " );
-// }
-// } else {
-// writer.print(fullSignature + " " );
-// }
-//
-//
-// if ((!decl.hasBody() && !decl.getKind().equals( "interface" ) ||
-// (decl.getKind().equals( "method" ) && declaringDeclIsInterface)) && // !!! bug in Jim's API?
-// !(decl.getKind().equals("initializer") && decl.getModifiers().indexOf("static") != -1 ) ) {
-//
-// if (decl.getModifiers().indexOf("static final") != -1) {
-// String fullSig = decl.getFullSignature().trim();
-// String stripped = fullSig.substring(0, fullSig.lastIndexOf(' '));
-// String type = stripped.substring(stripped.lastIndexOf(' '), stripped.length());
-//
-// if (type.equals("boolean")) {
-// writer.println(" = false");
-// } else if (type.equals("char")) {
-// writer.println(" = '0'");
-// } else if (type.equals("byte")) {
-// writer.println(" = 0");
-// } else if (type.equals("short")) {
-// writer.println(" = 0");
-// } else if (type.equals("int")) {
-// writer.println(" = 0");
-// } else if (type.equals("long")) {
-// writer.println(" = 0");
-// } else if (type.equals("float")) {
-// writer.println(" = 0");
-// } else if (type.equals("double")) {
-// writer.println(" = 0");
-// } else if (type.equals("String")) {
-// writer.println(" = \"\"");
-// } else {
-// writer.println(" = null");
-// }
-// }
-// writer.println(";");
-//// } else if ((!decl.hasBody() && !decl.getKind().equals( "interface" ) ||
-//// (decl.getKind().equals( "method" ) && declaringDeclIsInterface)) && // !!! bug in Jim's API?
-//// !(decl.getKind().equals("initializer") && decl.getModifiers().indexOf("static") != -1 ) ) {
-////
-//// writer.println(";");
-//
-// } else {
-// if (subs != null) {
-// if ( decl.getKind().equals( "interface" ) ) {
-// declaringDeclIsInterface = true;
-// }
-// writer.println("{");
-// processDeclarations(subs, writer, declaringDeclIsInterface);
-// writer.println("}");
-// }
-// }
-// writer.println();
-// }
-
static int nextDeclID = 0;
static String addDeclID(IProgramElement decl, String formalComment) {
String declID = "" + ++nextDeclID;
@@ -238,18 +166,10 @@ class StubFileGenerator {
int atsignPos = formalComment.indexOf('@');
int endPos = formalComment.indexOf("*/");
int periodPos = formalComment.indexOf("/**")+2;
- //if ( atsignPos == -1 ) {
- // periodPos = formalComment.lastIndexOf(".");
- //} else {
- // periodPos = formalComment.substring(0, atsignPos).lastIndexOf(".");
- //}
int position = 0;
String periodPlaceHolder = "";
if ( periodPos != -1 ) {
position = periodPos+1;
- //if ( appendPeriod ) {
- //periodPlaceHolder = "#";
- //}
}
else if ( atsignPos != -1 ) {
string = string + "\n * ";
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java b/ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java
index 6c1a0dcbb..5e58d7fda 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java
@@ -19,100 +19,17 @@ import java.util.*;
import org.aspectj.asm.*;
-
-
-
+/**
+ * @author Mik Kersten
+ */
public class SymbolManager {
-// public static File mapFilenameToSymbolFile(String filename) {
-// return mapFilenameToNewExtensionFile(filename, SYMBOL_FILE_EXTENSION);
-// }
-//
-// public static File mapFilenameToSourceLinesFile(String filename) {
-// return mapFilenameToNewExtensionFile(filename, SOURCE_LINES_FILE_EXTENSION);
-// }
-//
-// public static File getSourceToOutputFile(String dirname) {
-// return new File(dirname, ".ajsline");
-// }
-//
-// public static File getOutputToSourceFile(String dirname) {
-// return new File(dirname, ".ajoline");
-// }
-
-//
-// private static File mapFilenameToNewExtensionFile(String filename, String ext) {
-// int lastDot = filename.lastIndexOf('.');
-// String basename = filename;
-// if (lastDot != -1) {
-// basename = basename.substring(0, lastDot);
-// }
-//
-// return new File(basename+ext);
-// }
-
private static SymbolManager INSTANCE = new SymbolManager();
public static SymbolManager getDefault() {
return INSTANCE;
}
- /**
- * @param filePath the full path to the preprocessed source file
- * @param lineNumber line number in the preprocessed source file
- * @return the <CODE>SourceLine</CODE> corresponding to the original file/line
- * @see SourceLine
- */
- public SourceLine mapToSourceLine(String filePath, int lineNumber) {
- System.err.println("> mapping: " + filePath);
- return null;
-// Map map = lookupOutputToSource(filePath);
-//
-// if (map == null) return null;
-//
-// return (SourceLine)map.get(new SourceLine(filePath, lineNumber));
- }
-
-
- /**
- * @param filePath the full path to the original source file
- * @param lineNumber line number in the original source file
- * @return the <CODE>SourceLine</CODE> corresponding to the preprocessed file/line
- * @see SourceLine
- */
- public SourceLine mapToOutputLine(String filePath, int lineNumber) {
- return null;
-// Map map = lookupSourceToOutput(filePath);
-//
-// if (map == null) return null;
-//
-// return (SourceLine)map.get(new SourceLine(filePath, lineNumber));
- }
-
-
-
- /****
- public int mapToOutputLine(String filename, int line) {
- Vector sourceLines = lookupSourceLines(filename);
-
- // do linear search here
- if (sourceLines == null) return -1;
-
- for(int outputLine = 0; outputLine < sourceLines.size(); outputLine++) {
- SourceLine sl = (SourceLine)sourceLines.elementAt(outputLine);
-
- if (sl == null) continue;
- if (sl.line == line) {
- String outputRoot = new File(filename).getName();
- String sourceRoot = new File(sl.filename).getName();
- if (outputRoot.equals(sourceRoot)) return outputLine + 1;
- }
- }
-
- return -1;
- }
- ****/
-
/**
* TODO: only works for one class
@@ -133,14 +50,17 @@ public class SymbolManager {
file.walk(walker);
- System.err.println("> got: " + nodes);
+// System.err.println("> got: " + nodes);
return (Declaration[])nodes.toArray(new Declaration[nodes.size()]);
// return lookupDeclarations(filename);
}
private boolean accept(IProgramElement node) {
- return !node.getKind().equals(IProgramElement.Kind.IMPORT_REFERENCE);
+ return
+ !node.getKind().equals(IProgramElement.Kind.IMPORT_REFERENCE)
+ && !(node.getKind().isType() &&
+ node.getParent().getKind().equals(IProgramElement.Kind.METHOD));
}
private Declaration buildDecl(IProgramElement node) {
@@ -168,7 +88,16 @@ public class SymbolManager {
}
signature += node.toSignatureString();
-// System.err.println(">>>> " + signature);
+
+ String name = node.getName();
+ if (node.getKind().isType()) {
+ name = genPartiallyQualifiedName(node, node.getName());
+ }
+
+ String declaringType = node.getParent().getName();
+// if (!node.getKind().isType()) {
+// declaringType = node.getParent().getName();
+// }
Declaration dec = new Declaration(
node.getSourceLocation().getLine(),
@@ -176,7 +105,7 @@ public class SymbolManager {
node.getSourceLocation().getColumn(),
-1,
modifiers,
- node.getName(),
+ name,
signature,
"", // crosscut designator
node.getDeclaringType(),
@@ -195,7 +124,16 @@ public class SymbolManager {
// return getDeclarationAtPoint(filename, line, -1);
// }
- public Declaration getDeclarationAtPoint(String filename, int line, int column) {
+ private String genPartiallyQualifiedName(IProgramElement node, String name) {
+// if (node.getParent() != null) System.err.println("%%% " + node.getParent());
+ if (node.getParent() != null && node.getParent().getKind().isType()) {
+ name = node.getParent().getName() + '.' + name;
+ genPartiallyQualifiedName(node.getParent(), name);
+ }
+ return name;
+ }
+
+ public Declaration getDeclarationAtPoint(String filename, int line, int column) {
Declaration[] declarations = lookupDeclarations(filename);
//System.out.println("getting "+filename+", "+line+":"+column);