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.

PointcutDocImpl.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.ClassDoc;
  24. import org.aspectj.ajdoc.PointcutDoc;
  25. import org.aspectj.compiler.base.ast.Dec;
  26. import org.aspectj.compiler.base.ast.Formals;
  27. import org.aspectj.compiler.base.ast.NameType;
  28. import org.aspectj.compiler.base.ast.TypeD;
  29. import org.aspectj.compiler.base.ast.TypeDec;
  30. import org.aspectj.compiler.base.ast.TypeDs;
  31. import org.aspectj.compiler.crosscuts.ast.PointcutDec;
  32. import java.util.Collection;
  33. import java.util.Collections;
  34. public class PointcutDocImpl
  35. extends ExecutableMemberDocImpl
  36. implements PointcutDoc {
  37. /** The pointcut to which we delegate. */
  38. private final PointcutDec pointcutDec;
  39. public PointcutDocImpl(ClassDoc containingClass, PointcutDec pointcutDec) {
  40. super(containingClass);
  41. this.pointcutDec = pointcutDec;
  42. }
  43. /**
  44. * Returns a empty list because advice cannot
  45. * be placed on a pointcut.
  46. *
  47. * @return Collection.EMPTY_LIST;
  48. */
  49. protected Collection createAdvice() {
  50. return Collections.EMPTY_LIST;
  51. }
  52. /**
  53. * Returns the underlying Dec -- a PointcutDec.
  54. *
  55. * @return the underlying Dec -- a PointcutDec.
  56. */
  57. protected Dec dec() {
  58. return pointcutDec;
  59. }
  60. /**
  61. * Returns the Formals of the underlying PointcutDec.
  62. *
  63. * @return the Formals of the underlying PointcutDec.
  64. */
  65. protected Formals getFormals() {
  66. return pointcutDec.getFormals();
  67. }
  68. /**
  69. * Returns null because pointcut cannot throw execptions.
  70. *
  71. * @return null.
  72. */
  73. public TypeDs getThrows() {
  74. return null;
  75. }
  76. /**
  77. * Returns the return type of this method.
  78. *
  79. * @return the Type representing the type this
  80. * method returns.
  81. */
  82. public com.sun.javadoc.Type resultType() {
  83. TypeD typed = pointcutDec.getResultTypeD();
  84. if (typed == null) return null; //TODO: maybe return VOID
  85. return null; //TODOtyped.getType();
  86. }
  87. /**
  88. * Returns the type that nearest super class that defines
  89. * this method.
  90. *
  91. * @return the type that nearest super class that defines
  92. * this method.
  93. */
  94. public com.sun.javadoc.ClassDoc overriddenClass() {
  95. //TODO: This sucks!!!
  96. TypeDec where = pointcutDec.getDeclaringType().getTypeDec();
  97. NameType superType = (NameType)where.getSuperClassType();
  98. while (superType != null) {
  99. PointcutDec pc = Util.pointcutDec(superType,
  100. pointcutDec.getId(),
  101. pointcutDec.getFormals());
  102. if (pc != null && !pc.getId().equals("NOT_FOUND")) {
  103. // XXX TypeDec result = superType.getTypeDec();
  104. return null; //TODOresult;
  105. }
  106. if (superType.getTypeDec().getFullName().
  107. equals("java.lang.Object")) {
  108. return null;
  109. }
  110. superType = (NameType)superType.getTypeDec().getSuperClassType();
  111. }
  112. return null;
  113. }
  114. /**
  115. * Returns <code>true</code>.
  116. *
  117. * @return <code>true</code>.
  118. */
  119. public boolean isPointcut() {
  120. return true;
  121. }
  122. /**
  123. * Returns <code>true</code> if this method is <code>abstract</code>.
  124. *
  125. * @return <code>true</code> if this method is <code>abstract</code>.
  126. */
  127. public boolean isAbstract() {
  128. return pointcutDec.isAbstract();
  129. }
  130. }