OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [tools/] [gnu/] [classpath/] [tools/] [gjdoc/] [MemberDocImpl.java] - Blame information for rev 779

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 779 jeremybenn
/* gnu.classpath.tools.gjdoc.MemberDocImpl
2
   Copyright (C) 2001 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
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)
9
any later version.
10
 
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.
15
 
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
19
02111-1307 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
package gnu.classpath.tools.gjdoc;
39
 
40
import java.util.*;
41
import com.sun.javadoc.*;
42
 
43
public abstract class MemberDocImpl extends ProgramElementDocImpl implements MemberDoc {
44
 
45
   protected String typeName;
46
   protected Type   type;
47
 
48
   public MemberDocImpl(ClassDoc containingClass,
49
                        PackageDoc containingPackage,
50
                        SourcePosition position) {
51
 
52
      super(containingClass,
53
            containingPackage,
54
            position);
55
   }
56
 
57
   public String qualifiedName() {
58
      return containingClass().qualifiedName()+"."+name();
59
   }
60
 
61
   public boolean isSynthetic() {
62
      return false;
63
   }
64
 
65
   int parseModifiers(char[] source, int startIndex, int endIndex) {
66
 
67
      Debug.log(9,"parseModifiers '"+new String(source,startIndex,endIndex-startIndex)+"'");
68
 
69
      final int STATE_NORMAL = 1;
70
      final int STATE_STARC  = 2;
71
      final int STATE_SLASHC = 3;
72
 
73
      int state = STATE_NORMAL;
74
 
75
      StringBuffer word = new StringBuffer();
76
      StringBuffer typeNameBuf = new StringBuffer();
77
      int lastWordStart = startIndex;
78
      int firstChar = 0;
79
      int lastChar = 0;
80
      for (; startIndex<endIndex; ++startIndex) {
81
         if (state==STATE_STARC) {
82
            if (startIndex<endIndex-1 && source[startIndex]=='*' && source[startIndex+1]=='/') {
83
               ++startIndex;
84
               state=STATE_NORMAL;
85
            }
86
         }
87
         else if (state==STATE_SLASHC) {
88
            if (source[startIndex]=='\n') {
89
               state=STATE_NORMAL;
90
            }
91
         }
92
         else if (startIndex<endIndex-1 && source[startIndex]=='/' && source[startIndex+1]=='*') {
93
            ++startIndex;
94
            state=STATE_STARC;
95
         }
96
         else if (source[startIndex]=='=' || source[startIndex]=='(' || source[startIndex]==';') {
97
            typeName = typeNameBuf.toString();
98
            return lastWordStart;
99
         }
100
         else if (Parser.WHITESPACE.indexOf(source[startIndex])>=0
101
                  || (startIndex > 0 && source[startIndex-1] == ']' && source[startIndex] != '[')) {
102
            if (word.length()>0 && lastChar != '.') {
103
               if (processModifier(word.toString())) {
104
               }
105
               else if (typeNameBuf.length()==0 && !isConstructor()) {
106
                  typeNameBuf.setLength(0);
107
                  typeNameBuf.append(word);
108
               }
109
               else if ((firstChar=='[' || firstChar==']') && !isConstructor()) {
110
                  typeNameBuf.append(word);
111
               }
112
               else {
113
                  typeName = typeNameBuf.toString();
114
                  return lastWordStart;
115
               }
116
               word.setLength(0);
117
               lastWordStart=startIndex;
118
            }
119
         }
120
         else {
121
            if (lastWordStart<0) lastWordStart=startIndex;
122
            lastChar = source[startIndex];
123
            if (0 == word.length()) {
124
               firstChar = lastChar;
125
            }
126
            word.append((char)lastChar);
127
         }
128
      }
129
 
130
      typeName = typeNameBuf.toString();
131
      return startIndex;
132
   }
133
 
134
    public Type type() {
135
        //public Type type() throws ParseException {
136
        Debug.log(9,"type() called on "+containingClass()+"."+this);
137
        if (type==null) {
138
            try {
139
                type=((ClassDocImpl)containingClass()).typeForString(typeName);
140
            } catch (ParseException e) {
141
               System.err.println("FIXME: add try-catch to force compilation");
142
               e.printStackTrace();
143
            }
144
        }
145
        return type;
146
    }
147
 
148
 
149
   protected void setName(String name) {
150
      this.name=name;
151
   }
152
   private String name;
153
 
154
 
155
   public String name() {
156
      return name;
157
   }
158
 
159
   public void setTypeName(String typeName) {
160
      this.typeName=typeName;
161
      this.type=null;
162
   }
163
 
164
   public String getTypeName() {
165
      return typeName;
166
   }
167
 
168
   // return true if this Doc is include in the active set.
169
   public boolean isIncluded() {
170
      return Main.getInstance().includeAccessLevel(accessLevel);
171
   }
172
 
173
   public int compareTo(Object o) {
174
      if (o instanceof MemberDocImpl) {
175
         int rc=name().compareTo(((MemberDocImpl)o).name());
176
         if (rc==0)
177
            rc=containingClass().qualifiedName().compareTo(((MemberDocImpl)o).containingClass().qualifiedName());
178
         return rc;
179
      }
180
      else {
181
         return super.compareTo(o);
182
      }
183
   }
184
 
185
   void resolve() {
186
 
187
      if (type==null && typeName!=null) {
188
         Debug.log(1, "MemberDocImpl.resolve(), looking up type named "+typeName);
189
         try {
190
            type=((ClassDocImpl)containingClass()).typeForString(typeName);
191
         } catch (ParseException e) {
192
            //System.err.println("FIXME: add try-catch to force compilation");
193
            //e.printStackTrace();
194
            Debug.log(1, "INTERNAL WARNING: Couldn't find type for name '"+typeName+"'");
195
         }
196
      }
197
 
198
      if (type instanceof ClassDocProxy) {
199
         String className=type.qualifiedTypeName();
200
         ClassDoc realClassDoc=((ClassDocImpl)containingClass()).findClass(className, type.dimension());
201
         if (realClassDoc!=null) {
202
            type=realClassDoc;
203
         }
204
         else {
205
            //throw new Error("Class not found: "+className);
206
            /*** This is not an error, the class was not included
207
             * on the command line. Perhaps emit a notice here.
208
             *
209
 
210
            Main.getRootDoc().printError("Class not found '"
211
                                         + className
212
                                         + "' in class '"
213
                                         + containingClass().qualifiedName()
214
                                         + "' member '"
215
                                         + name()
216
                                         + "'");
217
            */
218
         }
219
      }
220
   }
221
 
222
   public void resolveComments()
223
   {
224
      super.resolveComments();
225
 
226
      if (tagMap.isEmpty()) {
227
         TagContainer inheritedTagMap = ClassDocImpl.findInheritedDoc(containingClass(),
228
                                                                      this,
229
                                                                      null);
230
         if (null != inheritedTagMap) {
231
            this.tagMap = inheritedTagMap.getTagMap();
232
         }
233
      }
234
   }
235
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.