KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > ajdoc > MethodDocImpl


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
24 import org.aspectj.compiler.base.ast.MethodDec;
25 import org.aspectj.compiler.base.ast.NameType;
26 import org.aspectj.compiler.base.ast.TypeDec;
27
28 import com.sun.javadoc.ClassDoc;
29
30 import java.lang.reflect.Modifier JavaDoc;
31
32 public class MethodDocImpl
33     extends CodeDocImpl
34     implements org.aspectj.ajdoc.MethodDoc {
35
36     /*
37      * This is a hack because the compiler isn't resolving
38      * introduced types.
39      */

40     private org.aspectj.compiler.base.ast.Type type;
41     public void setType(org.aspectj.compiler.base.ast.Type type) {
42         this.type = type;
43     }
44
45     public MethodDocImpl(ClassDoc containingClass, MethodDec methodDec) {
46         super(containingClass, methodDec);
47         setType(codeDec().getResultTypeD().getType());
48     }
49     
50     protected MethodDec methodDec() {
51         return (MethodDec)codeDec();
52     }
53
54     /**
55      * Returns <code>true</code>.
56      *
57      * @return <code>true</code>.
58      */

59     public boolean isMethod() {
60         return true;
61     }
62
63     /**
64      * Returns <code>true</code> if this method is <code>abstract</code>.
65      *
66      * @return <code>true</code> if this method is <code>abstract</code>.
67      */

68     public boolean isAbstract() {
69         return methodDec().isAbstract();
70     }
71     
72     /**
73      * Returns the return type of this method.
74      *
75      * @return the Type representing the type this
76      * method returns.
77      */

78     public com.sun.javadoc.Type returnType() {
79         return TypeImpl.getInstance(type);
80         //return null; //TODO getResultTypeD().getType();
81
}
82
83     /**
84      * Returns the type that nearest super class that defines
85      * this method.
86      *
87      * @return the type that nearest super class that defines
88      * this method.
89      */

90     public ClassDoc overriddenClass() {
91         //Exprs params = getFormals().makeExprs(); // do this for side-effect?XXX
92
TypeDec where = methodDec().getDeclaringType().getTypeDec();
93         NameType superType = (NameType)where.getSuperClassType();
94         while (superType != null) {
95             MethodDec method = Util.methodDec(superType,
96                                               methodDec().getId(),
97                                               methodDec().getFormals());
98             if (method != null && !method.getId().equals("not$found")) {
99                 if (method.getDeclaringType().equals(superType)) {
100                     return null;
101                 }
102             }
103             if (superType.getTypeDec().getFullName().
104                 equals("java.lang.Object")) {
105                 return null;
106             }
107             superType = (NameType)superType.getTypeDec().getSuperClassType();
108         }
109         return null;
110     }
111
112     /**
113      * Returns the int modifiers for this method.
114      *
115      * @return the int modifiers for this method.
116      * @see java.lang.reflect.Modifier
117      */

118     public int modifierSpecifier() {
119         //XXX interface methods have the ABSTRACT bit set
120
if (containingClass().isInterface()) {
121             return super.modifierSpecifier() & ~Modifier.ABSTRACT;
122         }
123         return super.modifierSpecifier();
124     }
125 }
126
Popular Tags