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.

FieldIntroductionSubWriter.java 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 FieldIntroductionSubWriter extends FieldSubWriter {
  36. public FieldIntroductionSubWriter
  37. (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
  38. AspectDoc ad)
  39. {
  40. super(writer, ad);
  41. }
  42. public FieldIntroductionSubWriter
  43. (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
  44. {
  45. super(writer);
  46. }
  47. protected final String keyName() { return "Field_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.isField()) {
  61. //FieldDec field = (FieldDec)member;
  62. //TODO: field.bindSignatures(((ClassDec)cd).getTypeScope());
  63. list.add(member); //field);
  64. }
  65. }
  66. return list;
  67. }
  68. /** print links back to aspect in target class docs?
  69. * or forward from aspects to target class members? */
  70. public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
  71. org.aspectj.ajdoc.FieldDoc field = (org.aspectj.ajdoc.FieldDoc)member;
  72. IntroducedDoc intro = field.introduced();
  73. //String name = field.name();
  74. ClassDoc[] targets = intro.targets();
  75. if (targets.length > 0) {
  76. writer.dt(); // define term
  77. writer.boldText("doclet.Introduced_on");
  78. writer.dd();
  79. writer.code();
  80. for (int i = 0; i < targets.length; i++) {
  81. if (i > 0) writer.print(", ");
  82. ClassDoc target = targets[i];
  83. writer.printClassLink(target,
  84. "fields_introduced_from_class_" +
  85. cd.qualifiedName(),
  86. target.name());
  87. }
  88. writer.codeEnd();
  89. writer.ddEnd(); // XXX added for balance
  90. }
  91. }
  92. public void printSummaryCrosscuts(ClassDoc cd,
  93. ProgramElementDoc member) {
  94. Set set = new HashSet();
  95. org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member;
  96. IntroducedDoc intro = md.introduced();
  97. ClassDoc[] targets = intro.targets();
  98. for (int i = 0; i < targets.length; i++) {
  99. set.add(targets[i]);
  100. }
  101. if (targets.length > 0) {
  102. writer.boldText("doclet.Advises");
  103. List list = new ArrayList(set);
  104. Collections.sort(list);
  105. for (Iterator i = list.iterator(); i.hasNext();) {
  106. print(' ');
  107. ClassDoc target = (ClassDoc)i.next();
  108. writer.printClassLink(target,
  109. "fields_introduced_from_class_"
  110. + cd.qualifiedName(),
  111. target.name());
  112. if (i.hasNext()) print(",");
  113. }
  114. }
  115. }
  116. public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) {
  117. return true;
  118. }
  119. }