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/] [SeeTagImpl.java] - Blame information for rev 779

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 779 jeremybenn
/* gnu.classpath.tools.gjdoc.SeeTagImpl
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 com.sun.javadoc.*;
41
import java.util.*;
42
import java.text.*;
43
 
44
public class SeeTagImpl extends AbstractTagImpl implements SeeTag {
45
 
46
   protected String     reference;
47
   private String       referencedClassName;
48
   private String       referencedMemberName;
49
   private ClassDoc     referencedClass;
50
   private MemberDoc    referencedMember;
51
   private PackageDoc   referencedPackage;
52
   private String       label;
53
   private ClassDocImpl contextClass;
54
 
55
   public SeeTagImpl(String text, ClassDocImpl contextClass) {
56
      super(text);
57
      this.contextClass=contextClass;
58
   }
59
 
60
   public void resolve() {
61
 
62
      super.resolve();
63
 
64
      text = text.trim();
65
 
66
      if (text.startsWith("<") || text.startsWith("\"")) {
67
         label = text;
68
         return;
69
      }
70
 
71
      int labelNdx=text.indexOf(';');
72
      if (labelNdx>=0) {
73
         label="";
74
         return;
75
      }
76
 
77
      for (int i=0; i<text.length(); ++i) {
78
         if (" \t\r\n".indexOf(text.charAt(i)) >= 0) {
79
            labelNdx = i;
80
            break;
81
         }
82
      }
83
 
84
      int openParenNdx = text.indexOf('(');
85
      if (openParenNdx >= 0 && openParenNdx < labelNdx) {
86
         labelNdx=text.indexOf(')', openParenNdx);
87
         if (labelNdx >= 0) {
88
            ++ labelNdx;
89
         }
90
      }
91
 
92
      if (labelNdx<0 || labelNdx>=text.length()) {
93
         reference=text.trim();
94
         label="";
95
      }
96
      else {
97
         reference=text.substring(0,labelNdx).trim();
98
         label=text.substring(labelNdx).trim();
99
      }
100
 
101
      int mspecNdx=reference.indexOf('#');
102
      String referencedFqName;
103
      if (mspecNdx<0) {
104
         referencedFqName=reference;
105
      }
106
      else {
107
         referencedFqName=reference.substring(0,mspecNdx);
108
         referencedMemberName=reference.substring(mspecNdx+1);
109
     }
110
 
111
      // the following is in contradiction to the api docs, but
112
      // conform to sun javadoc: return fully qualified classname
113
      // with referencedClassName().
114
      if (referencedFqName.trim().length()>0) {
115
         referencedClassName=referencedFqName;
116
         if (contextClass==null)
117
            referencedClass=Main.getRootDoc().classNamed(referencedFqName);
118
         else
119
            referencedClass=contextClass.findClass(referencedFqName);
120
      }
121
      else {
122
         referencedClassName="";
123
         referencedClass=contextClass;
124
      }
125
 
126
      if (referencedClass==null) {
127
         referencedClass = Main.getRootDoc().classNamed("java.lang." + referencedFqName);
128
      }
129
 
130
      if (referencedClass!=null && !referencedClass.isIncluded()) referencedClass=null;
131
 
132
      if (referencedClass!=null) {
133
         referencedPackage=referencedClass.containingPackage();
134
         referencedClassName=referencedClass.qualifiedName();
135
 
136
         if (referencedMemberName!=null) {
137
 
138
            if (referencedMemberName.indexOf('(')<0) {
139
               referencedMember=((ClassDocImpl)referencedClass).findFieldRec(referencedMemberName);
140
               if (null == referencedMember) {
141
                  MethodDoc[] methods = ((ClassDocImpl)referencedClass).methods();
142
                  for (int i=0; i<methods.length; ++i) {
143
                     if (methods[i].name().equals(referencedMemberName)) {
144
                        if (null == referencedMember) {
145
                           referencedMember = methods[i];
146
                        }
147
                        else {
148
                           referencedClass = null;
149
                           referencedMember = null;
150
                           //print warning here
151
                           break;
152
                        }
153
                     }
154
                  }
155
               }
156
               else {
157
                  referencedClass = referencedMember.containingClass();
158
               }
159
            }
160
            else {
161
               referencedMember=((ClassDocImpl)referencedClass).findExecutableRec(referencedMemberName);
162
               if (referencedMember==null) {
163
                  //System.err.println("cannot find member for '"+referencedMemberName+"'");
164
                  referencedClass = null;
165
               }
166
            }
167
         }
168
      }
169
      /*
170
      else {
171
         System.err.println("class not found: '"+referencedFqName + "' in context class " + contextClass + " in " + this);
172
      }
173
      */
174
   }
175
 
176
   public ClassDoc referencedClass() {
177
      return referencedClass;
178
   }
179
 
180
   public String referencedClassName() {
181
      return referencedClassName;
182
   }
183
 
184
   public MemberDoc referencedMember() {
185
      return referencedMember;
186
   }
187
 
188
   public String referencedMemberName() {
189
      return referencedMemberName;
190
   }
191
 
192
   public PackageDoc referencedPackage() {
193
      return referencedPackage;
194
   }
195
 
196
   public String label() {
197
      return label;
198
   }
199
 
200
   public String kind() {
201
      return "@see";
202
   }
203
 
204
   public String name() {
205
      return "@see";
206
   }
207
 
208
   public Tag[] firstSentenceTags() {
209
      return inlineTags();
210
   }
211
 
212
   public Tag[] inlineTags() {
213
      return new Tag[]{new TextTagImpl(referencedClassName)};
214
   }
215
}

powered by: WebSVN 2.1.0

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