34 |
|
|
35 |
import com.sun.tools.doclets.Taglet; |
import com.sun.tools.doclets.Taglet; |
36 |
|
|
37 |
|
import gnu.classpath.tools.taglets.GnuExtendedTaglet; |
38 |
import gnu.classpath.tools.taglets.AuthorTaglet; |
import gnu.classpath.tools.taglets.AuthorTaglet; |
39 |
|
import gnu.classpath.tools.taglets.CodeTaglet; |
40 |
import gnu.classpath.tools.taglets.DeprecatedTaglet; |
import gnu.classpath.tools.taglets.DeprecatedTaglet; |
41 |
import gnu.classpath.tools.taglets.GenericTaglet; |
import gnu.classpath.tools.taglets.GenericTaglet; |
42 |
import gnu.classpath.tools.taglets.SinceTaglet; |
import gnu.classpath.tools.taglets.SinceTaglet; |
43 |
|
import gnu.classpath.tools.taglets.ValueTaglet; |
44 |
import gnu.classpath.tools.taglets.VersionTaglet; |
import gnu.classpath.tools.taglets.VersionTaglet; |
45 |
import gnu.classpath.tools.taglets.TagletContext; |
import gnu.classpath.tools.taglets.TagletContext; |
46 |
|
|
82 |
* Mapping from tag type to Taglet for user Taglets specified on |
* Mapping from tag type to Taglet for user Taglets specified on |
83 |
* the command line. |
* the command line. |
84 |
*/ |
*/ |
85 |
private Map tagletMap = new LinkedHashMap(); |
protected Map tagletMap = new LinkedHashMap(); |
86 |
|
|
87 |
/** |
/** |
88 |
* Stores the package groups specified in the user |
* Stores the package groups specified in the user |
144 |
|
|
145 |
private RootDoc rootDoc; |
private RootDoc rootDoc; |
146 |
|
|
147 |
|
protected abstract InlineTagRenderer getInlineTagRenderer(); |
148 |
|
|
149 |
private void startInstance(RootDoc rootDoc) |
private void startInstance(RootDoc rootDoc) |
150 |
throws DocletConfigurationException, IOException |
throws DocletConfigurationException, IOException |
151 |
{ |
{ |
155 |
|
|
156 |
registerTaglet(new VersionTaglet()); |
registerTaglet(new VersionTaglet()); |
157 |
registerTaglet(new AuthorTaglet()); |
registerTaglet(new AuthorTaglet()); |
158 |
registerTaglet(new SinceTaglet()); |
registerTaglet(new SinceTaglet(getInlineTagRenderer())); |
159 |
registerTaglet(new StandardTaglet("deprecated")); |
registerTaglet(new StandardTaglet("deprecated")); |
160 |
registerTaglet(new StandardTaglet("see")); |
registerTaglet(new StandardTaglet("see")); |
161 |
registerTaglet(new StandardTaglet("param")); |
registerTaglet(new StandardTaglet("param")); |
162 |
|
|
163 |
|
registerTaglet(new ValueTaglet()); |
164 |
|
registerTaglet(new CodeTaglet()); |
165 |
|
|
166 |
// Process command line options |
// Process command line options |
167 |
|
|
168 |
for (int i=0, ilim=rootDoc.options().length; i<ilim; ++i) { |
for (int i=0, ilim=rootDoc.options().length; i<ilim; ++i) { |
674 |
tagletMap.put(taglet.getName(), taglet); |
tagletMap.put(taglet.getName(), taglet); |
675 |
} |
} |
676 |
|
|
677 |
protected void printTaglets(Tag[] tags, TagletContext context, TagletPrinter output) |
protected void printTaglets(Tag[] tags, TagletContext context, TagletPrinter output, boolean inline) |
678 |
{ |
{ |
679 |
for (Iterator it = tagletMap.keySet().iterator(); it.hasNext(); ) { |
for (Iterator it = tagletMap.keySet().iterator(); it.hasNext(); ) { |
680 |
String tagName = (String)it.next(); |
String tagName = (String)it.next(); |
681 |
Object o = tagletMap.get(tagName); |
Object o = tagletMap.get(tagName); |
682 |
Taglet taglet = (Taglet)o; |
Taglet taglet = (Taglet)o; |
683 |
|
Doc doc = context.getDoc(); |
684 |
|
if (inline == taglet.isInlineTag() |
685 |
|
&& ((doc == null |
686 |
|
&& taglet.inOverview()) |
687 |
|
|| (doc != null |
688 |
|
&& ((doc.isConstructor() && taglet.inConstructor()) |
689 |
|
|| (doc.isField() && taglet.inField()) |
690 |
|
|| (doc.isMethod() && taglet.inMethod()) |
691 |
|
|| (doc instanceof PackageDoc && taglet.inPackage()) |
692 |
|
|| ((doc.isClass() || doc.isInterface()) && taglet.inType()))))) { |
693 |
|
|
|
if (!taglet.isInlineTag() |
|
|
&& ((context != TagletContext.CONSTRUCTOR || taglet.inConstructor()) |
|
|
|| (context != TagletContext.FIELD || taglet.inField()) |
|
|
|| (context != TagletContext.METHOD || taglet.inMethod()) |
|
|
|| (context != TagletContext.OVERVIEW || taglet.inOverview()) |
|
|
|| (context != TagletContext.PACKAGE || taglet.inPackage()) |
|
|
|| (context != TagletContext.TYPE || taglet.inType()))) { |
|
|
|
|
694 |
List tagsOfThisType = new LinkedList(); |
List tagsOfThisType = new LinkedList(); |
695 |
for (int i=0; i<tags.length; ++i) { |
for (int i=0; i<tags.length; ++i) { |
696 |
if (tags[i].name().substring(1).equals(tagName)) { |
if (tags[i].name().substring(1).equals(tagName)) { |
701 |
if (!tagsOfThisType.isEmpty()) { |
if (!tagsOfThisType.isEmpty()) { |
702 |
Tag[] tagletTags = (Tag[])tagsOfThisType.toArray(new Tag[tagsOfThisType.size()]); |
Tag[] tagletTags = (Tag[])tagsOfThisType.toArray(new Tag[tagsOfThisType.size()]); |
703 |
|
|
704 |
String tagletString = taglet.toString(tagletTags); |
String tagletString; |
705 |
|
if (taglet instanceof GnuExtendedTaglet) { |
706 |
|
tagletString = ((GnuExtendedTaglet)taglet).toString(tagletTags, context); |
707 |
|
} |
708 |
|
else { |
709 |
|
tagletString = taglet.toString(tagletTags); |
710 |
|
} |
711 |
if (null != tagletString) { |
if (null != tagletString) { |
712 |
output.printTagletString(tagletString); |
output.printTagletString(tagletString); |
713 |
} |
} |
716 |
} |
} |
717 |
} |
} |
718 |
|
|
719 |
|
protected void printInlineTaglet(Tag tag, TagletContext context, TagletPrinter output) |
720 |
|
{ |
721 |
|
Taglet taglet = (Taglet)tagletMap.get(tag.name().substring(1)); |
722 |
|
if (null != taglet) { |
723 |
|
String tagletString; |
724 |
|
if (taglet instanceof GnuExtendedTaglet) { |
725 |
|
tagletString = ((GnuExtendedTaglet)taglet).toString(tag, context); |
726 |
|
} |
727 |
|
else { |
728 |
|
tagletString = taglet.toString(tag); |
729 |
|
} |
730 |
|
if (null != tagletString) { |
731 |
|
output.printTagletString(tagletString); |
732 |
|
} |
733 |
|
} |
734 |
|
else { |
735 |
|
printWarning("Unknown tag: " + tag.name()); |
736 |
|
} |
737 |
|
} |
738 |
|
|
739 |
|
protected void printMainTaglets(Tag[] tags, TagletContext context, TagletPrinter output) |
740 |
|
{ |
741 |
|
printTaglets(tags, context, output, false); |
742 |
|
} |
743 |
|
|
744 |
/** |
/** |
745 |
* @param usedClassToPackagesMap ClassDoc to (PackageDoc to (UsageType to (Set of Doc))) |
* @param usedClassToPackagesMap ClassDoc to (PackageDoc to (UsageType to (Set of Doc))) |
746 |
*/ |
*/ |
1083 |
return type.typeName(); |
return type.typeName(); |
1084 |
} |
} |
1085 |
} |
} |
1086 |
|
|
1087 |
|
protected static class InterfaceRelation |
1088 |
|
{ |
1089 |
|
public Set superInterfaces; |
1090 |
|
public Set subInterfaces; |
1091 |
|
} |
1092 |
|
|
1093 |
|
private void addAllInterfaces(ClassDoc classDoc, Set allInterfaces) |
1094 |
|
{ |
1095 |
|
ClassDoc[] interfaces = classDoc.interfaces(); |
1096 |
|
for (int i=0; i<interfaces.length; ++i) { |
1097 |
|
allInterfaces.add(interfaces[i]); |
1098 |
|
addAllInterfaces(interfaces[i], allInterfaces); |
1099 |
|
} |
1100 |
|
} |
1101 |
|
|
1102 |
|
private Map allSubClasses; |
1103 |
|
|
1104 |
|
protected Map getAllSubClasses() |
1105 |
|
{ |
1106 |
|
if (null == allSubClasses) { |
1107 |
|
allSubClasses = new HashMap(); |
1108 |
|
|
1109 |
|
ClassDoc[] classDocs = getRootDoc().classes(); |
1110 |
|
for (int i=0; i<classDocs.length; ++i) { |
1111 |
|
if (!classDocs[i].isInterface()) { |
1112 |
|
for (ClassDoc cd = classDocs[i].superclass(); |
1113 |
|
null != cd; |
1114 |
|
cd = cd.superclass()) { |
1115 |
|
|
1116 |
|
if (!cd.qualifiedTypeName().equals("java.lang.Object")) { |
1117 |
|
List subClasses = (List)allSubClasses.get(cd); |
1118 |
|
if (null == subClasses) { |
1119 |
|
subClasses = new LinkedList(); |
1120 |
|
allSubClasses.put(cd, subClasses); |
1121 |
|
} |
1122 |
|
subClasses.add(classDocs[i]); |
1123 |
|
} |
1124 |
|
} |
1125 |
|
} |
1126 |
|
} |
1127 |
|
} |
1128 |
|
return allSubClasses; |
1129 |
|
} |
1130 |
|
|
1131 |
|
private Map interfaceRelations; |
1132 |
|
|
1133 |
|
protected Map getInterfaceRelations() |
1134 |
|
{ |
1135 |
|
if (null == interfaceRelations) { |
1136 |
|
interfaceRelations = new HashMap(); |
1137 |
|
|
1138 |
|
ClassDoc[] classDocs = getRootDoc().classes(); |
1139 |
|
for (int i=0; i<classDocs.length; ++i) { |
1140 |
|
if (classDocs[i].isInterface()) { |
1141 |
|
InterfaceRelation relation = new InterfaceRelation(); |
1142 |
|
relation.superInterfaces = new TreeSet(); |
1143 |
|
relation.subInterfaces = new TreeSet(); |
1144 |
|
addAllInterfaces(classDocs[i], relation.superInterfaces); |
1145 |
|
interfaceRelations.put(classDocs[i], relation); |
1146 |
|
} |
1147 |
|
} |
1148 |
|
|
1149 |
|
Iterator it = interfaceRelations.keySet().iterator(); |
1150 |
|
while (it.hasNext()) { |
1151 |
|
ClassDoc interfaceDoc = (ClassDoc)it.next(); |
1152 |
|
InterfaceRelation relation |
1153 |
|
= (InterfaceRelation)interfaceRelations.get(interfaceDoc); |
1154 |
|
Iterator superIt = relation.superInterfaces.iterator(); |
1155 |
|
while (superIt.hasNext()) { |
1156 |
|
ClassDoc superInterfaceDoc = (ClassDoc)superIt.next(); |
1157 |
|
InterfaceRelation superRelation |
1158 |
|
= (InterfaceRelation)interfaceRelations.get(superInterfaceDoc); |
1159 |
|
superRelation.subInterfaces.add(interfaceDoc); |
1160 |
|
} |
1161 |
|
} |
1162 |
|
} |
1163 |
|
return interfaceRelations; |
1164 |
|
} |
1165 |
} |
} |
1166 |
|
|
1167 |
|
|