From: mkersten Date: Thu, 8 Apr 2004 23:25:20 +0000 (+0000) Subject: Fixed: X-Git-Tag: Root_ajdt_support~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b8ffb1f44c4e67a8742c411fb1c99744763a7132;p=aspectj.git Fixed: 57780: ajdoc package summary should not show synthetic information; 57773: ajdoc crash; Cleaned up link generation, added support for arbitrary levels of type nesting. --- diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Config.java b/ajdoc/src/org/aspectj/tools/ajdoc/Config.java index 990568fff..04f740d76 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Config.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Config.java @@ -33,7 +33,7 @@ interface Config { " -classpath Specify where to find user class files\n" + " -bootclasspath Override location of class files loaded\n" + " -d Destination directory for output files\n" + - " -argfile the file is a line-delimted list of arguments" + + " -argfile Build config file (wildcards not supported\n" + " -verbose Output messages about what Javadoc is doing\n" + " -v Print out the version of ajdoc" + "\n"+ diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java b/ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java index 3970a7c04..84156ccbb 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Declaration.java @@ -61,13 +61,15 @@ public class Declaration implements Serializable { transient private Declaration[] pointsTo = null; private Declaration parentDeclaration = null; + private IProgramElement node; public Declaration(int beginLine, int endLine, int beginColumn, int endColumn, String modifiers, String signature, String fullSignature, String crosscutDesignator, String declaringType, String kind, String filename, String formalComment, - String packageName) + String packageName, + IProgramElement node) { this.beginLine = beginLine; this.endLine = endLine; @@ -92,6 +94,7 @@ public class Declaration implements Serializable { this.pointsToHandles = new Handle[0]; //??? this.declarations = new Declaration[0]; + this.node = node; } public int getBeginLine() { return beginLine; } @@ -296,4 +299,7 @@ public class Declaration implements Serializable { return manager.getDeclarationAtPoint(filename, line, column); } } + public IProgramElement getNode() { + return node; + } } diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java index 2f2a82cde..e680bdd0a 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -82,25 +82,29 @@ class HtmlDecorator { 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())) { - // !!! hack for inner class !!! + 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.getNode()); + filename = newBase + Config.DIR_SEP_CHAR + packageName + Config.DIR_SEP_CHAR + currFileClass + //"." + - decl.getSignature() + ".html"; - nestedClass = true; + signature + ".html"; } else { - packageName = packageName.replace( '.','/' ); // !!! + packageName = packageName.replace( '.','/' ); filename = base + packageName + Config.DIR_SEP_CHAR + decl.getSignature() + ".html"; } } @@ -109,6 +113,7 @@ class HtmlDecorator { } if (!exceededNestingLevel) { decorateHTMLFile(new File(filename)); + decorateHTMLFromDecls(decl.getDeclarations(), base + decl.getSignature() + ".", docModifier, @@ -122,7 +127,17 @@ class HtmlDecorator { } } - static void decorateHTMLFile(File file) throws IOException { + 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; + } + } + + static void decorateHTMLFile(File file) throws IOException { System.out.println( "> Decorating " + file.getCanonicalPath() + "..." ); BufferedReader reader = new BufferedReader(new FileReader(file)); StringBuffer fileContents = new StringBuffer(); @@ -166,7 +181,7 @@ class HtmlDecorator { } else { decorateMemberDocumentation(decl, fileContents, index); - } + } } // Change "Class" to "Aspect", HACK: depends on "affects:" @@ -479,52 +494,25 @@ class HtmlDecorator { if (currDecl.getPackageName() != null && !currDecl.getPackageName().equals("")) { packagePath = currDecl.getPackageName().replace('.', '/') + Config.DIR_SEP_CHAR; } - String hrefLink = ""; - String hrefName = rootDir.getAbsolutePath() + "/"; - if (currDecl.getKind().isType()) { - hrefName = packagePath; - if (currDecl.getParent().getKind().isType()) { - hrefName = - hrefName + currDecl.getParent().getName() + "."; - } - hrefName = hrefName + currDecl.getName(); - - hrefLink = rootDir.getAbsolutePath() + "/" + packagePath; -// hrefLink = getRelativeComponent(packagePath) + packagePath; - // XXX: only one level of nested classes - if (currDecl.getParent().getKind().isType()) { - hrefLink = - hrefLink + currDecl.getParent().getName() + "."; - } - hrefLink = hrefLink + currDecl.toLabelString() + ".html"; - } else { - hrefName = packagePath; - if (currDecl.getParent().getParent().getKind().isType()) { - hrefName += currDecl.getParent().getParent().getName() - + "."; - } - hrefName += currDecl.getParent().getName() - + "." + currDecl.getName(); - - hrefLink = rootDir.getAbsolutePath() + "/" + packagePath; -// getRelativeComponent(packagePath) + packagePath; - - // Constructing the hrefLink string requires a check - // to see if the parent type is actually nested inside - // another type. - - // XXX: only one level of nested classes - if (currDecl.getParent().getParent().getKind().isType()) { - hrefLink += - currDecl.getParent().getParent().getName() - + "."; - } - hrefLink += - currDecl.getParent().getName() - + ".html" - + "#" - + currDecl.toLabelString(); + + String typeSignature = constructNestedTypeName(currDecl); + + String hrefName = + packagePath + + typeSignature; + + String hrefLink = + rootDir.getAbsolutePath() + "/" +// getRelativePathFromHere(packagePath) + + packagePath + + typeSignature + + ".html"; + + if (!currDecl.getKind().isType()) { + hrefName += '.' + currDecl.getName(); + hrefLink += "#" + currDecl.toLabelString(); } + if (!addedNames.contains(hrefName)) { entry += "" + hrefName.replace('/', '.') + ""; // !!! don't replace @@ -544,11 +532,11 @@ class HtmlDecorator { * @param packagePath * @return String consisting of multiple "../" parts, one for * each component part of the input packagePath. - */ - private static String getRelativeComponent(String packagePath) { - StringBuffer result = new StringBuffer(""); - if (packagePath != null && (packagePath.indexOf("/") != -1)) { - StringTokenizer sTok = new StringTokenizer(packagePath, "/", false); + */ + 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); diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java index 89d78c4f5..67c12c7f5 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java @@ -53,7 +53,7 @@ public class Main implements Config { /** Default to package visiblity. */ static String docModifier = "package"; - static Vector sourcepath = new Vector(); + static Vector sourcepath; static boolean verboseMode = false; static boolean packageMode = false; @@ -81,17 +81,12 @@ public class Main implements Config { rootDir = null; declIDTable = new Hashtable(); docDir = "."; + aborted = false; + deleteTempFilesOnExit = true; } public static void main(String[] args) { - aborted = false; - deleteTempFilesOnExit = true; - - filenames = new Vector(); - fileList= new Vector(); - packageList = new Vector(); - options = new Vector(); - ajcOptions = new Vector(); + clearState(); // if (!JavadocRunner.has14ToolsAvailable()) { // System.err.println("ajdoc requires a JDK 1.4 or later tools jar - exiting"); // aborted = true; @@ -322,9 +317,10 @@ public class Main implements Config { if ( ((String)options.elementAt(i)).equals( "-d" ) ) { rootDir = new File((String)options.elementAt(i+1)); if ( !rootDir.exists() ) { - System.out.println( "Destination directory not found: " + - (String)options.elementAt(i+1) ); - System.exit( -1 ); + rootDir.mkdir(); +// System.out.println( "Destination directory not found: " + +// (String)options.elementAt(i+1) ); +// System.exit( -1 ); } } } @@ -581,10 +577,12 @@ public class Main implements Config { options.addElement(arg); addNextAsOption = false; } - else { + else { // check if this is a file or a package - if ( arg.indexOf( ".java" ) == arg.length() - 5 || - arg.indexOf( ".lst" ) == arg.length() - 4 && +// System.err.println(">>>>>>>> " + ); + String entryName = arg.substring(arg.lastIndexOf(File.separator)+1); + if ((arg.endsWith(".java") && entryName.indexOf('.') == entryName.length()-5) || + arg.endsWith(".lst") && arg != null ) { File f = new File(arg); if (f.isAbsolute()) { @@ -598,6 +596,7 @@ public class Main implements Config { // PACKAGE MODE STUFF else if (!ignoreArg) { + packageMode = true; packageList.addElement( arg ); arg = arg.replace( '.', '/' ); // !!! diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java b/ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java index 00bddb060..59edbb2fd 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/SymbolManager.java @@ -118,7 +118,8 @@ public class SymbolManager { node.getKind().toString(), node.getSourceLocation().getSourceFile().getAbsolutePath(), node.getFormalComment(), - node.getPackageName() + node.getPackageName(), + node ); return dec; } diff --git a/ajdoc/testdata/coverage/.cvsignore b/ajdoc/testdata/coverage/.cvsignore new file mode 100644 index 000000000..8e695ec83 --- /dev/null +++ b/ajdoc/testdata/coverage/.cvsignore @@ -0,0 +1 @@ +doc