1 /* gnu.classpath.tools.gjdoc.MemberDocImpl
2 Copyright (C) 2001 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 package gnu.classpath.tools.gjdoc;
24 import com.sun.javadoc.*;
26 public abstract class MemberDocImpl extends ProgramElementDocImpl implements MemberDoc {
28 protected String typeName;
31 public MemberDocImpl(ClassDoc containingClass,
32 PackageDoc containingPackage,
33 SourcePosition position) {
35 super(containingClass,
40 public String qualifiedName() {
41 return containingClass().qualifiedName()+"."+name();
44 public boolean isSynthetic() {
48 int parseModifiers(char[] source, int startIndex, int endIndex) {
50 Debug.log(9,"parseModifiers '"+new String(source,startIndex,endIndex-startIndex)+"'");
52 final int STATE_NORMAL = 1;
53 final int STATE_STARC = 2;
54 final int STATE_SLASHC = 3;
56 int state = STATE_NORMAL;
58 StringBuffer word = new StringBuffer();
59 StringBuffer typeNameBuf = new StringBuffer();
60 int lastWordStart = startIndex;
63 for (; startIndex<endIndex; ++startIndex) {
64 if (state==STATE_STARC) {
65 if (startIndex<endIndex-1 && source[startIndex]=='*' && source[startIndex+1]=='/') {
70 else if (state==STATE_SLASHC) {
71 if (source[startIndex]=='\n') {
75 else if (startIndex<endIndex-1 && source[startIndex]=='/' && source[startIndex+1]=='*') {
79 else if (source[startIndex]=='=' || source[startIndex]=='(' || source[startIndex]==';') {
80 typeName = typeNameBuf.toString();
83 else if (Parser.WHITESPACE.indexOf(source[startIndex])>=0
84 || (startIndex > 0 && source[startIndex-1] == ']' && source[startIndex] != '[')) {
85 if (word.length()>0 && lastChar != '.') {
86 if (processModifier(word.toString())) {
88 else if (typeNameBuf.length()==0 && !isConstructor()) {
89 typeNameBuf.setLength(0);
90 typeNameBuf.append(word);
92 else if ((firstChar=='[' || firstChar==']') && !isConstructor()) {
93 typeNameBuf.append(word);
96 typeName = typeNameBuf.toString();
100 lastWordStart=startIndex;
104 if (lastWordStart<0) lastWordStart=startIndex;
105 lastChar = source[startIndex];
106 if (0 == word.length()) {
107 firstChar = lastChar;
109 word.append((char)lastChar);
113 typeName = typeNameBuf.toString();
118 //public Type type() throws ParseException {
119 Debug.log(9,"type() called on "+containingClass()+"."+this);
122 type=((ClassDocImpl)containingClass()).typeForString(typeName);
123 } catch (ParseException e) {
124 System.err.println("FIXME: add try-catch to force compilation");
132 protected void setName(String name) {
138 public String name() {
142 public void setTypeName(String typeName) {
143 this.typeName=typeName;
147 public String getTypeName() {
151 // return true if this Doc is include in the active set.
152 public boolean isIncluded() {
153 return Main.getInstance().includeAccessLevel(accessLevel);
156 public int compareTo(Object o) {
157 if (o instanceof MemberDocImpl) {
158 int rc=name().compareTo(((MemberDocImpl)o).name());
160 rc=containingClass().qualifiedName().compareTo(((MemberDocImpl)o).containingClass().qualifiedName());
164 return super.compareTo(o);
170 if (type==null && typeName!=null) {
171 Debug.log(1, "MemberDocImpl.resolve(), looking up type named "+typeName);
173 type=((ClassDocImpl)containingClass()).typeForString(typeName);
174 } catch (ParseException e) {
175 //System.err.println("FIXME: add try-catch to force compilation");
176 //e.printStackTrace();
177 Debug.log(1, "INTERNAL WARNING: Couldn't find type for name '"+typeName+"'");
181 if (type instanceof ClassDocProxy) {
182 String className=type.qualifiedTypeName();
183 ClassDoc realClassDoc=((ClassDocImpl)containingClass()).findClass(className, type.dimension());
184 if (realClassDoc!=null) {
188 //throw new Error("Class not found: "+className);
189 /*** This is not an error, the class was not included
190 * on the command line. Perhaps emit a notice here.
193 Main.getRootDoc().printError("Class not found '"
196 + containingClass().qualifiedName()
205 public void resolveComments()
207 super.resolveComments();
209 if (tagMap.isEmpty()) {
210 TagContainer inheritedTagMap = ClassDocImpl.findInheritedDoc(containingClass(),
213 if (null != inheritedTagMap) {
214 this.tagMap = inheritedTagMap.getTagMap();