aboutsummaryrefslogtreecommitdiffstats
path: root/ajdoc/src/org/aspectj/tools
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-01-29 17:07:22 -0800
committerAndy Clement <aclement@pivotal.io>2019-01-29 17:07:22 -0800
commit89739bc1ff28a18fadcb27dba7fd26d27ea7b343 (patch)
tree165bc12fa79f098634d888b4068b8d203e377546 /ajdoc/src/org/aspectj/tools
parente8436048b1667bc2d1d7c9a48070fb73a281daf9 (diff)
downloadaspectj-89739bc1ff28a18fadcb27dba7fd26d27ea7b343.tar.gz
aspectj-89739bc1ff28a18fadcb27dba7fd26d27ea7b343.zip
mavenizing ajdoc - wip
Diffstat (limited to 'ajdoc/src/org/aspectj/tools')
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/CompilerWrapper.java39
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/Config.java49
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/DocException.java20
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java969
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/JavadocRunner.java112
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/Main.java835
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java189
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java230
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/Util.java24
9 files changed, 0 insertions, 2467 deletions
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/CompilerWrapper.java b/ajdoc/src/org/aspectj/tools/ajdoc/CompilerWrapper.java
deleted file mode 100644
index f27d3b166..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/CompilerWrapper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2003 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten initial implementation
- * ******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import org.aspectj.asm.AsmManager;
-import org.aspectj.bridge.IMessage;
-
-/**
- * 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 AsmManager executeMain(String[] args) {
- INSTANCE = new CompilerWrapper();
- INSTANCE.runMain(args, true);
- return AsmManager.lastActiveStructureModel;
- }
-
- public static boolean hasErrors() {
- return INSTANCE.ourHandler.getErrors().length > 0;
- }
-
- public static IMessage[] getErrors() {
- return INSTANCE.ourHandler.getErrors();
- }
-}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Config.java b/ajdoc/src/org/aspectj/tools/ajdoc/Config.java
deleted file mode 100644
index 4a65f105f..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/Config.java
+++ /dev/null
@@ -1,49 +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 Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * Mik Kersten port to AspectJ 1.1+ code base
- * ******************************************************************/
-
-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 USAGE =
- "Usage: ajdoc <options> <source files>\n" +
- "\n" +
- "where <options> includes:\n"+
- " -public Show only public classes and members\n"+
- " -protected Show protected/public classes and members\n"+
- " -package Show package/protected/public classes and members\n" + // default
- " -private Show all classes and members\n" +
- " -help Display command line options\n" +
- " -sourcepath <pathlist> Specify where to find source files\n" +
- " -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" +
- " -windowtitle <text> Browser window title for the documenation" +
- " -bottom <html-code> Include bottom text for each page" +
- " -link <url> Create links to javadoc output at <url>" +
- " -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\n" +
- " -source <version> set source level (1.3, 1.4 or 1.5)\n" +
- "\n" +
- "as well as the AspectJ Compiler options.\n" +
- "\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.\n";
-
-}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/DocException.java b/ajdoc/src/org/aspectj/tools/ajdoc/DocException.java
deleted file mode 100644
index 0c8bc3575..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/DocException.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-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/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
deleted file mode 100644
index ec492fce9..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
+++ /dev/null
@@ -1,969 +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 Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * Mik Kersten port to AspectJ 1.1+ code base
- * ******************************************************************/
-
-package org.aspectj.tools.ajdoc;
-
-import java.io.BufferedReader;
-import java.io.DataInputStream;
-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.HierarchyWalker;
-import org.aspectj.asm.IProgramElement;
-import org.aspectj.asm.IRelationship;
-import org.aspectj.util.TypeSafeEnum;
-
-/**
- * @author Mik Kersten
- */
-class HtmlDecorator {
-
- 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";
- private static final String ITD_METHOD_SUMMARY = "Inter-Type Method Summary";
- private static final String ITD_FIELD_SUMMARY = "Inter-Type Field Summary";
- private static final String ITD_CONSTRUCTOR_SUMMARY = "Inter-Type Constructor Summary";
-
- static List<String> visibleFileList = new ArrayList<String>();
- static Hashtable declIDTable = null;
- static File rootDir = null;
- static String docVisibilityModifier;
-
- static void decorateHTMLFromInputFiles(AsmManager model, Hashtable table, File newRootDir, File[] inputFiles, String docModifier)
- throws IOException {
- rootDir = newRootDir;
- declIDTable = table;
- docVisibilityModifier = docModifier;
- for (int i = 0; i < inputFiles.length; i++) {
- decorateHTMLFromIPEs(getProgramElements(model, inputFiles[i].getCanonicalPath()), rootDir.getCanonicalPath()
- + Config.DIR_SEP_CHAR, docModifier, false);
- }
- }
-
- static void decorateHTMLFromIPEs(IProgramElement[] decls, String base, String docModifier, boolean exceededNestingLevel)
- throws IOException {
- if (decls != null) {
- for (int i = 0; i < decls.length; i++) {
- IProgramElement decl = decls[i];
- decorateHTMLFromIPE(decl, base, docModifier, exceededNestingLevel);
- }
- }
- }
-
- /**
- * Before attempting to decorate the HTML file we have to verify that it exists, which depends on the documentation visibility
- * specified to c.
- *
- * Depending on docModifier, can document - public: only public - protected: protected and public (default) - package: package
- * protected and public - private: everything
- */
- static void decorateHTMLFromIPE(IProgramElement decl, String base, String docModifier, boolean exceededNestingLevel)
- throws IOException {
- boolean nestedClass = false;
- if (decl.getKind().isType()) {
- boolean decorateFile = true;
- if (isAboveVisibility(decl)) {
- visibleFileList.add(decl.toSignatureString());
- String packageName = decl.getPackageName();
- String filename = "";
- if (packageName != null) {
-
- int index1 = base.lastIndexOf(Config.DIR_SEP_CHAR);
- int index2 = base.lastIndexOf(".");
- String currFileClass = "";
- if (index1 > -1 && index2 > 0 && index1 < index2) {
- currFileClass = base.substring(index1 + 1, index2);
- }
-
- // XXX only one level of nexting
- if (currFileClass.equals(decl.getDeclaringType())) {
- nestedClass = true;
- packageName = packageName.replace('.', '/');
- String newBase = "";
- if (base.lastIndexOf(Config.DIR_SEP_CHAR) > 0) {
- newBase = base.substring(0, base.lastIndexOf(Config.DIR_SEP_CHAR));
- }
- String signature = constructNestedTypeName(decl);
-
- filename = newBase + Config.DIR_SEP_CHAR + packageName + Config.DIR_SEP_CHAR + currFileClass + // "." +
- signature + ".html";
- } else {
- packageName = packageName.replace('.', '/');
- filename = base + packageName + Config.DIR_SEP_CHAR + decl.toSignatureString() + ".html";
- }
- } else {
- filename = base + decl.toSignatureString() + ".html";
- }
- if (!exceededNestingLevel) {
- decorateHTMLFile(new File(filename));
- } else {
- System.out.println("Warning: can not generate documentation for nested " + "inner class: "
- + decl.toSignatureString());
- }
- }
- }
- }
-
- private static String constructNestedTypeName(IProgramElement node) {
- if (node.getParent().getKind().isSourceFile()) {
- return node.getName();
- } else {
- String nodeName = "";
- if (node.getKind().isType())
- nodeName += '.' + node.getName();
- return constructNestedTypeName(node.getParent()) + nodeName;
- }
- }
-
- /**
- * Skips files that are public in the model but not public in the source, e.g. nested aspects.
- */
- static void decorateHTMLFile(File file) throws IOException {
- if (!file.exists())
- return;
-
- System.out.println("> Decorating " + file.getCanonicalPath() + "...");
- BufferedReader reader = new BufferedReader(new FileReader(file));
-
- StringBuffer fileContents = new StringBuffer();
- String line = reader.readLine();
- while (line != null) {
- fileContents.append(line + "\n");
- line = reader.readLine();
- }
-
- boolean isSecond = false;
- int index = 0;
- IProgramElement decl;
- while (true) {
-
- // ---this next part is an inlined procedure that returns two values---
- // ---the next declaration and the index at which that declaration's---
- // ---DeclID sits in the .html file ---
- String contents = fileContents.toString();
- int start = contents.indexOf(Config.DECL_ID_STRING, index);
- int end = contents.indexOf(Config.DECL_ID_TERMINATOR, index);
- if (start == -1)
- decl = null;
- else if (end == -1)
- throw new Error("Malformed DeclID.");
- else {
- String tid = contents.substring(start + Config.DECL_ID_STRING.length(), end);
- decl = (IProgramElement) declIDTable.get(tid);
- index = start;
- }
- // --- ---
- // --- ---
-
- if (decl == null)
- break;
- fileContents.delete(start, end + Config.DECL_ID_TERMINATOR.length());
- if (decl.getKind().isType()) {
- isSecond = true;
- String fullname = "";
- if (decl.getParent().getKind().equals(IProgramElement.Kind.ASPECT)
- || decl.getParent().getKind().equals(IProgramElement.Kind.CLASS)) {
- fullname += decl.getParent().toSignatureString().concat(".").concat(decl.toSignatureString());
- } else {
- fullname += decl.toSignatureString();
- }
- // only add aspect documentation if we're in the correct
- // file for the given IProgramElement
- if (file.getName().indexOf(fullname + ".html") != -1) {
- addAspectDocumentation(decl, fileContents, index);
- }
- } else {
- decorateMemberDocumentation(decl, fileContents, index);
- }
- // Change "Class" to "Aspect"
- // moved this here because then can use the IProgramElement.Kind
- // rather than checking to see if there's advice - this fixes
- // the case with an inner aspect not having the title "Aspect"
- if (decl.getKind().equals(IProgramElement.Kind.ASPECT) && file.getName().indexOf(decl.toSignatureString()) != -1) {
- // only want to change "Class" to "Aspect" if we're in the
- // file corresponding to the IProgramElement
- String fullname = "";
- if (decl.getParent().getKind().equals(IProgramElement.Kind.ASPECT)
- || decl.getParent().getKind().equals(IProgramElement.Kind.CLASS)) {
- fullname += decl.getParent().toSignatureString().concat(".").concat(decl.toSignatureString());
- } else {
- fullname += decl.toSignatureString();
- }
- if (file.getName().indexOf(fullname + ".html") == -1) {
- // we're still in the file for a parent IPE
- continue;
- }
-
- boolean br = true;
- int classStartIndex = fileContents.toString().indexOf("<BR>\nClass ");
- if (classStartIndex == -1) {
- classStartIndex = fileContents.toString().indexOf("<H2>\nClass ");
- br = false;
- }
- if (classStartIndex == -1) {
- // Java8 looks more like this:
- // <h2 title="Class A" class="title">Class A</h2>
- classStartIndex = fileContents.toString().indexOf("<h2 title=\"Class ");
- int classEndIndex = fileContents.toString().indexOf("</h2>", classStartIndex);
- if (classEndIndex != -1) {
- // Convert it to "<h2 title="Aspect A" class="title">Aspect A</h2>"
- String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
- String aspectLine = classLine.replaceAll("Class ","Aspect ");
- fileContents.delete(classStartIndex, classEndIndex);
- fileContents.insert(classStartIndex, aspectLine);
- }
- }
- else if (classStartIndex != -1) {
- int classEndIndex = fileContents.toString().indexOf("</H2>", classStartIndex);
- if (classStartIndex != -1 && classEndIndex != -1) {
- String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
- String aspectLine = "";
- if (br) {
- aspectLine += "<BR>\n" + "Aspect " + classLine.substring(11, classLine.length());
- } else {
- aspectLine += "<H2>\n" + "Aspect " + classLine.substring(11, classLine.length());
- }
- fileContents.delete(classStartIndex, classEndIndex);
- fileContents.insert(classStartIndex, aspectLine);
- }
- }
- int secondClassStartIndex = fileContents.toString().indexOf("class <B>");
- if (secondClassStartIndex != -1) {
- String name = decl.toSignatureString();
- int classEndIndex = fileContents.toString().indexOf(name + "</B><DT>");
- if (secondClassStartIndex != -1 && classEndIndex != -1) {
- StringBuffer sb = new StringBuffer(fileContents.toString().substring(secondClassStartIndex, classEndIndex));
- sb.replace(0, 5, "aspect");
- fileContents.delete(secondClassStartIndex, classEndIndex);
- fileContents.insert(secondClassStartIndex, sb.toString());
- }
- }
- else {
- // Java8:
- // <pre>static class <span class="typeNameLabel">ClassA.InnerAspect</span>
- classStartIndex = fileContents.toString().indexOf("class <span class=\"typeNameLabel\">");
- if (classStartIndex == -1) {
- // Java7: 464604
- // <pre>public class <span class="strong">Azpect</span>
- classStartIndex = fileContents.toString().indexOf("class <span class=\"strong\">");
- }
- int classEndIndex = fileContents.toString().indexOf("</span>", classStartIndex);
- if (classEndIndex != -1) {
- // Convert it to "aspect <span class="typeNameLabel">ClassA.InnerAspect</span>"
- String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
- String aspectLine = "aspect"+fileContents.substring(classStartIndex+5,classEndIndex);
- fileContents.delete(classStartIndex, classEndIndex);
- fileContents.insert(classStartIndex, aspectLine);
- }
- }
- }
- }
- file.delete();
- FileOutputStream fos = new FileOutputStream(file);
- fos.write(fileContents.toString().getBytes());
-
- reader.close();
- fos.close();
- }
-
- static void addAspectDocumentation(IProgramElement node, StringBuffer fileBuffer, int index) {
- List<IProgramElement> pointcuts = new ArrayList<IProgramElement>();
- List<IProgramElement> advice = new ArrayList<IProgramElement>();
- List<IProgramElement> declares = new ArrayList<IProgramElement>();
- List<IProgramElement> methodsDeclaredOn = StructureUtil.getDeclareInterTypeTargets(node, IProgramElement.Kind.INTER_TYPE_METHOD);
- if (methodsDeclaredOn != null && !methodsDeclaredOn.isEmpty()) {
- insertDeclarationsSummary(fileBuffer, methodsDeclaredOn, ITD_METHOD_SUMMARY, index);
- }
- List<IProgramElement> fieldsDeclaredOn = StructureUtil.getDeclareInterTypeTargets(node, IProgramElement.Kind.INTER_TYPE_FIELD);
- if (fieldsDeclaredOn != null && !fieldsDeclaredOn.isEmpty()) {
- insertDeclarationsSummary(fileBuffer, fieldsDeclaredOn, ITD_FIELD_SUMMARY, index);
- }
- List<IProgramElement> constDeclaredOn = StructureUtil.getDeclareInterTypeTargets(node, IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR);
- if (fieldsDeclaredOn != null && !constDeclaredOn.isEmpty()) {
- insertDeclarationsSummary(fileBuffer, constDeclaredOn, ITD_CONSTRUCTOR_SUMMARY, index);
- }
- for (Iterator<IProgramElement> 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);
- }
- if (advice.size() > 0) {
- insertDeclarationsSummary(fileBuffer, advice, ADVICE_SUMMARY, index);
- insertDeclarationsDetails(fileBuffer, advice, ADVICE_DETAIL, index);
- }
- // add the 'aspect declarations' information against the type
- List<IProgramElement> parentsDeclaredOn = StructureUtil.getDeclareInterTypeTargets(node, IProgramElement.Kind.DECLARE_PARENTS);
- if (parentsDeclaredOn != null && parentsDeclaredOn.size() > 0) {
- decorateDocWithRel(node, fileBuffer, index, parentsDeclaredOn, HtmlRelationshipKind.ASPECT_DECLARATIONS);
- }
- // add the 'annotated by' information against the type
- List<String> annotatedBy = StructureUtil.getTargets(node, IRelationship.Kind.DECLARE_INTER_TYPE, "annotated by");
- if (annotatedBy != null && annotatedBy.size() > 0) {
- decorateDocWithRel(node, fileBuffer, index, annotatedBy, HtmlRelationshipKind.ANNOTATED_BY);
- }
- // add the 'advised by' information against the type
- List<String> advisedBy = StructureUtil.getTargets(node, IRelationship.Kind.ADVICE);
- if (advisedBy != null && advisedBy.size() > 0) {
- decorateDocWithRel(node, fileBuffer, index, advisedBy, HtmlRelationshipKind.ADVISED_BY);
- }
- }
-
- static void insertDeclarationsSummary(StringBuffer fileBuffer, List decls, String kind, int index) {
- if (!declsAboveVisibilityExist(decls))
- return;
-
- int insertIndex = findSummaryIndex(fileBuffer, index);
-
- // insert the head of the table
- String tableHead = "<!-- ======== " + kind.toUpperCase() + " ======= -->\n\n"
- + "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"1\""
- + "CELLSPACING=\"0\"><TR><TD COLSPAN=2 BGCOLOR=\"#CCCCFF\">" + "<FONT SIZE=\"+2\"><B>" + kind
- + "</B></FONT></TD></TR>\n";
- fileBuffer.insert(insertIndex, tableHead);
- insertIndex += tableHead.length();
-
- // insert the body of the table
- for (int i = 0; i < decls.size(); i++) {
- IProgramElement decl = (IProgramElement) decls.get(i);
- if (isAboveVisibility(decl)) {
- // insert the table row accordingly
- String comment = generateSummaryComment(decl);
- String entry = "";
- if (kind.equals(ADVICE_SUMMARY)) {
- entry += "<TR><TD>" + "<A HREF=\"#" + generateHREFName(decl) + "\">" + "<TT>" + generateSignatures(decl)
- + "</TT></A><BR>&nbsp;";
- if (!comment.equals("")) {
- entry += comment + "<P>";
- }
- entry += generateAffects(decl) + "</TD>" + "</TR><TD>\n";
- } else if (kind.equals(POINTCUT_SUMMARY)) {
- entry += "<TR><TD WIDTH=\"1%\">" + "<FONT SIZE=-1><TT>" + genAccessibility(decl) + "</TT></FONT>" + "</TD>\n"
- + "<TD>" + "<TT><A HREF=\"#" + generateHREFName(decl) + "\">" + decl.toLabelString()
- + "</A></TT><BR>&nbsp;";
- if (!comment.equals("")) {
- entry += comment + "<P>";
- }
- entry += "</TR></TD>\n";
- } else if (kind.equals(DECLARE_SUMMARY)) {
- entry += "<TR><TD WIDTH=\"1%\">" + "<FONT SIZE=-1><TT>" + generateModifierInformation(decl, false)
- + "</TT></FONT>" + "</TD>" + "<TD>" + "<A HREF=\"#" + generateHREFName(decl) + "\">" + "<TT>"
- + decl.toLabelString() + "</TT></A><P>" + generateAffects(decl);
- } else if (kind.equals(ITD_FIELD_SUMMARY) || kind.equals(ITD_METHOD_SUMMARY)) {
- entry += "<TR><TD WIDTH=\"1%\">" + "<FONT SIZE=-1><TT>" + generateModifierInformation(decl, false)
- + "</TT></FONT>" + "</TD>" + "<TD>" + "<A HREF=\"#" + generateHREFName(decl) + "\">" + "<TT>"
- + decl.toLabelString() + "</TT></A><P>" + generateDeclaredBy(decl);
- } else if (kind.equals(ITD_CONSTRUCTOR_SUMMARY)) {
- entry += "<TD>" + "<A HREF=\"#" + generateHREFName(decl) + "\">" + "<TT>" + decl.toLabelString()
- + "</TT></A><P>" + generateDeclaredBy(decl);
- }
-
- // insert the entry
- fileBuffer.insert(insertIndex, entry);
- insertIndex += entry.length();
- }
- }
-
- // insert the end of the table
- String tableTail = "</TABLE><P>&nbsp;\n";
- fileBuffer.insert(insertIndex, tableTail);
- insertIndex += tableTail.length();
- }
-
- private static boolean declsAboveVisibilityExist(List decls) {
- boolean exist = false;
- for (Iterator it = decls.iterator(); it.hasNext();) {
- IProgramElement element = (IProgramElement) it.next();
- if (isAboveVisibility(element))
- exist = true;
- }
- return exist;
- }
-
- private static boolean isAboveVisibility(IProgramElement element) {
- IProgramElement.Accessibility acc = element.getAccessibility();
- if (docVisibilityModifier.equals("private")) {
- // show all classes and members
- return true;
- } else if (docVisibilityModifier.equals("package")) {
- // show package, protected and public classes and members
- return acc.equals(IProgramElement.Accessibility.PACKAGE) || acc.equals(IProgramElement.Accessibility.PROTECTED)
- || acc.equals(IProgramElement.Accessibility.PUBLIC);
- } else if (docVisibilityModifier.equals("protected")) {
- // show protected and public classes and members
- return acc.equals(IProgramElement.Accessibility.PROTECTED) || acc.equals(IProgramElement.Accessibility.PUBLIC);
- } else if (docVisibilityModifier.equals("public")) {
- // show public classes and members
- return acc.equals(IProgramElement.Accessibility.PUBLIC);
- }
- return false;
- }
-
- 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) {
- if (!declsAboveVisibilityExist(decls))
- return;
- int insertIndex = findDetailsIndex(fileBuffer, index);
-
- // insert the table heading
- String detailsHeading = "<P>&nbsp;\n" + "<!-- ======== " + kind.toUpperCase() + " SUMMARY ======= -->\n\n"
- + "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">\n"
- + "<TR BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">\n" + "<TD COLSPAN=1><FONT SIZE=\"+2\">\n" + "<B>" + kind
- + "</B></FONT></TD>\n" + "</TR>\n" + "</TABLE>";
- fileBuffer.insert(insertIndex, detailsHeading);
- insertIndex += detailsHeading.length();
-
- // insert the details
- for (int i = 0; i < decls.size(); i++) {
- IProgramElement decl = (IProgramElement) decls.get(i);
- if (isAboveVisibility(decl)) {
- String entry = "";
-
- // insert the table row accordingly
- entry += "<A NAME=\"" + generateHREFName(decl) + "\"><!-- --></A>\n";
- if (kind.equals(ADVICE_DETAIL)) {
- entry += "<H3>" + decl.getName() + "</H3><P>";
- entry += "<TT>" + generateSignatures(decl) + "</TT>\n" + "<P>" + generateDetailsComment(decl) + "<P>"
- + generateAffects(decl);
- } else if (kind.equals(POINTCUT_DETAIL)) {
- entry += "<H3>" + decl.toLabelString() + "</H3><P>" + generateDetailsComment(decl);
- } else if (kind.equals(DECLARE_DETAIL)) {
- entry += "<H3>" + decl.toLabelString() + "</H3><P>" + generateModifierInformation(decl, true);
- if (!decl.getKind().equals(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR)) {
- entry += "&nbsp;&nbsp;";
- }
- // if we're not a declare statement then we need to generate the signature.
- // If we did this for declare statements we get two repeated lines
- if (!decl.getKind().isDeclare()) {
- String sigs = generateSignatures(decl);
- entry += sigs + "<P>";
- }
- entry += generateAffects(decl) + generateDetailsComment(decl);
- }
-
- // insert the entry
- if (i != decls.size() - 1) {
- entry += "<P><HR>\n";
- } else {
- entry += "<P>";
- }
- fileBuffer.insert(insertIndex, entry);
- insertIndex += entry.length();
- }
- }
- }
-
- /**
- * TODO: don't place the summary first.
- */
- static int findSummaryIndex(StringBuffer fileBuffer, int index) {
- String fbs = fileBuffer.toString();
- String MARKER_1 = "<!-- =========== FIELD SUMMARY =========== -->";
- String MARKER_2 = "<!-- ======== CONSTRUCTOR SUMMARY ======== -->";
- int index1 = fbs.indexOf(MARKER_1, index);
- int index2 = fbs.indexOf(MARKER_2, index);
- if (index1 < index2 && index1 != -1) {
- return index1;
- } else if (index2 != -1) {
- return index2;
- } else {
- return index;
- }
- }
-
- static int findDetailsIndex(StringBuffer fileBuffer, int index) {
- String fbs = fileBuffer.toString();
- String MARKER_1 = "<!-- ========= CONSTRUCTOR DETAIL ======== -->";
- String MARKER_2 = "<!-- ============ FIELD DETAIL =========== -->";
- String MARKER_3 = "<!-- ============ METHOD DETAIL ========== -->";
- int index1 = fbs.indexOf(MARKER_1, index);
- int index2 = fbs.indexOf(MARKER_2, index);
- int index3 = fbs.indexOf(MARKER_3, index);
- if (index1 != -1 && index1 < index2 && index1 < index3) {
- return index1;
- } else if (index2 != -1 && index2 < index1 && index2 < index3) {
- return index2;
- } else if (index3 != -1) {
- return index3;
- } else {
- return index;
- }
- }
-
- static void decorateDocWithRel(IProgramElement node, StringBuffer fileContentsBuffer, int index, List targets,
- HtmlRelationshipKind relKind) {
- if (targets != null && !targets.isEmpty()) {
- String adviceDoc = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>"
- + "<TD width=\"15%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>" + relKind.toString() + "</font></b></td><td>";
-
- String relativePackagePath = getRelativePathFromHere(node.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR);
-
- List addedNames = new ArrayList();
- for (Iterator it = targets.iterator(); it.hasNext();) {
- Object o = it.next();
- IProgramElement currDecl = null;
- if (o instanceof String) {
- String currHandle = (String) o;
- currDecl = node.getModel().getHierarchy().findElementForHandle(currHandle);
- } else if (o instanceof IProgramElement) {
- currDecl = (IProgramElement) o;
- } else {
- return;
- }
-
- String packagePath = "";
- if (currDecl.getPackageName() != null && !currDecl.getPackageName().equals("")) {
- packagePath = currDecl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR;
- }
-
- String hrefName = "";
- String hrefLink = "";
-
- // Start the hRefLink with the relative path based on where
- // *this* type (i.e. the advised) is in the package structure.
- hrefLink = relativePackagePath + packagePath;
-
- if (currDecl.getPackageName() != null) {
- hrefName = currDecl.getPackageName().replace('.', '/');
- }
-
- // in the case of nested classes, in order for the links to work,
- // need to have the correct file name which is something of the
- // form parentClass.nestedAspect.html
- List names = new ArrayList();
- IProgramElement parent = currDecl;
- while (parent != null
- && parent.getParent() != null
- && (!parent.getParent().getKind().equals(IProgramElement.Kind.FILE_JAVA) && !parent.getParent().getKind()
- .equals(IProgramElement.Kind.FILE_ASPECTJ))) {
- parent = parent.getParent();
- names.add(parent.toLinkLabelString());
- }
- StringBuffer sbuff = new StringBuffer();
- for (int i = names.size() - 1; i >= 0; i--) {
- String element = (String) names.get(i);
- if (i == 0) {
- sbuff.append(element);
- } else {
- sbuff.append(element + ".");
- }
- }
- // use the currDecl.toLabelString rather than currDecl.getName()
- // because two distinct advice blocks can have the same
- // currDecl.getName() and wouldn't both appear in the ajdoc
- hrefName += Config.DIR_SEP_CHAR + sbuff.toString() + "." + currDecl.toLabelString();
-
- // need to replace " with quot; otherwise the links wont work
- // for 'matches declare' relationship
- StringBuffer sb = new StringBuffer(currDecl.toLabelString());
- int nextQuote = sb.toString().indexOf("\"");
- while (nextQuote != -1) {
- sb.deleteCharAt(nextQuote);
- sb.insert(nextQuote, "quot;");
- nextQuote = sb.toString().indexOf("\"");
- }
- hrefLink += sbuff.toString() + ".html" + "#" + sb.toString();
-
- if (!addedNames.contains(hrefName)) {
- adviceDoc = adviceDoc + "<A HREF=\"" + hrefLink + "\"><tt>" + hrefName.replace('/', '.') + "</tt></A>";
-
- if (it.hasNext())
- adviceDoc += ", ";
- addedNames.add(hrefName);
- }
- }
- adviceDoc += "</TR></TD></TABLE>\n";
- fileContentsBuffer.insert(index, adviceDoc);
- }
- }
-
- static void decorateMemberDocumentation(IProgramElement node, StringBuffer fileContentsBuffer, int index) {
- List<String> targets = StructureUtil.getTargets(node, IRelationship.Kind.ADVICE);
- decorateDocWithRel(node, fileContentsBuffer, index, targets, HtmlRelationshipKind.ADVISED_BY);
-
- List<String> warnings = StructureUtil.getTargets(node, IRelationship.Kind.DECLARE, "matches declare");
- decorateDocWithRel(node, fileContentsBuffer, index, warnings, HtmlRelationshipKind.MATCHES_DECLARE);
-
- List<String> softenedBy = StructureUtil.getTargets(node, IRelationship.Kind.DECLARE, "softened by");
- decorateDocWithRel(node, fileContentsBuffer, index, softenedBy, HtmlRelationshipKind.SOFTENED_BY);
-
- List<String> annotatedBy = StructureUtil.getTargets(node, IRelationship.Kind.DECLARE_INTER_TYPE, "annotated by");
- decorateDocWithRel(node, fileContentsBuffer, index, annotatedBy, HtmlRelationshipKind.ANNOTATED_BY);
- }
-
- /**
- * pr119453 - adding "declared by" relationship
- */
- static String generateDeclaredBy(IProgramElement decl) {
- String entry = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>"
- + "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>" + "&nbsp;Declared&nbsp;by:</b></font></td><td>";
-
- String relativePackagePath = getRelativePathFromHere(decl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR);
-
- if (decl != null && !StructureUtil.isAnonymous(decl.getParent())) {
- String packagePath = "";
- if (decl.getPackageName() != null && !decl.getPackageName().equals("")) {
- packagePath = decl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR;
- }
-
- String typeSignature = constructNestedTypeName(decl);
-
- String hrefName = packagePath + typeSignature;
-
- // The hrefLink needs to just be the corresponding aspect
- String hrefLink = relativePackagePath + packagePath + typeSignature + ".html";
-
- entry += "<A HREF=\"" + hrefLink + "\"><tt>" + hrefName.replace('/', '.') + "</tt></A>"; // !!! don't replace
- }
- entry += "</B></FONT></TD></TR></TABLE>\n</TR></TD>\n";
- return entry;
- }
-
- /**
- * TODO: probably want to make this the same for intros and advice.
- */
- static String generateAffects(IProgramElement decl) {
- List targets = null;
- if (decl.getKind().isDeclare() || decl.getKind().isInterTypeMember()) {
- targets = StructureUtil.getDeclareTargets(decl);
- } else {
- targets = StructureUtil.getTargets(decl, IRelationship.Kind.ADVICE);
- }
- if (targets == null)
- return "";
- String entry = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>";
-
- IProgramElement.Kind kind = decl.getKind();
- if (kind.equals(IProgramElement.Kind.ADVICE)) {
- entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>" + HtmlRelationshipKind.ADVISES.toString()
- + "</b></font></td><td>";
- } else if (kind.equals(IProgramElement.Kind.DECLARE_WARNING) || kind.equals(IProgramElement.Kind.DECLARE_ERROR)) {
- entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>" + HtmlRelationshipKind.MATCHED_BY.toString()
- + "</b></font></td><td>";
- } else if (kind.isDeclareAnnotation()) {
- entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>" + HtmlRelationshipKind.ANNOTATES.toString()
- + "</b></font></td><td>";
- } else if (kind.equals(IProgramElement.Kind.DECLARE_SOFT)) {
- entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>" + HtmlRelationshipKind.SOFTENS.toString()
- + "</b></font></td><td>";
- } else {
- entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000>" + HtmlRelationshipKind.DECLARED_ON.toString()
- + "</b></font></td><td>";
- }
-
- String relativePackagePath = getRelativePathFromHere(decl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR);
-
- List addedNames = new ArrayList(); // for ensuring that we don't add duplciates
- for (Iterator it = targets.iterator(); it.hasNext();) {
- String currHandle = (String) it.next();
- IProgramElement currDecl = decl.getModel().getHierarchy().findElementForHandle(currHandle);
- if (currDecl.getKind().equals(IProgramElement.Kind.CODE)) {
- currDecl = currDecl.getParent(); // promote to enclosing
- }
- if (currDecl != null && !StructureUtil.isAnonymous(currDecl.getParent())) {
- String packagePath = "";
- if (currDecl.getPackageName() != null && !currDecl.getPackageName().equals("")) {
- packagePath = currDecl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR;
- }
-
- String typeSignature = constructNestedTypeName(currDecl);
-
- String hrefName = packagePath + typeSignature;
-
- // Start the hRefLink with the relative path based on where
- // *this* type (i.e. the advisor) is in the package structure.
- String hrefLink = relativePackagePath + packagePath + typeSignature + ".html";
-
- if (!currDecl.getKind().isType()) {
- hrefName += '.' + currDecl.getName();
- hrefLink += "#" + currDecl.toLabelString();
- }
-
- if (!addedNames.contains(hrefName)) {
- entry += "<A HREF=\"" + hrefLink + "\"><tt>" + hrefName.replace('/', '.') + "</tt></A>"; // !!! don't replace
- if (it.hasNext())
- entry += ", ";
- addedNames.add(hrefName);
- }
- }
- }
- entry += "</B></FONT></TD></TR></TABLE>\n</TR></TD>\n";
- return entry;
- }
-
- /**
- * Generates a relative directory path fragment that can be used to navigate "upwards" from the directory location implied by
- * the argument.
- *
- * @param packagePath
- * @return String consisting of multiple "../" parts, one for each component part of the input <code>packagePath</code>.
- */
- private static String getRelativePathFromHere(String packagePath) {
- StringBuffer result = new StringBuffer("");
- if (packagePath != null && (packagePath.indexOf("/") != -1)) {
- StringTokenizer sTok = new StringTokenizer(packagePath, "/", false);
- while (sTok.hasMoreTokens()) {
- sTok.nextToken(); // don't care about the token value
- result.append(".." + Config.DIR_SEP_CHAR);
- }// end while
- }// end if
-
- return result.toString();
- }
-
- /**
- * Generate the "public int"-type information about the given IProgramElement. Used when dealing with ITDs. To mirror the
- * behaviour of methods and fields in classes, if we're generating the summary information we don't want to include "public" if
- * the accessibility of the IProgramElement is public.
- *
- */
- private static String generateModifierInformation(IProgramElement decl, boolean isDetails) {
- String intro = "";
- if (decl.getKind().isDeclare()) {
- return intro + "</TT>";
- }
- if (isDetails || !decl.getAccessibility().equals(IProgramElement.Accessibility.PUBLIC)) {
- intro += "<TT>" + decl.getAccessibility().toString() + "&nbsp;";
- }
- if (decl.getKind().equals(IProgramElement.Kind.INTER_TYPE_FIELD)) {
- return intro + decl.getCorrespondingType() + "</TT>";
- } else if (decl.getKind().equals(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR) && isDetails) {
- return intro + "</TT>";
- } else {
- return intro + decl.getCorrespondingType(true) + "</TT>";
- }
- }
-
- static String generateIntroductionSignatures(IProgramElement decl, boolean isDetails) {
- return "<not implemented>";
- }
-
- static String generateSignatures(IProgramElement decl) {
- return "<B>" + decl.toLabelString() + "</B>";
- }
-
- 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('.');
- if (formattedComment.equals("")) {
- return "";
- } else if (periodIndex != -1) {
- return COMMENT_INDENT + formattedComment.substring(0, periodIndex + 1);
- } else {
- return COMMENT_INDENT + formattedComment;
- }
- }
-
- static String generateDetailsComment(IProgramElement decl) {
- return getFormattedComment(decl);
- }
-
- static String generateHREFName(IProgramElement decl) {
- StringBuffer hrefLinkBuffer = new StringBuffer();
- char[] declChars = decl.toLabelString().toCharArray();
- for (int i = 0; i < declChars.length; i++) {
- if (declChars[i] == '"') {
- hrefLinkBuffer.append("quot;");
- } else {
- hrefLinkBuffer.append(declChars[i]);
- }
- }
- return hrefLinkBuffer.toString();
- }
-
- /**
- * Figure out the link relative to the package.
- */
- static String generateAffectsHREFLink(String declaringType) {
- String link = rootDir.getAbsolutePath() + "/" + declaringType + ".html";
- 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 the /** that begins the comment and the 'star-slash' that ends it. The text is devided into one or
- * more lines. On each of these lines, the leading * characters are ignored; for lines other than the first, blanks and tabs
- * preceding the initial * characters are also discarded.</I>
- *
- * TODO: implement formatting or linking for tags.
- */
- static String getFormattedComment(IProgramElement decl) {
-
- String comment = decl.getFormalComment();
- if (comment == null)
- return "";
-
- String formattedComment = "";
- // strip the comment markers
-
- int startIndex = comment.indexOf("/**");
- int endIndex = comment.indexOf("*/");
- if (startIndex == -1) {
- startIndex = 0;
- } else {
- startIndex += 3;
- }
- if (endIndex == -1) {
- endIndex = comment.length();
- }
- comment = comment.substring(startIndex, endIndex);
-
- // string the leading whitespace and '*' characters at the beginning of each line
- BufferedReader reader = new BufferedReader(new StringReader(comment));
- try {
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- line = line.trim();
- for (int i = 0; i < line.length(); i++) {
- if (line.charAt(0) == '*') {
- line = line.substring(1, line.length());
- } else {
- break;
- }
- }
- // !!! remove any @see and @link tags from the line
- // int seeIndex = line.indexOf("@see");
- // int linkIndex = line.indexOf("@link");
- // if ( seeIndex != -1 ) {
- // line = line.substring(0, seeIndex) + line.substring(seeIndex);
- // }
- // if ( linkIndex != -1 ) {
- // line = line.substring(0, linkIndex) + line.substring(linkIndex);
- // }
- formattedComment += line;
- }
- } catch (IOException ioe) {
- throw new Error("Couldn't format comment for declaration: " + decl.getName());
- }
- return formattedComment;
- }
-
- static public IProgramElement[] getProgramElements(AsmManager model, String filename) {
-
- IProgramElement file = (IProgramElement) model.getHierarchy().findElementForSourceFile(filename);
- final List nodes = new ArrayList();
- HierarchyWalker walker = new HierarchyWalker() {
- public void preProcess(IProgramElement node) {
- IProgramElement p = (IProgramElement) node;
- if (accept(node))
- nodes.add(p);
- }
- };
-
- file.walk(walker);
- return (IProgramElement[]) nodes.toArray(new IProgramElement[nodes.size()]);
- }
-
- /**
- * Rejects anonymous kinds by checking if their name is an integer
- */
- static private boolean accept(IProgramElement node) {
- if (node.getKind().isType()) {
- boolean isAnonymous = StructureUtil.isAnonymous(node);
- return !node.getParent().getKind().equals(IProgramElement.Kind.METHOD) && !isAnonymous;
- } else {
- return !node.getKind().equals(IProgramElement.Kind.IMPORT_REFERENCE);
- }
- }
-
- /**
- * TypeSafeEnum for the entries which need to be put in the html doc
- */
- public static class HtmlRelationshipKind extends TypeSafeEnum {
-
- public HtmlRelationshipKind(String name, int key) {
- super(name, key);
-
- }
-
- public static HtmlRelationshipKind read(DataInputStream s) throws IOException {
- int key = s.readByte();
- switch (key) {
- case 1:
- return ADVISES;
- case 2:
- return ADVISED_BY;
- case 3:
- return MATCHED_BY;
- case 4:
- return MATCHES_DECLARE;
- case 5:
- return DECLARED_ON;
- case 6:
- return ASPECT_DECLARATIONS;
- case 7:
- return SOFTENS;
- case 8:
- return SOFTENED_BY;
- case 9:
- return ANNOTATES;
- case 10:
- return ANNOTATED_BY;
- case 11:
- return USES_POINTCUT;
- case 12:
- return POINTCUT_USED_BY;
- }
- throw new Error("weird relationship kind " + key);
- }
-
- public static final HtmlRelationshipKind ADVISES = new HtmlRelationshipKind("&nbsp;Advises:", 1);
- public static final HtmlRelationshipKind ADVISED_BY = new HtmlRelationshipKind("&nbsp;Advised&nbsp;by:", 2);
- public static final HtmlRelationshipKind MATCHED_BY = new HtmlRelationshipKind("&nbsp;Matched&nbsp;by:", 3);
- public static final HtmlRelationshipKind MATCHES_DECLARE = new HtmlRelationshipKind("&nbsp;Matches&nbsp;declare:", 4);
- public static final HtmlRelationshipKind DECLARED_ON = new HtmlRelationshipKind("&nbsp;Declared&nbsp;on:", 5);
- public static final HtmlRelationshipKind ASPECT_DECLARATIONS = new HtmlRelationshipKind("&nbsp;Aspect&nbsp;declarations:",
- 6);
- public static final HtmlRelationshipKind SOFTENS = new HtmlRelationshipKind("&nbsp;Softens:", 7);
- public static final HtmlRelationshipKind SOFTENED_BY = new HtmlRelationshipKind("&nbsp;Softened&nbsp;by:", 8);
- public static final HtmlRelationshipKind ANNOTATES = new HtmlRelationshipKind("&nbsp;Annotates:", 9);
- public static final HtmlRelationshipKind ANNOTATED_BY = new HtmlRelationshipKind("&nbsp;Annotated&nbsp;by:", 10);
- public static final HtmlRelationshipKind USES_POINTCUT = new HtmlRelationshipKind("&nbsp;Uses&nbsp;pointcut:", 11);
- public static final HtmlRelationshipKind POINTCUT_USED_BY = new HtmlRelationshipKind("&nbsp;Pointcut&nbsp;used&nbsp;by:",
- 12);
-
- }
-}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/JavadocRunner.java b/ajdoc/src/org/aspectj/tools/ajdoc/JavadocRunner.java
deleted file mode 100644
index 64e53eead..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/JavadocRunner.java
+++ /dev/null
@@ -1,112 +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 Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * Mik Kersten port to AspectJ 1.1+ code base
- * ******************************************************************/
-
-package org.aspectj.tools.ajdoc;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Vector;
-
-import javax.tools.DocumentationTool;
-import javax.tools.DocumentationTool.DocumentationTask;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
-/**
- * @author Mik Kersten
- */
-class JavadocRunner {
-
- static boolean has14ToolsAvailable() {
- try {
- Class jdMainClass = com.sun.tools.javadoc.Main.class;
- Class[] paramTypes = new Class[] { String[].class };
- jdMainClass.getMethod("execute", paramTypes);
- } catch (NoClassDefFoundError e) {
- return false;
- } catch (UnsupportedClassVersionError e) {
- return false;
- } catch (NoSuchMethodException e) {
- return false;
- }
- return true;
- }
-
- static void callJavadoc(String[] javadocargs) {
- // final SecurityManager defaultSecurityManager = System.getSecurityManager();
- //
- // System.setSecurityManager( new SecurityManager() {
- // public void checkExit(int status) {
- // if (status == 0) {
- // throw new SecurityException();
- // }
- // else {
- // System.setSecurityManager(defaultSecurityManager);
- // //System.out.println("Error: javadoc exited unexpectedly");
- // System.exit(0);
- // throw new SecurityException();
- // }
- // }
- // 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 {
- // for JDK 1.4 and above call the execute method...
- Class jdMainClass = com.sun.tools.javadoc.Main.class;
- Method executeMethod = null;
- try {
- Class[] paramTypes = new Class[] { String[].class };
- executeMethod = jdMainClass.getMethod("execute", paramTypes);
- } catch (NoSuchMethodException e) {
- com.sun.tools.javadoc.Main.main(javadocargs);
- // throw new UnsupportedOperationException("ajdoc requires a tools library from JDK 1.4 or later.");
- }
- try {
- executeMethod.invoke(null, new Object[] { javadocargs });
- } catch (IllegalArgumentException e1) {
- throw new RuntimeException("Failed to invoke javadoc");
- } catch (IllegalAccessException e1) {
- throw new RuntimeException("Failed to invoke javadoc");
- } catch (InvocationTargetException e1) {
- throw new RuntimeException("Failed to invoke javadoc");
- }
- // main method is documented as calling System.exit() - which stops us dead in our tracks
- // com.sun.tools.javadoc.Main.main( javadocargs );
- } catch (SecurityException se) {
- // Do nothing since we expect it to be thrown
- // System.out.println( ">> se: " + se.getMessage() );
- }
- // Set the security manager back
- // System.setSecurityManager(defaultSecurityManager);
- }
-
- public static void callJavadocViaToolProvider(Vector<String> options, List<String> files) {
- DocumentationTool doctool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = doctool.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> jfos = fm.getJavaFileObjects(files.toArray(new String[0]));
- DocumentationTask task = doctool.getTask(null/*standard System.err*/, null/*standard file manager*/,
- null/*default diagnostic listener*/, null/*standard doclet*/, options, jfos);
- task.call();
- }
-}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java
deleted file mode 100644
index 2e622ba9c..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java
+++ /dev/null
@@ -1,835 +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 Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * Mik Kersten port to AspectJ 1.1+ code base
- * ******************************************************************/
-
-package org.aspectj.tools.ajdoc;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.aspectj.asm.AsmManager;
-import org.aspectj.bridge.IMessage;
-import org.aspectj.bridge.Version;
-import org.aspectj.util.FileUtil;
-import org.aspectj.util.LangUtil;
-
-/**
- * This is an old implementation of ajdoc that does not use an OO style. However, it does the job, and should serve to evolve a
- * lightweight ajdoc implementation until we can make a properly extended javadoc implementation.
- *
- * @author Mik Kersten
- */
-public class Main implements Config {
-
- private static final String FAIL_MESSAGE = "> compile failed, exiting ajdoc";
-
- /** Command line options. */
- static Vector<String> options;
-
- /** Options to pass to ajc. */
- static Vector<String> ajcOptions;
-
- /** All of the files to be processed by ajdoc. */
- static Vector<String> filenames;
-
- /** List of files to pass to javadoc. */
- static Vector<String> fileList;
-
- /** List of packages to pass to javadoc. */
- static Vector<String> packageList;
-
- /** Default to package visiblity. */
- static String docModifier = "package";
-
- static Vector<String> sourcepath;
-
- static boolean verboseMode = false;
- static boolean packageMode = false;
- static boolean authorStandardDocletSwitch = false;
- static boolean versionStandardDocletSwitch = false;
- static File rootDir = null;
- static Hashtable declIDTable = new Hashtable();
- static String docDir = ".";
-
- private static boolean deleteTempFilesOnExit = true;
-
- private static boolean aborted = false;
- private static IMessage[] errors;
- private static boolean shownAjdocUsageMessage = false;
-
- // creating a local variable to enable us to create the ajdocworkingdir
- // in a local sandbox during testing
- private static String outputWorkingDir = Config.WORKING_DIR;
-
- public static void clearState() {
- options = new Vector<String>();
- ajcOptions = new Vector<String>();
- filenames = new Vector<String>();
- fileList = new Vector<String>();
- packageList = new Vector<String>();
- docModifier = "package";
- sourcepath = new Vector<String>();
- verboseMode = false;
- packageMode = false;
- rootDir = null;
- declIDTable = new Hashtable();
- docDir = ".";
- aborted = false;
- deleteTempFilesOnExit = true;
- }
-
- public static void main(String[] args) {
- clearState();
- if (!JavadocRunner.has14ToolsAvailable()) {
- System.err.println("ajdoc requires a JDK 1.4 or later tools jar - exiting");
- aborted = true;
- return;
- }
-
- // STEP 1: parse the command line and do other global setup
- sourcepath.addElement("."); // add the current directory to the classapth
- parseCommandLine(args);
- rootDir = getRootDir();
- File[] inputFiles = new File[filenames.size()];
- File[] signatureFiles = new File[filenames.size()];
- try {
- // create the workingdir if it doesn't exist
- if (!(new File(outputWorkingDir).isDirectory())) {
- File dir = new File(outputWorkingDir);
- dir.mkdir();
- if (deleteTempFilesOnExit)
- dir.deleteOnExit();
- }
-
- for (int i = 0; i < filenames.size(); i++) {
- inputFiles[i] = new File(filenames.elementAt(i));
- }
-
- // PHASE 0: call ajc
- AsmManager model = callAjc(inputFiles);
- if (CompilerWrapper.hasErrors()) {
- System.out.println(FAIL_MESSAGE);
- aborted = true;
- errors = CompilerWrapper.getErrors();
- return;
- }
-
- for (int ii = 0; ii < filenames.size(); ii++) {
- signatureFiles[ii] = createSignatureFile(model, inputFiles[ii]);
- }
-
- // PHASE 1: generate Signature files (Java with DeclIDs and no bodies).
- System.out.println("> Building signature files...");
- try {
- StubFileGenerator.doFiles(model, declIDTable, inputFiles, signatureFiles);
- // Copy package.html and related files over
- packageHTML(model, inputFiles);
- } catch (DocException d) {
- System.err.println(d.getMessage());
- return;
- }
-
- // PHASE 2: let Javadoc generate HTML (with DeclIDs)
- callJavadoc(signatureFiles);
-
- // PHASE 3: add AspectDoc specific stuff to the HTML (and remove the DeclIDS).
- decorateHtmlFiles(model, inputFiles);
- System.out.println("> Finished.");
- } catch (Throwable e) {
- handleInternalError(e);
- exit(-2);
- }
- }
-
- /**
- * Method to copy over any package.html files that may be part of the documentation so that javadoc generates the
- * package-summary properly.
- */
- private static void packageHTML(AsmManager model, File[] inputFiles) throws IOException {
- ArrayList<String> dirList = new ArrayList<String>();
- for (int i = 0; i < inputFiles.length; i++) {
- String packageName = StructureUtil.getPackageDeclarationFromFile(model, inputFiles[i]);
- // Only copy the package.html file once.
- if (dirList.contains(packageName))
- continue;
-
- // Check to see if there exist a package.html file for this package.
- String dir = inputFiles[i].getAbsolutePath().substring(0, inputFiles[i].getAbsolutePath().lastIndexOf(File.separator));
- File input = new File(dir + Config.DIR_SEP_CHAR + "package.html");
- File inDir = new File(dir + Config.DIR_SEP_CHAR + "doc-files");
- // If it does not exist lets go to the next package.
- if (!input.exists()) {
- dirList.add(packageName);
- continue;
- }
-
- String filename = "";
- String docFiles = "";
- if (packageName != null) {
- String pathName = outputWorkingDir + File.separator + packageName.replace('.', File.separatorChar);
- File packageDir = new File(pathName);
- if (!packageDir.exists()) {
- dirList.add(packageName);
- continue;
- }
- packageName = packageName.replace('.', '/'); // !!!
- filename = outputWorkingDir + Config.DIR_SEP_CHAR + packageName + Config.DIR_SEP_CHAR + "package.html";
- docFiles = rootDir.getAbsolutePath() + Config.DIR_SEP_CHAR + packageName + Config.DIR_SEP_CHAR + "doc-files";
- } else {
- filename = outputWorkingDir + Config.DIR_SEP_CHAR + "package.html";
- docFiles = rootDir.getAbsolutePath() + Config.DIR_SEP_CHAR + "doc-files";
- }
-
- File output = new File(filename);
- FileUtil.copyFile(input, output);// Copy package.html
- // javadoc doesn't do anything with the doc-files folder so
- // we'll just copy it directly to the document location.
- if (!inDir.exists())
- continue;
- File outDir = new File(docFiles);
- System.out.println("> Copying folder " + outDir);
- FileUtil.copyFile(inDir, outDir);// Copy doc-files folder if it exist
- }
- }
-
- private static AsmManager callAjc(File[] inputFiles) {
- ajcOptions.addElement("-noExit");
- ajcOptions.addElement("-XjavadocsInModel"); // TODO: wrong option to force model gen
- ajcOptions.addElement("-d");
- ajcOptions.addElement(rootDir.getAbsolutePath());
- String[] argsToCompiler = new String[ajcOptions.size() + inputFiles.length];
- int i = 0;
- for (; i < ajcOptions.size(); i++) {
- argsToCompiler[i] = ajcOptions.elementAt(i);
- }
- for (int j = 0; j < inputFiles.length; j++) {
- argsToCompiler[i] = inputFiles[j].getAbsolutePath();
- // System.out.println(">> file to ajc: " + inputFiles[j].getAbsolutePath());
- i++;
- }
- System.out.println("> Calling ajc...");
- return CompilerWrapper.executeMain(argsToCompiler);
- }
-
- private static void callJavadoc(File[] signatureFiles) throws IOException {
- System.out.println("> Calling javadoc...");
- String[] javadocargs = null;
-
- List<String> files = new ArrayList<String>();
- if (packageMode) {
- int numExtraArgs = 2;
- if (authorStandardDocletSwitch)
- numExtraArgs++;
- if (versionStandardDocletSwitch)
- numExtraArgs++;
- javadocargs = new String[numExtraArgs + options.size() + packageList.size() + fileList.size()];
- javadocargs[0] = "-sourcepath";
- javadocargs[1] = outputWorkingDir;
- int argIndex = 2;
- if (authorStandardDocletSwitch) {
- javadocargs[argIndex] = "-author";
- argIndex++;
- }
- if (versionStandardDocletSwitch) {
- javadocargs[argIndex] = "-version";
- }
- // javadocargs[1] = getSourcepathAsString();
- for (int k = 0; k < options.size(); k++) {
- javadocargs[numExtraArgs + k] = options.elementAt(k);
- }
- for (int k = 0; k < packageList.size(); k++) {
- javadocargs[numExtraArgs + options.size() + k] = packageList.elementAt(k);
- }
- for (int k = 0; k < fileList.size(); k++) {
- javadocargs[numExtraArgs + options.size() + packageList.size() + k] = fileList.elementAt(k);
- }
- if (LangUtil.is19VMOrGreater()) {
- options = new Vector<String>();
- for (String a: javadocargs) {
- options.add(a);
- }
- }
- } else {
- javadocargs = new String[options.size() + signatureFiles.length];
- for (int k = 0; k < options.size(); k++) {
- javadocargs[k] = options.elementAt(k);
- }
- for (int k = 0; k < signatureFiles.length; k++) {
- javadocargs[options.size() + k] = StructureUtil.translateAjPathName(signatureFiles[k].getCanonicalPath());
- }
- for (int k = 0; k < signatureFiles.length; k++) {
- files.add(StructureUtil.translateAjPathName(signatureFiles[k].getCanonicalPath()));
- }
- }
- if (LangUtil.is19VMOrGreater()) {
- JavadocRunner.callJavadocViaToolProvider(options, files);
- } else {
- JavadocRunner.callJavadoc(javadocargs);
- }
- }
-
- /**
- * We start with the known HTML files (the ones that correspond directly to the input files.) As we go along, we may learn that
- * Javadoc split one .java file into multiple .html files to handle inner classes or local classes. The html file decorator
- * picks that up.
- */
- private static void decorateHtmlFiles(AsmManager model, File[] inputFiles) throws IOException {
- System.out.println("> Decorating html files...");
- HtmlDecorator.decorateHTMLFromInputFiles(model, declIDTable, rootDir, inputFiles, docModifier);
-
- System.out.println("> Removing generated tags...");
- removeDeclIDsFromFile("index-all.html", true);
- removeDeclIDsFromFile("serialized-form.html", true);
- if (packageList.size() > 0) {
- for (int p = 0; p < packageList.size(); p++) {
- removeDeclIDsFromFile(packageList.elementAt(p).replace('.', '/') + Config.DIR_SEP_CHAR
- + "package-summary.html", true);
- }
- } else {
- 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() {
- @Override
- public boolean accept(File f) {
- return f.getName().equals("package-summary.html");
- }
- });
- for (int j = 0; j < files.length; j++) {
- removeDeclIDsFromFile(files[j].getAbsolutePath(), false);
- }
- }
- }
-
- private static void removeDeclIDsFromFile(String filename, boolean relativePath) {
- // Remove the decl ids from "index-all.html"
- File indexFile;
- if (relativePath) {
- indexFile = new File(docDir + Config.DIR_SEP_CHAR + filename);
- } else {
- indexFile = new File(filename);
- }
- try {
- if (indexFile.exists()) {
- BufferedReader indexFileReader = new BufferedReader(new FileReader(indexFile));
- // StringBuffer greatly reduces the time it takes to remove generated tags
- StringBuffer indexFileBuffer = new StringBuffer((int) indexFile.length());
- String line = indexFileReader.readLine();
- while (line != null) {
- int indexStart = line.indexOf(Config.DECL_ID_STRING);
- int indexEnd = line.indexOf(Config.DECL_ID_TERMINATOR);
- if (indexStart != -1 && indexEnd != -1) {
- line = line.substring(0, indexStart) + line.substring(indexEnd + Config.DECL_ID_TERMINATOR.length());
- }
- indexFileBuffer.append(line);
- line = indexFileReader.readLine();
- }
- FileOutputStream fos = new FileOutputStream(indexFile);
- fos.write(indexFileBuffer.toString().getBytes());
-
- indexFileReader.close();
- fos.close();
- }
- } catch (IOException ioe) {
- // be siltent
- }
- }
-
- static Vector<String> getSourcePath() {
- Vector<String> sourcePath = new Vector<String>();
- boolean found = false;
- for (int i = 0; i < options.size(); i++) {
- String currOption = options.elementAt(i);
- if (found && !currOption.startsWith("-")) {
- sourcePath.add(currOption);
- }
- if (currOption.equals("-sourcepath")) {
- found = true;
- }
- }
- return sourcePath;
- }
-
- static File getRootDir() {
- File rootDir = new File(".");
- for (int i = 0; i < options.size(); i++) {
- if (options.elementAt(i).equals("-d")) {
- rootDir = new File(options.elementAt(i + 1));
- if (!rootDir.exists()) {
- rootDir.mkdir();
- // System.out.println( "Destination directory not found: " +
- // (String)options.elementAt(i+1) );
- // System.exit( -1 );
- }
- }
- }
- return rootDir;
- }
-
- static File createSignatureFile(AsmManager model, File inputFile) throws IOException {
- String packageName = StructureUtil.getPackageDeclarationFromFile(model, inputFile);
-
- String filename = "";
- if (packageName != null) {
- String pathName = outputWorkingDir + '/' + packageName.replace('.', '/');
- File packageDir = new File(pathName);
- if (!packageDir.exists()) {
- packageDir.mkdirs();
- if (deleteTempFilesOnExit)
- packageDir.deleteOnExit();
- }
- // verifyPackageDirExists(packageName, null);
- packageName = packageName.replace('.', '/'); // !!!
- filename = outputWorkingDir + Config.DIR_SEP_CHAR + packageName + Config.DIR_SEP_CHAR + inputFile.getName();
- } else {
- filename = outputWorkingDir + Config.DIR_SEP_CHAR + inputFile.getName();
- }
- File signatureFile = new File(filename);
- if (deleteTempFilesOnExit)
- signatureFile.deleteOnExit();
- return signatureFile;
- }
-
- // static void verifyPackageDirExists( String packageName, String offset ) {
- // System.err.println(">>> name: " + packageName + ", offset: " + offset);
- // if ( packageName.indexOf( "." ) != -1 ) {
- // File tempFile = new File("c:/aspectj-test/d1/d2/d3");
- // tempFile.mkdirs();
- // String currPkgDir = packageName.substring( 0, packageName.indexOf( "." ) );
- // String remainingPkg = packageName.substring( packageName.indexOf( "." )+1 );
- // String filePath = null;
- // if ( offset != null ) {
- // filePath = Config.WORKING_DIR + Config.DIR_SEP_CHAR +
- // offset + Config.DIR_SEP_CHAR + currPkgDir ;
- // }
- // else {
- // filePath = Config.WORKING_DIR + Config.DIR_SEP_CHAR + currPkgDir;
- // }
- // File packageDir = new File( filePath );
- // if ( !packageDir.exists() ) {
- // packageDir.mkdir();
- // if (deleteTempFilesOnExit) packageDir.deleteOnExit();
- // }
- // if ( remainingPkg != "" ) {
- // verifyPackageDirExists( remainingPkg, currPkgDir );
- // }
- // }
- // else {
- // String filePath = null;
- // if ( offset != null ) {
- // filePath = Config.WORKING_DIR + Config.DIR_SEP_CHAR + offset + Config.DIR_SEP_CHAR + packageName;
- // }
- // else {
- // filePath = Config.WORKING_DIR + Config.DIR_SEP_CHAR + packageName;
- // }
- // File packageDir = new File( filePath );
- // if ( !packageDir.exists() ) {
- // packageDir.mkdir();
- // if (deleteTempFilesOnExit) packageDir.deleteOnExit();
- // }
- // }
- // }
-
- /**
- * Can read Eclipse-generated single-line arg
- */
- static void parseCommandLine(String[] args) {
- if (args.length == 0) {
- displayHelpAndExit(null);
- } else if (args.length == 1 && args[0].startsWith("@")) {
- String argFile = args[0].substring(1);
- System.out.println("> Using arg file: " + argFile);
- BufferedReader br;
- try {
- br = new BufferedReader(new FileReader(argFile));
- String line = "";
- line = br.readLine();
- StringTokenizer st = new StringTokenizer(line, " ");
- List<String> argList = new ArrayList<String>();
- while (st.hasMoreElements()) {
- argList.add(st.nextToken());
- }
- // System.err.println(argList);
- args = new String[argList.size()];
- int counter = 0;
- for (Iterator<String> it = argList.iterator(); it.hasNext();) {
- args[counter] = it.next();
- counter++;
- }
- } catch (FileNotFoundException e) {
- System.err.println("> could not read arg file: " + argFile);
- e.printStackTrace();
- } catch (IOException ioe) {
- System.err.println("> could not read arg file: " + argFile);
- ioe.printStackTrace();
- }
- }
- List<String> vargs = new LinkedList<String>(Arrays.asList(args));
- vargs.add("-Xset:minimalModel=false");
- parseArgs(vargs, new File(".")); // !!!
-
- if (filenames.size() == 0) {
- displayHelpAndExit("ajdoc: No packages or classes specified");
- }
- }
-
- static void setSourcepath(String arg) {
- sourcepath.clear();
- arg = arg + File.pathSeparator; // makes things easier for ourselves
- StringTokenizer tokenizer = new StringTokenizer(arg, File.pathSeparator);
- while (tokenizer.hasMoreElements()) {
- sourcepath.addElement(tokenizer.nextToken());
- }
- }
-
- static String getSourcepathAsString() {
- String cPath = "";
- for (int i = 0; i < sourcepath.size(); i++) {
- cPath += sourcepath.elementAt(i) + Config.DIR_SEP_CHAR + outputWorkingDir;
- if (i != sourcepath.size() - 1) {
- cPath += File.pathSeparator;
- }
- }
- return cPath;
- }
-
- static void parseArgs(List vargs, File currentWorkingDir) {
- boolean addNextAsOption = false;
- boolean addNextAsArgFile = false;
- boolean addNextToAJCOptions = false;
- boolean addNextAsDocDir = false;
- boolean addNextAsClasspath = false;
- boolean ignoreArg = false; // used for discrepancy betwen class/sourcepath in ajc/javadoc
- boolean addNextAsSourcePath = false;
- if (vargs.size() == 0) {
- displayHelpAndExit(null);
- }
- for (int i = 0; i < vargs.size(); i++) {
- String arg = (String) vargs.get(i);
- ignoreArg = false;
- if (addNextAsDocDir) {
- docDir = arg;
- addNextAsDocDir = false;
- }
- if (addNextAsClasspath) {
- addNextAsClasspath = false;
- }
- if (addNextAsSourcePath) {
- setSourcepath(arg);
- addNextAsSourcePath = false;
- ignoreArg = true;
- }
-
- if (arg.startsWith("@")) {
- expandAtSignFile(arg.substring(1), currentWorkingDir);
- } else if (arg.equals("-argfile")) {
- addNextAsArgFile = true;
- } else if (addNextAsArgFile) {
- expandAtSignFile(arg, currentWorkingDir);
- addNextAsArgFile = false;
- } else if (arg.equals("-d")) {
- addNextAsOption = true;
- options.addElement(arg);
- addNextAsDocDir = true;
- } else if (arg.equals("-bootclasspath")) {
- addNextAsOption = true;
- addNextToAJCOptions = true;
- options.addElement(arg);
- ajcOptions.addElement(arg);
- } else if (arg.equals("-source")) {
- addNextAsOption = true;
- addNextToAJCOptions = true;
- addNextAsClasspath = true;
- options.addElement(arg);
- ajcOptions.addElement(arg);
- } else if (arg.equals("-classpath")) {
- addNextAsOption = true;
- addNextToAJCOptions = true;
- addNextAsClasspath = true;
- options.addElement(arg);
- ajcOptions.addElement(arg);
- } else if (arg.equals("-encoding")) {
- addNextAsOption = true;
- addNextToAJCOptions = false;
- options.addElement(arg);
- } else if (arg.equals("-docencoding")) {
- addNextAsOption = true;
- addNextToAJCOptions = false;
- options.addElement(arg);
- } else if (arg.equals("-charset")) {
- addNextAsOption = true;
- addNextToAJCOptions = false;
- options.addElement(arg);
- } else if (arg.equals("-sourcepath")) {
- addNextAsSourcePath = true;
- // options.addElement( arg );
- // ajcOptions.addElement( arg );
- } else if (arg.equals("-link")) {
- addNextAsOption = true;
- options.addElement(arg);
- } else if (arg.equals("-bottom")) {
- addNextAsOption = true;
- options.addElement(arg);
- } else if (arg.equals("-windowtitle")) {
- addNextAsOption = true;
- options.addElement(arg);
- } else if (arg.equals("-XajdocDebug")) {
- deleteTempFilesOnExit = false;
- } else if (arg.equals("-use")) {
- System.out.println("> Ignoring unsupported option: -use");
- } else if (arg.equals("-splitindex")) {
- // passed to javadoc
- } else if (arg.startsWith("-") || addNextAsOption || addNextToAJCOptions) {
- if (arg.equals("-private")) {
- docModifier = "private";
- } else if (arg.equals("-package")) {
- docModifier = "package";
- } else if (arg.equals("-protected")) {
- docModifier = "protected";
- } else if (arg.equals("-public")) {
- docModifier = "public";
- } else if (arg.equals("-verbose")) {
- verboseMode = true;
- } else if (arg.equals("-author")) {
- authorStandardDocletSwitch = true;
- } else if (arg.equals("-version")) {
- versionStandardDocletSwitch = true;
- } else if (arg.equals("-v")) {
- System.out.println(getVersion());
- exit(0);
- } else if (arg.equals("-help")) {
- displayHelpAndExit(null);
- } else if (arg.equals("-doclet") || arg.equals("-docletpath")) {
- System.out.println("The doclet and docletpath options are not currently supported \n"
- + "since ajdoc makes assumptions about the behavior of the standard \n"
- + "doclet. If you would find this option useful please email us at: \n"
- + " \n"
- + " aspectj-dev@eclipse.org \n"
- + " \n");
- exit(0);
- } else if (arg.equals("-nonavbar") || arg.equals("-noindex")) {
- // pass through
- // System.err.println("> ignoring unsupported option: " + arg);
- } else if (addNextToAJCOptions || addNextAsOption) {
- // deal with these two options together even though effectively
- // just falling through if addNextAsOption is true. Otherwise
- // will have to ensure check "addNextToAJCOptions" before
- // "addNextAsOption" so as the options are added to the
- // correct lists.
- if (addNextToAJCOptions) {
- ajcOptions.addElement(arg);
- if (!arg.startsWith("-")) {
- addNextToAJCOptions = false;
- }
- if (!addNextAsOption) {
- continue;
- }
- }
- } else if (arg.startsWith("-")) {
- ajcOptions.addElement(arg);
- addNextToAJCOptions = true;
- continue;
- } else {
- System.err.println("> unrecognized argument: " + arg);
- displayHelpAndExit(null);
- }
- options.addElement(arg);
- addNextAsOption = false;
- } else {
- // check if this is a file or a package
- // System.err.println(">>>>>>>> " + );
- // String entryName = arg.substring(arg.lastIndexOf(File.separator)+1);
- if (FileUtil.hasSourceSuffix(arg) || arg.endsWith(".lst") && arg != null) {
- File f = new File(arg);
- if (f.isAbsolute()) {
- filenames.addElement(arg);
- } else {
- filenames.addElement(currentWorkingDir + Config.DIR_SEP_CHAR + arg);
- }
- fileList.addElement(arg);
- }
-
- // PACKAGE MODE STUFF
- else if (!ignoreArg) {
-
- packageMode = true;
- packageList.addElement(arg);
- arg = arg.replace('.', '/'); // !!!
-
- // do this for every item in the classpath
- for (int c = 0; c < sourcepath.size(); c++) {
- String path = sourcepath.elementAt(c) + Config.DIR_SEP_CHAR + arg;
- File pkg = new File(path);
- if (pkg.isDirectory()) {
- String[] files = pkg.list(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- int index1 = name.lastIndexOf(".");
- int index2 = name.length();
- if ((index1 >= 0 && index2 >= 0)
- && (name.substring(index1, index2).equals(".java") || name.substring(index1, index2)
- .equals(".aj"))) {
- return true;
- } else {
- return false;
- }
- }
- });
- for (int j = 0; j < files.length; j++) {
- filenames.addElement(sourcepath.elementAt(c) + Config.DIR_SEP_CHAR + arg
- + Config.DIR_SEP_CHAR + files[j]);
- }
- } else if (c == sourcepath.size()) { // last element on classpath
- System.out.println("ajdoc: No package, class, or source file " + "found named " + arg + ".");
- } else {
- // didn't find it on that element of the classpath but that's ok
- }
- }
- }
- }
- }
- // set the default visibility as an option to javadoc option
- if (!options.contains("-private") && !options.contains("-package") && !options.contains("-protected")
- && !options.contains("-public")) {
- options.addElement("-package");
- }
- }
-
- static void expandAtSignFile(String filename, File currentWorkingDir) {
- List<String> result = new LinkedList<String>();
-
- File atFile = qualifiedFile(filename, currentWorkingDir);
- String atFileParent = atFile.getParent();
- File myWorkingDir = null;
- if (atFileParent != null)
- myWorkingDir = new File(atFileParent);
-
- try {
- BufferedReader stream = new BufferedReader(new FileReader(atFile));
- String line = null;
- while ((line = stream.readLine()) != null) {
- // strip out any comments of the form # to end of line
- int commentStart = line.indexOf("//");
- if (commentStart != -1) {
- line = line.substring(0, commentStart);
- }
-
- // remove extra whitespace that might have crept in
- line = line.trim();
- // ignore blank lines
- if (line.length() == 0)
- continue;
- result.add(line);
- }
- stream.close();
- } catch (IOException e) {
- System.err.println("Error while reading the @ file " + atFile.getPath() + ".\n" + e);
- System.exit(-1);
- }
-
- parseArgs(result, myWorkingDir);
- }
-
- static File qualifiedFile(String name, File currentWorkingDir) {
- name = name.replace('/', File.separatorChar);
- File file = new File(name);
- if (!file.isAbsolute() && currentWorkingDir != null) {
- file = new File(currentWorkingDir, name);
- }
- return file;
- }
-
- static void displayHelpAndExit(String message) {
- shownAjdocUsageMessage = true;
- 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) {
- System.out.flush();
- System.err.flush();
- System.exit(value);
- }
-
- /* This section of code handles errors that occur during compilation */
- static final String internalErrorMessage = " \n"
- + "If this has not already been logged as a bug raised please raise \n"
- + "a new AspectJ bug at https://bugs.eclipse.org/bugs including the \n"
- + "text below. To make the bug a priority, please also include a test\n"
- + "program that can reproduce this problem.\n ";
-
- static public void handleInternalError(Throwable uncaughtThrowable) {
- System.err.println("An internal error occured in ajdoc");
- System.err.println(internalErrorMessage);
- System.err.println(uncaughtThrowable.toString());
- uncaughtThrowable.printStackTrace();
- System.err.println();
- }
-
- static String getVersion() {
- return "ajdoc version " + Version.text;
- }
-
- public static boolean hasAborted() {
- return aborted;
- }
-
- public static IMessage[] getErrors() {
- return errors;
- }
-
- public static boolean hasShownAjdocUsageMessage() {
- return shownAjdocUsageMessage;
- }
-
- /**
- * Sets the output working dir to be <fullyQualifiedOutputDir>\ajdocworkingdir Useful in testing to redirect the ajdocworkingdir
- * to the sandbox
- */
- public static void setOutputWorkingDir(String fullyQulifiedOutputDir) {
- if (fullyQulifiedOutputDir == null) {
- resetOutputWorkingDir();
- } else {
- outputWorkingDir = fullyQulifiedOutputDir + File.separatorChar + Config.WORKING_DIR;
- }
- }
-
- /**
- * Resets the output working dir to be the default which is <the current directory>\ajdocworkingdir
- */
- public static void resetOutputWorkingDir() {
- outputWorkingDir = Config.WORKING_DIR;
- }
-}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java b/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java
deleted file mode 100644
index 3d866b625..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2003 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten initial implementation
- * ******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import java.io.File;
-import java.util.ArrayList;
-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 {
-
- /**
- * Calculate the targets for a given IProgramElement (and it's immediate children if its not a type or if the child is CODE) and
- * relationship kind
- *
- * @return null if a relationship of that kind is not found
- */
- public static List<String> getTargets(IProgramElement node, IRelationship.Kind kind) {
- return getTargets(node, kind, null);
- }
-
- /**
- * Calculate the targets for a given IProgramElement (and it's immediate children if its not a type or if the child is CODE) and
- * relationship kind with the specified relationship name.
- *
- * @return null if a relationship of that kind is not found
- */
- public static List<String> getTargets(IProgramElement node, IRelationship.Kind kind, String relName) {
- List<IRelationship> relations = new ArrayList<IRelationship>();
- List<IRelationship> rels = node.getModel().getRelationshipMap().get(node);
- if (rels != null) {
- relations.addAll(rels);
- }
- for (Iterator<IProgramElement> iter = node.getChildren().iterator(); iter.hasNext();) {
- IProgramElement child = (IProgramElement) iter.next();
- // if we're not a type, or if we are and the child is code, then
- // we want to get the relationships for this child - this means that the
- // correct relationships appear against the type in the ajdoc
- if (!node.getKind().isType() || child.getKind().equals(IProgramElement.Kind.CODE)) {
- List<IRelationship> childRelations = node.getModel().getRelationshipMap().get(child);
- if (childRelations != null) {
- for (Iterator<IRelationship> iterator = childRelations.iterator(); iterator.hasNext();) {
- IRelationship rel = (IRelationship) iterator.next();
- if (!relations.contains(rel)) {
- relations.add(rel);
- }
- }
- }
- }
- }
- if (relations == null || relations.isEmpty())
- return null;
- List<String> targets = new ArrayList<String>();
- for (Iterator<IRelationship> it = relations.iterator(); it.hasNext();) {
- IRelationship rtn = (IRelationship) it.next();
- if (rtn.getKind().equals(kind) && ((relName != null && relName.equals(rtn.getName())) || relName == null)) {
- List<String> targs = rtn.getTargets();
- for (String element: targs) {
- if (!targets.contains(element)) {
- targets.add(element);
- }
- }
- }
- }
- return targets;
- }
-
- static List<IProgramElement> getDeclareInterTypeTargets(IProgramElement node, IProgramElement.Kind kind) {
- List<IProgramElement> targets = new ArrayList<IProgramElement>();
- List<String> stringTargets = StructureUtil.getTargets(node, IRelationship.Kind.DECLARE_INTER_TYPE);
- if (stringTargets == null) {
- return null;
- }
- for (String element: stringTargets) {
- IProgramElement ipe = node.getModel().getHierarchy().findElementForHandle(element);
- if (ipe != null && ipe.getKind().equals(kind)) {
- targets.add(ipe);
- }
- }
- return targets;
- }
-
- public static List<String> getDeclareTargets(IProgramElement node) {
- List<IRelationship> relations = node.getModel().getRelationshipMap().get(node);
- List<String> targets = null;
- if (relations == null)
- return null;
- for (IRelationship rtn: relations) {
- if (rtn.getKind().isDeclareKind()) {
- targets = rtn.getTargets();
- }
- }
- return targets;
- }
-
- public static String getPackageDeclarationFromFile(AsmManager model, File file) {
- IProgramElement fileNode = model.getHierarchy().findElementForSourceFile(file.getAbsolutePath());
- String packageName = ((IProgramElement) fileNode.getChildren().get(0)).getPackageName();
- return packageName;
- }
-
- public static String genSignature(IProgramElement node) {
- StringBuffer sb = new StringBuffer();
-
- String accessibility = node.getAccessibility().toString();
- if (!accessibility.equals("package")) {
- sb.append(accessibility);
- sb.append(' ');
- }
-
- String modifiers = "";
- for (Iterator modIt = node.getModifiers().iterator(); modIt.hasNext();) {
- modifiers += modIt.next() + " ";
- }
-
- if (node.getKind().equals(IProgramElement.Kind.METHOD) || node.getKind().equals(IProgramElement.Kind.FIELD)) {
- sb.append(node.getCorrespondingType());
- sb.append(' ');
- }
-
- if (node.getKind().equals(IProgramElement.Kind.CLASS)) {
- sb.append("class ");
- } else if (node.getKind().equals(IProgramElement.Kind.INTERFACE)) {
- sb.append("interface ");
- }
-
- sb.append(node.getName());
-
- if (node.getParameterTypes() != null) {
- sb.append('(');
- for (int i = 0; i < node.getParameterTypes().size(); i++) {
- sb.append(String.valueOf(node.getParameterTypes().get(i)));
- sb.append(' ');
- sb.append((String) node.getParameterNames().get(i));
- if (i < node.getParameterTypes().size() - 1) {
- sb.append(", ");
- }
- }
- sb.append(')');
- }
-
- return sb.toString();
- }
-
- public static boolean isAnonymous(IProgramElement node) {
- boolean isIntName = true;
- try {
- Integer.valueOf(node.getName());
- } catch (NumberFormatException nfe) {
- // !!! using exceptions for logic, fix
- isIntName = false;
- }
- // System.err.println(">>>>>>>> " + node.getName());
- return isIntName || node.getName().startsWith("new ");
- // return isIntName;
- // if (!isIntName) {
- //
- // return node.getName().startsWith("new ");
- // } else {
- // return false;
- // }
- }
-
- /**
- * @return same path, but ending in ".java" instead of ".aj"
- */
- public static String translateAjPathName(String path) {
- if (path.endsWith(".aj")) {
- path = path.substring(0, path.lastIndexOf(".aj")) + ".java";
- }
- return path;
- }
-}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java
deleted file mode 100644
index 6b5c816f7..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java
+++ /dev/null
@@ -1,230 +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 Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * Mik Kersten port to AspectJ 1.1+ code base
- * ******************************************************************/
-
-package org.aspectj.tools.ajdoc;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
-import org.aspectj.asm.AsmManager;
-import org.aspectj.asm.IProgramElement;
-import org.aspectj.util.FileUtil;
-
-/**
- * @author Mik Kersten
- */
-class StubFileGenerator {
-
- static Hashtable declIDTable = null;
-
- static void doFiles(AsmManager model, Hashtable table, File[] inputFiles, File[] signatureFiles) throws DocException {
- declIDTable = table;
- for (int i = 0; i < inputFiles.length; i++) {
- processFile(model, inputFiles[i], signatureFiles[i]);
- }
- }
-
- static void processFile(AsmManager model, File inputFile, File signatureFile) throws DocException {
- try {
- // Special Case for package-info.java just copy file directly.
- if(signatureFile.getName().equals("package-info.java")) {
- FileUtil.copyFile(inputFile, signatureFile);
- return;
- }
-
- String path = StructureUtil.translateAjPathName(signatureFile.getCanonicalPath());
- PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(path)));
-
- String packageName = StructureUtil.getPackageDeclarationFromFile(model, inputFile);
-
- if (packageName != null && packageName != "") {
- writer.println("package " + packageName + ";");
- }
-
- IProgramElement fileNode = model.getHierarchy().findElementForSourceFile(inputFile.getAbsolutePath());
- for (Iterator it = fileNode.getChildren().iterator(); it.hasNext();) {
- IProgramElement node = (IProgramElement) it.next();
- if (node.getKind().isPackageDeclaration()) {
- // skip
- } else if (node.getKind().equals(IProgramElement.Kind.IMPORT_REFERENCE)) {
- processImportDeclaration(node, writer);
- } else {
- try {
- processTypeDeclaration(node, writer);
- } catch (DocException d) {
- throw new DocException("File name invalid: " + inputFile.toString());
- }
- }
- }
-
- // if we got an error we don't want the contents of the file
- writer.close();
- } catch (IOException e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- }
- }
-
- 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.println(importNode.getSourceSignature());
- }
- }
-
- 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>")) {
- 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 DocException {
- for (Iterator it = members.iterator(); it.hasNext();) {
- IProgramElement member = (IProgramElement) it.next();
-
- if (member.getKind().isType()) {
- if (!member.getParent().getKind().equals(IProgramElement.Kind.METHOD) && !StructureUtil.isAnonymous(member)) {// don't
- // print
- // anonymous
- // types
- // System.err.println(">>>>>>>>>>>>>" + member.getName() + "<<<<" + member.getParent());
- processTypeDeclaration(member, writer);
- }
- } else {
- String formalComment = addDeclID(member, member.getFormalComment());
- ;
- writer.println(formalComment);
-
- String signature = "";
- if (!member.getKind().equals(IProgramElement.Kind.POINTCUT)
- && !member.getKind().equals(IProgramElement.Kind.ADVICE)) {
- signature = member.getSourceSignature();// StructureUtil.genSignature(member);
- if (member.getKind().equals(IProgramElement.Kind.ENUM_VALUE)) {
- int index = members.indexOf(member);
- if ((index + 1 < members.size())
- && ((IProgramElement) members.get(index + 1)).getKind().equals(IProgramElement.Kind.ENUM_VALUE)) {
- // if the next member is also an ENUM_VALUE:
- signature = signature + ",";
- } else {
- signature = signature + ";";
- }
- }
- }
-
- if (member.getKind().isDeclare()) {
- // System.err.println("> Skipping declare (ajdoc limitation): " + member.toLabelString());
- } else if (signature != null && signature != "" && !member.getKind().isInterTypeMember()
- && !member.getKind().equals(IProgramElement.Kind.INITIALIZER) && !StructureUtil.isAnonymous(member)) {
- writer.print(signature);
- } else {
- // System.err.println(">> skipping: " + member.getKind());
- }
-
- if (member.getKind().equals(IProgramElement.Kind.METHOD)
- || member.getKind().equals(IProgramElement.Kind.CONSTRUCTOR)) {
- if (member.getParent().getKind().equals(IProgramElement.Kind.INTERFACE) || signature.indexOf("abstract ") != -1) {
- writer.println(";");
- } else {
- writer.println(" { }");
- }
-
- } else if (member.getKind().equals(IProgramElement.Kind.FIELD)) {
- // writer.println(";");
- }
- }
- }
- }
-
- /**
- * Translates "aspect" to "class", as long as its not ".aspect"
- */
- private static String genSourceSignature(IProgramElement classNode) {
- String signature = classNode.getSourceSignature();
- if (signature != null) {
- int index = signature.indexOf("aspect");
- if (index == 0 || (index != -1 && signature.charAt(index - 1) != '.')) {
- signature = signature.substring(0, index) + "class " + signature.substring(index + 6, signature.length());
- }
- }
- return signature;
- }
-
- static int nextDeclID = 0;
-
- static String addDeclID(IProgramElement decl, String formalComment) {
- String declID = "" + ++nextDeclID;
- declIDTable.put(declID, decl);
- return addToFormal(formalComment, Config.DECL_ID_STRING + declID + Config.DECL_ID_TERMINATOR);
- }
-
- /**
- * We want to go: just before the first period just before the first @ just before the end of the comment
- *
- * Adds a place holder for the period ('#') if one will need to be replaced.
- */
- static String addToFormal(String formalComment, String string) {
- if (string == null || string.equals("")) {
- return formalComment;
- }
- // boolean appendPeriod = true;
- if ((formalComment == null) || formalComment.equals("")) {
- // formalComment = "/**\n * . \n */\n";
- formalComment = "/**\n * \n */\n";
- // appendPeriod = false;
- }
- formalComment = formalComment.trim();
-
- int atsignPos = formalComment.indexOf('@');
- int endPos = formalComment.indexOf("*/");
- int periodPos = formalComment.indexOf("/**");
- int position = 0;
- String periodPlaceHolder = "";
- if (periodPos != -1) {
- position = periodPos + 3;// length of "/**"
- } else if (atsignPos != -1) {
- string = string + "\n * ";
- position = atsignPos;
- } else if (endPos != -1) {
- string = "* " + string + "\n";
- position = endPos;
- } else {
- // !!! perhaps this error should not be silent
- throw new Error("Failed to append to formal comment for comment: " + formalComment);
- }
-
- return formalComment.substring(0, position) + periodPlaceHolder + string + formalComment.substring(position);
- }
-
-}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Util.java b/ajdoc/src/org/aspectj/tools/ajdoc/Util.java
deleted file mode 100644
index c5eb5f921..000000000
--- a/ajdoc/src/org/aspectj/tools/ajdoc/Util.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten initial implementation
- * ******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-/**
- * @author Mik Kersten
- */
-public class Util {
-
- public static boolean isExecutingOnJava5() {
- String version = System.getProperty("java.class.version","44.0");
- return version.equals("49.0");
- }
-
-}