You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SuperIntroductionSubWriter.java 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This file is part of the debugger and core tools for the AspectJ(tm)
  4. * programming language; see http://aspectj.org
  5. *
  6. * The contents of this file are subject to the Mozilla Public License
  7. * Version 1.1 (the "License"); you may not use this file except in
  8. * compliance with the License. You may obtain a copy of the License at
  9. * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is AspectJ.
  17. *
  18. * The Initial Developer of the Original Code is Xerox Corporation. Portions
  19. * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
  20. * All Rights Reserved.
  21. */
  22. package org.aspectj.tools.doclets.standard;
  23. import org.aspectj.ajdoc.AspectDoc;
  24. import org.aspectj.ajdoc.IntroducedSuperDoc;
  25. import org.aspectj.ajdoc.IntroductionDoc;
  26. import com.sun.javadoc.ClassDoc;
  27. import com.sun.javadoc.ProgramElementDoc;
  28. import com.sun.javadoc.Type;
  29. import java.util.ArrayList;
  30. import java.util.Collections;
  31. import java.util.HashSet;
  32. import java.util.Iterator;
  33. import java.util.List;
  34. import java.util.Set;
  35. public class SuperIntroductionSubWriter extends AbstractSubWriter {
  36. protected Class delegateClass() {
  37. return null; //XXX ????
  38. }
  39. public SuperIntroductionSubWriter
  40. (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
  41. AspectDoc ad)
  42. {
  43. super(writer, ad);
  44. }
  45. public SuperIntroductionSubWriter
  46. (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
  47. {
  48. super(writer);
  49. }
  50. protected final String keyName() { return "Super_Introduction"; }
  51. public void printInheritedSummaryAnchor(ClassDoc cd) {}
  52. public void printInheritedSummaryLabel(ClassDoc cd) {}
  53. protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {}
  54. protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) {
  55. IntroducedSuperDoc intro = (IntroducedSuperDoc)member;
  56. writer.codeEnd();
  57. writer.printText("doclet.declare_parents");
  58. print(' ');
  59. Type[] targets = intro.targets();
  60. for (int i = 0; i < targets.length; i++) {
  61. if (i > 0) print(", ");
  62. printTypeLink(targets[i]);
  63. }
  64. print(' ');
  65. String str = intro.isImplements() ? "implements" : "extends";
  66. writer.printClassLink(cd, link(intro), str, false);
  67. print(' ');
  68. Type[] types = intro.types();
  69. for (int i = 0; i < types.length; i++) {
  70. if (i > 0) print(", ");
  71. printTypeLink(types[i]);
  72. }
  73. }
  74. protected static String link(IntroducedSuperDoc intro) {
  75. String str = intro.isImplements() ? "+implements" : "+extends";
  76. Type[] types = intro.types();
  77. str += "%";
  78. for (int i = 0; i < types.length; i++) str += types[i].qualifiedTypeName();
  79. str += "%";
  80. ClassDoc[] targets = intro.targets();
  81. for (int i = 0; i < targets.length; i++) str += targets[i].qualifiedTypeName();
  82. return str;
  83. }
  84. protected void printSummaryType(ProgramElementDoc member) {}
  85. protected void printBodyHtmlEnd(ClassDoc cd) {}
  86. protected void nonfinalPrintMember(ProgramElementDoc member) {
  87. IntroducedSuperDoc intro = (IntroducedSuperDoc)member;
  88. writer.anchor(link(intro));
  89. String head = intro.isImplements() ? "+implements " : "+extends ";
  90. Type[] types = intro.types();
  91. for (int i = 0; i < types.length; i++) {
  92. head += (i > 0 ? ", " : "") + types[i].typeName();
  93. }
  94. printHead(head);
  95. printFullComment(intro);
  96. }
  97. protected void printDeprecatedLink(ProgramElementDoc member) {
  98. //TODO: ???
  99. }
  100. protected List getMembers(ClassDoc cd) {
  101. if (!(cd instanceof AspectDoc)) return Collections.EMPTY_LIST;
  102. IntroductionDoc[] introductions = ((AspectDoc)cd).introductions();
  103. List list = new ArrayList();
  104. if (introductions == null) return list;
  105. for (int i = 0; i < introductions.length; i++) {
  106. IntroductionDoc intro = introductions[i];
  107. if (intro instanceof IntroducedSuperDoc) {
  108. list.add(intro);
  109. }
  110. }
  111. return list;
  112. }
  113. public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
  114. org.aspectj.ajdoc.IntroducedSuperDoc intro =
  115. (org.aspectj.ajdoc.IntroducedSuperDoc)member;
  116. ClassDoc[] targets = intro.targets();
  117. if (targets.length > 0) {
  118. writer.dt();
  119. writer.boldText("doclet.Introduced_on");
  120. writer.dd();
  121. writer.code();
  122. Set targetSet = new HashSet();
  123. for (int i = 0; i < targets.length; i++) {
  124. targetSet.add(targets[i]);
  125. }
  126. List targetList = new ArrayList(targetSet);
  127. Collections.sort(targetList);
  128. for (Iterator i = targetList.iterator(); i.hasNext();) {
  129. ClassDoc target = (ClassDoc)i.next();
  130. writer.printClassLink(target);
  131. if (i.hasNext()) writer.print(", ");
  132. }
  133. writer.codeEnd();
  134. }
  135. }
  136. public void printSummaryCrosscuts(ClassDoc cd,
  137. ProgramElementDoc member) {
  138. Set set = new HashSet();
  139. org.aspectj.ajdoc.IntroducedSuperDoc intro =
  140. (org.aspectj.ajdoc.IntroducedSuperDoc)member;
  141. ClassDoc[] targets = intro.targets();
  142. for (int i = 0; i < targets.length; i++) {
  143. set.add(targets[i]);
  144. }
  145. if (targets.length > 0) {
  146. writer.boldText("doclet.Advises");
  147. List list = new ArrayList(set);
  148. Collections.sort(list);
  149. for (Iterator i = list.iterator(); i.hasNext();) {
  150. print(' ');
  151. ClassDoc target = (ClassDoc)i.next();
  152. writer.printClassLink(target);
  153. if (i.hasNext()) print(",");
  154. }
  155. }
  156. }
  157. public boolean hasCrosscuts(ClassDoc cd, ProgramElementDoc member) {
  158. return true;
  159. }
  160. }