Browse Source

Fix broken links in ajdoc. Part 4 : fix links to members of types

in other packages (again). Also, fix for nested types. Covers more than one
level of nesting. NOTE: the tool is currently not capable of producing
output for more than one level of nesting. Bug will be raised if Ron has
not already opened it.
tags/Root_ajdt_support
aclement 20 years ago
parent
commit
66be44ad6c
1 changed files with 45 additions and 17 deletions
  1. 45
    17
      ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java

+ 45
- 17
ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java View File

@@ -475,27 +475,32 @@ class HtmlDecorator {
String linkRef = "";
String linkName = rootDir.getAbsolutePath() + "/";
if (currDecl.getKind().isType()) {
// Handling type
linkName = packagePath;
if (currDecl.getParent().getKind().isType()) {
if (isNestedType(currDecl)) {
linkName =
linkName + currDecl.getParent().getName() + ".";
getAncestorComponents(
currDecl.getParent(),
linkName);
}
linkName = linkName + currDecl.getName();

linkRef = getRelativeComponent(packagePath) + packagePath;
// XXX: only one level of nested classes
if (currDecl.getParent().getKind().isType()) {
if (isNestedType(currDecl)) {
linkRef =
linkRef + currDecl.getParent().getName() + ".";
getAncestorComponents(
currDecl.getParent(),
linkRef);
}
linkRef = linkRef + currDecl.toLabelString() + ".html";
} else {
// Handling member
linkName = packagePath;
if (currDecl.getParent().getParent().getKind().isType()) {
if (isMemberOfNestedType(currDecl)) {
linkName =
linkName
+ currDecl.getParent().getParent().getName()
+ ".";
getAncestorComponents(
currDecl.getParent().getParent(),
linkName);
}
linkName =
linkName
@@ -503,16 +508,12 @@ class HtmlDecorator {
+ "."
+ currDecl.getName();

// Constructing the linkRef string requires a check
// to see if the parent type is actually nested inside
// another type.
linkRef = getRelativeComponent(packagePath) + packagePath;
// XXX: only one level of nested classes
if (currDecl.getParent().getParent().getKind().isType()) {
if (isMemberOfNestedType(currDecl)) {
linkRef =
linkRef
+ currDecl.getParent().getParent().getName()
+ ".";
getAncestorComponents(
currDecl.getParent().getParent(),
linkRef);
}
linkRef =
linkRef
@@ -533,6 +534,33 @@ class HtmlDecorator {
return entry;
}

private static boolean isNestedType(IProgramElement currDecl) {
return currDecl.getParent().getKind().isType();
}

private static boolean isMemberOfNestedType(IProgramElement currDecl) {
return currDecl.getParent().getParent().getKind().isType();
}

/**
* Convenience method for dealing with nested inner types.
* Add the parent types to the link path for the supplied
* <code>IProgramElement</code>.
* HEALTH WARNING : May contain traces of recursion.
* @param decl
* @param path
* @return
*/
private static String getAncestorComponents(
IProgramElement decl,
String path) {
String result = path;
if (decl.getParent().getKind().isType()) {
result = getAncestorComponents(decl.getParent(), result);
}
return result + decl.getName() + ".";
}

/**
* Generates a relative directory path fragment that can be
* used to navigate "upwards" from the directory location

Loading…
Cancel
Save