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.

IntroducedSuperDocImpl.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.ajdoc;
  23. import org.aspectj.ajdoc.IntroducedSuperDoc;
  24. import org.aspectj.compiler.base.ast.Dec;
  25. import org.aspectj.compiler.base.ast.TypeDs;
  26. import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec;
  27. import java.util.ArrayList;
  28. import java.util.Collection;
  29. import java.util.Collections;
  30. import java.util.List;
  31. public class IntroducedSuperDocImpl
  32. extends IntroductionDocImpl
  33. implements IntroducedSuperDoc {
  34. /** The introduction to which we delegate. */
  35. private final IntroducedSuperDec introducedSuperDec;
  36. /** The types we introduce onto our targets. */
  37. private final Collection types;
  38. public IntroducedSuperDocImpl(com.sun.javadoc.ClassDoc containingClass,
  39. IntroducedSuperDec introducedSuperDec) {
  40. super(containingClass);
  41. this.introducedSuperDec = introducedSuperDec;
  42. types = createTypes();
  43. }
  44. protected Dec dec() {
  45. return introducedSuperDec;
  46. }
  47. /**
  48. * Returns <code>true</code> is this introduction
  49. * places <code>implements</code> introductions on its
  50. * targets.
  51. *
  52. * @return <code>true</code> is this introduction
  53. * places <code>implements</code> introductions
  54. * on its targets.
  55. */
  56. public boolean isImplements() {
  57. return introducedSuperDec.getIsImplements();
  58. }
  59. /**
  60. * Returns the types that this introduction introduces
  61. * into it's targets type hierarchy.
  62. *
  63. * @return an array of org.aspectj.ajdoc.Type representing
  64. * the types this introduction has introducted onto
  65. * its targets type hierarchy.
  66. */
  67. public org.aspectj.ajdoc.Type[] types() {
  68. return (org.aspectj.ajdoc.Type[])types.toArray
  69. (new org.aspectj.ajdoc.Type[types.size()]);
  70. }
  71. /**
  72. * Returns the name of the type introduction.
  73. *
  74. * @return the name.
  75. */
  76. public String name() { if (true) return ""; // XXX unimplemented
  77. return (introducedSuperDec.getTypeDs().size() != 0)
  78. ? ((org.aspectj.ajdoc.Type)introducedSuperDec.getTypeDs().
  79. get(0).getType()).typeName()
  80. : "";
  81. //TODO: This could fuck us up!!!
  82. }
  83. private final Collection createTypes() {
  84. TypeDs typeds = introducedSuperDec.getTypeDs();
  85. if (typeds == null) return Collections.EMPTY_LIST;
  86. List list = new ArrayList();
  87. for (int i = 0, N = typeds.size(); i < N; i++) {
  88. list.add(ClassDocImpl.getInstance(typeds.get(i).getType().getTypeDec()));
  89. }
  90. return list;
  91. }
  92. }