diff options
author | mkersten <mkersten> | 2005-01-13 15:53:01 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2005-01-13 15:53:01 +0000 |
commit | b460597575b05920885bd2f5f226b0140b687d6e (patch) | |
tree | 32baeedee64bb236c133471c88b4842fcda4456f | |
parent | f70b383d6292995c1e0521e7312e827022fe8fc9 (diff) | |
download | aspectj-b460597575b05920885bd2f5f226b0140b687d6e.tar.gz aspectj-b460597575b05920885bd2f5f226b0140b687d6e.zip |
Fixed 3 bugs reported in bug#82340, including correct use of visibility modifiers.
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java | 201 | ||||
-rw-r--r-- | ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java | 2 | ||||
-rw-r--r-- | ajdoc/testdata/bug82340/.cvsignore | 1 | ||||
-rw-r--r-- | ajdoc/testdata/bug82340/Pointcuts.java | 27 | ||||
-rw-r--r-- | ajdoc/testdata/coverage/foo/NoMembers.java | 2 | ||||
-rw-r--r-- | ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java | 26 | ||||
-rw-r--r-- | ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java | 29 |
7 files changed, 184 insertions, 104 deletions
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java index 43d7b1851..a2cb7919b 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -30,6 +30,7 @@ class HtmlDecorator { static Hashtable declIDTable = null; static SymbolManager symbolManager = null; static File rootDir = null; + static String docVisibilityModifier; static void decorateHTMLFromInputFiles(Hashtable table, File newRootDir, @@ -39,6 +40,7 @@ class HtmlDecorator { rootDir = newRootDir; declIDTable = table; symbolManager = sm; + docVisibilityModifier = docModifier; for (int i = 0; i < inputFiles.length; i++) { decorateHTMLFromDecls(symbolManager.getDeclarations(inputFiles[i].getCanonicalPath()), rootDir.getCanonicalPath() + Config.DIR_SEP_CHAR, @@ -73,11 +75,7 @@ class HtmlDecorator { boolean nestedClass = false; if ( decl.isType() ) { boolean decorateFile = true; - if ( (docModifier.equals("private")) || // everything - (docModifier.equals("package") && decl.getModifiers().indexOf( "private" ) == -1) || // package - (docModifier.equals("protected") && (decl.getModifiers().indexOf( "protected" ) != -1 || - decl.getModifiers().indexOf( "public" ) != -1 )) || - (docModifier.equals("public") && decl.getModifiers().indexOf( "public" ) != -1) ) { + if (isAboveVisibility(decl.getNode())) { visibleFileList.add(decl.getSignature()); String packageName = decl.getPackageName(); String filename = ""; @@ -192,10 +190,13 @@ class HtmlDecorator { } } - // Change "Class" to "Aspect", HACK: depends on "affects:" - int classStartIndex = fileContents.toString().indexOf("<BR>\nClass"); + // 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"); if (classStartIndex != -1 && - fileContents.toString().indexOf("Advises:") != -1) { + (adviceSummaryIndex != -1 || pointcutSummaryIndex != -1)) { int classEndIndex = fileContents.toString().indexOf("</H2>", classStartIndex); if (classStartIndex != -1 && classEndIndex != -1) { String classLine = fileContents.toString().substring(classStartIndex, classEndIndex); @@ -211,10 +212,6 @@ class HtmlDecorator { } static void addAspectDocumentation(IProgramElement node, StringBuffer fileBuffer, int index ) { -// List relations = AsmManager.getDefault().getRelationshipMap().get(node); -// System.err.println("> node: " + node + ", " + "relations: " + relations); - - List pointcuts = new ArrayList(); List advice = new ArrayList(); for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { @@ -255,6 +252,8 @@ class HtmlDecorator { List decls, String kind, int index) { + if (!declsAboveVisibilityExist(decls)) return; + int insertIndex = findSummaryIndex(fileBuffer, index); // insert the head of the table @@ -269,52 +268,53 @@ class HtmlDecorator { // insert the body of the table for ( int i = 0; i < decls.size(); i++ ) { IProgramElement decl = (IProgramElement)decls.get(i); - - // insert the table row accordingly - String comment = generateSummaryComment(decl); - String entry = ""; - if ( kind.equals( "Advice Summary" ) ) { - entry += - "<TR><TD>" + - "<A HREF=\"#" + generateHREFName(decl) + "\">" + - "<TT>" + generateAdviceSignatures(decl) + - "</TT></A><BR> "; - if (!comment.equals("")) { - entry += comment + "<P>"; + 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>" + generateAdviceSignatures(decl) + + "</TT></A><BR> "; + if (!comment.equals("")) { + entry += comment + "<P>"; + } + entry += + generateAffects(decl, false) + "</TD>" + + "</TR><TD>\n"; } - entry += - generateAffects(decl, false) + "</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>"; + 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"; } - entry += - "</TR></TD>\n"; - } - else if ( kind.equals( "Introduction 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) + - generateAffects(decl, true); + else if ( kind.equals( "Introduction 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) + + generateAffects(decl, true); + } + + // insert the entry + fileBuffer.insert(insertIndex, entry); + insertIndex += entry.length(); } - - // insert the entry - fileBuffer.insert(insertIndex, entry); - insertIndex += entry.length(); } // insert the end of the table @@ -322,6 +322,24 @@ class HtmlDecorator { 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) { + return + (docVisibilityModifier.equals("private")) || // everything + (docVisibilityModifier.equals("package") && element.getAccessibility().equals(IProgramElement.Accessibility.PACKAGE)) || // package + (docVisibilityModifier.equals("protected") && (element.getAccessibility().equals(IProgramElement.Accessibility.PROTECTED) || + element.getAccessibility().equals(IProgramElement.Accessibility.PUBLIC))) || + (docVisibilityModifier.equals("public") && element.getAccessibility().equals(IProgramElement.Accessibility.PUBLIC)); + } private static String genAccessibility(IProgramElement decl) { if (decl.getAccessibility().equals(IProgramElement.Accessibility.PACKAGE)) { @@ -335,6 +353,7 @@ class HtmlDecorator { List decls, String kind, int index) { + if (!declsAboveVisibilityExist(decls)) return; int insertIndex = findDetailsIndex(fileBuffer, index); // insert the table heading @@ -353,42 +372,44 @@ class HtmlDecorator { // insert the details for ( int i = 0; i < decls.size(); i++ ) { IProgramElement decl = (IProgramElement)decls.get(i); - String entry = ""; - - // insert the table row accordingly - entry += "<A NAME=\"" + generateHREFName(decl) + "\"><!-- --></A>\n"; - if ( kind.equals( "Advice Detail" ) ) { - entry += "<H3>" + decl.getName() + "</H3><P>"; - entry += - "<TT>" + - generateAdviceSignatures(decl) + "</TT>\n" + "<P>" + - generateDetailsComment(decl) + "<P>" + - generateAffects(decl, false); - } - 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>"; - entry += - generateIntroductionSignatures(decl, true) + - generateAffects(decl, true) + - generateDetailsComment(decl); - } - - // insert the entry - if (i != decls.size()-1) { - entry += "<P><HR>\n"; - } - else { - entry += "<P>"; + 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>" + + generateAdviceSignatures(decl) + "</TT>\n" + "<P>" + + generateDetailsComment(decl) + "<P>" + + generateAffects(decl, false); + } + 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>"; + entry += + generateIntroductionSignatures(decl, true) + + generateAffects(decl, true) + + generateDetailsComment(decl); + } + + // insert the entry + if (i != decls.size()-1) { + entry += "<P><HR>\n"; + } + else { + entry += "<P>"; + } + fileBuffer.insert(insertIndex, entry); + insertIndex += entry.length(); } - fileBuffer.insert(insertIndex, entry); - insertIndex += entry.length(); } } diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java index ef5fdbf8d..dc4e6485d 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/StubFileGenerator.java @@ -112,7 +112,7 @@ class StubFileGenerator { if (!member.getKind().equals(IProgramElement.Kind.POINTCUT) && !member.getKind().equals(IProgramElement.Kind.ADVICE)) { signature = member.getSourceSignature();//StructureUtil.genSignature(member); - } + } if (member.getKind().isDeclare()) { System.err.println("> Skipping declare (ajdoc limitation): " + member.toLabelString()); diff --git a/ajdoc/testdata/bug82340/.cvsignore b/ajdoc/testdata/bug82340/.cvsignore new file mode 100644 index 000000000..8e695ec83 --- /dev/null +++ b/ajdoc/testdata/bug82340/.cvsignore @@ -0,0 +1 @@ +doc diff --git a/ajdoc/testdata/bug82340/Pointcuts.java b/ajdoc/testdata/bug82340/Pointcuts.java new file mode 100644 index 000000000..d36116de8 --- /dev/null +++ b/ajdoc/testdata/bug82340/Pointcuts.java @@ -0,0 +1,27 @@ +/* + * Created on Jan 12, 2005 + */ + +package foo; + +/** + * @author Mik Kersten + */ +public abstract aspect Pointcuts { + + private pointcut privatePointcut (); + protected pointcut protectedPointcut (); + public pointcut publicPointcut (); + + private void privateMethod () { + + } + + public void protectedMethod () { + + } + + public void publicMethod () { + + } +} diff --git a/ajdoc/testdata/coverage/foo/NoMembers.java b/ajdoc/testdata/coverage/foo/NoMembers.java index d8dfcb3ce..f5067de99 100644 --- a/ajdoc/testdata/coverage/foo/NoMembers.java +++ b/ajdoc/testdata/coverage/foo/NoMembers.java @@ -2,6 +2,8 @@ * Created on Jan 12, 2005 */ +package foo; + /** * @author Mik Kersten */ diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java index 34f22a03d..c03a4ecd7 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java @@ -22,20 +22,20 @@ import junit.framework.TestCase; */ public class CoverageTestCase extends TestCase { - File file0 = new File("testdata/coverage/InDefaultPackage.java"); - File file1 = new File("testdata/coverage/foo/ClassA.java"); - File aspect1 = new File("testdata/coverage/foo/UseThisAspectForLinkCheck.aj"); - File file2 = new File("testdata/coverage/foo/InterfaceI.java"); - File file3 = new File("testdata/coverage/foo/PlainJava.java"); - File file4 = new File("testdata/coverage/foo/ModelCoverage.java"); - File file5 = new File("testdata/coverage/fluffy/Fluffy.java"); - File file6 = new File("testdata/coverage/fluffy/bunny/Bunny.java"); - File file7 = new File("testdata/coverage/fluffy/bunny/rocks/Rocks.java"); - File file8 = new File("testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java"); - File file9 = new File("testdata/coverage/foo/PkgVisibleClass.java"); - File file10 = new File("testdata/coverage/foo/NoMembers.java"); + 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"); - File outdir = new File("testdata/coverage/doc"); + protected File outdir = new File("testdata/coverage/doc"); public void testOptions() { outdir.delete(); diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java new file mode 100644 index 000000000..760e4c22c --- /dev/null +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java @@ -0,0 +1,29 @@ +/* + * Created on Jan 12, 2005 + */ +package org.aspectj.tools.ajdoc; + +import java.io.File; + +import junit.framework.TestCase; + +/** + * @author Mik Kersten + */ +public class PointcutVisibilityTest extends TestCase { + + protected File file1 = new File("testdata/bug82340/Pointcuts.java"); + protected File outdir = new File("testdata/bug82340/doc"); + + public void testCoveragePublicMode() { + outdir.delete(); + String[] args = { + "-XajdocDebug", + "-protected", + "-d", + outdir.getAbsolutePath(), + file1.getAbsolutePath() + }; + org.aspectj.tools.ajdoc.Main.main(args); + } +} |