+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="/asm"/>
- <classpathentry kind="src" path="/org.aspectj.ajdt.core"/>
- <classpathentry kind="src" path="/bridge"/>
- <classpathentry kind="src" path="/util"/>
- <classpathentry kind="src" path="testsrc"/>
- <classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/>
- <classpathentry kind="var" path="JAVA_HOME/lib/tools.jar"/>
- <classpathentry kind="var" path="JRE15_LIB"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="/asm"/>
+ <classpathentry kind="src" path="/org.aspectj.ajdt.core"/>
+ <classpathentry kind="src" path="/bridge"/>
+ <classpathentry kind="src" path="/util"/>
+ <classpathentry kind="src" path="testsrc"/>
+ <classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/>
+ <classpathentry kind="var" path="JAVA_HOME/lib/tools.jar"/>
+ <classpathentry kind="var" path="JRE15_LIB"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
+++ /dev/null
-ajdocworkingdir
-bin
-bintest
+++ /dev/null
-
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ajdoc</name>
- <comment></comment>
- <projects>
- <project>asm</project>
- <project>bridge</project>
- <project>org.aspectj.ajdt.core</project>
- <project>util</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.compliance=1.7
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
+++ /dev/null
-#Thu Oct 06 08:06:04 PDT 2005
-eclipse.preferences.version=1
-internal.default.compliance=default
+++ /dev/null
-<?xml version="1.0"?>
-<!-- see ../build/*.html for explanation -->
-<project name="ajdoc" default="test" basedir=".">
- <import file="${basedir}/../build/build.xml"/>
-</project>
-
-
\ No newline at end of file
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectj-parent</artifactId>
+ <version>1.9.3.BUILD-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>ajdoc</artifactId>
+ <packaging>jar</packaging>
+ <name>ajdoc</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>bridge</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>asm</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>org.aspectj.ajdt.core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/* *******************************************************************
+ * 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();
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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";
+
+}
--- /dev/null
+/* *******************************************************************
+ * 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);
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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> ";
+ 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> ";
+ 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> \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> \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 += " ";
+ }
+ // 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>" + " Declared 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() + " ";
+ }
+ 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 = " "; // !!!
+ 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(" Advises:", 1);
+ public static final HtmlRelationshipKind ADVISED_BY = new HtmlRelationshipKind(" Advised by:", 2);
+ public static final HtmlRelationshipKind MATCHED_BY = new HtmlRelationshipKind(" Matched by:", 3);
+ public static final HtmlRelationshipKind MATCHES_DECLARE = new HtmlRelationshipKind(" Matches declare:", 4);
+ public static final HtmlRelationshipKind DECLARED_ON = new HtmlRelationshipKind(" Declared on:", 5);
+ public static final HtmlRelationshipKind ASPECT_DECLARATIONS = new HtmlRelationshipKind(" Aspect declarations:",
+ 6);
+ public static final HtmlRelationshipKind SOFTENS = new HtmlRelationshipKind(" Softens:", 7);
+ public static final HtmlRelationshipKind SOFTENED_BY = new HtmlRelationshipKind(" Softened by:", 8);
+ public static final HtmlRelationshipKind ANNOTATES = new HtmlRelationshipKind(" Annotates:", 9);
+ public static final HtmlRelationshipKind ANNOTATED_BY = new HtmlRelationshipKind(" Annotated by:", 10);
+ public static final HtmlRelationshipKind USES_POINTCUT = new HtmlRelationshipKind(" Uses pointcut:", 11);
+ public static final HtmlRelationshipKind POINTCUT_USED_BY = new HtmlRelationshipKind(" Pointcut used by:",
+ 12);
+
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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();
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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;
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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;
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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);
+ }
+
+}
--- /dev/null
+/* *******************************************************************
+ * 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");
+ }
+
+}
+++ /dev/null
-/* *******************************************************************
- * 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();
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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";
-
-}
+++ /dev/null
-/* *******************************************************************
- * 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);
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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> ";
- 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> ";
- 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> \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> \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 += " ";
- }
- // 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>" + " Declared 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() + " ";
- }
- 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 = " "; // !!!
- 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(" Advises:", 1);
- public static final HtmlRelationshipKind ADVISED_BY = new HtmlRelationshipKind(" Advised by:", 2);
- public static final HtmlRelationshipKind MATCHED_BY = new HtmlRelationshipKind(" Matched by:", 3);
- public static final HtmlRelationshipKind MATCHES_DECLARE = new HtmlRelationshipKind(" Matches declare:", 4);
- public static final HtmlRelationshipKind DECLARED_ON = new HtmlRelationshipKind(" Declared on:", 5);
- public static final HtmlRelationshipKind ASPECT_DECLARATIONS = new HtmlRelationshipKind(" Aspect declarations:",
- 6);
- public static final HtmlRelationshipKind SOFTENS = new HtmlRelationshipKind(" Softens:", 7);
- public static final HtmlRelationshipKind SOFTENED_BY = new HtmlRelationshipKind(" Softened by:", 8);
- public static final HtmlRelationshipKind ANNOTATES = new HtmlRelationshipKind(" Annotates:", 9);
- public static final HtmlRelationshipKind ANNOTATED_BY = new HtmlRelationshipKind(" Annotated by:", 10);
- public static final HtmlRelationshipKind USES_POINTCUT = new HtmlRelationshipKind(" Uses pointcut:", 11);
- public static final HtmlRelationshipKind POINTCUT_USED_BY = new HtmlRelationshipKind(" Pointcut used by:",
- 12);
-
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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();
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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;
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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;
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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);
- }
-
-}
+++ /dev/null
-/* *******************************************************************
- * 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");
- }
-
-}
--- /dev/null
+package org.aspectj.tools.ajdoc;
+/* *******************************************************************
+ * 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
+ * ******************************************************************/
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * @author Mik Kersten
+ */
+public class AjdocModuleTests {
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AjdocModuleTests.class.getName());
+ suite.addTest(AjdocTests.suite());
+ return suite;
+ }
+}
--- /dev/null
+/********************************************************************
+ * 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - iniital version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.util.LangUtil;
+
+/**
+ * Helper class to check whether the ajdoc contains the expected
+ * information.
+ */
+public class AjdocOutputChecker {
+
+ /**
+ * Checks whether the given html file contains the required String.
+ *
+ * @param htmlFile
+ * @param requiredString
+ * @return true if the file contains the given string or
+ * false otherwise (or if the file is null or not an html file)
+ * @throws Exception
+ */
+ public static boolean containsString(File htmlFile,
+ String requiredString) throws Exception {
+ if ((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html")) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf(requiredString) != -1) {
+ reader.close();
+ return true;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+
+ /**
+ * Returns those strings from the given array which aren't in the html file.
+ *
+ * @param htmlFile
+ * @param an array of requiredStrings
+ * @return a List of those strings not found
+ * @throws Exception
+ */
+ public static List<String> getMissingStringsInFile(File htmlFile, String[] requiredStrings) throws Exception {
+ List<String> missingStrings = new ArrayList<String>();
+ for (int i = 0; i < requiredStrings.length; i++) {
+ String string = requiredStrings[i];
+ if (!containsString(htmlFile, string)) {
+ missingStrings.add(string);
+ }
+ }
+ return missingStrings;
+ }
+
+ /**
+ * Checks whether the section of the html file contains the
+ * required String
+ *
+ * @param htmlFile
+ * @param requiredString
+ * @param sectionHeader
+ * @return true if the file contains the given string within the
+ * required section or false otherwise (or if the file is null or
+ * not an html file)
+ * @throws Exception
+ */
+ public static boolean containsStringWithinSection(File htmlFile,
+ String requiredString, String sectionHeader) throws Exception {
+ if ((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html")) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf(sectionHeader) != -1) {
+ String nextLine = reader.readLine();
+ while (nextLine != null &&
+ (nextLine.indexOf("========") == -1)) {
+ if (nextLine.indexOf(requiredString) != -1) {
+ reader.close();
+ return true;
+ }
+ nextLine = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+
+ /**
+ * Returns those strings from the given array which aren't in the
+ * ajdoc html file
+ *
+ * @param htmlFile
+ * @param an array of requiredStrings
+ * @param sectionHeader
+ * @return List of those requiredStrings not found
+ * @throws Exception
+ */
+ public static List /*String*/ getMissingStringsInSection(File htmlFile,
+ String[] requiredStrings, String sectionHeader) throws Exception {
+ List missingStrings = new ArrayList();
+ for (int i = 0; i < requiredStrings.length; i++) {
+ String string = requiredStrings[i];
+ if (!containsStringWithinSection(htmlFile,string,sectionHeader)) {
+ missingStrings.add(string);
+ }
+ }
+ return missingStrings;
+ }
+
+ /**
+ * Returns whether the class data section has the expected
+ * relationship and target i.e. have the relationships been
+ * applied to the type.
+ *
+ * @param the ajdoc html file
+ * @param the detail sectionHeader, for example "DECLARE DETAIL SUMMARY"
+ * @param the source of the relationship, for example "Point()"
+ * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY
+ * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\""
+ * @return true if the section contains the expected source/relationship/target,
+ * false otherwise
+ */
+ public static boolean classDataSectionContainsRel(File htmlFile,
+ HtmlDecorator.HtmlRelationshipKind relationship,
+ String target) throws Exception {
+ if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf("START OF CLASS DATA") != -1) {
+ // found the required class data section
+ String subLine = reader.readLine();
+ while(subLine != null
+ && (subLine.indexOf("========") == -1)){
+ int relIndex = subLine.indexOf(relationship.toString());
+ int targetIndex = subLine.indexOf(target);
+ if ((relIndex != -1) && (targetIndex != -1)) {
+ reader.close();
+ if (relIndex < targetIndex) {
+ return true;
+ }
+ return false;
+ }
+ subLine = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+
+ /**
+ * Returns whether the supplied source has the expected
+ * relationship and target within the given detail section
+ *
+ * @param the ajdoc html file
+ * @param the detail sectionHeader, for example "DECLARE DETAIL SUMMARY"
+ * @param the source of the relationship, for example "Point()"
+ * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY
+ * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\""
+ * @return true if the section contains the expected source/relationship/target,
+ * false otherwise
+ */
+ public static boolean detailSectionContainsRel(File htmlFile,
+ String sectionHeader, String source,
+ HtmlDecorator.HtmlRelationshipKind relationship,
+ String target) throws Exception {
+ if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
+ return false;
+ }
+ if (sectionHeader.indexOf("DETAIL") == -1) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf(sectionHeader) != -1) {
+ // found the required main section
+ String nextLine = reader.readLine();
+ while (nextLine != null && (nextLine.indexOf("========") == -1)) {
+ // On JDK11 it looks like <a id="doIt()"> on earlier JDKs it can look like <a name="doit">
+ if ((LangUtil.is11VMOrGreater() && nextLine.indexOf("ID=\""+source+"\"") != -1 || nextLine.indexOf("id=\""+source+"\"") != -1) ||
+ nextLine.indexOf("NAME=\""+source+"\"") != -1 || nextLine.indexOf("name=\""+source+"\"") != -1) {
+ // found the required subsection
+ String subLine = reader.readLine();
+ while(subLine != null
+ && (subLine.indexOf("========") == -1)
+ && (subLine.indexOf("NAME") == -1 && subLine.indexOf("name") == -1)) {
+ int relIndex = subLine.indexOf(relationship.toString());
+ int targetIndex = subLine.indexOf(target);
+ if ((relIndex != -1) && (targetIndex != -1)) {
+ reader.close();
+ if (relIndex < targetIndex) {
+ return true;
+ }
+ return false;
+ }
+ subLine = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+ nextLine = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+
+ /**
+ * Returns whether the supplied source has the expected
+ * relationship and target within the given summary section
+ *
+ * @param the ajdoc html file
+ * @param the detail sectionHeader, for example "DECLARE SUMMARY"
+ * @param the source of the relationship, for example "Point()"
+ * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY
+ * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\""
+ * @return true if the section contains the expected source/relationship/target,
+ * false otherwise
+ */
+ public static boolean summarySectionContainsRel(
+ File htmlFile,
+ String sectionHeader,
+ String source,
+ HtmlDecorator.HtmlRelationshipKind relationship,
+ String target) throws Exception {
+ if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
+ return false;
+ }
+ if (sectionHeader.indexOf("SUMMARY") == -1) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf(sectionHeader) != -1) {
+ // found the required main section
+ String nextLine = reader.readLine();
+ while (nextLine != null && (nextLine.indexOf("========") == -1)) {
+ if (nextLine.indexOf(source) != -1) {
+ // found the required subsection
+ String subLine = nextLine;
+ while(subLine != null
+ && (subLine.indexOf("========") == -1)
+ && (subLine.indexOf("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">") == -1)) {
+ int relIndex = subLine.indexOf(relationship.toString());
+ int targetIndex = subLine.indexOf(target);
+ if ((relIndex != -1) && (targetIndex != -1)) {
+ reader.close();
+ if (relIndex < targetIndex) {
+ return true;
+ }
+ return false;
+ }
+ subLine = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+ nextLine = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+
+}
--- /dev/null
+/********************************************************************
+ * 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - iniital version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.aspectj.tools.ajc.Ajc;
+import org.aspectj.util.LangUtil;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+/**
+ * This class is the super class of all Ajdoc tests. It creates a sandbox directory and provides utility methods for copying over
+ * the test projects and running the ajdoc command
+ */
+public class AjdocTestCase extends TestCase {
+
+ public final static String testdataSrcDir = "../ajdoc/testdata";
+ protected static File sandboxDir;
+ private String docOutdir, projectDir;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ docOutdir = null;
+ projectDir = null;
+ // Create a sandbox in which to work
+ sandboxDir = Ajc.createEmptySandbox();
+ // create the ajdocworkdingdir in the sandbox
+ Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ // reset where ajdocworkingdir is created
+ Main.resetOutputWorkingDir();
+ }
+
+ /**
+ * Fill in the working directory with the project files and create a doc top level directory in which to generate the ajdoc
+ * output.
+ */
+ public void initialiseProject(String projectName) {
+ File projectSrc = new File(testdataSrcDir + File.separatorChar + projectName);
+ File destination = new File(getWorkingDir(), projectName);
+ if (!destination.exists()) {
+ destination.mkdir();
+ }
+ copy(projectSrc, destination);
+ projectDir = destination.getAbsolutePath();
+
+ File docDestination = new File(getWorkingDir().toString() + File.separatorChar + projectName, "doc");
+ if (!docDestination.exists()) {
+ docDestination.mkdir();
+ }
+ docOutdir = docDestination.getAbsolutePath();
+ }
+
+ /**
+ * @return the working directory
+ */
+ protected File getWorkingDir() {
+ return sandboxDir;
+ }
+
+ /**
+ * @return the absolute path of the project directory for example c:\temp\ajcSandbox\ajcTest15200.tmp\myProject
+ */
+ protected String getAbsoluteProjectDir() {
+ return projectDir;
+ }
+
+ /**
+ * @return the absolute path of the doc output directory for example c:\temp\ajcSandbox\ajcTest15200.tmp\myProject\doc
+ */
+ protected String getAbsolutePathOutdir() {
+ return docOutdir;
+ }
+
+ /**
+ * Copy the contents of some directory to another location - the copy is recursive.
+ */
+ private void copy(File from, File to) {
+ String contents[] = from.list();
+ if (contents == null)
+ return;
+ for (int i = 0; i < contents.length; i++) {
+ String string = contents[i];
+ File f = new File(from, string);
+ File t = new File(to, string);
+
+ if (f.isDirectory()) {
+ t.mkdir();
+ copy(f, t);
+ } else if (f.isFile()) {
+ try {
+ org.aspectj.util.FileUtil.copyFile(f, t);
+ } catch (IOException e) {
+ throw new AssertionFailedError("Unable to copy " + f + " to " + t);
+ }
+ }
+ }
+ }
+
+ /**
+ * Run the ajdoc command with the given visibility argument, the default source level and the given input files.
+ */
+ public void runAjdoc(String visibility, File[] inputFiles) {
+ if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
+ fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
+ }
+ if (inputFiles.length == 0) {
+ fail("need to pass some files into ajdoc");
+ }
+ String[] args = new String[5 + inputFiles.length];
+ args[0] = "-" + visibility;
+ args[1] = "-classpath";
+ args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[3] = "-d";
+ args[4] = getAbsolutePathOutdir();
+ for (int i = 0; i < inputFiles.length; i++) {
+ args[5 + i] = inputFiles[i].getAbsolutePath();
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the default visibility and source level and the given input files.
+ */
+ public void runAjdoc(File[] inputFiles) {
+ if (inputFiles.length == 0) {
+ fail("need to pass some files into ajdoc");
+ }
+ String[] args = new String[4 + inputFiles.length];
+ args[0] = "-classpath";
+ args[1] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[2] = "-d";
+ args[3] = getAbsolutePathOutdir();
+ for (int i = 0; i < inputFiles.length; i++) {
+ args[4 + i] = inputFiles[i].getAbsolutePath();
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the default visibility and source level, the given input files and the given aspectj options
+ */
+ public void runAjdoc(File[] inputFiles, String sourceLevel, String[] ajOptions) {
+ if (inputFiles.length == 0) {
+ fail("need to pass some files into ajdoc");
+ }
+ if (!sourceLevel.equals("1.3") &&
+ !sourceLevel.equals("1.4") &&
+ !sourceLevel.equals("1.5") &&
+ !sourceLevel.equals("1.6") &&
+ !sourceLevel.equals("1.7") &&
+ !sourceLevel.equals("1.8") &&
+ !sourceLevel.equals("1.9") &&
+ !sourceLevel.equals("10")) {
+ fail("need to pass ajdoc '1.3' > '1.9' as the source level");
+ }
+ String[] args = new String[6 + inputFiles.length + ajOptions.length];
+ args[0] = "-source";
+ args[1] = sourceLevel;
+ args[2] = "-classpath";
+ args[3] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[4] = "-d";
+ args[5] = getAbsolutePathOutdir();
+ for (int i = 0; i < ajOptions.length; i++) {
+ args[6 + i] = ajOptions[i];
+ }
+ for (int i = 0; i < inputFiles.length; i++) {
+ args[6 + i + ajOptions.length] = inputFiles[i].getAbsolutePath();
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the given visibility argument, the given source level argument and the given input files.
+ */
+ public void runAjdoc(String visibility, String sourceLevel, File[] inputFiles) {
+ if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
+ fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
+ }
+ if (!sourceLevel.equals("1.3") &&
+ !sourceLevel.equals("1.4") &&
+ !sourceLevel.equals("1.5") &&
+ !sourceLevel.equals("1.6") &&
+ !sourceLevel.equals("1.7") &&
+ !sourceLevel.equals("1.8") &&
+ !sourceLevel.equals("1.9") &&
+ !sourceLevel.startsWith("9") &&
+ !sourceLevel.startsWith("10")) {
+ fail("need to pass suitable version to ajdoc as the source level");
+ }
+ if (inputFiles.length == 0) {
+ fail("need to pass some files into ajdoc");
+ }
+ for (int i = 0; i < inputFiles.length; i++) {
+ if (!inputFiles[i].exists()) {
+ fail(inputFiles[i].getAbsolutePath() + " does not exist");
+ }
+ }
+
+ String[] args = new String[7 + inputFiles.length];
+ args[0] = "-" + visibility;
+ args[1] = "-source";
+ args[2] = sourceLevel;
+ args[3] = "-classpath";
+ StringBuilder classpath = new StringBuilder();
+ if (LangUtil.is19VMOrGreater()) {
+ classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator);
+ }
+ classpath.append(AjdocTests.ASPECTJRT_PATH.getPath());
+ args[4] = classpath.toString();
+ args[5] = "-d";
+ args[6] = getAbsolutePathOutdir();
+ // args[7] = "-Xset:minimalModel=false";
+ for (int i = 0; i < inputFiles.length; i++) {
+ args[7 + i] = inputFiles[i].getAbsolutePath();
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the given visibility argument, the default source level and the given input directories.
+ */
+ public void runAjdoc(String visibility, String[] directoryNames) {
+ if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
+ fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
+ }
+ if (directoryNames.length == 0) {
+ fail("need to pass some directories into ajdoc");
+ }
+ String[] args = new String[7 + directoryNames.length];
+ args[0] = "-" + visibility;
+ args[1] = "-classpath";
+ args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[3] = "-d";
+ args[4] = getAbsolutePathOutdir();
+ args[5] = "-sourcepath";
+ args[6] = getAbsoluteProjectDir();
+ for (int i = 0; i < directoryNames.length; i++) {
+ args[7 + i] = directoryNames[i];
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the default visibility and source level and the given input directories.
+ */
+ public void runAjdoc(String[] directoryNames) {
+ if (directoryNames.length == 0) {
+ fail("need to pass some directories into ajdoc");
+ }
+ String[] args = new String[6 + directoryNames.length];
+ args[0] = "-classpath";
+ args[1] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[2] = "-d";
+ args[3] = getAbsolutePathOutdir();
+ args[4] = "-sourcepath";
+ args[5] = getAbsoluteProjectDir();
+ for (int i = 0; i < directoryNames.length; i++) {
+ args[6 + i] = directoryNames[i];
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the given visibility argument, the default source level and the given input directories.
+ */
+ public void runAjdoc(String visibility, String lstFile) {
+ if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
+ fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
+ }
+
+ String[] args = new String[8];
+ args[0] = "-" + visibility;
+ args[1] = "-classpath";
+ args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[3] = "-d";
+ args[4] = getAbsolutePathOutdir();
+ args[5] = "-sourcepath";
+ args[6] = getAbsoluteProjectDir();
+ args[7] = "@" + getAbsoluteProjectDir() + File.separatorChar + lstFile;
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the given options
+ */
+ public void runAjdoc(List options) {
+ String[] args = new String[options.size()];
+ int i = 0;
+ for (Iterator iter = options.iterator(); iter.hasNext();) {
+ String element = (String) iter.next();
+ args[i] = element;
+ i++;
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.tools.ajdoc;
+
+import java.io.File;
+
+import org.aspectj.util.FileUtil;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class AjdocTests extends TestCase {
+
+ public static File ASPECTJRT_PATH;
+
+ static {
+ String[] paths = { "sp:aspectjrt.path", "sp:aspectjrt.jar",
+ "../lib/test/aspectjrt.jar", "../aj-build/jars/aspectj5rt-all.jar",
+ "../aj-build/jars/runtime.jar",
+ "../runtime/bin"};
+ ASPECTJRT_PATH = FileUtil.getBestFile(paths);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AjdocTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(DeclareFormsTest.class);
+ suite.addTestSuite(SpacewarTestCase.class);
+ suite.addTestSuite(PatternsTestCase.class);
+ suite.addTestSuite(CoverageTestCase.class);
+ suite.addTestSuite(ITDTest.class);
+ suite.addTestSuite(FullyQualifiedArgumentTest.class);
+ suite.addTestSuite(EnumTest.class);
+ suite.addTestSuite(PointcutVisibilityTest.class);
+ suite.addTestSuite(ExecutionTestCase.class);
+ suite.addTestSuite(BugTests.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
--- /dev/null
+/********************************************************************
+ * Copyright (c) 2006 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - initial version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class BugTests extends AjdocTestCase {
+
+ public void testPr160302() throws Exception {
+ initialiseProject("pr160302");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ runAjdoc(files);
+ assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
+ File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
+ if (!html.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
+ }
+ assertFalse("expected all decorating tags to be removed but found that they" +
+ " weren't",AjdocOutputChecker.containsString(html, Config.DECL_ID_STRING));
+ }
+
+ /**
+ * Passing the "-Xlint:error" option through to the compiler should
+ * cause the ajc build to fail because the advice did not match
+ */
+ public void testPr148906_1() {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")};
+ String[] ajOptions = {new String("-Xlint:error")};
+ runAjdoc(files,"1.5",ajOptions);
+ assertTrue("expected ajc to fail but it did not", Main.hasAborted());
+ assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" +
+ " failed instead with " + Main.getErrors()[0].getMessage(),
+ "advice defined in AdviceDidNotMatch has not been applied [Xlint:adviceDidNotMatch]",
+ Main.getErrors()[0].getMessage());
+ }
+
+ /**
+ * Passing the "-Xlintfile" option through to the compiler should
+ * cause the ajc build to fail because the advice did not match
+ */
+ public void testPr148906_2() {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")};
+ String[] ajOptions = {new String("-Xlintfile"), new String(getAbsoluteProjectDir() + File.separator + "Xlint.properties")};
+ runAjdoc(files,"1.5",ajOptions);
+ assertTrue("expected ajc to fail but it did not", Main.hasAborted());
+ assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" +
+ " failed instead with " + Main.getErrors()[0].getMessage(),
+ "advice defined in AdviceDidNotMatch has not been applied [Xlint:adviceDidNotMatch]",
+ Main.getErrors()[0].getMessage());
+ }
+
+ /**
+ * Passing the -aspectpath option though to the compiler should
+ * result in relationships being displayed
+ */
+ public void testPr148906_3() throws Exception {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ String[] ajOptions = {new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
+ runAjdoc(files,"1.6",ajOptions);
+ assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
+ File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
+ if (!html.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
+ }
+ assertTrue("expected to find 'Advised by' in the html output but did " +
+ " not",AjdocOutputChecker.containsString(html,
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY.getName()));
+ }
+
+ /**
+ * Passing an option starting with "-" that doesn't require a second entry
+ * should mean everything is correctly given to the compiler. For example:
+ * '-outxml -aspectpath <file>" should mean both '-outxml' and the aspectpath
+ * options are given correctly.
+ */
+ public void testPr148906_4() throws Exception {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ String[] ajOptions = {new String("-outxml"),new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
+ runAjdoc(files,"1.6",ajOptions);
+ assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
+ File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
+ if (!html.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
+ }
+ assertTrue("expected to find 'Advised by' in the html output but did " +
+ " not",AjdocOutputChecker.containsString(html,
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY.getName()));
+ File aopFile = new File(getAbsolutePathOutdir() + File.separator
+ + "META-INF" + File.separator + "aop-ajc.xml");
+ assertTrue("couldn't find " + getAbsolutePathOutdir() + File.separator
+ + "META-INF" + File.separator + "aop-ajc.xml" ,
+ aopFile.exists());
+ }
+
+ /**
+ * Passing bogus option to ajc
+ */
+ public void testPr148906_5() throws Exception {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ String[] ajOptions = {new String("-bogus")};
+ runAjdoc(files,"1.5",ajOptions);
+ assertTrue("expected build of project to abort",Main.hasAborted());
+ }
+
+ /**
+ * Not passing any files to ajdoc should result in both the ajdoc
+ * and ajc usage messages
+ */
+ public void testPr148906_6() throws Exception {
+ initialiseProject("pr148906");
+ List options = new ArrayList();
+ options.add("-verbose");
+ runAjdoc(options);
+ assertTrue("expected the ajdoc usage message to be reported",Main.hasShownAjdocUsageMessage());
+ assertTrue("expected build of project to abort",Main.hasAborted());
+ }
+
+ /**
+ * javadoc comments should still appear even if preceded by
+ * 'normal' comments
+ */
+ public void testPr164356() throws Exception {
+ initialiseProject("pr164356");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ runAjdoc(files);
+ File htmlFile = new File(getAbsolutePathOutdir() + "/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() +
+ " (ajc aborted: " + Main.hasAborted() + ")");
+ }
+ String foo = "description of foo";
+ String bar = "description of bar";
+ String goo = "description of goo";
+ String bas = "description of bas";
+ assertTrue("expected method description 'description of foo' to appear" +
+ " in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, foo));
+ assertTrue("expected method description 'description of bar' to " +
+ "appear in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, bar));
+ assertFalse("didn't expect method description 'description of goo' to " +
+ "appear in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, goo));
+ assertTrue("expected method description 'description of bas' to appear" +
+ " in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, bas));
+ }
+
+ /**
+ * Comments for a constructor should be included in the ajdoc output
+ */
+ public void testPr164340() throws Exception {
+ initialiseProject("pr164340");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ runAjdoc(files);
+ File htmlFile = new File(getAbsolutePathOutdir() + "/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() +
+ " (ajc aborted: " + Main.hasAborted() + ")");
+ }
+ String methodDesc = "This is method foo";
+ String constDesc = "This is a constructor";
+ assertTrue("expected method description 'This is method foo' to appear" +
+ " in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, methodDesc));
+ assertTrue("expected constructor description 'This is a constructor' to " +
+ "appear in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, constDesc));
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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.List;
+
+import org.aspectj.util.LangUtil;
+
+/**
+ * A long way to go until full coverage, but this is the place to add more.
+ *
+ * @author Mik Kersten
+ */
+public class CoverageTestCase extends AjdocTestCase {
+
+ protected File file0,file1,aspect1,file2,file3,file4,file5,file6,file7,file8,file9,file10;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ initialiseProject("coverage");
+ createFiles();
+ }
+
+ public void testOptions() {
+ String[] args = {
+ "-private",
+ "-encoding",
+ "EUCJIS",
+ "-docencoding",
+ "EUCJIS",
+ "-charset",
+ "UTF-8",
+ "-classpath",
+ AjdocTests.ASPECTJRT_PATH.getPath(),
+ "-d",
+ getAbsolutePathOutdir(),
+ file0.getAbsolutePath(),
+ };
+ org.aspectj.tools.ajdoc.Main.main(args);
+ assertTrue(true);
+ }
+
+ /**
+ * Test the "-public" argument
+ */
+ public void testCoveragePublicMode() throws Exception {
+ File[] files = {file3,file9};
+ runAjdoc("public","9",files);
+
+ // have passed the "public" modifier as well as
+ // one public and one package visible class. There
+ // should only be ajdoc for the public class
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/PkgVisibleClass.html");
+ assertFalse("ajdoc for PkgVisibleClass shouldn't exist because passed" +
+ " the 'public' flag to ajdoc",htmlFile.exists());
+
+ htmlFile = new File(getAbsolutePathOutdir() + "/foo/PlainJava.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // check there's no private fields within the file, that
+ // the file contains the getI() method but doesn't contain
+ // the private ClassBar, Bazz and Jazz classes.
+ String[] strings = { "private", "getI()","ClassBar", "Bazz", "Jazz"};
+ List missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
+ assertEquals("There should be 4 missing strings",4,missing.size());
+ assertTrue(htmlFile.getName() + " should not contain the private modifier",missing.contains("private"));
+ assertTrue(htmlFile.getName() + " should not contain the private ClassBar class",missing.contains("ClassBar"));
+ assertTrue(htmlFile.getName() + " should not contain the private Bazz class",missing.contains("Bazz"));
+ assertTrue(htmlFile.getName() + " should not contain the private Jazz class",missing.contains("Jazz"));
+ }
+
+ /**
+ * Test that the ajdoc for an aspect has the title "Aspect"
+ */
+ public void testAJdocHasAspectTitle() throws Exception {
+ File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A.aj")};
+ runAjdoc("private","1.6",files);
+ File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/A.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?");
+ }
+ assertTrue(htmlFile.getAbsolutePath() + " should have Aspect A as it's title",
+ AjdocOutputChecker.containsString(htmlFile,"Aspect A"));
+ }
+
+ /**
+ * Test that the ajdoc for a class has the title "Class"
+ */
+ public void testAJdocHasClassTitle() throws Exception {
+ File[] files = {new File(getAbsoluteProjectDir() + "/pkg/C.java")};
+ runAjdoc("private","1.6",files);
+ File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?");
+ }
+ assertTrue(htmlFile.getAbsolutePath() + " should have Class C as it's title",
+ AjdocOutputChecker.containsString(htmlFile,"Class C"));
+
+ }
+
+ /**
+ * Test that the ajdoc for an inner aspect is entitled "Aspect" rather
+ * than "Class", but that the enclosing class is still "Class"
+ */
+ public void testInnerAspect() throws Exception {
+ File[] files = {file1, file2};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/ClassA.InnerAspect.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // ensure that the file is entitled "Aspect ClassA.InnerAspect" rather
+ // than "Class ClassA.InnerAspect"
+
+ String[] strings = null;
+ if (LangUtil.is18VMOrGreater()) {
+ strings = new String[] {
+ "Aspect ClassA.InnerAspect",
+ "<pre>static aspect <span class=\"typeNameLabel\">ClassA.InnerAspect</span>",
+ "Class ClassA.InnerAspect",
+ "<pre>static class <span class=\"typeNameLabel\">ClassA.InnerAspect</span>"};
+ }
+ else {
+ strings = new String[] {
+ "Aspect ClassA.InnerAspect",
+ "<PRE>static aspect <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>",
+ "Class ClassA.InnerAspect",
+ "<PRE>static class <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>"};
+ }
+ List<String> missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
+ StringBuilder buf = new StringBuilder();
+ for (String str:missingStrings) {
+ buf.append(str).append("\n");
+ }
+ buf.append("HTMLFILE=\n").append(htmlFile).append("\n");
+ assertEquals("There should be 2 missing strings:\n"+buf.toString(), 2, missingStrings.size());
+ assertTrue(htmlFile.getName() + " should not have Class as it's title",
+ missingStrings.contains("Class ClassA.InnerAspect"));
+ if (LangUtil.is18VMOrGreater()) {
+ assertTrue(htmlFile.getName() + " should not have class in its subtitle",
+ missingStrings.contains("<pre>static class <span class=\"typeNameLabel\">ClassA.InnerAspect</span>"));
+ }
+ else {
+ assertTrue(htmlFile.getName() + " should not have class in its subtitle",
+ missingStrings.contains("<PRE>static class <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>"));
+ }
+
+ // get the html file for the enclosing class
+ File htmlFileClass = new File(getAbsolutePathOutdir() + "/foo/ClassA.html");
+ if (!htmlFileClass.exists()) {
+ fail("couldn't find " + htmlFileClass.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // ensure that the file is entitled "Class ClassA" and
+ // has not been changed to "Aspect ClassA"
+ String[] classStrings = null;
+
+ if (LangUtil.is18VMOrGreater()) {
+ classStrings = new String[] {
+ "Class ClassA</h2>",
+ "public abstract class <span class=\"typeNameLabel\">ClassA</span>",
+ "Aspect ClassA</H2>",
+ "public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"};
+ }
+ else {
+ classStrings = new String[] {
+ "Class ClassA</H2>",
+ "public abstract class <B>ClassA</B><DT>extends java.lang.Object<DT>",
+ "Aspect ClassA</H2>",
+ "public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"};
+ }
+ List classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
+ assertEquals("There should be 2 missing strings:\n"+classMissing,2,classMissing.size());
+ assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>"));
+ if (LangUtil.is18VMOrGreater()) {
+ assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
+ classMissing.contains("public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"));
+ }
+ else {
+ assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
+ classMissing.contains("public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"));
+ }
+ }
+
+ /**
+ * Test that all the different types of advice appear
+ * with the named pointcut in it's description
+ */
+ public void testAdviceNamingCoverage() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdviceNamingCoverage.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ "after(): named..",
+ "afterReturning(int,int): namedWithArgs..",
+ "afterThrowing(): named..",
+ "before(): named..",
+ "around(int): namedWithOneArg..",
+ "before(int):",
+ "before(int): named()..",
+ "before():"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile, strings,"ADVICE DETAIL SUMMARY");
+ assertTrue(htmlFile.getName() + " should contain all advice in the Advice Detail section",missing.isEmpty());
+ missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile,strings,"ADVICE SUMMARY");
+ assertTrue(htmlFile.getName() + " should contain all advice in the Advice Summary section",missing.isEmpty());
+ }
+
+ /**
+ * Test that all the advises relationships appear in the
+ * Advice Detail and Advice Summary sections and that
+ * the links are correct
+ */
+ public void testAdvisesRelationshipCoverage() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ "before(): methodExecutionP..",
+ "HREF=\"../foo/Point.html#setX(int)\"",
+ "before(): constructorExecutionP..",
+ "HREF=\"../foo/Point.html#Point()\"",
+ "before(): callMethodP..",
+ "HREF=\"../foo/Point.html#changeX(int)\"",
+ "before(): callConstructorP..",
+ "HREF=\"../foo/Point.html#doIt()\"",
+ "before(): getP..",
+ "HREF=\"../foo/Point.html#getX()\"",
+ "before(): setP..",
+ "HREF=\"../foo/Point.html\"><tt>foo.Point</tt></A>, <A HREF=\"../foo/Point.html#Point()\"><tt>foo.Point.Point</tt></A>, <A HREF=\"../foo/Point.html#setX(int)\"",
+ "before(): initializationP..",
+ "HREF=\"../foo/Point.html#Point()\"",
+ "before(): staticinitializationP..",
+ "HREF=\"../foo/Point.html\"",
+ "before(): handlerP..",
+ "HREF=\"../foo/Point.html#doIt()\""
+ };
+
+ for (int i = 0; i < strings.length - 1; i = i+2) {
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"ADVICE DETAIL SUMMARY",strings[i],
+ HtmlDecorator.HtmlRelationshipKind.ADVISES,
+ strings[i+1]);
+ assertTrue(strings[i] + " should advise " + strings[i+1] +
+ " in the Advice Detail section", b);
+ }
+
+ for (int i = 0; i < strings.length - 1; i = i+2) {
+ boolean b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"ADVICE SUMMARY",strings[i],
+ HtmlDecorator.HtmlRelationshipKind.ADVISES,
+ strings[i+1]);
+ assertTrue(strings[i] + " should advise " + strings[i+1] +
+ " in the Advice Summary section", b);
+ }
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a method execution pointcut
+ */
+ public void testAdvisedByMethodExecution() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ toName("setX(int)"),
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): methodExecutionP..\""};
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a constructor execution pointcut
+ */
+ public void testAdvisedByConstructorExecution() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): constructorExecutionP..\""};
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== CONSTRUCTOR DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Constructor Detail should have " + strings[0]+" advised by " + strings[1],b);
+
+ // Pre-JDK 11:
+ // This precedes the line containing strings[1]
+ // <td class="colOne"><code><span class="memberNameLink"><a href="../foo/Point.html#Point--">Point</a></span>()</code>
+ // On JDK 11:
+ // This precedes the line containing strings[1]
+ // <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">Point</a></span>()</code></th>
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== CONSTRUCTOR SUMMARY",
+ LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Constructor Summary should have " + strings[0]+" advised by " + strings[1],b);
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a method call pointcut
+ */
+ public void testAdvisedByMethodCall() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ toName("changeX(int)"),
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): callMethodP..\""};
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a constructor call pointcut
+ */
+ public void testAdvisedByConstructorCall() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ toName("doIt()"),
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): callConstructorP..\""};
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a get pointcut
+ */
+ public void testAdvisedByGet() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ toName("getX()"),
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): getP..\""};
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a set pointcut
+ */
+ public void testAdvisedBySet() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String href = "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): setP..\"";
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName("setX(int)"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ href);
+ assertTrue("the Method Detail should have setX(int) advised by " + href,b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName("setX(int)"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ href);
+ assertTrue("the Method Summary should have setX(int) advised by " + href,b);
+
+ b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== CONSTRUCTOR DETAIL",
+ LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ href);
+ assertTrue("the Constructor Detail should have advised by " + href,b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== CONSTRUCTOR SUMMARY",
+ LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ href);
+ assertTrue("the Constructor Summary should have advised by " + href,b);
+
+ b = AjdocOutputChecker.classDataSectionContainsRel(
+ htmlFile,
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ href);
+ assertTrue("The class data section should have 'advised by " + href + "'",b);
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with an initialization pointcut
+ */
+ public void testAdvisedByInitialization() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): initializationP..\""};
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,
+ "=== CONSTRUCTOR DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Detail should have 'setX(int) advised by ... before()'",b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,
+ "=== CONSTRUCTOR SUMMARY",
+ LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Summary should have 'setX(int) advised by ... before()'",b);
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a staticinitialization pointcut
+ */
+ public void testAdvisedByStaticInitialization() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String href = "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): staticinitializationP..\"";
+ boolean b = AjdocOutputChecker.classDataSectionContainsRel(
+ htmlFile,
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ href);
+ assertTrue("The class data section should have 'advised by " + href + "'",b);
+ }
+
+ /**
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a handler pointcut
+ */
+ public void testAdvisedByHandler() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ toName("doIt()"),
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): handlerP..\""};
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
+ }
+
+ private String toName(String name) {
+ if (LangUtil.is18VMOrGreater() && !LangUtil.is11VMOrGreater()) {
+ name = name.replace('(','-');
+ name = name.replace(')','-');
+ }
+ return name;
+ }
+ /**
+ * Test that if have two before advice blocks from the same
+ * aspect affect the same method, then both appear in the ajdoc
+ */
+ public void testTwoBeforeAdvice() throws Exception {
+ File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ toName("amethod()"),
+ "HREF=\"../pkg/A2.html#before(): p..\"",
+ "HREF=\"../pkg/A2.html#before(): p2..\""};
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[1]);
+ assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
+
+ b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[2]);
+ assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[2],b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ strings[0],
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ strings[2]);
+ assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[2],b);
+ }
+
+ /**
+ * Test that there are no spurious "advised by" entries
+ * against the aspect in the ajdoc
+ */
+ public void testNoSpuriousAdvisedByRels() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String href = "foo.Point.setX(int)";
+ boolean b = AjdocOutputChecker.classDataSectionContainsRel(
+ htmlFile,
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ href);
+ assertFalse("The class data section should not have 'advised by " + href + "'",b);
+
+ }
+
+ public void testCoverage() {
+ File[] files = {aspect1,file0,file1,file2,file3,file4,file5,file6,
+ file7,file8,file9,file10};
+ runAjdoc("private","1.6",files);
+ }
+
+ /**
+ * Test that nested aspects appear with "aspect" in their title
+ * when the ajdoc file is written slightly differently (when it's
+ * written for this apsect, it's different than for testInnerAspect())
+ */
+ public void testNestedAspect() throws Exception {
+ File[] files = {file9};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.NestedAspect.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // ensure that the file is entitled "Aspect PkgVisibleClass.NestedAspect" rather
+ // than "Class PkgVisibleClass.NestedAspect"
+ String[] strings = null;
+ if (LangUtil.is18VMOrGreater()) {
+ strings = new String[] {
+ "Aspect PkgVisibleClass.NestedAspect",
+ "<pre>static aspect <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>",
+ "Class PkgVisibleClass.NestedAspect",
+ "<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>"};
+ }
+ else {
+ strings = new String[] {
+ "Aspect PkgVisibleClass.NestedAspect",
+ "<PRE>static aspect <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>",
+ "Class PkgVisibleClass.NestedAspect",
+ "<PRE>static class <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>"};
+ }
+ List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
+ assertEquals("There should be 2 missing strings",2,missing.size());
+ assertTrue(htmlFile.getName() + " should not have Class as it's title",missing.contains("Class PkgVisibleClass.NestedAspect"));
+ if (LangUtil.is18VMOrGreater()) {
+ assertTrue(htmlFile.getName() + " should not have class in its subtitle",
+ missing.contains("<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>"));
+ }
+ else {
+ assertTrue(htmlFile.getName() + " should not have class in its subtitle",
+ missing.contains("<PRE>static class <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>"));
+ }
+ // get the html file for the enclosing class
+ File htmlFileClass = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.html");
+ if (!htmlFileClass.exists()) {
+ fail("couldn't find " + htmlFileClass.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // ensure that the file is entitled "Class PkgVisibleClass" and
+ // has not been changed to "Aspect PkgVisibleClass"
+ String[] classStrings = null;
+ if (LangUtil.is18VMOrGreater()) {
+ classStrings = new String[] {
+ "Class PkgVisibleClass</h2>",
+ "<pre>class <span class=\"typeNameLabel\">PkgVisibleClass</span>",
+ "Aspect PkgVisibleClass</h2>",
+ "<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"};
+ }
+ else {
+ classStrings = new String[] {
+ "Class PkgVisibleClass</H2>",
+ "class <B>PkgVisibleClass</B><DT>extends java.lang.Object</DL>",
+ "Aspect PkgVisibleClass</H2>",
+ "aspect <B>PkgVisibleClass</B><DT>extends java.lang.Object<DT>"};
+ }
+ List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
+ assertEquals("There should be 2 missing strings",2,classMissing.size());
+ if (LangUtil.is18VMOrGreater()) {
+ assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
+ classMissing.contains("Aspect PkgVisibleClass</h2>"));
+ assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
+ classMissing.contains("<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"));
+ }
+ else {
+ assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect PkgVisibleClass</H2>"));
+ assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",classMissing.contains("aspect <B>PkgVisibleClass</B><DT>extends java.lang.Object<DT>"));
+ }
+ }
+
+ /**
+ * Test that in the case when you have a nested aspect whose
+ * name is part of the enclosing class, for example a class called
+ * ClassWithNestedAspect has nested aspect called NestedAspect,
+ * that the titles for the ajdoc are correct.
+ */
+ public void testNestedAspectWithSimilarName() throws Exception {
+ File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+ // ensure that the file is entitled "Aspect ClassWithNestedAspect.NestedAspect"
+ // rather than "Class ClassWithNestedAspect.NestedAspect"
+ String[] strings = null;
+ if (LangUtil.is18VMOrGreater()) {
+ strings = new String [] {
+ "Aspect ClassWithNestedAspect.NestedAspect",
+ "<pre>static aspect <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>",
+ "Class ClassWithNestedAspect.NestedAspect",
+ "<pre>static class <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>"};
+ }
+ else {
+ strings = new String [] {
+ "Aspect ClassWithNestedAspect.NestedAspect",
+ "<PRE>static a;spect <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>",
+ "Class ClassWithNestedAspect.NestedAspect",
+ "<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"};
+ }
+ List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
+ assertEquals("There should be 2 missing strings",2,missing.size());
+ assertTrue(htmlFile.getName() + " should not have Class as it's title",missing.contains("Class ClassWithNestedAspect.NestedAspect"));
+ if (LangUtil.is18VMOrGreater()) {
+ assertTrue(htmlFile.getName() + " should not have class in its subtitle",
+ missing.contains("<pre>static class <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>"));
+ }
+ else {
+ assertTrue(htmlFile.getName() + " should not have class in its subtitle",missing.contains("<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"));
+ }
+
+ // get the html file for the enclosing class
+ File htmlFileClass = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
+ if (htmlFileClass == null || !htmlFileClass.exists()) {
+ fail("couldn't find " + htmlFileClass.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // ensure that the file is entitled "Class ClassWithNestedAspect" and
+ // has not been changed to "Aspect ClassWithNestedAspect"
+ String[] classStrings = null;
+ if (LangUtil.is18VMOrGreater()) {
+ classStrings = new String[] {
+ "Class ClassWithNestedAspect</h2>",
+ "public class <span class=\"typeNameLabel\">ClassWithNestedAspect</span>",
+ "Aspect ClassWithNestedAspect</h2>",
+ "public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"};
+ }
+ else {
+ classStrings = new String[] {
+ "Class ClassWithNestedAspect</H2>",
+ "public class <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>",
+ "Aspect ClassWithNestedAspect</H2>",
+ "public aspect <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>"};
+ }
+ List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
+ assertEquals("There should be 2 missing strings",2,classMissing.size());
+ if (LangUtil.is18VMOrGreater()) {
+ assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
+ classMissing.contains("Aspect ClassWithNestedAspect</h2>"));
+ assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
+ classMissing.contains("public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"));
+ }
+ else {
+ assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
+ classMissing.contains("Aspect ClassWithNestedAspect</H2>"));
+ assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
+ classMissing.contains("public aspect <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>"));
+ }
+ }
+
+ /**
+ * Test that everythings being decorated correctly within the ajdoc
+ * for the aspect when the aspect is a nested aspect
+ */
+ public void testAdviceInNestedAspect() throws Exception {
+ File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"ADVICE DETAIL SUMMARY",
+ "before(): p..",
+ HtmlDecorator.HtmlRelationshipKind.ADVISES,
+ "HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"");
+ assertTrue("Should have 'before(): p.. advises HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"" +
+ "' in the Advice Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"ADVICE SUMMARY",
+ "before(): p..",
+ HtmlDecorator.HtmlRelationshipKind.ADVISES,
+ "HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"");
+ assertTrue("Should have 'before(): p.. advises HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"" +
+ "' in the Advice Summary section", b);
+
+ }
+
+ /**
+ * Test that everythings being decorated correctly within the ajdoc
+ * for the advised class when the aspect is a nested aspect
+ */
+ public void testAdvisedByInNestedAspect() throws Exception {
+ File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.containsString(htmlFile,"POINTCUT SUMMARY ");
+ assertFalse(htmlFile.getName() + " should not contain a pointcut summary section",b);
+ b = AjdocOutputChecker.containsString(htmlFile,"ADVICE SUMMARY ");
+ assertFalse(htmlFile.getName() + " should not contain an adivce summary section",b);
+ b = AjdocOutputChecker.containsString(htmlFile,"POINTCUT DETAIL ");
+ assertFalse(htmlFile.getName() + " should not contain a pointcut detail section",b);
+ b = AjdocOutputChecker.containsString(htmlFile,"ADVICE DETAIL ");
+ assertFalse(htmlFile.getName() + " should not contain an advice detail section",b);
+
+ b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"");
+ assertTrue("Should have 'amethod() advised by " +
+ "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"" +
+ "' in the Method Detail section", b);
+
+ b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p..");
+ assertFalse("Should not have the label " +
+ "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p.." +
+ " in the Method Detail section", b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"");
+ assertTrue("Should have 'amethod() advised by " +
+ "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"" +
+ "' in the Method Summary section", b);
+
+ b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p..");
+ assertFalse("Should not have the label " +
+ "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p.." +
+ " in the Method Summary section", b);
+
+ }
+
+ private void createFiles() {
+ file0 = new File(getAbsoluteProjectDir() + "/InDefaultPackage.java");
+ file1 = new File(getAbsoluteProjectDir() + "/foo/ClassA.java");
+ aspect1 = new File(getAbsoluteProjectDir() + "/foo/UseThisAspectForLinkCheck.aj");
+ file2 = new File(getAbsoluteProjectDir() + "/foo/InterfaceI.java");
+ file3 = new File(getAbsoluteProjectDir() + "/foo/PlainJava.java");
+ file4 = new File(getAbsoluteProjectDir() + "/foo/ModelCoverage.java");
+ file5 = new File(getAbsoluteProjectDir() + "/fluffy/Fluffy.java");
+ file6 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/Bunny.java");
+ file7 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/rocks/Rocks.java");
+ file8 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java");
+ file9 = new File(getAbsoluteProjectDir() + "/foo/PkgVisibleClass.java");
+ file10 = new File(getAbsoluteProjectDir() + "/foo/NoMembers.java");
+ }
+
+// public void testPlainJava() {
+// String[] args = { "-d",
+// getAbsolutePathOutdir(),
+// file3.getAbsolutePath() };
+// org.aspectj.tools.ajdoc.Main.main(args);
+// }
+
+}
--- /dev/null
+/* *******************************************************************
+ * 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.List;
+
+import org.aspectj.util.LangUtil;
+
+/**
+ * @author Mik Kersten
+ */
+public class DeclareFormsTest extends AjdocTestCase {
+
+ private String declareError = "declare error: quot;Illegal construct..quot";
+ private String declareWarningQuotes = "declare warning: quot;Illegal call.quot;";
+ private String declareWarning = "declare warning: \"Illegal call.\"";
+ private String declareParentsImpl = "declare parents: implements Serializable";
+ private String declareSoft = "declare soft: foo.SizeException2";
+ private String declarePrecedence = "declare precedence: foo.DeclareCoverage2, foo.InterTypeDecCoverage2";
+
+ private String doItHref = "HREF=\"../foo/Main2.html#doIt()\"";
+ private String pointHref = "HREF=\"../foo/Point2.html\"";
+ private String cHref = "HREF=\"../foo/C.html\"";
+
+ private String doIt = "doIt()";
+
+
+ public void testCoverage() {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage.java")};
+ runAjdoc("private","1.6",files);
+ }
+
+ /**
+ * Test that the declare statements appear in the Declare Detail
+ * and Declare Summary sections of the ajdoc
+ */
+ public void testDeclareStatments() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+ // check the contents of the declare detail summary
+ String[] strings = {
+ declareError,
+ declareWarning,
+ declareParentsImpl,
+ declareSoft,
+ declarePrecedence};
+
+ List missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile,strings,"DECLARE DETAIL SUMMARY");
+ assertTrue(htmlFile.getName() + " should contain all declare statements in " +
+ "the Declare Detail section",missing.isEmpty());
+
+ // check the contents of the declare summary - should contain
+ // the same strings
+ missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile,strings,"DECLARE SUMMARY");
+ assertTrue(htmlFile.getName() + " should contain all declare statements in " +
+ "the Declare Summary section",missing.isEmpty());
+ }
+
+ /**
+ * Declare warning's should have the 'matched by' relationship
+ * in the ajdoc for the declaring aspect
+ */
+ public void testDeclareWarning() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"DECLARE DETAIL SUMMARY",
+ declareWarningQuotes,
+ HtmlDecorator.HtmlRelationshipKind.MATCHED_BY,
+ doItHref);
+ assertTrue("Should have '" + declareWarningQuotes + " matched by " + doItHref +
+ "' in the Declare Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"DECLARE SUMMARY",
+ declareWarningQuotes,
+ HtmlDecorator.HtmlRelationshipKind.MATCHED_BY,
+ doItHref);
+ assertTrue("Should have '" + declareWarningQuotes + " matched by " + doItHref +
+ "' in the Declare Summary section", b);
+ }
+
+ /**
+ * The target of a declare warning should have the 'matches
+ * declare' relationship in the ajdoc - test the case when
+ * the declare warning matches a call join point
+ */
+ public void testMatchesDeclareCall() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName(doIt),
+ HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
+ declareWarningQuotes);
+ assertTrue("Should have '" + doIt + " matches declare " +
+ declareWarningQuotes + "' in the Declare Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName(doIt),
+ HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
+ declareWarningQuotes);
+ assertTrue("Should have '" + doIt + " matches declare " +
+ declareWarningQuotes + "' in the Declare Summary section", b);
+ }
+
+ /**
+ * The target of a declare warning should have the 'matches
+ * declare' relationship in the ajdoc - test the case when
+ * the declare warning matches an execution join point
+ */
+ public void testMatchesDeclareExecution() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName("setX(int)"),
+// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)",
+ HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
+ "declare warning: quot;blahquot;");
+ assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" +
+ "' in the Method Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName("setX(int)"),
+// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)",
+ HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
+ "declare warning: quot;blahquot;");
+ assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" +
+ "' in the Method Summary section", b);
+ }
+
+ /**
+ * Declare parents's should have the 'declared on' relationship
+ * in the ajdoc for the declaring aspect
+ */
+ public void testDeclareParents() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"DECLARE DETAIL SUMMARY",
+ declareParentsImpl,
+ HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
+ pointHref);
+ assertTrue("Should have ' " + declareParentsImpl + " declared on " +
+ pointHref + "' in the Declare Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"DECLARE SUMMARY",
+ declareParentsImpl,
+ HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
+ pointHref);
+ assertTrue("Should have ' " + declareParentsImpl + " declared on " +
+ pointHref + "' in the Declare Summary section", b);
+ }
+
+ /**
+ * The target of a declare parent should have the 'aspect
+ * declarations' relationship in the ajdoc
+ */
+ public void testAspectDeclarations() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+ boolean b = AjdocOutputChecker.classDataSectionContainsRel(
+ htmlFile,
+ HtmlDecorator.HtmlRelationshipKind.ASPECT_DECLARATIONS,
+ "declare parents: implements Serializable");
+ assertTrue("The class data section should have 'aspect declarations" +
+ " declare parents: implements Serializable'",b);
+
+ }
+
+ /**
+ * Declare soft's should have the 'softens' relationship
+ * in the ajdoc for the declaring aspect
+ */
+ public void testDeclareSoft() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"DECLARE DETAIL SUMMARY",
+ declareSoft,
+ HtmlDecorator.HtmlRelationshipKind.SOFTENS,
+ doItHref);
+ assertTrue("Should have '" + declareSoft + " softens " + doItHref +
+ "' in the Declare Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"DECLARE SUMMARY",
+ declareSoft,
+ HtmlDecorator.HtmlRelationshipKind.SOFTENS,
+ doItHref);
+ assertTrue("Should have '" + declareSoft + " softens " + doItHref +
+ "' in the Declare Summary section", b);
+ }
+
+ /**
+ * The target of a declare soft should have the 'softened
+ * by' relationship in the ajdoc
+ */
+ public void testSoftenedBy() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName(doIt),
+ HtmlDecorator.HtmlRelationshipKind.SOFTENED_BY,
+ declareSoft);
+ assertTrue("Should have '" + doIt + " softened by " + declareSoft +
+ "' in the Method Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName(doIt),
+ HtmlDecorator.HtmlRelationshipKind.SOFTENED_BY,
+ declareSoft);
+ assertTrue("Should have '" + doIt + " softened by " + declareSoft +
+ "' in the Method Summary section", b);
+ }
+
+ private String toName(String name) {
+ if (LangUtil.is18VMOrGreater() && !LangUtil.is11VMOrGreater()) {
+ name = name.replace('(','-');
+ name = name.replace(')','-');
+ }
+ return name;
+ }
+
+ /**
+ * Declare annotation should have the 'annotates' relationship
+ * in the ajdoc for the declaring aspect
+ */
+ public void testDeclareAnnotation() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")};
+ runAjdoc("private","1.6",files);
+
+ // Aspect AnnotationTest should contain within it's declare
+ // detail and summary the declare annotation statement.
+ // Check for this....
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareAtType.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // check there's no return type for the declare annotation
+ // statement in the declare summary section
+ String[] returnType = {"[]"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile,returnType,"DECLARE SUMMARY");
+ assertEquals("there should be no return type for declare annotation" +
+ " in the ajdoc",1,missing.size());
+ assertEquals("there shouldn't be the '[]' return type for declare annotation" +
+ " in the ajdoc","[]",missing.get(0));
+
+ // check that the 'annotates' relationship is there
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"DECLARE DETAIL SUMMARY",
+ "declare @type: foo.C : @MyAnnotation",
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATES,
+ cHref);
+ assertTrue("Should have 'declare @type: foo.C : @MyAnnotation annotates "
+ + cHref + "' in the Declare Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"DECLARE SUMMARY",
+ "declare @type: foo.C : @MyAnnotation",
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATES,
+ cHref);
+ assertTrue("Should have 'declare @type: foo.C : @MyAnnotation annotates "
+ + cHref + "' in the Declare Summary section", b);
+ }
+
+ /**
+ * The target of a declare method annotation should have the
+ * 'annotated by' relationship in the ajdoc within the method
+ * information
+ */
+ public void testMethodAnnotatedBy() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtMethod.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
+ "declare @method: public * foo.C.*(..) : @MyAnnotation");
+ assertTrue("Should have 'amethod() annotated by " +
+ "declare @method: public * foo.C.*(..) : @MyAnnotation" +
+ "' in the Method Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
+ "declare @method: public * foo.C.*(..) : @MyAnnotation");
+ assertTrue("Should have 'amethod() annotated by " +
+ "declare @method: public * foo.C.*(..) : @MyAnnotation" +
+ "' in the Method Summary section", b);
+ }
+
+ /**
+ * The target of a declare method annotation should have the
+ * 'annotated by' relationship in the ajdoc within the method
+ * information
+ */
+ public void testConstructorAnnotatedBy() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtConstructor.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== CONSTRUCTOR DETAIL",
+ LangUtil.is11VMOrGreater()?"<init>(java.lang.String)":toName("C(java.lang.String)"),
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
+ "declare @constructor: foo.C.new(..) : @MyAnnotation");
+ assertTrue("Should have '" + doIt + " annotated by " +
+ "declare @constructor: foo.C.new(..) : @MyAnnotation" +
+ "' in the Method Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== CONSTRUCTOR SUMMARY",
+ LangUtil.is11VMOrGreater()?"#%3Cinit%3E(java.lang.String)":toName("C(java.lang.String)"),
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
+ "declare @constructor: foo.C.new(..) : @MyAnnotation");
+ assertTrue("Should have '" + doIt + " annotated by " +
+ "declare @constructor: foo.C.new(..) : @MyAnnotation" +
+ "' in the Method Summary section", b);
+ }
+
+ /**
+ * The target of a declare method annotation should have the
+ * 'annotated by' relationship in the ajdoc within the method
+ * information
+ */
+ public void testFieldAnnotatedBy() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtField.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== FIELD DETAIL",
+ "x",
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
+ "declare @field: int foo.C.* : @MyAnnotation");
+ assertTrue("Should have '" + doIt + " annotated by " +
+ "declare @field: int foo.C.* : @MyAnnotation" +
+ "' in the Field Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== FIELD SUMMARY",
+ "x",
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
+ "declare @field: int foo.C.* : @MyAnnotation");
+ assertTrue("Should have '" + doIt + " annotated by " +
+ "declare @field: int foo.C.* : @MyAnnotation" +
+ "' in the Field Summary section", b);
+ }
+
+ /**
+ * The target of a declare method annotation should have the
+ * 'annotated by' relationship in the ajdoc within the method
+ * information
+ */
+ public void testTypeAnnotatedBy() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+ boolean b = AjdocOutputChecker.classDataSectionContainsRel(
+ htmlFile,
+ HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
+ "declare @type: foo.C : @MyAnnotation");
+ assertTrue("The class data section should have 'annotated by" +
+ " declare @type: foo.C : @MyAnnotation'",b);
+ }
+
+ /**
+ * Test that info for both "matches declare" and "advised by"
+ * appear in the ajdoc for a method when the method is affected
+ * by both.
+ */
+ public void testMatchesDeclareAndAdvisedBy() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "A.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
+ "declare warning: quot;warningquot;");
+ assertTrue("Should have 'amethod() matches declare declare warning: " +
+ "quot;warningquot;' in the Method Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
+ "declare warning: quot;warningquot;");
+ assertTrue("Should have 'amethod() matches declare declare warning: " +
+ "quot;warningquot;' in the Method Summary section", b);
+
+ b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"=== METHOD DETAIL",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ "before(): p..");
+ assertTrue("the Method Detail should have amethod() advised by before(): p..",b);
+
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"=== METHOD SUMMARY",
+ toName("amethod()"),
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
+ "before(): p..");
+ assertTrue("the Method Summary should have amethod() advised by before(): p..",b);
+ }
+
+ /**
+ * Test that if there are two declare parents statements within
+ * an aspect, one which extends and one which implements, that the
+ * ajdoc shows the correct information
+ */
+ public void testTwoDeclareParents() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareParents.aj")};
+ runAjdoc("private","1.6",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareParents.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ "declare parents: implements Serializable",
+ "HREF=\"../foo/Class1.html\"",
+ "declare parents: extends Observable",
+ "HREF=\"../foo/Class2.html\""};
+
+ // check that the correct declare statements are there
+ for (int i = 0; i < strings.length - 1; i = i+2) {
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"DECLARE DETAIL SUMMARY",strings[i],
+ HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
+ strings[i+1]);
+ assertTrue("Should have ' " + strings[i] + " declared on " + strings[i+1] +
+ "' in the Declare Detail section", b);
+ }
+
+ for (int i = 0; i < strings.length - 1; i = i+2) {
+ boolean b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlFile,"DECLARE SUMMARY",
+ strings[i],
+ HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
+ strings[i+1]);
+ assertTrue("Should have ' " + strings[i] + " declared on " + strings[i+1] +
+ "' in the Declare Summary section", b);
+ }
+
+ // check that we don't have declare statements for those that don't
+ // exist in the code
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlFile,"DECLARE DETAIL SUMMARY",strings[0],
+ HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
+ strings[3]);
+ assertFalse("Should not have ' " + strings[0] + " declared on " + strings[3] +
+ "' in the Declare Detail section", b);
+
+ }
+
+}
--- /dev/null
+/********************************************************************
+ * 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - iniital version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.File;
+
+
+public class EnumTest extends AjdocTestCase {
+
+ /**
+ * Test for pr122728 - no StringOutOfBoundsException
+ * when processing an Enum
+ */
+ public void testEnum() throws Exception {
+ initialiseProject("pr122728");
+ File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/MyEnum.java")};
+ runAjdoc("private","1.5",files);
+ }
+
+ /**
+ * Test for pr122728 - no StringOutOfBoundsException
+ * when processing an Enum
+ */
+ public void testInlinedEnum() throws Exception {
+ initialiseProject("pr122728");
+ File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/ClassWithInnerEnum.java")};
+ runAjdoc("private","1.5",files);
+ }
+
+ /**
+ * Test for pr122728 - no StringOutOfBoundsException
+ * when processing an Enum
+ */
+ public void testEnumWithMethods() throws Exception {
+ initialiseProject("pr122728");
+ File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/EnumWithMethods.java")};
+ runAjdoc("private","1.5",files);
+ }
+}
--- /dev/null
+/* *******************************************************************
+ * 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 org.aspectj.bridge.Version;
+
+/**
+ * @author Mik Kersten
+ */
+public class ExecutionTestCase extends AjdocTestCase {
+
+ public void testVersionMatch() {
+ String ajdocVersion = Main.getVersion();
+ String compilerVersion = Version.text;
+ assertTrue("version check", ajdocVersion.endsWith(compilerVersion));
+ }
+
+ public void testFailingBuild() {
+ initialiseProject("failing-build");
+ File file1 = new File(getAbsoluteProjectDir() + File.separatorChar + "Fail.java");
+ String[] args = { file1.getAbsolutePath() };
+ org.aspectj.tools.ajdoc.Main.main(args);
+ assertTrue(Main.hasAborted());
+ }
+}
--- /dev/null
+/********************************************************************
+ * 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - iniital version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.File;
+import java.util.List;
+
+public class FullyQualifiedArgumentTest extends AjdocTestCase {
+
+ /**
+ * Test for pr58520
+ */
+ public void testPr58520() throws Exception {
+ initialiseProject("pr119453");
+ File[] files = {
+ new File(getAbsoluteProjectDir() + File.separatorChar +"src/pack/C.java"),
+ new File(getAbsoluteProjectDir() + File.separatorChar + "src/pack/A.aj")};
+ runAjdoc("private",files);
+
+ // check the contents of A.html
+ File htmlA = new File(getAbsolutePathOutdir() + "/pack/A.html");
+ if (!htmlA.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir()
+ + "/pack/A.html - were there compilation errors?");
+ }
+
+ // check the contents of the declare detail summary
+ String[] stringsA = { "C.html#method3(java.lang.String)",
+ "C.html#method3(String)"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlA,stringsA,"ADVICE SUMMARY");
+ assertEquals("There should be one missing string",1,missing.size());
+ assertEquals("The fully qualified name should appear in the argument",
+ "C.html#method3(String)",missing.get(0));
+ }
+
+}
--- /dev/null
+/********************************************************************
+ * 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - iniital version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.File;
+import java.util.List;
+
+public class ITDTest extends AjdocTestCase {
+
+ /**
+ * Test for pr119453
+ */
+ public void testITDDeclaredOn() throws Exception {
+ initialiseProject("pr119453");
+ File[] files = {
+ new File(getAbsoluteProjectDir() + "/src/pack/C.java"),
+ new File(getAbsoluteProjectDir() + "/src/pack/A.aj")
+ };
+ runAjdoc("private",files);
+ File htmlA = new File(getAbsolutePathOutdir() + "/pack/A.html");
+ if (!htmlA.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir() + "/pack/A.html - were there compilation errors?");
+ }
+
+ // check field itd appears
+ boolean b = AjdocOutputChecker.detailSectionContainsRel(
+ htmlA,"DECLARE DETAIL SUMMARY",
+ "C.y",
+ HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
+ "HREF=\"../pack/C.html\"");
+ assertTrue("Should have 'C.y declared on HREF=\"../pack/C.html\"" +
+ "' in the Declare Detail section", b);
+ b = AjdocOutputChecker.summarySectionContainsRel(
+ htmlA,"DECLARE SUMMARY",
+ "C.y",
+ HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
+ "HREF=\"../pack/C.html\"");
+ assertTrue("Should have 'C.y declared on HREF=\"../pack/C.html\"" +
+ "' in the Declare Summary section", b);
+
+ // check the modifiers are correct in the declare detail summary
+ String[] stringsA = { "private int",
+ "public java.lang.String",
+ "<H3>C.y</H3>",
+ "public </TT><B>C.C",
+ "package void"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlA,stringsA,"DECLARE DETAIL SUMMARY");
+ assertEquals("There should be one missing string ",1,missing.size());
+ assertEquals("the 'package' and 'void' modifiers shouldn't appear in the 'Declare Detail' section of the ajdoc",
+ "package void", missing.get(0));
+
+ // check the modifiers are correct in the declare summary
+ String[] stringsA2 = {"private", "int", "public", "String", "package void"};
+ missing = AjdocOutputChecker.getMissingStringsInSection(htmlA,stringsA2,"DECLARE SUMMARY");
+ assertEquals("There should be two missing strings ",2,missing.size());
+ assertTrue("the public modifier shouldn't appear in the 'Declare Summary' section of the ajdoc", missing.contains("public"));
+ assertTrue("the 'package' and 'void' modifiers shouldn't appear in the 'Declare Summary' section of the ajdoc", missing.contains("package void"));
+
+ }
+
+ /**
+ * Test for pr119453
+ */
+ public void testITDMatchesDeclare() throws Exception {
+ initialiseProject("pr119453");
+ File[] files = {
+ new File(getAbsoluteProjectDir() + "/src/pack/C.java"),
+ new File(getAbsoluteProjectDir() + "/src/pack/A.aj")
+ };
+ runAjdoc("private",files);
+
+ // Check the contents of C.html
+ File htmlC = new File(getAbsolutePathOutdir() + "/pack/C.html");
+ if (!htmlC.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir()
+ + "/pack/C.html - were there compilation errors?");
+ }
+
+ // check that the required sections exist
+ assertTrue(htmlC.getAbsolutePath() + " should contain an "
+ + "'INTER-TYPE METHOD SUMMARY' section",
+ AjdocOutputChecker.containsString(htmlC, "INTER-TYPE METHOD SUMMARY"));
+ assertTrue(htmlC.getAbsolutePath() + " should contain an "
+ + "'INTER-TYPE FIELD SUMMARY' section",
+ AjdocOutputChecker.containsString(htmlC, "INTER-TYPE FIELD SUMMARY"));
+ assertTrue(htmlC.getAbsolutePath() + " should contain an "
+ + "'INTER-TYPE CONSTRUCTOR SUMMARY' section",
+ AjdocOutputChecker.containsString(htmlC,"INTER-TYPE CONSTRUCTOR SUMMARY"));
+
+ // check the modifier information in the sections is correct
+ String[] stringsC = { "public", "String", "pack.A" };
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlC,stringsC,"INTER-TYPE METHOD SUMMARY");
+ assertEquals("There should be one missing string",1,missing.size());
+ assertEquals("public itd methods should not have the 'public' modifier in the ajdoc",
+ "public",missing.get(0));
+
+ String[] stringsC2 = { "private" };
+ missing = AjdocOutputChecker.getMissingStringsInSection(htmlC,stringsC2,"INTER-TYPE FIELD SUMMARY");
+ assertTrue("the private modifier for itd methods should appear in the ajdoc ",missing.size() == 0);
+
+ }
+
+ /**
+ * Test that the ITD's do not appear in as 'aspect declarations' in the
+ * class data information.
+ */
+ public void testNoAspectDeclarations() throws Exception {
+ initialiseProject("pr119453");
+ File[] files = {
+ new File(getAbsoluteProjectDir() + "/src/pack/C.java"),
+ new File(getAbsoluteProjectDir() + "/src/pack/A.aj")
+ };
+ runAjdoc("private",files);
+
+ File htmlC = new File(getAbsolutePathOutdir() + "/pack/C.html");
+ if (htmlC == null || !htmlC.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir()
+ + "/pack/C.html - were there compilation errors?");
+ }
+
+ boolean b = AjdocOutputChecker.classDataSectionContainsRel(
+ htmlC,
+ HtmlDecorator.HtmlRelationshipKind.ASPECT_DECLARATIONS,
+ "pack.A.C.y");
+ assertFalse("The class data section should not have 'aspect declarations" +
+ " pack.A.C.y' since this is an ITD",b);
+ }
+
+}
--- /dev/null
+/* *******************************************************************
+ * 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 JDKVersionTest extends AjdocTestCase {
+
+// public void testIsUsing1point4() {
+// String v = System.getProperty("java.class.version","44.0");
+// assertTrue(("49.0".compareTo(v) > 0) && ("48.0".compareTo(v) <= 0));
+// assertFalse(Util.isExecutingOnJava5());
+// }
+
+ public void testNothing() {}
+// public void testIsUsing1point5() {
+// assertTrue(Util.isExecutingOnJava5());
+// }
+
+}
--- /dev/null
+/* *******************************************************************
+ * 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;
+
+/**
+ * A long way to go until full coverage, but this is the place to add more.
+ *
+ * @author Mik Kersten
+ */
+public class PatternsTestCase extends AjdocTestCase {
+
+ public void testSimpleExample() {
+
+// System.err.println(new File("testdata.figures-demo").exists());
+// File file1 = new File("testdata/patterns/allPatterns.lst");
+ File outdir = new File("testdata/patterns/doc");
+ File srcdir = new File("../../docs/sandbox/ubc-design-patterns/src");
+
+ String[] args = {
+// "-XajdocDebug",
+ "-classpath",
+ AjdocTests.ASPECTJRT_PATH.getPath(),
+ "-d",
+ outdir.getAbsolutePath(),
+ "-sourcepath",
+ srcdir.getAbsolutePath(),
+ "ca.ubc.cs.spl.aspectPatterns.patternLibrary",
+ "ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.builder.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.builder.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.prototype.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.prototype.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.singleton.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.singleton.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.adapter.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.adapter.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.bridge.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.composite.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.composite.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.decorator.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.decorator.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.facade.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.facade.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.flyweight.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.flyweight.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.proxy.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.command.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.iterator.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.iterator.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.mediator.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.mediator.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.memento.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.memento.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.observer.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.state.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.strategy.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.strategy.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.aspectj",
+ "ca.ubc.cs.spl.aspectPatterns.examples.visitor.java",
+ "ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj"
+ };
+
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+}
--- /dev/null
+/* *******************************************************************
+ * 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;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author Mik Kersten
+ */
+public class PointcutVisibilityTest extends AjdocTestCase {
+
+ /**
+ * Test that passing the "public" argument only shows
+ * public pointcuts in the ajdoc
+ */
+ public void testCoveragePublicMode() throws Exception {
+ initialiseProject("bug82340");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
+ runAjdoc("public",files);
+
+ // ajdoc for Pointcut.java should contain info about
+ // the public pointcuts but not the protected and
+ // private one (since "public" was an argument)
+ // Check that this is the case......
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+ // check the contents of the pointcut summary
+ String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
+ assertEquals("There should be two missing strings",2,missing.size());
+ assertTrue("passing the 'public' argument means the private pointcut shouldn't appear in the ajdoc", missing.contains("privatePointcut"));
+ assertTrue("passing the 'public' argument means the protected pointcut shouldn't appear in the ajdoc", missing.contains("protectedPointcut"));
+ }
+
+ /**
+ * Test that passing the "protected" argument only shows
+ * public and protected pointcuts in the ajdoc
+ */
+ public void testCoverageProtectedMode() throws Exception {
+ initialiseProject("bug82340");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
+ runAjdoc("protected",files);
+
+ // ajdoc for Pointcut.java should contain info about
+ // the public and protected pointcuts but not the
+ // private one (since "protected" was an argument)
+ // Check that this is the case......
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+ // check the contents of the pointcut summary
+ String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
+ assertEquals("There should be one missing strings",1,missing.size());
+ assertEquals("passing the 'protected' argument means the private pointcut shouldn't appear in the ajdoc",
+ "privatePointcut", missing.get(0));
+ }
+
+ /**
+ * Test that passing the "private" argument shows all
+ * pointcuts (public, protected and private) in the ajdoc
+ */
+ public void testCoveragePrivateMode() throws Exception {
+ initialiseProject("bug82340");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
+ runAjdoc("private",files);
+
+ // ajdoc for Pointcut.java should contain info about
+ // the public, protected and private pointcuts
+ // (since "private" was an argument)
+ // Check that this is the case......
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+ // check the contents of the pointcut summary
+ String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
+ assertTrue("passing the 'private' modifier means that private, protected and public " +
+ "pointcuts should appear in the ajdoc",missing.isEmpty());
+ }
+
+}
--- /dev/null
+/* *******************************************************************
+ * 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;
+
+
+/**
+ * @author Mik Kersten
+ */
+public class SpacewarTestCase extends AjdocTestCase {
+
+ private String[] dirs = {"spacewar","coordination"};
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ initialiseProject("spacewar");
+ }
+
+ public void testSimpleExample() {
+ runAjdoc(dirs);
+ }
+
+ public void testPublicModeExample() {
+ runAjdoc("public",dirs);
+ }
+
+ public void testPr134063() {
+ String lstFile = "spacewar" + File.separatorChar + "demo.lst";
+ runAjdoc("private",lstFile);
+ }
+}
+++ /dev/null
-package org.aspectj.tools.ajdoc;
-/* *******************************************************************
- * 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
- * ******************************************************************/
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-/**
- * @author Mik Kersten
- */
-public class AjdocModuleTests {
- public static Test suite() {
- TestSuite suite = new TestSuite(AjdocModuleTests.class.getName());
- suite.addTest(AjdocTests.suite());
- return suite;
- }
-}
+++ /dev/null
-/********************************************************************
- * 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://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- * Helen Hawkins - iniital version
- *******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.aspectj.util.LangUtil;
-
-/**
- * Helper class to check whether the ajdoc contains the expected
- * information.
- */
-public class AjdocOutputChecker {
-
- /**
- * Checks whether the given html file contains the required String.
- *
- * @param htmlFile
- * @param requiredString
- * @return true if the file contains the given string or
- * false otherwise (or if the file is null or not an html file)
- * @throws Exception
- */
- public static boolean containsString(File htmlFile,
- String requiredString) throws Exception {
- if ((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html")) {
- return false;
- }
- BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
- String line = reader.readLine();
- while (line != null) {
- if (line.indexOf(requiredString) != -1) {
- reader.close();
- return true;
- }
- line = reader.readLine();
- }
- reader.close();
- return false;
- }
-
- /**
- * Returns those strings from the given array which aren't in the html file.
- *
- * @param htmlFile
- * @param an array of requiredStrings
- * @return a List of those strings not found
- * @throws Exception
- */
- public static List<String> getMissingStringsInFile(File htmlFile, String[] requiredStrings) throws Exception {
- List<String> missingStrings = new ArrayList<String>();
- for (int i = 0; i < requiredStrings.length; i++) {
- String string = requiredStrings[i];
- if (!containsString(htmlFile, string)) {
- missingStrings.add(string);
- }
- }
- return missingStrings;
- }
-
- /**
- * Checks whether the section of the html file contains the
- * required String
- *
- * @param htmlFile
- * @param requiredString
- * @param sectionHeader
- * @return true if the file contains the given string within the
- * required section or false otherwise (or if the file is null or
- * not an html file)
- * @throws Exception
- */
- public static boolean containsStringWithinSection(File htmlFile,
- String requiredString, String sectionHeader) throws Exception {
- if ((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html")) {
- return false;
- }
- BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
- String line = reader.readLine();
- while (line != null) {
- if (line.indexOf(sectionHeader) != -1) {
- String nextLine = reader.readLine();
- while (nextLine != null &&
- (nextLine.indexOf("========") == -1)) {
- if (nextLine.indexOf(requiredString) != -1) {
- reader.close();
- return true;
- }
- nextLine = reader.readLine();
- }
- reader.close();
- return false;
- }
- line = reader.readLine();
- }
- reader.close();
- return false;
- }
-
- /**
- * Returns those strings from the given array which aren't in the
- * ajdoc html file
- *
- * @param htmlFile
- * @param an array of requiredStrings
- * @param sectionHeader
- * @return List of those requiredStrings not found
- * @throws Exception
- */
- public static List /*String*/ getMissingStringsInSection(File htmlFile,
- String[] requiredStrings, String sectionHeader) throws Exception {
- List missingStrings = new ArrayList();
- for (int i = 0; i < requiredStrings.length; i++) {
- String string = requiredStrings[i];
- if (!containsStringWithinSection(htmlFile,string,sectionHeader)) {
- missingStrings.add(string);
- }
- }
- return missingStrings;
- }
-
- /**
- * Returns whether the class data section has the expected
- * relationship and target i.e. have the relationships been
- * applied to the type.
- *
- * @param the ajdoc html file
- * @param the detail sectionHeader, for example "DECLARE DETAIL SUMMARY"
- * @param the source of the relationship, for example "Point()"
- * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY
- * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\""
- * @return true if the section contains the expected source/relationship/target,
- * false otherwise
- */
- public static boolean classDataSectionContainsRel(File htmlFile,
- HtmlDecorator.HtmlRelationshipKind relationship,
- String target) throws Exception {
- if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
- return false;
- }
- BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
- String line = reader.readLine();
- while (line != null) {
- if (line.indexOf("START OF CLASS DATA") != -1) {
- // found the required class data section
- String subLine = reader.readLine();
- while(subLine != null
- && (subLine.indexOf("========") == -1)){
- int relIndex = subLine.indexOf(relationship.toString());
- int targetIndex = subLine.indexOf(target);
- if ((relIndex != -1) && (targetIndex != -1)) {
- reader.close();
- if (relIndex < targetIndex) {
- return true;
- }
- return false;
- }
- subLine = reader.readLine();
- }
- reader.close();
- return false;
- }
- line = reader.readLine();
- }
- reader.close();
- return false;
- }
-
- /**
- * Returns whether the supplied source has the expected
- * relationship and target within the given detail section
- *
- * @param the ajdoc html file
- * @param the detail sectionHeader, for example "DECLARE DETAIL SUMMARY"
- * @param the source of the relationship, for example "Point()"
- * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY
- * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\""
- * @return true if the section contains the expected source/relationship/target,
- * false otherwise
- */
- public static boolean detailSectionContainsRel(File htmlFile,
- String sectionHeader, String source,
- HtmlDecorator.HtmlRelationshipKind relationship,
- String target) throws Exception {
- if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
- return false;
- }
- if (sectionHeader.indexOf("DETAIL") == -1) {
- return false;
- }
- BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
- String line = reader.readLine();
- while (line != null) {
- if (line.indexOf(sectionHeader) != -1) {
- // found the required main section
- String nextLine = reader.readLine();
- while (nextLine != null && (nextLine.indexOf("========") == -1)) {
- // On JDK11 it looks like <a id="doIt()"> on earlier JDKs it can look like <a name="doit">
- if ((LangUtil.is11VMOrGreater() && nextLine.indexOf("ID=\""+source+"\"") != -1 || nextLine.indexOf("id=\""+source+"\"") != -1) ||
- nextLine.indexOf("NAME=\""+source+"\"") != -1 || nextLine.indexOf("name=\""+source+"\"") != -1) {
- // found the required subsection
- String subLine = reader.readLine();
- while(subLine != null
- && (subLine.indexOf("========") == -1)
- && (subLine.indexOf("NAME") == -1 && subLine.indexOf("name") == -1)) {
- int relIndex = subLine.indexOf(relationship.toString());
- int targetIndex = subLine.indexOf(target);
- if ((relIndex != -1) && (targetIndex != -1)) {
- reader.close();
- if (relIndex < targetIndex) {
- return true;
- }
- return false;
- }
- subLine = reader.readLine();
- }
- reader.close();
- return false;
- }
- nextLine = reader.readLine();
- }
- reader.close();
- return false;
- }
- line = reader.readLine();
- }
- reader.close();
- return false;
- }
-
- /**
- * Returns whether the supplied source has the expected
- * relationship and target within the given summary section
- *
- * @param the ajdoc html file
- * @param the detail sectionHeader, for example "DECLARE SUMMARY"
- * @param the source of the relationship, for example "Point()"
- * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY
- * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\""
- * @return true if the section contains the expected source/relationship/target,
- * false otherwise
- */
- public static boolean summarySectionContainsRel(
- File htmlFile,
- String sectionHeader,
- String source,
- HtmlDecorator.HtmlRelationshipKind relationship,
- String target) throws Exception {
- if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
- return false;
- }
- if (sectionHeader.indexOf("SUMMARY") == -1) {
- return false;
- }
- BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
- String line = reader.readLine();
- while (line != null) {
- if (line.indexOf(sectionHeader) != -1) {
- // found the required main section
- String nextLine = reader.readLine();
- while (nextLine != null && (nextLine.indexOf("========") == -1)) {
- if (nextLine.indexOf(source) != -1) {
- // found the required subsection
- String subLine = nextLine;
- while(subLine != null
- && (subLine.indexOf("========") == -1)
- && (subLine.indexOf("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">") == -1)) {
- int relIndex = subLine.indexOf(relationship.toString());
- int targetIndex = subLine.indexOf(target);
- if ((relIndex != -1) && (targetIndex != -1)) {
- reader.close();
- if (relIndex < targetIndex) {
- return true;
- }
- return false;
- }
- subLine = reader.readLine();
- }
- reader.close();
- return false;
- }
- nextLine = reader.readLine();
- }
- reader.close();
- return false;
- }
- line = reader.readLine();
- }
- reader.close();
- return false;
- }
-
-}
+++ /dev/null
-/********************************************************************
- * 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://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- * Helen Hawkins - iniital version
- *******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.aspectj.tools.ajc.Ajc;
-import org.aspectj.util.LangUtil;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-/**
- * This class is the super class of all Ajdoc tests. It creates a sandbox directory and provides utility methods for copying over
- * the test projects and running the ajdoc command
- */
-public class AjdocTestCase extends TestCase {
-
- public final static String testdataSrcDir = "../ajdoc/testdata";
- protected static File sandboxDir;
- private String docOutdir, projectDir;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- docOutdir = null;
- projectDir = null;
- // Create a sandbox in which to work
- sandboxDir = Ajc.createEmptySandbox();
- // create the ajdocworkdingdir in the sandbox
- Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- // reset where ajdocworkingdir is created
- Main.resetOutputWorkingDir();
- }
-
- /**
- * Fill in the working directory with the project files and create a doc top level directory in which to generate the ajdoc
- * output.
- */
- public void initialiseProject(String projectName) {
- File projectSrc = new File(testdataSrcDir + File.separatorChar + projectName);
- File destination = new File(getWorkingDir(), projectName);
- if (!destination.exists()) {
- destination.mkdir();
- }
- copy(projectSrc, destination);
- projectDir = destination.getAbsolutePath();
-
- File docDestination = new File(getWorkingDir().toString() + File.separatorChar + projectName, "doc");
- if (!docDestination.exists()) {
- docDestination.mkdir();
- }
- docOutdir = docDestination.getAbsolutePath();
- }
-
- /**
- * @return the working directory
- */
- protected File getWorkingDir() {
- return sandboxDir;
- }
-
- /**
- * @return the absolute path of the project directory for example c:\temp\ajcSandbox\ajcTest15200.tmp\myProject
- */
- protected String getAbsoluteProjectDir() {
- return projectDir;
- }
-
- /**
- * @return the absolute path of the doc output directory for example c:\temp\ajcSandbox\ajcTest15200.tmp\myProject\doc
- */
- protected String getAbsolutePathOutdir() {
- return docOutdir;
- }
-
- /**
- * Copy the contents of some directory to another location - the copy is recursive.
- */
- private void copy(File from, File to) {
- String contents[] = from.list();
- if (contents == null)
- return;
- for (int i = 0; i < contents.length; i++) {
- String string = contents[i];
- File f = new File(from, string);
- File t = new File(to, string);
-
- if (f.isDirectory()) {
- t.mkdir();
- copy(f, t);
- } else if (f.isFile()) {
- try {
- org.aspectj.util.FileUtil.copyFile(f, t);
- } catch (IOException e) {
- throw new AssertionFailedError("Unable to copy " + f + " to " + t);
- }
- }
- }
- }
-
- /**
- * Run the ajdoc command with the given visibility argument, the default source level and the given input files.
- */
- public void runAjdoc(String visibility, File[] inputFiles) {
- if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
- fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
- }
- if (inputFiles.length == 0) {
- fail("need to pass some files into ajdoc");
- }
- String[] args = new String[5 + inputFiles.length];
- args[0] = "-" + visibility;
- args[1] = "-classpath";
- args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
- args[3] = "-d";
- args[4] = getAbsolutePathOutdir();
- for (int i = 0; i < inputFiles.length; i++) {
- args[5 + i] = inputFiles[i].getAbsolutePath();
- }
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-
- /**
- * Run the ajdoc command with the default visibility and source level and the given input files.
- */
- public void runAjdoc(File[] inputFiles) {
- if (inputFiles.length == 0) {
- fail("need to pass some files into ajdoc");
- }
- String[] args = new String[4 + inputFiles.length];
- args[0] = "-classpath";
- args[1] = AjdocTests.ASPECTJRT_PATH.getPath();
- args[2] = "-d";
- args[3] = getAbsolutePathOutdir();
- for (int i = 0; i < inputFiles.length; i++) {
- args[4 + i] = inputFiles[i].getAbsolutePath();
- }
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-
- /**
- * Run the ajdoc command with the default visibility and source level, the given input files and the given aspectj options
- */
- public void runAjdoc(File[] inputFiles, String sourceLevel, String[] ajOptions) {
- if (inputFiles.length == 0) {
- fail("need to pass some files into ajdoc");
- }
- if (!sourceLevel.equals("1.3") &&
- !sourceLevel.equals("1.4") &&
- !sourceLevel.equals("1.5") &&
- !sourceLevel.equals("1.6") &&
- !sourceLevel.equals("1.7") &&
- !sourceLevel.equals("1.8") &&
- !sourceLevel.equals("1.9") &&
- !sourceLevel.equals("10")) {
- fail("need to pass ajdoc '1.3' > '1.9' as the source level");
- }
- String[] args = new String[6 + inputFiles.length + ajOptions.length];
- args[0] = "-source";
- args[1] = sourceLevel;
- args[2] = "-classpath";
- args[3] = AjdocTests.ASPECTJRT_PATH.getPath();
- args[4] = "-d";
- args[5] = getAbsolutePathOutdir();
- for (int i = 0; i < ajOptions.length; i++) {
- args[6 + i] = ajOptions[i];
- }
- for (int i = 0; i < inputFiles.length; i++) {
- args[6 + i + ajOptions.length] = inputFiles[i].getAbsolutePath();
- }
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-
- /**
- * Run the ajdoc command with the given visibility argument, the given source level argument and the given input files.
- */
- public void runAjdoc(String visibility, String sourceLevel, File[] inputFiles) {
- if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
- fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
- }
- if (!sourceLevel.equals("1.3") &&
- !sourceLevel.equals("1.4") &&
- !sourceLevel.equals("1.5") &&
- !sourceLevel.equals("1.6") &&
- !sourceLevel.equals("1.7") &&
- !sourceLevel.equals("1.8") &&
- !sourceLevel.equals("1.9") &&
- !sourceLevel.startsWith("9") &&
- !sourceLevel.startsWith("10")) {
- fail("need to pass suitable version to ajdoc as the source level");
- }
- if (inputFiles.length == 0) {
- fail("need to pass some files into ajdoc");
- }
- for (int i = 0; i < inputFiles.length; i++) {
- if (!inputFiles[i].exists()) {
- fail(inputFiles[i].getAbsolutePath() + " does not exist");
- }
- }
-
- String[] args = new String[7 + inputFiles.length];
- args[0] = "-" + visibility;
- args[1] = "-source";
- args[2] = sourceLevel;
- args[3] = "-classpath";
- StringBuilder classpath = new StringBuilder();
- if (LangUtil.is19VMOrGreater()) {
- classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator);
- }
- classpath.append(AjdocTests.ASPECTJRT_PATH.getPath());
- args[4] = classpath.toString();
- args[5] = "-d";
- args[6] = getAbsolutePathOutdir();
- // args[7] = "-Xset:minimalModel=false";
- for (int i = 0; i < inputFiles.length; i++) {
- args[7 + i] = inputFiles[i].getAbsolutePath();
- }
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-
- /**
- * Run the ajdoc command with the given visibility argument, the default source level and the given input directories.
- */
- public void runAjdoc(String visibility, String[] directoryNames) {
- if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
- fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
- }
- if (directoryNames.length == 0) {
- fail("need to pass some directories into ajdoc");
- }
- String[] args = new String[7 + directoryNames.length];
- args[0] = "-" + visibility;
- args[1] = "-classpath";
- args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
- args[3] = "-d";
- args[4] = getAbsolutePathOutdir();
- args[5] = "-sourcepath";
- args[6] = getAbsoluteProjectDir();
- for (int i = 0; i < directoryNames.length; i++) {
- args[7 + i] = directoryNames[i];
- }
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-
- /**
- * Run the ajdoc command with the default visibility and source level and the given input directories.
- */
- public void runAjdoc(String[] directoryNames) {
- if (directoryNames.length == 0) {
- fail("need to pass some directories into ajdoc");
- }
- String[] args = new String[6 + directoryNames.length];
- args[0] = "-classpath";
- args[1] = AjdocTests.ASPECTJRT_PATH.getPath();
- args[2] = "-d";
- args[3] = getAbsolutePathOutdir();
- args[4] = "-sourcepath";
- args[5] = getAbsoluteProjectDir();
- for (int i = 0; i < directoryNames.length; i++) {
- args[6 + i] = directoryNames[i];
- }
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-
- /**
- * Run the ajdoc command with the given visibility argument, the default source level and the given input directories.
- */
- public void runAjdoc(String visibility, String lstFile) {
- if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
- fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
- }
-
- String[] args = new String[8];
- args[0] = "-" + visibility;
- args[1] = "-classpath";
- args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
- args[3] = "-d";
- args[4] = getAbsolutePathOutdir();
- args[5] = "-sourcepath";
- args[6] = getAbsoluteProjectDir();
- args[7] = "@" + getAbsoluteProjectDir() + File.separatorChar + lstFile;
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-
- /**
- * Run the ajdoc command with the given options
- */
- public void runAjdoc(List options) {
- String[] args = new String[options.size()];
- int i = 0;
- for (Iterator iter = options.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
- args[i] = element;
- i++;
- }
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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://eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wes Isberg initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.tools.ajdoc;
-
-import java.io.File;
-
-import org.aspectj.util.FileUtil;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class AjdocTests extends TestCase {
-
- public static File ASPECTJRT_PATH;
-
- static {
- String[] paths = { "sp:aspectjrt.path", "sp:aspectjrt.jar",
- "../lib/test/aspectjrt.jar", "../aj-build/jars/aspectj5rt-all.jar",
- "../aj-build/jars/runtime.jar",
- "../runtime/bin"};
- ASPECTJRT_PATH = FileUtil.getBestFile(paths);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AjdocTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(DeclareFormsTest.class);
- suite.addTestSuite(SpacewarTestCase.class);
- suite.addTestSuite(PatternsTestCase.class);
- suite.addTestSuite(CoverageTestCase.class);
- suite.addTestSuite(ITDTest.class);
- suite.addTestSuite(FullyQualifiedArgumentTest.class);
- suite.addTestSuite(EnumTest.class);
- suite.addTestSuite(PointcutVisibilityTest.class);
- suite.addTestSuite(ExecutionTestCase.class);
- suite.addTestSuite(BugTests.class);
- //$JUnit-END$
- return suite;
- }
-
-}
+++ /dev/null
-/********************************************************************
- * Copyright (c) 2006 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://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- * Helen Hawkins - initial version
- *******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-public class BugTests extends AjdocTestCase {
-
- public void testPr160302() throws Exception {
- initialiseProject("pr160302");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- runAjdoc(files);
- assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
- File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
- if (!html.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
- }
- assertFalse("expected all decorating tags to be removed but found that they" +
- " weren't",AjdocOutputChecker.containsString(html, Config.DECL_ID_STRING));
- }
-
- /**
- * Passing the "-Xlint:error" option through to the compiler should
- * cause the ajc build to fail because the advice did not match
- */
- public void testPr148906_1() {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")};
- String[] ajOptions = {new String("-Xlint:error")};
- runAjdoc(files,"1.5",ajOptions);
- assertTrue("expected ajc to fail but it did not", Main.hasAborted());
- assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" +
- " failed instead with " + Main.getErrors()[0].getMessage(),
- "advice defined in AdviceDidNotMatch has not been applied [Xlint:adviceDidNotMatch]",
- Main.getErrors()[0].getMessage());
- }
-
- /**
- * Passing the "-Xlintfile" option through to the compiler should
- * cause the ajc build to fail because the advice did not match
- */
- public void testPr148906_2() {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")};
- String[] ajOptions = {new String("-Xlintfile"), new String(getAbsoluteProjectDir() + File.separator + "Xlint.properties")};
- runAjdoc(files,"1.5",ajOptions);
- assertTrue("expected ajc to fail but it did not", Main.hasAborted());
- assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" +
- " failed instead with " + Main.getErrors()[0].getMessage(),
- "advice defined in AdviceDidNotMatch has not been applied [Xlint:adviceDidNotMatch]",
- Main.getErrors()[0].getMessage());
- }
-
- /**
- * Passing the -aspectpath option though to the compiler should
- * result in relationships being displayed
- */
- public void testPr148906_3() throws Exception {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- String[] ajOptions = {new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
- runAjdoc(files,"1.6",ajOptions);
- assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
- File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
- if (!html.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
- }
- assertTrue("expected to find 'Advised by' in the html output but did " +
- " not",AjdocOutputChecker.containsString(html,
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY.getName()));
- }
-
- /**
- * Passing an option starting with "-" that doesn't require a second entry
- * should mean everything is correctly given to the compiler. For example:
- * '-outxml -aspectpath <file>" should mean both '-outxml' and the aspectpath
- * options are given correctly.
- */
- public void testPr148906_4() throws Exception {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- String[] ajOptions = {new String("-outxml"),new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
- runAjdoc(files,"1.6",ajOptions);
- assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
- File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
- if (!html.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
- }
- assertTrue("expected to find 'Advised by' in the html output but did " +
- " not",AjdocOutputChecker.containsString(html,
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY.getName()));
- File aopFile = new File(getAbsolutePathOutdir() + File.separator
- + "META-INF" + File.separator + "aop-ajc.xml");
- assertTrue("couldn't find " + getAbsolutePathOutdir() + File.separator
- + "META-INF" + File.separator + "aop-ajc.xml" ,
- aopFile.exists());
- }
-
- /**
- * Passing bogus option to ajc
- */
- public void testPr148906_5() throws Exception {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- String[] ajOptions = {new String("-bogus")};
- runAjdoc(files,"1.5",ajOptions);
- assertTrue("expected build of project to abort",Main.hasAborted());
- }
-
- /**
- * Not passing any files to ajdoc should result in both the ajdoc
- * and ajc usage messages
- */
- public void testPr148906_6() throws Exception {
- initialiseProject("pr148906");
- List options = new ArrayList();
- options.add("-verbose");
- runAjdoc(options);
- assertTrue("expected the ajdoc usage message to be reported",Main.hasShownAjdocUsageMessage());
- assertTrue("expected build of project to abort",Main.hasAborted());
- }
-
- /**
- * javadoc comments should still appear even if preceded by
- * 'normal' comments
- */
- public void testPr164356() throws Exception {
- initialiseProject("pr164356");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- runAjdoc(files);
- File htmlFile = new File(getAbsolutePathOutdir() + "/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() +
- " (ajc aborted: " + Main.hasAborted() + ")");
- }
- String foo = "description of foo";
- String bar = "description of bar";
- String goo = "description of goo";
- String bas = "description of bas";
- assertTrue("expected method description 'description of foo' to appear" +
- " in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, foo));
- assertTrue("expected method description 'description of bar' to " +
- "appear in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, bar));
- assertFalse("didn't expect method description 'description of goo' to " +
- "appear in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, goo));
- assertTrue("expected method description 'description of bas' to appear" +
- " in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, bas));
- }
-
- /**
- * Comments for a constructor should be included in the ajdoc output
- */
- public void testPr164340() throws Exception {
- initialiseProject("pr164340");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- runAjdoc(files);
- File htmlFile = new File(getAbsolutePathOutdir() + "/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() +
- " (ajc aborted: " + Main.hasAborted() + ")");
- }
- String methodDesc = "This is method foo";
- String constDesc = "This is a constructor";
- assertTrue("expected method description 'This is method foo' to appear" +
- " in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, methodDesc));
- assertTrue("expected constructor description 'This is a constructor' to " +
- "appear in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, constDesc));
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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.List;
-
-import org.aspectj.util.LangUtil;
-
-/**
- * A long way to go until full coverage, but this is the place to add more.
- *
- * @author Mik Kersten
- */
-public class CoverageTestCase extends AjdocTestCase {
-
- protected File file0,file1,aspect1,file2,file3,file4,file5,file6,file7,file8,file9,file10;
-
- protected void setUp() throws Exception {
- super.setUp();
- initialiseProject("coverage");
- createFiles();
- }
-
- public void testOptions() {
- String[] args = {
- "-private",
- "-encoding",
- "EUCJIS",
- "-docencoding",
- "EUCJIS",
- "-charset",
- "UTF-8",
- "-classpath",
- AjdocTests.ASPECTJRT_PATH.getPath(),
- "-d",
- getAbsolutePathOutdir(),
- file0.getAbsolutePath(),
- };
- org.aspectj.tools.ajdoc.Main.main(args);
- assertTrue(true);
- }
-
- /**
- * Test the "-public" argument
- */
- public void testCoveragePublicMode() throws Exception {
- File[] files = {file3,file9};
- runAjdoc("public","9",files);
-
- // have passed the "public" modifier as well as
- // one public and one package visible class. There
- // should only be ajdoc for the public class
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/PkgVisibleClass.html");
- assertFalse("ajdoc for PkgVisibleClass shouldn't exist because passed" +
- " the 'public' flag to ajdoc",htmlFile.exists());
-
- htmlFile = new File(getAbsolutePathOutdir() + "/foo/PlainJava.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- // check there's no private fields within the file, that
- // the file contains the getI() method but doesn't contain
- // the private ClassBar, Bazz and Jazz classes.
- String[] strings = { "private", "getI()","ClassBar", "Bazz", "Jazz"};
- List missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
- assertEquals("There should be 4 missing strings",4,missing.size());
- assertTrue(htmlFile.getName() + " should not contain the private modifier",missing.contains("private"));
- assertTrue(htmlFile.getName() + " should not contain the private ClassBar class",missing.contains("ClassBar"));
- assertTrue(htmlFile.getName() + " should not contain the private Bazz class",missing.contains("Bazz"));
- assertTrue(htmlFile.getName() + " should not contain the private Jazz class",missing.contains("Jazz"));
- }
-
- /**
- * Test that the ajdoc for an aspect has the title "Aspect"
- */
- public void testAJdocHasAspectTitle() throws Exception {
- File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A.aj")};
- runAjdoc("private","1.6",files);
- File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/A.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?");
- }
- assertTrue(htmlFile.getAbsolutePath() + " should have Aspect A as it's title",
- AjdocOutputChecker.containsString(htmlFile,"Aspect A"));
- }
-
- /**
- * Test that the ajdoc for a class has the title "Class"
- */
- public void testAJdocHasClassTitle() throws Exception {
- File[] files = {new File(getAbsoluteProjectDir() + "/pkg/C.java")};
- runAjdoc("private","1.6",files);
- File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?");
- }
- assertTrue(htmlFile.getAbsolutePath() + " should have Class C as it's title",
- AjdocOutputChecker.containsString(htmlFile,"Class C"));
-
- }
-
- /**
- * Test that the ajdoc for an inner aspect is entitled "Aspect" rather
- * than "Class", but that the enclosing class is still "Class"
- */
- public void testInnerAspect() throws Exception {
- File[] files = {file1, file2};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/ClassA.InnerAspect.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- // ensure that the file is entitled "Aspect ClassA.InnerAspect" rather
- // than "Class ClassA.InnerAspect"
-
- String[] strings = null;
- if (LangUtil.is18VMOrGreater()) {
- strings = new String[] {
- "Aspect ClassA.InnerAspect",
- "<pre>static aspect <span class=\"typeNameLabel\">ClassA.InnerAspect</span>",
- "Class ClassA.InnerAspect",
- "<pre>static class <span class=\"typeNameLabel\">ClassA.InnerAspect</span>"};
- }
- else {
- strings = new String[] {
- "Aspect ClassA.InnerAspect",
- "<PRE>static aspect <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>",
- "Class ClassA.InnerAspect",
- "<PRE>static class <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>"};
- }
- List<String> missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
- StringBuilder buf = new StringBuilder();
- for (String str:missingStrings) {
- buf.append(str).append("\n");
- }
- buf.append("HTMLFILE=\n").append(htmlFile).append("\n");
- assertEquals("There should be 2 missing strings:\n"+buf.toString(), 2, missingStrings.size());
- assertTrue(htmlFile.getName() + " should not have Class as it's title",
- missingStrings.contains("Class ClassA.InnerAspect"));
- if (LangUtil.is18VMOrGreater()) {
- assertTrue(htmlFile.getName() + " should not have class in its subtitle",
- missingStrings.contains("<pre>static class <span class=\"typeNameLabel\">ClassA.InnerAspect</span>"));
- }
- else {
- assertTrue(htmlFile.getName() + " should not have class in its subtitle",
- missingStrings.contains("<PRE>static class <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>"));
- }
-
- // get the html file for the enclosing class
- File htmlFileClass = new File(getAbsolutePathOutdir() + "/foo/ClassA.html");
- if (!htmlFileClass.exists()) {
- fail("couldn't find " + htmlFileClass.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- // ensure that the file is entitled "Class ClassA" and
- // has not been changed to "Aspect ClassA"
- String[] classStrings = null;
-
- if (LangUtil.is18VMOrGreater()) {
- classStrings = new String[] {
- "Class ClassA</h2>",
- "public abstract class <span class=\"typeNameLabel\">ClassA</span>",
- "Aspect ClassA</H2>",
- "public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"};
- }
- else {
- classStrings = new String[] {
- "Class ClassA</H2>",
- "public abstract class <B>ClassA</B><DT>extends java.lang.Object<DT>",
- "Aspect ClassA</H2>",
- "public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"};
- }
- List classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
- assertEquals("There should be 2 missing strings:\n"+classMissing,2,classMissing.size());
- assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>"));
- if (LangUtil.is18VMOrGreater()) {
- assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
- classMissing.contains("public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"));
- }
- else {
- assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
- classMissing.contains("public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"));
- }
- }
-
- /**
- * Test that all the different types of advice appear
- * with the named pointcut in it's description
- */
- public void testAdviceNamingCoverage() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdviceNamingCoverage.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- String[] strings = {
- "after(): named..",
- "afterReturning(int,int): namedWithArgs..",
- "afterThrowing(): named..",
- "before(): named..",
- "around(int): namedWithOneArg..",
- "before(int):",
- "before(int): named()..",
- "before():"};
- List missing = AjdocOutputChecker.getMissingStringsInSection(
- htmlFile, strings,"ADVICE DETAIL SUMMARY");
- assertTrue(htmlFile.getName() + " should contain all advice in the Advice Detail section",missing.isEmpty());
- missing = AjdocOutputChecker.getMissingStringsInSection(
- htmlFile,strings,"ADVICE SUMMARY");
- assertTrue(htmlFile.getName() + " should contain all advice in the Advice Summary section",missing.isEmpty());
- }
-
- /**
- * Test that all the advises relationships appear in the
- * Advice Detail and Advice Summary sections and that
- * the links are correct
- */
- public void testAdvisesRelationshipCoverage() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- "before(): methodExecutionP..",
- "HREF=\"../foo/Point.html#setX(int)\"",
- "before(): constructorExecutionP..",
- "HREF=\"../foo/Point.html#Point()\"",
- "before(): callMethodP..",
- "HREF=\"../foo/Point.html#changeX(int)\"",
- "before(): callConstructorP..",
- "HREF=\"../foo/Point.html#doIt()\"",
- "before(): getP..",
- "HREF=\"../foo/Point.html#getX()\"",
- "before(): setP..",
- "HREF=\"../foo/Point.html\"><tt>foo.Point</tt></A>, <A HREF=\"../foo/Point.html#Point()\"><tt>foo.Point.Point</tt></A>, <A HREF=\"../foo/Point.html#setX(int)\"",
- "before(): initializationP..",
- "HREF=\"../foo/Point.html#Point()\"",
- "before(): staticinitializationP..",
- "HREF=\"../foo/Point.html\"",
- "before(): handlerP..",
- "HREF=\"../foo/Point.html#doIt()\""
- };
-
- for (int i = 0; i < strings.length - 1; i = i+2) {
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"ADVICE DETAIL SUMMARY",strings[i],
- HtmlDecorator.HtmlRelationshipKind.ADVISES,
- strings[i+1]);
- assertTrue(strings[i] + " should advise " + strings[i+1] +
- " in the Advice Detail section", b);
- }
-
- for (int i = 0; i < strings.length - 1; i = i+2) {
- boolean b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"ADVICE SUMMARY",strings[i],
- HtmlDecorator.HtmlRelationshipKind.ADVISES,
- strings[i+1]);
- assertTrue(strings[i] + " should advise " + strings[i+1] +
- " in the Advice Summary section", b);
- }
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a method execution pointcut
- */
- public void testAdvisedByMethodExecution() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- toName("setX(int)"),
- "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): methodExecutionP..\""};
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a constructor execution pointcut
- */
- public void testAdvisedByConstructorExecution() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
- "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): constructorExecutionP..\""};
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== CONSTRUCTOR DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Constructor Detail should have " + strings[0]+" advised by " + strings[1],b);
-
- // Pre-JDK 11:
- // This precedes the line containing strings[1]
- // <td class="colOne"><code><span class="memberNameLink"><a href="../foo/Point.html#Point--">Point</a></span>()</code>
- // On JDK 11:
- // This precedes the line containing strings[1]
- // <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">Point</a></span>()</code></th>
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== CONSTRUCTOR SUMMARY",
- LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Constructor Summary should have " + strings[0]+" advised by " + strings[1],b);
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a method call pointcut
- */
- public void testAdvisedByMethodCall() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- toName("changeX(int)"),
- "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): callMethodP..\""};
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a constructor call pointcut
- */
- public void testAdvisedByConstructorCall() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- toName("doIt()"),
- "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): callConstructorP..\""};
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a get pointcut
- */
- public void testAdvisedByGet() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- toName("getX()"),
- "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): getP..\""};
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a set pointcut
- */
- public void testAdvisedBySet() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String href = "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): setP..\"";
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName("setX(int)"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- href);
- assertTrue("the Method Detail should have setX(int) advised by " + href,b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName("setX(int)"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- href);
- assertTrue("the Method Summary should have setX(int) advised by " + href,b);
-
- b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== CONSTRUCTOR DETAIL",
- LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- href);
- assertTrue("the Constructor Detail should have advised by " + href,b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== CONSTRUCTOR SUMMARY",
- LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- href);
- assertTrue("the Constructor Summary should have advised by " + href,b);
-
- b = AjdocOutputChecker.classDataSectionContainsRel(
- htmlFile,
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- href);
- assertTrue("The class data section should have 'advised by " + href + "'",b);
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with an initialization pointcut
- */
- public void testAdvisedByInitialization() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
- "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): initializationP..\""};
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,
- "=== CONSTRUCTOR DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Detail should have 'setX(int) advised by ... before()'",b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,
- "=== CONSTRUCTOR SUMMARY",
- LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Summary should have 'setX(int) advised by ... before()'",b);
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a staticinitialization pointcut
- */
- public void testAdvisedByStaticInitialization() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String href = "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): staticinitializationP..\"";
- boolean b = AjdocOutputChecker.classDataSectionContainsRel(
- htmlFile,
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- href);
- assertTrue("The class data section should have 'advised by " + href + "'",b);
- }
-
- /**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a handler pointcut
- */
- public void testAdvisedByHandler() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- toName("doIt()"),
- "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): handlerP..\""};
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
- }
-
- private String toName(String name) {
- if (LangUtil.is18VMOrGreater() && !LangUtil.is11VMOrGreater()) {
- name = name.replace('(','-');
- name = name.replace(')','-');
- }
- return name;
- }
- /**
- * Test that if have two before advice blocks from the same
- * aspect affect the same method, then both appear in the ajdoc
- */
- public void testTwoBeforeAdvice() throws Exception {
- File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String[] strings = {
- toName("amethod()"),
- "HREF=\"../pkg/A2.html#before(): p..\"",
- "HREF=\"../pkg/A2.html#before(): p2..\""};
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[1]);
- assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
-
- b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[2]);
- assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[2],b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- strings[0],
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- strings[2]);
- assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[2],b);
- }
-
- /**
- * Test that there are no spurious "advised by" entries
- * against the aspect in the ajdoc
- */
- public void testNoSpuriousAdvisedByRels() throws Exception {
- File[] files = {file4};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- String href = "foo.Point.setX(int)";
- boolean b = AjdocOutputChecker.classDataSectionContainsRel(
- htmlFile,
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- href);
- assertFalse("The class data section should not have 'advised by " + href + "'",b);
-
- }
-
- public void testCoverage() {
- File[] files = {aspect1,file0,file1,file2,file3,file4,file5,file6,
- file7,file8,file9,file10};
- runAjdoc("private","1.6",files);
- }
-
- /**
- * Test that nested aspects appear with "aspect" in their title
- * when the ajdoc file is written slightly differently (when it's
- * written for this apsect, it's different than for testInnerAspect())
- */
- public void testNestedAspect() throws Exception {
- File[] files = {file9};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.NestedAspect.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- // ensure that the file is entitled "Aspect PkgVisibleClass.NestedAspect" rather
- // than "Class PkgVisibleClass.NestedAspect"
- String[] strings = null;
- if (LangUtil.is18VMOrGreater()) {
- strings = new String[] {
- "Aspect PkgVisibleClass.NestedAspect",
- "<pre>static aspect <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>",
- "Class PkgVisibleClass.NestedAspect",
- "<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>"};
- }
- else {
- strings = new String[] {
- "Aspect PkgVisibleClass.NestedAspect",
- "<PRE>static aspect <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>",
- "Class PkgVisibleClass.NestedAspect",
- "<PRE>static class <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>"};
- }
- List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
- assertEquals("There should be 2 missing strings",2,missing.size());
- assertTrue(htmlFile.getName() + " should not have Class as it's title",missing.contains("Class PkgVisibleClass.NestedAspect"));
- if (LangUtil.is18VMOrGreater()) {
- assertTrue(htmlFile.getName() + " should not have class in its subtitle",
- missing.contains("<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>"));
- }
- else {
- assertTrue(htmlFile.getName() + " should not have class in its subtitle",
- missing.contains("<PRE>static class <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>"));
- }
- // get the html file for the enclosing class
- File htmlFileClass = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.html");
- if (!htmlFileClass.exists()) {
- fail("couldn't find " + htmlFileClass.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- // ensure that the file is entitled "Class PkgVisibleClass" and
- // has not been changed to "Aspect PkgVisibleClass"
- String[] classStrings = null;
- if (LangUtil.is18VMOrGreater()) {
- classStrings = new String[] {
- "Class PkgVisibleClass</h2>",
- "<pre>class <span class=\"typeNameLabel\">PkgVisibleClass</span>",
- "Aspect PkgVisibleClass</h2>",
- "<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"};
- }
- else {
- classStrings = new String[] {
- "Class PkgVisibleClass</H2>",
- "class <B>PkgVisibleClass</B><DT>extends java.lang.Object</DL>",
- "Aspect PkgVisibleClass</H2>",
- "aspect <B>PkgVisibleClass</B><DT>extends java.lang.Object<DT>"};
- }
- List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
- assertEquals("There should be 2 missing strings",2,classMissing.size());
- if (LangUtil.is18VMOrGreater()) {
- assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
- classMissing.contains("Aspect PkgVisibleClass</h2>"));
- assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
- classMissing.contains("<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"));
- }
- else {
- assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect PkgVisibleClass</H2>"));
- assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",classMissing.contains("aspect <B>PkgVisibleClass</B><DT>extends java.lang.Object<DT>"));
- }
- }
-
- /**
- * Test that in the case when you have a nested aspect whose
- * name is part of the enclosing class, for example a class called
- * ClassWithNestedAspect has nested aspect called NestedAspect,
- * that the titles for the ajdoc are correct.
- */
- public void testNestedAspectWithSimilarName() throws Exception {
- File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
- // ensure that the file is entitled "Aspect ClassWithNestedAspect.NestedAspect"
- // rather than "Class ClassWithNestedAspect.NestedAspect"
- String[] strings = null;
- if (LangUtil.is18VMOrGreater()) {
- strings = new String [] {
- "Aspect ClassWithNestedAspect.NestedAspect",
- "<pre>static aspect <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>",
- "Class ClassWithNestedAspect.NestedAspect",
- "<pre>static class <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>"};
- }
- else {
- strings = new String [] {
- "Aspect ClassWithNestedAspect.NestedAspect",
- "<PRE>static a;spect <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>",
- "Class ClassWithNestedAspect.NestedAspect",
- "<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"};
- }
- List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
- assertEquals("There should be 2 missing strings",2,missing.size());
- assertTrue(htmlFile.getName() + " should not have Class as it's title",missing.contains("Class ClassWithNestedAspect.NestedAspect"));
- if (LangUtil.is18VMOrGreater()) {
- assertTrue(htmlFile.getName() + " should not have class in its subtitle",
- missing.contains("<pre>static class <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>"));
- }
- else {
- assertTrue(htmlFile.getName() + " should not have class in its subtitle",missing.contains("<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"));
- }
-
- // get the html file for the enclosing class
- File htmlFileClass = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
- if (htmlFileClass == null || !htmlFileClass.exists()) {
- fail("couldn't find " + htmlFileClass.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- // ensure that the file is entitled "Class ClassWithNestedAspect" and
- // has not been changed to "Aspect ClassWithNestedAspect"
- String[] classStrings = null;
- if (LangUtil.is18VMOrGreater()) {
- classStrings = new String[] {
- "Class ClassWithNestedAspect</h2>",
- "public class <span class=\"typeNameLabel\">ClassWithNestedAspect</span>",
- "Aspect ClassWithNestedAspect</h2>",
- "public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"};
- }
- else {
- classStrings = new String[] {
- "Class ClassWithNestedAspect</H2>",
- "public class <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>",
- "Aspect ClassWithNestedAspect</H2>",
- "public aspect <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>"};
- }
- List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
- assertEquals("There should be 2 missing strings",2,classMissing.size());
- if (LangUtil.is18VMOrGreater()) {
- assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
- classMissing.contains("Aspect ClassWithNestedAspect</h2>"));
- assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
- classMissing.contains("public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"));
- }
- else {
- assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
- classMissing.contains("Aspect ClassWithNestedAspect</H2>"));
- assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
- classMissing.contains("public aspect <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>"));
- }
- }
-
- /**
- * Test that everythings being decorated correctly within the ajdoc
- * for the aspect when the aspect is a nested aspect
- */
- public void testAdviceInNestedAspect() throws Exception {
- File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"ADVICE DETAIL SUMMARY",
- "before(): p..",
- HtmlDecorator.HtmlRelationshipKind.ADVISES,
- "HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"");
- assertTrue("Should have 'before(): p.. advises HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"" +
- "' in the Advice Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"ADVICE SUMMARY",
- "before(): p..",
- HtmlDecorator.HtmlRelationshipKind.ADVISES,
- "HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"");
- assertTrue("Should have 'before(): p.. advises HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"" +
- "' in the Advice Summary section", b);
-
- }
-
- /**
- * Test that everythings being decorated correctly within the ajdoc
- * for the advised class when the aspect is a nested aspect
- */
- public void testAdvisedByInNestedAspect() throws Exception {
- File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.containsString(htmlFile,"POINTCUT SUMMARY ");
- assertFalse(htmlFile.getName() + " should not contain a pointcut summary section",b);
- b = AjdocOutputChecker.containsString(htmlFile,"ADVICE SUMMARY ");
- assertFalse(htmlFile.getName() + " should not contain an adivce summary section",b);
- b = AjdocOutputChecker.containsString(htmlFile,"POINTCUT DETAIL ");
- assertFalse(htmlFile.getName() + " should not contain a pointcut detail section",b);
- b = AjdocOutputChecker.containsString(htmlFile,"ADVICE DETAIL ");
- assertFalse(htmlFile.getName() + " should not contain an advice detail section",b);
-
- b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"");
- assertTrue("Should have 'amethod() advised by " +
- "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"" +
- "' in the Method Detail section", b);
-
- b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p..");
- assertFalse("Should not have the label " +
- "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p.." +
- " in the Method Detail section", b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"");
- assertTrue("Should have 'amethod() advised by " +
- "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"" +
- "' in the Method Summary section", b);
-
- b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p..");
- assertFalse("Should not have the label " +
- "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p.." +
- " in the Method Summary section", b);
-
- }
-
- private void createFiles() {
- file0 = new File(getAbsoluteProjectDir() + "/InDefaultPackage.java");
- file1 = new File(getAbsoluteProjectDir() + "/foo/ClassA.java");
- aspect1 = new File(getAbsoluteProjectDir() + "/foo/UseThisAspectForLinkCheck.aj");
- file2 = new File(getAbsoluteProjectDir() + "/foo/InterfaceI.java");
- file3 = new File(getAbsoluteProjectDir() + "/foo/PlainJava.java");
- file4 = new File(getAbsoluteProjectDir() + "/foo/ModelCoverage.java");
- file5 = new File(getAbsoluteProjectDir() + "/fluffy/Fluffy.java");
- file6 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/Bunny.java");
- file7 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/rocks/Rocks.java");
- file8 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java");
- file9 = new File(getAbsoluteProjectDir() + "/foo/PkgVisibleClass.java");
- file10 = new File(getAbsoluteProjectDir() + "/foo/NoMembers.java");
- }
-
-// public void testPlainJava() {
-// String[] args = { "-d",
-// getAbsolutePathOutdir(),
-// file3.getAbsolutePath() };
-// org.aspectj.tools.ajdoc.Main.main(args);
-// }
-
-}
+++ /dev/null
-/* *******************************************************************
- * 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.List;
-
-import org.aspectj.util.LangUtil;
-
-/**
- * @author Mik Kersten
- */
-public class DeclareFormsTest extends AjdocTestCase {
-
- private String declareError = "declare error: quot;Illegal construct..quot";
- private String declareWarningQuotes = "declare warning: quot;Illegal call.quot;";
- private String declareWarning = "declare warning: \"Illegal call.\"";
- private String declareParentsImpl = "declare parents: implements Serializable";
- private String declareSoft = "declare soft: foo.SizeException2";
- private String declarePrecedence = "declare precedence: foo.DeclareCoverage2, foo.InterTypeDecCoverage2";
-
- private String doItHref = "HREF=\"../foo/Main2.html#doIt()\"";
- private String pointHref = "HREF=\"../foo/Point2.html\"";
- private String cHref = "HREF=\"../foo/C.html\"";
-
- private String doIt = "doIt()";
-
-
- public void testCoverage() {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage.java")};
- runAjdoc("private","1.6",files);
- }
-
- /**
- * Test that the declare statements appear in the Declare Detail
- * and Declare Summary sections of the ajdoc
- */
- public void testDeclareStatments() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
- // check the contents of the declare detail summary
- String[] strings = {
- declareError,
- declareWarning,
- declareParentsImpl,
- declareSoft,
- declarePrecedence};
-
- List missing = AjdocOutputChecker.getMissingStringsInSection(
- htmlFile,strings,"DECLARE DETAIL SUMMARY");
- assertTrue(htmlFile.getName() + " should contain all declare statements in " +
- "the Declare Detail section",missing.isEmpty());
-
- // check the contents of the declare summary - should contain
- // the same strings
- missing = AjdocOutputChecker.getMissingStringsInSection(
- htmlFile,strings,"DECLARE SUMMARY");
- assertTrue(htmlFile.getName() + " should contain all declare statements in " +
- "the Declare Summary section",missing.isEmpty());
- }
-
- /**
- * Declare warning's should have the 'matched by' relationship
- * in the ajdoc for the declaring aspect
- */
- public void testDeclareWarning() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"DECLARE DETAIL SUMMARY",
- declareWarningQuotes,
- HtmlDecorator.HtmlRelationshipKind.MATCHED_BY,
- doItHref);
- assertTrue("Should have '" + declareWarningQuotes + " matched by " + doItHref +
- "' in the Declare Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"DECLARE SUMMARY",
- declareWarningQuotes,
- HtmlDecorator.HtmlRelationshipKind.MATCHED_BY,
- doItHref);
- assertTrue("Should have '" + declareWarningQuotes + " matched by " + doItHref +
- "' in the Declare Summary section", b);
- }
-
- /**
- * The target of a declare warning should have the 'matches
- * declare' relationship in the ajdoc - test the case when
- * the declare warning matches a call join point
- */
- public void testMatchesDeclareCall() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName(doIt),
- HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
- declareWarningQuotes);
- assertTrue("Should have '" + doIt + " matches declare " +
- declareWarningQuotes + "' in the Declare Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName(doIt),
- HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
- declareWarningQuotes);
- assertTrue("Should have '" + doIt + " matches declare " +
- declareWarningQuotes + "' in the Declare Summary section", b);
- }
-
- /**
- * The target of a declare warning should have the 'matches
- * declare' relationship in the ajdoc - test the case when
- * the declare warning matches an execution join point
- */
- public void testMatchesDeclareExecution() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName("setX(int)"),
-// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)",
- HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
- "declare warning: quot;blahquot;");
- assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" +
- "' in the Method Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName("setX(int)"),
-// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)",
- HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
- "declare warning: quot;blahquot;");
- assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" +
- "' in the Method Summary section", b);
- }
-
- /**
- * Declare parents's should have the 'declared on' relationship
- * in the ajdoc for the declaring aspect
- */
- public void testDeclareParents() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"DECLARE DETAIL SUMMARY",
- declareParentsImpl,
- HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
- pointHref);
- assertTrue("Should have ' " + declareParentsImpl + " declared on " +
- pointHref + "' in the Declare Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"DECLARE SUMMARY",
- declareParentsImpl,
- HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
- pointHref);
- assertTrue("Should have ' " + declareParentsImpl + " declared on " +
- pointHref + "' in the Declare Summary section", b);
- }
-
- /**
- * The target of a declare parent should have the 'aspect
- * declarations' relationship in the ajdoc
- */
- public void testAspectDeclarations() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
- boolean b = AjdocOutputChecker.classDataSectionContainsRel(
- htmlFile,
- HtmlDecorator.HtmlRelationshipKind.ASPECT_DECLARATIONS,
- "declare parents: implements Serializable");
- assertTrue("The class data section should have 'aspect declarations" +
- " declare parents: implements Serializable'",b);
-
- }
-
- /**
- * Declare soft's should have the 'softens' relationship
- * in the ajdoc for the declaring aspect
- */
- public void testDeclareSoft() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"DECLARE DETAIL SUMMARY",
- declareSoft,
- HtmlDecorator.HtmlRelationshipKind.SOFTENS,
- doItHref);
- assertTrue("Should have '" + declareSoft + " softens " + doItHref +
- "' in the Declare Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"DECLARE SUMMARY",
- declareSoft,
- HtmlDecorator.HtmlRelationshipKind.SOFTENS,
- doItHref);
- assertTrue("Should have '" + declareSoft + " softens " + doItHref +
- "' in the Declare Summary section", b);
- }
-
- /**
- * The target of a declare soft should have the 'softened
- * by' relationship in the ajdoc
- */
- public void testSoftenedBy() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName(doIt),
- HtmlDecorator.HtmlRelationshipKind.SOFTENED_BY,
- declareSoft);
- assertTrue("Should have '" + doIt + " softened by " + declareSoft +
- "' in the Method Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName(doIt),
- HtmlDecorator.HtmlRelationshipKind.SOFTENED_BY,
- declareSoft);
- assertTrue("Should have '" + doIt + " softened by " + declareSoft +
- "' in the Method Summary section", b);
- }
-
- private String toName(String name) {
- if (LangUtil.is18VMOrGreater() && !LangUtil.is11VMOrGreater()) {
- name = name.replace('(','-');
- name = name.replace(')','-');
- }
- return name;
- }
-
- /**
- * Declare annotation should have the 'annotates' relationship
- * in the ajdoc for the declaring aspect
- */
- public void testDeclareAnnotation() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")};
- runAjdoc("private","1.6",files);
-
- // Aspect AnnotationTest should contain within it's declare
- // detail and summary the declare annotation statement.
- // Check for this....
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareAtType.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- // check there's no return type for the declare annotation
- // statement in the declare summary section
- String[] returnType = {"[]"};
- List missing = AjdocOutputChecker.getMissingStringsInSection(
- htmlFile,returnType,"DECLARE SUMMARY");
- assertEquals("there should be no return type for declare annotation" +
- " in the ajdoc",1,missing.size());
- assertEquals("there shouldn't be the '[]' return type for declare annotation" +
- " in the ajdoc","[]",missing.get(0));
-
- // check that the 'annotates' relationship is there
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"DECLARE DETAIL SUMMARY",
- "declare @type: foo.C : @MyAnnotation",
- HtmlDecorator.HtmlRelationshipKind.ANNOTATES,
- cHref);
- assertTrue("Should have 'declare @type: foo.C : @MyAnnotation annotates "
- + cHref + "' in the Declare Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"DECLARE SUMMARY",
- "declare @type: foo.C : @MyAnnotation",
- HtmlDecorator.HtmlRelationshipKind.ANNOTATES,
- cHref);
- assertTrue("Should have 'declare @type: foo.C : @MyAnnotation annotates "
- + cHref + "' in the Declare Summary section", b);
- }
-
- /**
- * The target of a declare method annotation should have the
- * 'annotated by' relationship in the ajdoc within the method
- * information
- */
- public void testMethodAnnotatedBy() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtMethod.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
- "declare @method: public * foo.C.*(..) : @MyAnnotation");
- assertTrue("Should have 'amethod() annotated by " +
- "declare @method: public * foo.C.*(..) : @MyAnnotation" +
- "' in the Method Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
- "declare @method: public * foo.C.*(..) : @MyAnnotation");
- assertTrue("Should have 'amethod() annotated by " +
- "declare @method: public * foo.C.*(..) : @MyAnnotation" +
- "' in the Method Summary section", b);
- }
-
- /**
- * The target of a declare method annotation should have the
- * 'annotated by' relationship in the ajdoc within the method
- * information
- */
- public void testConstructorAnnotatedBy() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtConstructor.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== CONSTRUCTOR DETAIL",
- LangUtil.is11VMOrGreater()?"<init>(java.lang.String)":toName("C(java.lang.String)"),
- HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
- "declare @constructor: foo.C.new(..) : @MyAnnotation");
- assertTrue("Should have '" + doIt + " annotated by " +
- "declare @constructor: foo.C.new(..) : @MyAnnotation" +
- "' in the Method Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== CONSTRUCTOR SUMMARY",
- LangUtil.is11VMOrGreater()?"#%3Cinit%3E(java.lang.String)":toName("C(java.lang.String)"),
- HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
- "declare @constructor: foo.C.new(..) : @MyAnnotation");
- assertTrue("Should have '" + doIt + " annotated by " +
- "declare @constructor: foo.C.new(..) : @MyAnnotation" +
- "' in the Method Summary section", b);
- }
-
- /**
- * The target of a declare method annotation should have the
- * 'annotated by' relationship in the ajdoc within the method
- * information
- */
- public void testFieldAnnotatedBy() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtField.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== FIELD DETAIL",
- "x",
- HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
- "declare @field: int foo.C.* : @MyAnnotation");
- assertTrue("Should have '" + doIt + " annotated by " +
- "declare @field: int foo.C.* : @MyAnnotation" +
- "' in the Field Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== FIELD SUMMARY",
- "x",
- HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
- "declare @field: int foo.C.* : @MyAnnotation");
- assertTrue("Should have '" + doIt + " annotated by " +
- "declare @field: int foo.C.* : @MyAnnotation" +
- "' in the Field Summary section", b);
- }
-
- /**
- * The target of a declare method annotation should have the
- * 'annotated by' relationship in the ajdoc within the method
- * information
- */
- public void testTypeAnnotatedBy() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
- boolean b = AjdocOutputChecker.classDataSectionContainsRel(
- htmlFile,
- HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
- "declare @type: foo.C : @MyAnnotation");
- assertTrue("The class data section should have 'annotated by" +
- " declare @type: foo.C : @MyAnnotation'",b);
- }
-
- /**
- * Test that info for both "matches declare" and "advised by"
- * appear in the ajdoc for a method when the method is affected
- * by both.
- */
- public void testMatchesDeclareAndAdvisedBy() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "A.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
- "declare warning: quot;warningquot;");
- assertTrue("Should have 'amethod() matches declare declare warning: " +
- "quot;warningquot;' in the Method Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
- "declare warning: quot;warningquot;");
- assertTrue("Should have 'amethod() matches declare declare warning: " +
- "quot;warningquot;' in the Method Summary section", b);
-
- b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"=== METHOD DETAIL",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- "before(): p..");
- assertTrue("the Method Detail should have amethod() advised by before(): p..",b);
-
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"=== METHOD SUMMARY",
- toName("amethod()"),
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
- "before(): p..");
- assertTrue("the Method Summary should have amethod() advised by before(): p..",b);
- }
-
- /**
- * Test that if there are two declare parents statements within
- * an aspect, one which extends and one which implements, that the
- * ajdoc shows the correct information
- */
- public void testTwoDeclareParents() throws Exception {
- initialiseProject("declareForms");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareParents.aj")};
- runAjdoc("private","1.6",files);
-
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareParents.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath()
- + " - were there compilation errors?");
- }
-
- String[] strings = {
- "declare parents: implements Serializable",
- "HREF=\"../foo/Class1.html\"",
- "declare parents: extends Observable",
- "HREF=\"../foo/Class2.html\""};
-
- // check that the correct declare statements are there
- for (int i = 0; i < strings.length - 1; i = i+2) {
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"DECLARE DETAIL SUMMARY",strings[i],
- HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
- strings[i+1]);
- assertTrue("Should have ' " + strings[i] + " declared on " + strings[i+1] +
- "' in the Declare Detail section", b);
- }
-
- for (int i = 0; i < strings.length - 1; i = i+2) {
- boolean b = AjdocOutputChecker.summarySectionContainsRel(
- htmlFile,"DECLARE SUMMARY",
- strings[i],
- HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
- strings[i+1]);
- assertTrue("Should have ' " + strings[i] + " declared on " + strings[i+1] +
- "' in the Declare Summary section", b);
- }
-
- // check that we don't have declare statements for those that don't
- // exist in the code
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlFile,"DECLARE DETAIL SUMMARY",strings[0],
- HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
- strings[3]);
- assertFalse("Should not have ' " + strings[0] + " declared on " + strings[3] +
- "' in the Declare Detail section", b);
-
- }
-
-}
+++ /dev/null
-/********************************************************************
- * 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://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- * Helen Hawkins - iniital version
- *******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import java.io.File;
-
-
-public class EnumTest extends AjdocTestCase {
-
- /**
- * Test for pr122728 - no StringOutOfBoundsException
- * when processing an Enum
- */
- public void testEnum() throws Exception {
- initialiseProject("pr122728");
- File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/MyEnum.java")};
- runAjdoc("private","1.5",files);
- }
-
- /**
- * Test for pr122728 - no StringOutOfBoundsException
- * when processing an Enum
- */
- public void testInlinedEnum() throws Exception {
- initialiseProject("pr122728");
- File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/ClassWithInnerEnum.java")};
- runAjdoc("private","1.5",files);
- }
-
- /**
- * Test for pr122728 - no StringOutOfBoundsException
- * when processing an Enum
- */
- public void testEnumWithMethods() throws Exception {
- initialiseProject("pr122728");
- File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/EnumWithMethods.java")};
- runAjdoc("private","1.5",files);
- }
-}
+++ /dev/null
-/* *******************************************************************
- * 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 org.aspectj.bridge.Version;
-
-/**
- * @author Mik Kersten
- */
-public class ExecutionTestCase extends AjdocTestCase {
-
- public void testVersionMatch() {
- String ajdocVersion = Main.getVersion();
- String compilerVersion = Version.text;
- assertTrue("version check", ajdocVersion.endsWith(compilerVersion));
- }
-
- public void testFailingBuild() {
- initialiseProject("failing-build");
- File file1 = new File(getAbsoluteProjectDir() + File.separatorChar + "Fail.java");
- String[] args = { file1.getAbsolutePath() };
- org.aspectj.tools.ajdoc.Main.main(args);
- assertTrue(Main.hasAborted());
- }
-}
+++ /dev/null
-/********************************************************************
- * 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://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- * Helen Hawkins - iniital version
- *******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import java.io.File;
-import java.util.List;
-
-public class FullyQualifiedArgumentTest extends AjdocTestCase {
-
- /**
- * Test for pr58520
- */
- public void testPr58520() throws Exception {
- initialiseProject("pr119453");
- File[] files = {
- new File(getAbsoluteProjectDir() + File.separatorChar +"src/pack/C.java"),
- new File(getAbsoluteProjectDir() + File.separatorChar + "src/pack/A.aj")};
- runAjdoc("private",files);
-
- // check the contents of A.html
- File htmlA = new File(getAbsolutePathOutdir() + "/pack/A.html");
- if (!htmlA.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir()
- + "/pack/A.html - were there compilation errors?");
- }
-
- // check the contents of the declare detail summary
- String[] stringsA = { "C.html#method3(java.lang.String)",
- "C.html#method3(String)"};
- List missing = AjdocOutputChecker.getMissingStringsInSection(
- htmlA,stringsA,"ADVICE SUMMARY");
- assertEquals("There should be one missing string",1,missing.size());
- assertEquals("The fully qualified name should appear in the argument",
- "C.html#method3(String)",missing.get(0));
- }
-
-}
+++ /dev/null
-/********************************************************************
- * 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://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- * Helen Hawkins - iniital version
- *******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import java.io.File;
-import java.util.List;
-
-public class ITDTest extends AjdocTestCase {
-
- /**
- * Test for pr119453
- */
- public void testITDDeclaredOn() throws Exception {
- initialiseProject("pr119453");
- File[] files = {
- new File(getAbsoluteProjectDir() + "/src/pack/C.java"),
- new File(getAbsoluteProjectDir() + "/src/pack/A.aj")
- };
- runAjdoc("private",files);
- File htmlA = new File(getAbsolutePathOutdir() + "/pack/A.html");
- if (!htmlA.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir() + "/pack/A.html - were there compilation errors?");
- }
-
- // check field itd appears
- boolean b = AjdocOutputChecker.detailSectionContainsRel(
- htmlA,"DECLARE DETAIL SUMMARY",
- "C.y",
- HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
- "HREF=\"../pack/C.html\"");
- assertTrue("Should have 'C.y declared on HREF=\"../pack/C.html\"" +
- "' in the Declare Detail section", b);
- b = AjdocOutputChecker.summarySectionContainsRel(
- htmlA,"DECLARE SUMMARY",
- "C.y",
- HtmlDecorator.HtmlRelationshipKind.DECLARED_ON,
- "HREF=\"../pack/C.html\"");
- assertTrue("Should have 'C.y declared on HREF=\"../pack/C.html\"" +
- "' in the Declare Summary section", b);
-
- // check the modifiers are correct in the declare detail summary
- String[] stringsA = { "private int",
- "public java.lang.String",
- "<H3>C.y</H3>",
- "public </TT><B>C.C",
- "package void"};
- List missing = AjdocOutputChecker.getMissingStringsInSection(htmlA,stringsA,"DECLARE DETAIL SUMMARY");
- assertEquals("There should be one missing string ",1,missing.size());
- assertEquals("the 'package' and 'void' modifiers shouldn't appear in the 'Declare Detail' section of the ajdoc",
- "package void", missing.get(0));
-
- // check the modifiers are correct in the declare summary
- String[] stringsA2 = {"private", "int", "public", "String", "package void"};
- missing = AjdocOutputChecker.getMissingStringsInSection(htmlA,stringsA2,"DECLARE SUMMARY");
- assertEquals("There should be two missing strings ",2,missing.size());
- assertTrue("the public modifier shouldn't appear in the 'Declare Summary' section of the ajdoc", missing.contains("public"));
- assertTrue("the 'package' and 'void' modifiers shouldn't appear in the 'Declare Summary' section of the ajdoc", missing.contains("package void"));
-
- }
-
- /**
- * Test for pr119453
- */
- public void testITDMatchesDeclare() throws Exception {
- initialiseProject("pr119453");
- File[] files = {
- new File(getAbsoluteProjectDir() + "/src/pack/C.java"),
- new File(getAbsoluteProjectDir() + "/src/pack/A.aj")
- };
- runAjdoc("private",files);
-
- // Check the contents of C.html
- File htmlC = new File(getAbsolutePathOutdir() + "/pack/C.html");
- if (!htmlC.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir()
- + "/pack/C.html - were there compilation errors?");
- }
-
- // check that the required sections exist
- assertTrue(htmlC.getAbsolutePath() + " should contain an "
- + "'INTER-TYPE METHOD SUMMARY' section",
- AjdocOutputChecker.containsString(htmlC, "INTER-TYPE METHOD SUMMARY"));
- assertTrue(htmlC.getAbsolutePath() + " should contain an "
- + "'INTER-TYPE FIELD SUMMARY' section",
- AjdocOutputChecker.containsString(htmlC, "INTER-TYPE FIELD SUMMARY"));
- assertTrue(htmlC.getAbsolutePath() + " should contain an "
- + "'INTER-TYPE CONSTRUCTOR SUMMARY' section",
- AjdocOutputChecker.containsString(htmlC,"INTER-TYPE CONSTRUCTOR SUMMARY"));
-
- // check the modifier information in the sections is correct
- String[] stringsC = { "public", "String", "pack.A" };
- List missing = AjdocOutputChecker.getMissingStringsInSection(htmlC,stringsC,"INTER-TYPE METHOD SUMMARY");
- assertEquals("There should be one missing string",1,missing.size());
- assertEquals("public itd methods should not have the 'public' modifier in the ajdoc",
- "public",missing.get(0));
-
- String[] stringsC2 = { "private" };
- missing = AjdocOutputChecker.getMissingStringsInSection(htmlC,stringsC2,"INTER-TYPE FIELD SUMMARY");
- assertTrue("the private modifier for itd methods should appear in the ajdoc ",missing.size() == 0);
-
- }
-
- /**
- * Test that the ITD's do not appear in as 'aspect declarations' in the
- * class data information.
- */
- public void testNoAspectDeclarations() throws Exception {
- initialiseProject("pr119453");
- File[] files = {
- new File(getAbsoluteProjectDir() + "/src/pack/C.java"),
- new File(getAbsoluteProjectDir() + "/src/pack/A.aj")
- };
- runAjdoc("private",files);
-
- File htmlC = new File(getAbsolutePathOutdir() + "/pack/C.html");
- if (htmlC == null || !htmlC.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir()
- + "/pack/C.html - were there compilation errors?");
- }
-
- boolean b = AjdocOutputChecker.classDataSectionContainsRel(
- htmlC,
- HtmlDecorator.HtmlRelationshipKind.ASPECT_DECLARATIONS,
- "pack.A.C.y");
- assertFalse("The class data section should not have 'aspect declarations" +
- " pack.A.C.y' since this is an ITD",b);
- }
-
-}
+++ /dev/null
-/* *******************************************************************
- * 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 JDKVersionTest extends AjdocTestCase {
-
-// public void testIsUsing1point4() {
-// String v = System.getProperty("java.class.version","44.0");
-// assertTrue(("49.0".compareTo(v) > 0) && ("48.0".compareTo(v) <= 0));
-// assertFalse(Util.isExecutingOnJava5());
-// }
-
- public void testNothing() {}
-// public void testIsUsing1point5() {
-// assertTrue(Util.isExecutingOnJava5());
-// }
-
-}
+++ /dev/null
-/* *******************************************************************
- * 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;
-
-/**
- * A long way to go until full coverage, but this is the place to add more.
- *
- * @author Mik Kersten
- */
-public class PatternsTestCase extends AjdocTestCase {
-
- public void testSimpleExample() {
-
-// System.err.println(new File("testdata.figures-demo").exists());
-// File file1 = new File("testdata/patterns/allPatterns.lst");
- File outdir = new File("testdata/patterns/doc");
- File srcdir = new File("../../docs/sandbox/ubc-design-patterns/src");
-
- String[] args = {
-// "-XajdocDebug",
- "-classpath",
- AjdocTests.ASPECTJRT_PATH.getPath(),
- "-d",
- outdir.getAbsolutePath(),
- "-sourcepath",
- srcdir.getAbsolutePath(),
- "ca.ubc.cs.spl.aspectPatterns.patternLibrary",
- "ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.builder.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.builder.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.prototype.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.prototype.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.singleton.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.singleton.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.adapter.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.adapter.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.bridge.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.composite.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.composite.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.decorator.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.decorator.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.facade.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.facade.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.flyweight.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.flyweight.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.proxy.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.command.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.iterator.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.iterator.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.mediator.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.mediator.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.memento.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.memento.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.observer.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.state.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.strategy.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.strategy.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.aspectj",
- "ca.ubc.cs.spl.aspectPatterns.examples.visitor.java",
- "ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj"
- };
-
- org.aspectj.tools.ajdoc.Main.main(args);
- }
-
-}
+++ /dev/null
-/* *******************************************************************
- * 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;
-
-import java.io.File;
-import java.util.List;
-
-/**
- * @author Mik Kersten
- */
-public class PointcutVisibilityTest extends AjdocTestCase {
-
- /**
- * Test that passing the "public" argument only shows
- * public pointcuts in the ajdoc
- */
- public void testCoveragePublicMode() throws Exception {
- initialiseProject("bug82340");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
- runAjdoc("public",files);
-
- // ajdoc for Pointcut.java should contain info about
- // the public pointcuts but not the protected and
- // private one (since "public" was an argument)
- // Check that this is the case......
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
- // check the contents of the pointcut summary
- String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
- List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
- assertEquals("There should be two missing strings",2,missing.size());
- assertTrue("passing the 'public' argument means the private pointcut shouldn't appear in the ajdoc", missing.contains("privatePointcut"));
- assertTrue("passing the 'public' argument means the protected pointcut shouldn't appear in the ajdoc", missing.contains("protectedPointcut"));
- }
-
- /**
- * Test that passing the "protected" argument only shows
- * public and protected pointcuts in the ajdoc
- */
- public void testCoverageProtectedMode() throws Exception {
- initialiseProject("bug82340");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
- runAjdoc("protected",files);
-
- // ajdoc for Pointcut.java should contain info about
- // the public and protected pointcuts but not the
- // private one (since "protected" was an argument)
- // Check that this is the case......
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
- // check the contents of the pointcut summary
- String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
- List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
- assertEquals("There should be one missing strings",1,missing.size());
- assertEquals("passing the 'protected' argument means the private pointcut shouldn't appear in the ajdoc",
- "privatePointcut", missing.get(0));
- }
-
- /**
- * Test that passing the "private" argument shows all
- * pointcuts (public, protected and private) in the ajdoc
- */
- public void testCoveragePrivateMode() throws Exception {
- initialiseProject("bug82340");
- File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
- runAjdoc("private",files);
-
- // ajdoc for Pointcut.java should contain info about
- // the public, protected and private pointcuts
- // (since "private" was an argument)
- // Check that this is the case......
- File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
- }
- // check the contents of the pointcut summary
- String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
- List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
- assertTrue("passing the 'private' modifier means that private, protected and public " +
- "pointcuts should appear in the ajdoc",missing.isEmpty());
- }
-
-}
+++ /dev/null
-/* *******************************************************************
- * 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;
-
-
-/**
- * @author Mik Kersten
- */
-public class SpacewarTestCase extends AjdocTestCase {
-
- private String[] dirs = {"spacewar","coordination"};
-
- protected void setUp() throws Exception {
- super.setUp();
- initialiseProject("spacewar");
- }
-
- public void testSimpleExample() {
- runAjdoc(dirs);
- }
-
- public void testPublicModeExample() {
- runAjdoc("public",dirs);
- }
-
- public void testPr134063() {
- String lstFile = "spacewar" + File.separatorChar + "demo.lst";
- runAjdoc("private",lstFile);
- }
-}