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.

MethodDocImpl.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.compiler.base.ast.MethodDec;
  24. import org.aspectj.compiler.base.ast.NameType;
  25. import org.aspectj.compiler.base.ast.TypeDec;
  26. import com.sun.javadoc.ClassDoc;
  27. import java.lang.reflect.Modifier;
  28. public class MethodDocImpl
  29. extends CodeDocImpl
  30. implements org.aspectj.ajdoc.MethodDoc {
  31. /*
  32. * This is a hack because the compiler isn't resolving
  33. * introduced types.
  34. */
  35. private org.aspectj.compiler.base.ast.Type type;
  36. public void setType(org.aspectj.compiler.base.ast.Type type) {
  37. this.type = type;
  38. }
  39. public MethodDocImpl(ClassDoc containingClass, MethodDec methodDec) {
  40. super(containingClass, methodDec);
  41. setType(codeDec().getResultTypeD().getType());
  42. }
  43. protected MethodDec methodDec() {
  44. return (MethodDec)codeDec();
  45. }
  46. /**
  47. * Returns <code>true</code>.
  48. *
  49. * @return <code>true</code>.
  50. */
  51. public boolean isMethod() {
  52. return true;
  53. }
  54. /**
  55. * Returns <code>true</code> if this method is <code>abstract</code>.
  56. *
  57. * @return <code>true</code> if this method is <code>abstract</code>.
  58. */
  59. public boolean isAbstract() {
  60. return methodDec().isAbstract();
  61. }
  62. /**
  63. * Returns the return type of this method.
  64. *
  65. * @return the Type representing the type this
  66. * method returns.
  67. */
  68. public com.sun.javadoc.Type returnType() {
  69. return TypeImpl.getInstance(type);
  70. //return null; //TODO getResultTypeD().getType();
  71. }
  72. /**
  73. * Returns the type that nearest super class that defines
  74. * this method.
  75. *
  76. * @return the type that nearest super class that defines
  77. * this method.
  78. */
  79. public ClassDoc overriddenClass() {
  80. //Exprs params = getFormals().makeExprs(); // do this for side-effect?XXX
  81. TypeDec where = methodDec().getDeclaringType().getTypeDec();
  82. NameType superType = (NameType)where.getSuperClassType();
  83. while (superType != null) {
  84. MethodDec method = Util.methodDec(superType,
  85. methodDec().getId(),
  86. methodDec().getFormals());
  87. if (method != null && !method.getId().equals("not$found")) {
  88. if (method.getDeclaringType().equals(superType)) {
  89. return null;
  90. }
  91. }
  92. if (superType.getTypeDec().getFullName().
  93. equals("java.lang.Object")) {
  94. return null;
  95. }
  96. superType = (NameType)superType.getTypeDec().getSuperClassType();
  97. }
  98. return null;
  99. }
  100. /**
  101. * Returns the int modifiers for this method.
  102. *
  103. * @return the int modifiers for this method.
  104. * @see java.lang.reflect.Modifier
  105. */
  106. public int modifierSpecifier() {
  107. //XXX interface methods have the ABSTRACT bit set
  108. if (containingClass().isInterface()) {
  109. return super.modifierSpecifier() & ~Modifier.ABSTRACT;
  110. }
  111. return super.modifierSpecifier();
  112. }
  113. }