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.

ConstructorIntroductionSubWriter.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 ConstructorIntroductionSubWriter extends ConstructorSubWriter {
  36. public ConstructorIntroductionSubWriter
  37. (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
  38. AspectDoc ad)
  39. {
  40. super(writer, ad);
  41. }
  42. public ConstructorIntroductionSubWriter
  43. (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
  44. {
  45. super(writer);
  46. }
  47. protected final String keyName() { return "Constructor_Introduction"; }
  48. protected List getMembers(ClassDoc cd) {
  49. if (!(cd instanceof AspectDoc)) return super.getMembers(cd);
  50. IntroductionDoc[] introductions = ((AspectDoc)cd).introductions();
  51. List list = new ArrayList();
  52. if (introductions == null) return list;
  53. for (int i = 0; i < introductions.length; i++) {
  54. IntroductionDoc id = introductions[i];
  55. if (!(id instanceof IntroducedDoc)) continue;
  56. MemberDoc member = ((IntroducedDoc)id).member();
  57. if (member.isConstructor()) {
  58. //ConstructorDec constructor = (ConstructorDec)member;
  59. //TODO: constructor.bindSignatures(((ClassDec)cd).getTypeScope());
  60. list.add(member); //constructor);
  61. }
  62. }
  63. return list;
  64. }
  65. public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
  66. org.aspectj.ajdoc.ConstructorDoc constr =
  67. (org.aspectj.ajdoc.ConstructorDoc)member;
  68. IntroducedDoc intro = constr.introduced();
  69. //String name = where(constr);
  70. ClassDoc[] targets = intro.targets();
  71. if (targets.length > 0) {
  72. writer.dt();
  73. writer.boldText("doclet.Introduced_on");
  74. writer.dd();
  75. writer.code();
  76. for (int i = 0; i < targets.length; i++) {
  77. if (i > 0) writer.print(", ");
  78. ClassDoc target = targets[i];
  79. writer.printClassLink(target,
  80. "constructors_introduced_from_class_" +
  81. cd.qualifiedName(),
  82. target.name());
  83. }
  84. writer.codeEnd();
  85. writer.ddEnd(); // XXX added for balance
  86. }
  87. }
  88. public void printSummaryCrosscuts(ClassDoc cd,
  89. ProgramElementDoc member) {
  90. Set set = new HashSet();
  91. org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member;
  92. IntroducedDoc intro = md.introduced();
  93. ClassDoc[] targets = intro.targets();
  94. for (int i = 0; i < targets.length; i++) {
  95. set.add(targets[i]);
  96. }
  97. if (targets.length > 0) {
  98. writer.boldText("doclet.Advises");
  99. List list = new ArrayList(set);
  100. Collections.sort(list);
  101. for (Iterator i = list.iterator(); i.hasNext();) {
  102. print(' ');
  103. ClassDoc target = (ClassDoc)i.next();
  104. writer.printClassLink(target,
  105. "constructors_introduced_from_class_"
  106. + cd.qualifiedName(),
  107. target.name());
  108. if (i.hasNext()) print(",");
  109. }
  110. }
  111. }
  112. public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) {
  113. return true;
  114. }
  115. }