diff options
13 files changed, 193 insertions, 52 deletions
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java index a2cb7919b..3c064f573 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -14,8 +14,17 @@ package org.aspectj.tools.ajdoc; -import java.io.*; -import java.util.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IProgramElement; @@ -26,7 +35,13 @@ import org.aspectj.asm.IRelationship; */ class HtmlDecorator { - static List visibleFileList = new ArrayList(); + private static final String POINTCUT_DETAIL = "Pointcut Detail"; + private static final String ADVICE_DETAIL = "Advice Detail"; + private static final String DECLARE_DETAIL = "Declare Detail"; + private static final String ADVICE_SUMMARY = "Advice Summary"; + private static final String POINTCUT_SUMMARY = "Pointcut Summary"; + private static final String DECLARE_SUMMARY = "Declare Summary"; + static List visibleFileList = new ArrayList(); static Hashtable declIDTable = null; static SymbolManager symbolManager = null; static File rootDir = null; @@ -193,8 +208,8 @@ class HtmlDecorator { // Change "Class" to "Aspect" // HACK: depends on matching presence of advice or pointcut summary int classStartIndex = fileContents.toString().indexOf("<BR>\nClass "); - int pointcutSummaryIndex = fileContents.toString().indexOf("Pointcut Summary"); - int adviceSummaryIndex = fileContents.toString().indexOf("Advice Summary"); + int pointcutSummaryIndex = fileContents.toString().indexOf(POINTCUT_SUMMARY); + int adviceSummaryIndex = fileContents.toString().indexOf(ADVICE_SUMMARY); if (classStartIndex != -1 && (adviceSummaryIndex != -1 || pointcutSummaryIndex != -1)) { int classEndIndex = fileContents.toString().indexOf("</H2>", classStartIndex); @@ -214,21 +229,28 @@ class HtmlDecorator { static void addAspectDocumentation(IProgramElement node, StringBuffer fileBuffer, int index ) { List pointcuts = new ArrayList(); List advice = new ArrayList(); + List declares = new ArrayList(); for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { IProgramElement member = (IProgramElement)it.next(); if (member.getKind().equals(IProgramElement.Kind.POINTCUT)) { pointcuts.add(member); } else if (member.getKind().equals(IProgramElement.Kind.ADVICE)) { advice.add(member); + } else if (member.getKind().isDeclare() || member.getKind().isInterTypeMember()) { + declares.add(member); } } + if (declares.size() > 0) { + insertDeclarationsDetails(fileBuffer, declares, DECLARE_DETAIL, index); + insertDeclarationsSummary(fileBuffer, declares, DECLARE_SUMMARY, index); + } if (pointcuts.size() > 0) { - insertDeclarationsSummary(fileBuffer, pointcuts, "Pointcut Summary", index); - insertDeclarationsDetails(fileBuffer, pointcuts, "Pointcut Detail", index); + insertDeclarationsSummary(fileBuffer, pointcuts, POINTCUT_SUMMARY, index); + insertDeclarationsDetails(fileBuffer, pointcuts, POINTCUT_DETAIL, index); } if (advice.size() > 0) { - insertDeclarationsSummary(fileBuffer, advice, "Advice Summary", index); - insertDeclarationsDetails(fileBuffer, advice, "Advice Detail", index); + insertDeclarationsSummary(fileBuffer, advice, ADVICE_SUMMARY, index); + insertDeclarationsDetails(fileBuffer, advice, ADVICE_DETAIL, index); } } @@ -272,7 +294,7 @@ class HtmlDecorator { // insert the table row accordingly String comment = generateSummaryComment(decl); String entry = ""; - if ( kind.equals( "Advice Summary" ) ) { + if ( kind.equals( ADVICE_SUMMARY ) ) { entry += "<TR><TD>" + "<A HREF=\"#" + generateHREFName(decl) + "\">" + @@ -285,7 +307,7 @@ class HtmlDecorator { generateAffects(decl, false) + "</TD>" + "</TR><TD>\n"; } - else if ( kind.equals( "Pointcut Summary" ) ) { + else if ( kind.equals( POINTCUT_SUMMARY ) ) { entry += "<TR><TD WIDTH=\"1%\">" + "<FONT SIZE=-1><TT>" + genAccessibility(decl) + "</TT></FONT>" + @@ -299,15 +321,15 @@ class HtmlDecorator { entry += "</TR></TD>\n"; } - else if ( kind.equals( "Introduction Summary" ) ) { + else if ( kind.equals( DECLARE_SUMMARY ) ) { entry += "<TR><TD WIDTH=\"1%\">" + "<FONT SIZE=-1><TT>" + decl.getModifiers() + "</TT></FONT>" + "</TD>" + "<TD>" + "<A HREF=\"#" + generateHREFName(decl) + "\">" + - "<TT>introduction " + decl.toLabelString() + "</TT></A><P>" + - generateIntroductionSignatures(decl, false) + + "<TT>" + decl.toLabelString() + "</TT></A><P>" + + generateIntroductionSignatures(decl, true) + generateAffects(decl, true); } @@ -377,7 +399,7 @@ class HtmlDecorator { // insert the table row accordingly entry += "<A NAME=\"" + generateHREFName(decl) + "\"><!-- --></A>\n"; - if ( kind.equals( "Advice Detail" ) ) { + if ( kind.equals( ADVICE_DETAIL ) ) { entry += "<H3>" + decl.getName() + "</H3><P>"; entry += "<TT>" + @@ -385,15 +407,15 @@ class HtmlDecorator { generateDetailsComment(decl) + "<P>" + generateAffects(decl, false); } - else if (kind.equals("Pointcut Detail")) { + else if (kind.equals(POINTCUT_DETAIL)) { entry += "<H3>" + decl.toLabelString() + "</H3><P>" + generateDetailsComment(decl); } - else if (kind.equals("Introduction Detail")) { - entry += "<H3>introduction " + decl.toLabelString() + "</H3><P>"; + else if (kind.equals(DECLARE_DETAIL)) { + entry += "<H3>declare " + decl.toLabelString() + "</H3><P>"; entry += generateIntroductionSignatures(decl, true) + generateAffects(decl, true) + @@ -454,9 +476,7 @@ class HtmlDecorator { StringBuffer fileContentsBuffer, int index ) { List targets = StructureUtil.getTargets(node, IRelationship.Kind.ADVICE); - if (targets != null && !targets.isEmpty()) { - String prevName = ""; - + if (targets != null && !targets.isEmpty()) { String adviceDoc = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>" + "<TD width=\"15%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000> Advised by:</font></b></td><td>"; @@ -511,14 +531,20 @@ class HtmlDecorator { * TODO: probably want to make this the same for intros and advice. */ static String generateAffects(IProgramElement decl, boolean isIntroduction) { - - List targets = StructureUtil.getTargets(decl, IRelationship.Kind.ADVICE); - if (targets == null) return null; - List packageList = new ArrayList(); - String entry - = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>" + - "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000> Advises:</b></font></td><td>"; - + List targets = null; + if (isIntroduction) { + targets = StructureUtil.getDeclareTargets(decl); + } else { + targets = StructureUtil.getTargets(decl, IRelationship.Kind.ADVICE); + } + if (targets == null) return ""; + String entry = "<TABLE WIDTH=\"100%\" BGCOLOR=#FFFFFF><TR>"; + if (!isIntroduction) { + entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000> Advises:</b></font></td><td>"; + } else { + entry += "<TD width=\"10%\" bgcolor=\"#FFD8B0\"><B><FONT COLOR=000000> Affects:</b></font></td><td>"; + } + String relativePackagePath = getRelativePathFromHere( decl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR); @@ -634,7 +660,7 @@ class HtmlDecorator { } static String generateHREFName(IProgramElement decl) { - String hrefLink = decl.toLabelString(); // !!! + String hrefLink = decl.toLabelString().replace("\"", "quot;"); // !!! return hrefLink; } diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java b/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java index 25f2d4223..4dfed08a3 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java @@ -30,7 +30,7 @@ public class StructureUtil { */ public static List/*IProgramElement*/ getTargets(IProgramElement node, IRelationship.Kind kind) { List relations = AsmManager.getDefault().getRelationshipMap().get(node); - List targets = null; + List targets = null; if (relations == null) return null; for (Iterator it = relations.iterator(); it.hasNext(); ) { IRelationship rtn = (IRelationship)it.next(); @@ -40,6 +40,19 @@ public class StructureUtil { } return targets; } + + public static List/*IProgramElement*/ getDeclareTargets(IProgramElement node) { + List relations = AsmManager.getDefault().getRelationshipMap().get(node); + List targets = null; + if (relations == null) return null; + for (Iterator it = relations.iterator(); it.hasNext(); ) { + IRelationship rtn = (IRelationship)it.next(); + if (rtn.getKind().isDeclareKind()) { + targets = rtn.getTargets(); + } + } + return targets; + } public static String getPackageDeclarationFromFile(File file) { IProgramElement fileNode = (IProgramElement)AsmManager.getDefault().getHierarchy().findElementForSourceFile(file.getAbsolutePath()); diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java index 9843a2b94..c22906558 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java @@ -131,7 +131,7 @@ class StubFileGenerator{ } if (member.getKind().isDeclare()) { - System.err.println("> Skipping declare (ajdoc limitation): " + member.toLabelString()); +// System.err.println("> Skipping declare (ajdoc limitation): " + member.toLabelString()); } else if (signature != null && signature != "" && !member.getKind().isInterTypeMember() && diff --git a/ajdoc/testdata/declareForms/.cvsignore b/ajdoc/testdata/declareForms/.cvsignore new file mode 100644 index 000000000..8e695ec83 --- /dev/null +++ b/ajdoc/testdata/declareForms/.cvsignore @@ -0,0 +1 @@ +doc diff --git a/ajdoc/testdata/declareForms/DeclareCoverage.java b/ajdoc/testdata/declareForms/DeclareCoverage.java new file mode 100644 index 000000000..ff89cb0a7 --- /dev/null +++ b/ajdoc/testdata/declareForms/DeclareCoverage.java @@ -0,0 +1,39 @@ + +package foo; + +import java.io.*; +import java.util.List; + +public aspect DeclareCoverage { + + void foo() { } + + pointcut illegalNewFigElt(): call(Point.new(..)) && !withincode(* *.doIt(..)); + + declare error: illegalNewFigElt(): "Illegal constructor call."; + declare warning: call(* Point.setX(..)): "Illegal call."; + + declare parents: Point extends java.io.Serializable; + declare parents: Point && Line implements java.util.Observable; + declare soft: SizeException : call(* Point.getX()); + declare precedence: DeclareCoverage, InterTypeDecCoverage, *; +} + +aspect InterTypeDecCoverage { + + void foo() { } + + public int Point.xxx = 0; + public int Point.check(int i, int j) { return 1; } +} + +class Point { + +} + +class Line { + +} + +class SizeException extends Throwable { } + diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java index 1c4a1847b..5ec25317d 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java @@ -22,7 +22,9 @@ import junit.framework.TestCase; import junit.framework.TestSuite; public class AjdocTests extends TestCase { - public static File ASPECTJRT_PATH; + + public static File ASPECTJRT_PATH; + static { String[] paths = { "sp:aspectjrt.path", "sp:aspectjrt.jar", "../lib/test/aspectjrt.jar", "../aj-build/jars/aspectj5rt-all.jar", @@ -34,6 +36,7 @@ public class AjdocTests extends TestCase { 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); diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java index d6a9cd1a0..316f03280 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java @@ -22,18 +22,18 @@ import junit.framework.TestCase; */ public class CoverageTestCase extends TestCase { - protected File file0 = new File("testdata/coverage/InDefaultPackage.java"); - protected File file1 = new File("testdata/coverage/foo/ClassA.java"); - protected File aspect1 = new File("testdata/coverage/foo/UseThisAspectForLinkCheck.aj"); - protected File file2 = new File("testdata/coverage/foo/InterfaceI.java"); - protected File file3 = new File("testdata/coverage/foo/PlainJava.java"); - protected File file4 = new File("testdata/coverage/foo/ModelCoverage.java"); - protected File file5 = new File("testdata/coverage/fluffy/Fluffy.java"); - protected File file6 = new File("testdata/coverage/fluffy/bunny/Bunny.java"); - protected File file7 = new File("testdata/coverage/fluffy/bunny/rocks/Rocks.java"); - protected File file8 = new File("testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java"); - protected File file9 = new File("testdata/coverage/foo/PkgVisibleClass.java"); - protected File file10 = new File("testdata/coverage/foo/NoMembers.java"); + protected File file0 = new File("../ajdoc/testdata/coverage/InDefaultPackage.java"); + protected File file1 = new File("../ajdoc/testdata/coverage/foo/ClassA.java"); + protected File aspect1 = new File("../ajdoc/testdata/coverage/foo/UseThisAspectForLinkCheck.aj"); + protected File file2 = new File("../ajdoc/testdata/coverage/foo/InterfaceI.java"); + protected File file3 = new File("../ajdoc/testdata/coverage/foo/PlainJava.java"); + protected File file4 = new File("../ajdoc/testdata/coverage/foo/ModelCoverage.java"); + protected File file5 = new File("../ajdoc/testdata/coverage/fluffy/Fluffy.java"); + protected File file6 = new File("../ajdoc/testdata/coverage/fluffy/bunny/Bunny.java"); + protected File file7 = new File("../ajdoc/testdata/coverage/fluffy/bunny/rocks/Rocks.java"); + protected File file8 = new File("../ajdoc/testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java"); + protected File file9 = new File("../ajdoc/testdata/coverage/foo/PkgVisibleClass.java"); + protected File file10 = new File("../ajdoc/testdata/coverage/foo/NoMembers.java"); protected File outdir = new File("testdata/coverage/doc"); diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java new file mode 100644 index 000000000..f8c09e34b --- /dev/null +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java @@ -0,0 +1,51 @@ +/* ******************************************************************* + * Copyright (c) 2003 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Mik Kersten initial implementation + * ******************************************************************/ + +package org.aspectj.tools.ajdoc; + +import java.io.File; + +import junit.framework.TestCase; + +/** + * @author Mik Kersten + */ +public class DeclareFormsTest extends TestCase { + + protected File file0 = new File("../ajdoc/testdata/declareForms/DeclareCoverage.java"); + protected File outdir = new File("../ajdoc/testdata/declareForms/doc"); + + public void testCoverage() { + assertTrue(file0.exists()); + outdir.delete(); + String[] args = { +// "-XajdocDebug", + "-source", + "1.4", + "-private", + "-classpath", + AjdocTests.ASPECTJRT_PATH.getPath(), + "-d", + outdir.getAbsolutePath(), + file0.getAbsolutePath(), + }; + org.aspectj.tools.ajdoc.Main.main(args); + } + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } +} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java index f14c757e6..c7ca99cf1 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java @@ -30,7 +30,7 @@ public class ExecutionTestCase extends TestCase { } public void testFailingBuild() { - File file1 = new File("testdata/failing-build/Fail.java"); + File file1 = new File("../ajdoc/testdata/failing-build/Fail.java"); String[] args = { file1.getAbsolutePath() }; org.aspectj.tools.ajdoc.Main.main(args); diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java index f8551a2db..d0dd93a16 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java @@ -28,7 +28,7 @@ public class PatternsTestCase extends TestCase { // 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"); + File srcdir = new File("../../docs/sandbox/ubc-design-patterns/src"); String[] args = { // "-XajdocDebug", diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java index 760e4c22c..7a5d34a33 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java @@ -12,8 +12,8 @@ import junit.framework.TestCase; */ public class PointcutVisibilityTest extends TestCase { - protected File file1 = new File("testdata/bug82340/Pointcuts.java"); - protected File outdir = new File("testdata/bug82340/doc"); + protected File file1 = new File("../ajdoc/testdata/bug82340/Pointcuts.java"); + protected File outdir = new File("../ajdoc/testdata/bug82340/doc"); public void testCoveragePublicMode() { outdir.delete(); diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java index 1b3f5c509..0825ade26 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java @@ -22,7 +22,7 @@ public class SpacewarTestCase extends TestCase { protected void setUp() throws Exception { super.setUp(); - new File("testdata/spacewar/docdir").delete(); + new File("../ajdoc/testdata/spacewar/docdir").delete(); } public void testSimpleExample() { @@ -44,8 +44,8 @@ public class SpacewarTestCase extends TestCase { } public void testPublicModeExample() { - File outdir = new File("testdata/spacewar/docdir"); - File sourcepath = new File("testdata/spacewar"); + File outdir = new File("../ajdoc/testdata/spacewar/docdir"); + File sourcepath = new File("../ajdoc/testdata/spacewar"); String[] args = { "-public", diff --git a/asm/src/org/aspectj/asm/IRelationship.java b/asm/src/org/aspectj/asm/IRelationship.java index 500ba5b4f..d54f13f7b 100644 --- a/asm/src/org/aspectj/asm/IRelationship.java +++ b/asm/src/org/aspectj/asm/IRelationship.java @@ -58,6 +58,14 @@ public interface IRelationship extends Serializable { private final String name; + public boolean isDeclareKind() { + return this == DECLARE_WARNING + || this == DECLARE_ERROR + || this == DECLARE + || this == DECLARE_INTER_TYPE + || this == DECLARE_SOFT; + } + private Kind(String name) { this.name = name; } |