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.

ClassUseWriter.java 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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.tools.ajdoc.Access;
  24. import org.aspectj.tools.ajdoc.Util;
  25. import com.sun.javadoc.ClassDoc;
  26. import com.sun.javadoc.PackageDoc;
  27. import com.sun.tools.doclets.DirectoryManager;
  28. import com.sun.tools.doclets.DocletAbortException;
  29. import java.io.File;
  30. import java.io.IOException;
  31. import java.util.Map;
  32. /**
  33. * Provides support for aspects.
  34. *
  35. * @author Jeff Palm
  36. */
  37. public class ClassUseWriter
  38. extends com.sun.tools.doclets.standard.ClassUseWriter
  39. {
  40. /**
  41. * The target ClassDoc.
  42. */
  43. protected final ClassDoc classdoc;
  44. /**
  45. * Maps PackageDocs to advice arguments.
  46. */
  47. protected final Map pkgToAdviceArgs;
  48. /**
  49. * Maps PackageDocs to advice return types.
  50. */
  51. protected final Map pkgToAdviceReturn;
  52. /**
  53. * Maps PackageDocs to pointcut arguments.
  54. */
  55. protected final Map pkgToPointcutArgs;
  56. /**
  57. * Maps PackageDocs to pointcut return types.
  58. */
  59. protected final Map pkgToPointcutReturn;
  60. /**
  61. * Maps PackageDocs to field introductions.
  62. */
  63. protected final Map pkgToFieldIntroductions;
  64. /**
  65. * Maps PackageDocs to class introductions.
  66. */
  67. protected final Map pkgToClassIntroductions;
  68. /**
  69. * Maps PackageDocs to interface introductions.
  70. */
  71. protected final Map pkgToInterfaceIntroductions;
  72. /**
  73. * Maps PackageDocs to class advisors.
  74. */
  75. protected final Map pkgToClassAdvisors;
  76. /**
  77. * Maps PackageDocs to aspects that dominate
  78. * aspects in that package.
  79. */
  80. protected final Map pkgToAspectDominatees;
  81. /**
  82. * Maps PackageDocs to aspects that are dominated
  83. * by aspects in that package.
  84. */
  85. protected final Map pkgToAspectDominators;
  86. /**
  87. * The MethodSubWriter to use.
  88. */
  89. protected final MethodSubWriter methodSubWriter
  90. = new MethodSubWriter(this);
  91. /**
  92. * The ConstructorSubWriter to use.
  93. */
  94. protected final ConstructorSubWriter constrSubWriter
  95. = new ConstructorSubWriter(this);
  96. /**
  97. * The FieldSubWriter to use.
  98. */
  99. protected final FieldSubWriter fieldSubWriter
  100. = new FieldSubWriter(this);
  101. /**
  102. * The ClassSubWriter to use.
  103. */
  104. protected final ClassSubWriter classSubWriter
  105. = new ClassSubWriter(this);
  106. /**
  107. * The PointcutSubWriter to use.
  108. */
  109. protected final PointcutSubWriter pointcutSubWriter
  110. = new PointcutSubWriter(this);
  111. /**
  112. * The SuperIntroductionSubWriter to use.
  113. */
  114. protected final SuperIntroductionSubWriter superIntroductionSubWriter
  115. = new SuperIntroductionSubWriter(this);
  116. /**
  117. * The FieldIntroductionSubWriter to use.
  118. */
  119. protected final FieldIntroductionSubWriter fieldIntroductionSubWriter
  120. = new FieldIntroductionSubWriter(this);
  121. /**
  122. * The ConstructorIntroductionSubWriter to use.
  123. */
  124. protected final ConstructorIntroductionSubWriter constrIntroductionSubWriter
  125. = new ConstructorIntroductionSubWriter(this);
  126. /**
  127. * The MethodIntroductionSubWriter to use.
  128. */
  129. protected final MethodIntroductionSubWriter methodIntroductionSubWriter
  130. = new MethodIntroductionSubWriter(this);
  131. /**
  132. * The AdviceSubWriter to use.
  133. */
  134. protected final AdviceSubWriter adviceSubWriter
  135. = new AdviceSubWriter(this);
  136. public ClassUseWriter(ClassUseMapper mapper,
  137. String path,
  138. String filename,
  139. String relpath,
  140. ClassDoc classdoc)
  141. throws IOException, DocletAbortException {
  142. super(mapper.mapper(classdoc), path,
  143. filename, relpath, classdoc);
  144. mapper.restore(classdoc);
  145. this.classdoc = Access.classdoc(this);
  146. this.pkgToAdviceReturn =
  147. _pkgDivide(mapper.classToAdviceReturn);
  148. this.pkgToAdviceArgs =
  149. _pkgDivide(mapper.classToAdviceArgs);
  150. this.pkgToPointcutReturn =
  151. _pkgDivide(mapper.classToPointcutReturn);
  152. this.pkgToPointcutArgs =
  153. _pkgDivide(mapper.classToPointcutArgs);
  154. this.pkgToFieldIntroductions =
  155. _pkgDivide(mapper.classToFieldIntroductions);
  156. this.pkgToClassIntroductions =
  157. _pkgDivide(mapper.classToClassIntroductions);
  158. this.pkgToInterfaceIntroductions =
  159. _pkgDivide(mapper.classToInterfaceIntroductions);
  160. this.pkgToClassAdvisors =
  161. _pkgDivide(mapper.classToAdvisors);
  162. this.pkgToAspectDominatees =
  163. _pkgDivide(mapper.classToDominatees);
  164. this.pkgToAspectDominators =
  165. _pkgDivide(mapper.classToDominators);
  166. }
  167. protected com.sun.tools.doclets.standard.ClassUseWriter
  168. writer;
  169. private Map _pkgDivide(Map classMap) {
  170. return (Map)Util.invoke
  171. (com.sun.tools.doclets.standard.ClassUseWriter.class,
  172. this, "pkgDivide",
  173. new Class[]{java.util.Map.class},
  174. new Object[]{classMap});
  175. }
  176. public static void generate(ClassUseMapper mapper,
  177. ClassDoc classdoc)
  178. throws DocletAbortException {
  179. ClassUseWriter cw = null;
  180. String path = DirectoryManager.getDirectoryPath(classdoc.
  181. containingPackage());
  182. if (path.length() > 0) {
  183. path += File.separator;
  184. }
  185. path += "class-use";
  186. String filename = classdoc.name() + ".html";
  187. String pkgname = classdoc.containingPackage().name();
  188. pkgname += (pkgname.length() > 0 ? "." : "") + "class-use";
  189. String relpath = DirectoryManager.getRelativePath(pkgname);
  190. try {
  191. (cw = new ClassUseWriter(mapper, path, filename,
  192. relpath, classdoc)).
  193. generateClassUseFile();
  194. } catch (IOException e) {
  195. Standard.configuration().standardmessage.
  196. error("doclet.exception_encountered", e+"", filename);
  197. throw new DocletAbortException();
  198. } finally {
  199. if (cw != null) cw.close();
  200. }
  201. }
  202. protected void generateClassUse(PackageDoc pkg) throws IOException {
  203. super.generateClassUse(pkg);
  204. String classlink = getClassLink(classdoc);
  205. String pkglink = getPackageLink(pkg);
  206. printUseInfo(adviceSubWriter, pkgToAdviceReturn,
  207. pkg, "AdviceReturn", classlink, pkglink);
  208. printUseInfo(adviceSubWriter, pkgToAdviceArgs,
  209. pkg, "AdviceArgs", classlink, pkglink);
  210. printUseInfo(pointcutSubWriter, pkgToPointcutReturn,
  211. pkg, "PointcutReturn", classlink, pkglink);
  212. printUseInfo(pointcutSubWriter, pkgToPointcutArgs,
  213. pkg, "PointcutArgs", classlink, pkglink);
  214. printUseInfo(fieldIntroductionSubWriter, pkgToFieldIntroductions,
  215. pkg, "FieldIntroductions", classlink, pkglink);
  216. printUseInfo(superIntroductionSubWriter, pkgToClassIntroductions,
  217. pkg, "ClassIntroductions", classlink, pkglink);
  218. printUseInfo(superIntroductionSubWriter, pkgToInterfaceIntroductions,
  219. pkg, "InterfaceIntroductions", classlink, pkglink);
  220. printUseInfo(classSubWriter, pkgToClassAdvisors,
  221. pkg, "ClassAdvisors", classlink, pkglink);
  222. printUseInfo(classSubWriter, pkgToAspectDominatees,
  223. pkg, "AspectDominatees", classlink, pkglink);
  224. printUseInfo(classSubWriter, pkgToAspectDominators,
  225. pkg, "AspectDominators", classlink, pkglink);
  226. }
  227. protected final void printUseInfo(AbstractSubWriter mw, Map map,
  228. PackageDoc pkg, String kind,
  229. String classlink, String pkglink) {
  230. Access.printUseInfo(mw, map.get(pkg),
  231. getText("doclet.ClassUse_" + kind,
  232. classlink,pkglink));
  233. }
  234. }