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) {
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);