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.

MethodIntroductionSubWriter.java 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.IntroducedDoc;
  25. import org.aspectj.ajdoc.IntroductionDoc;
  26. import com.sun.javadoc.ClassDoc;
  27. import com.sun.javadoc.MemberDoc;
  28. import com.sun.javadoc.ProgramElementDoc;
  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 MethodIntroductionSubWriter extends MethodSubWriter {
  36. public MethodIntroductionSubWriter
  37. (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
  38. AspectDoc ad)
  39. {
  40. super(writer, ad);
  41. }
  42. public MethodIntroductionSubWriter
  43. (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
  44. {
  45. super(writer);
  46. }
  47. protected final String keyName() { return "Method_Introduction"; }
  48. public void printInheritedSummaryAnchor(ClassDoc cd) {}
  49. public void printInheritedSummaryLabel(ClassDoc cd) {}
  50. protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {}
  51. protected List getMembers(ClassDoc cd) {
  52. if (!(cd instanceof AspectDoc)) return super.getMembers(cd);
  53. IntroductionDoc[] introductions = ((AspectDoc)cd).introductions();
  54. List list = new ArrayList();
  55. if (introductions == null) return list;
  56. for (int i = 0; i < introductions.length; i++) {
  57. IntroductionDoc id = introductions[i];
  58. if (!(id instanceof IntroducedDoc)) continue;
  59. MemberDoc member = ((IntroducedDoc)id).member();
  60. if (member.isMethod()) {
  61. //MethodDec method = (MethodDec)member;
  62. //TODO: method.bindSignatures(((ClassDec)cd).getTypeScope());
  63. list.add(member); //method);
  64. }
  65. }
  66. return list;
  67. }
  68. /** print in the detail context at the bottom of the page
  69. * the links out to affected classes/members for this method introduction
  70. * (in this aspect)
  71. */
  72. public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
  73. org.aspectj.ajdoc.MethodDoc method = (org.aspectj.ajdoc.MethodDoc)member;
  74. IntroducedDoc intro = method.introduced();
  75. ClassDoc[] targets = intro.targets();
  76. if (targets.length > 0) {
  77. writer.dt();
  78. writer.boldText("doclet.Introduced_on");
  79. writer.dd();
  80. writer.code();
  81. for (int i = 0; i < targets.length; i++) {
  82. if (i > 0) writer.print(", ");
  83. ClassDoc target = targets[i];
  84. writer.printClassLink(target,
  85. "methods_introduced_from_class_" +
  86. cd.qualifiedName(),
  87. target.name());
  88. }
  89. writer.codeEnd();
  90. writer.ddEnd(); // XXX added for balance
  91. }
  92. }
  93. /** print in the summary context at the top of the page
  94. * the links out to affected classes/members for this method introduction
  95. * (in this aspect)
  96. */
  97. public void printSummaryCrosscuts(ClassDoc cd,
  98. ProgramElementDoc member) {
  99. Set set = new HashSet();
  100. org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member;
  101. IntroducedDoc intro = md.introduced();
  102. ClassDoc[] targets = intro.targets();
  103. for (int i = 0; i < targets.length; i++) {
  104. set.add(targets[i]);
  105. }
  106. if (targets.length > 0) {
  107. writer.boldText("doclet.Advises");
  108. List list = new ArrayList(set);
  109. Collections.sort(list);
  110. for (Iterator i = list.iterator(); i.hasNext();) {
  111. print(' ');
  112. ClassDoc target = (ClassDoc)i.next();
  113. writer.printClassLink(target,
  114. "methods_introduced_from_class_"
  115. + cd.qualifiedName(),
  116. target.name());
  117. if (i.hasNext()) print(",");
  118. }
  119. }
  120. }
  121. public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) {
  122. return true;
  123. }
  124. }