KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > usages > SourceAnalyser


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.java.source.usages;
21
22 import com.sun.source.tree.ClassTree;
23 import com.sun.source.tree.CompilationUnitTree;
24 import com.sun.source.tree.ErroneousTree;
25 import com.sun.source.tree.IdentifierTree;
26 import com.sun.source.tree.MemberSelectTree;
27 import com.sun.source.tree.MethodTree;
28 import com.sun.source.tree.NewClassTree;
29 import com.sun.source.tree.ParameterizedTypeTree;
30 import com.sun.source.tree.Tree;
31 import com.sun.source.util.TreeScanner;
32 import com.sun.tools.javac.api.JavacTaskImpl;
33 import com.sun.tools.javac.code.Symbol;
34 import com.sun.tools.javac.code.Symbol;
35 import com.sun.tools.javac.code.Symbol.ClassSymbol;
36 import com.sun.tools.javac.code.Types;
37 import com.sun.tools.javac.tree.JCTree;
38 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
39 import com.sun.tools.javac.util.Name;
40 import com.sun.tools.javac.util.Name;
41 import java.io.BufferedReader JavaDoc;
42 import java.io.IOException JavaDoc;
43 import java.io.OutputStreamWriter JavaDoc;
44 import java.io.PrintWriter JavaDoc;
45 import java.io.PrintWriter JavaDoc;
46 import java.net.MalformedURLException JavaDoc;
47 import java.net.URI JavaDoc;
48 import java.util.ArrayList JavaDoc;
49 import java.util.EnumSet JavaDoc;
50 import java.util.HashMap JavaDoc;
51 import java.util.HashSet JavaDoc;
52 import java.util.LinkedList JavaDoc;
53 import java.util.List JavaDoc;
54 import java.util.Map JavaDoc;
55 import java.util.Set JavaDoc;
56 import java.util.Stack JavaDoc;
57 import java.util.logging.Logger JavaDoc;
58 import javax.lang.model.element.Element;
59 import javax.lang.model.element.ElementKind;
60 import javax.lang.model.element.TypeElement;
61 import javax.lang.model.type.ArrayType;
62 import javax.lang.model.type.DeclaredType;
63 import javax.lang.model.type.TypeKind;
64 import javax.lang.model.type.TypeMirror;
65 import javax.tools.JavaFileManager;
66 import javax.tools.JavaFileObject;
67 import javax.tools.StandardLocation;
68 import org.netbeans.api.java.classpath.ClassPath;
69 import org.netbeans.modules.java.source.parsing.FileObjects;
70 import org.openide.filesystems.FileObject;
71 import org.openide.filesystems.URLMapper;
72 import org.openide.util.Exceptions;
73
74 /**
75  *
76  * @author Tomas Zezula
77  */

78 public class SourceAnalyser {
79     
80     private final Index index;
81     private final Map JavaDoc<String JavaDoc, List JavaDoc<String JavaDoc>> references;
82     private final Set JavaDoc<String JavaDoc> toDelete;
83     
84     /** Creates a new instance of SourceAnalyser */
85     public SourceAnalyser (final Index index) {
86         assert index != null;
87         this.index = index;
88         this.references = new HashMap JavaDoc<String JavaDoc, List JavaDoc<String JavaDoc>> ();
89         this.toDelete = new HashSet JavaDoc<String JavaDoc> ();
90     }
91     
92     
93     public void store () throws IOException JavaDoc {
94         if (this.references.size() > 0 || this.toDelete.size() > 0) {
95             this.index.store(this.references, toDelete);
96             this.references.clear();
97             this.toDelete.clear();
98         }
99     }
100     
101     public boolean isValid () throws IOException JavaDoc {
102         return this.index.isValid(true);
103     }
104
105     public void analyse (final Iterable JavaDoc<? extends CompilationUnitTree> data, JavacTaskImpl jt, JavaFileManager manager, javax.tools.JavaFileObject sibling) throws IOException JavaDoc {
106         final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> usages = new HashMap JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> ();
107         for (CompilationUnitTree cu : data) {
108             UsagesVisitor uv = new UsagesVisitor (jt, cu, manager, sibling);
109             uv.scan(cu,usages);
110             if (uv.rsList != null && uv.rsList.size()>0) {
111                 final int index = uv.sourceName.lastIndexOf('.'); //NOI18N
112
final String JavaDoc pkg = index == -1 ? "" : uv.sourceName.substring(0,index); //NOI18N
113
final String JavaDoc rsName = (index == -1 ? uv.sourceName : uv.sourceName.substring(index+1)) + '.' + FileObjects.RS; //NOI18N
114
javax.tools.FileObject fo = manager.getFileForOutput(StandardLocation.CLASS_OUTPUT, pkg, rsName, sibling);
115                 assert fo != null;
116                 BufferedReader JavaDoc in = new BufferedReader JavaDoc (fo.openReader(false));
117                 try {
118                     String JavaDoc line;
119                     while ((line = in.readLine())!=null) {
120                         uv.rsList.add (line);
121                     }
122                 } finally {
123                     in.close();
124                 }
125                 PrintWriter JavaDoc rsOut = new PrintWriter JavaDoc(fo.openWriter());
126                 try {
127                     for (String JavaDoc sig : uv.rsList) {
128                         rsOut.println(sig);
129                     }
130                 } finally {
131                     rsOut.close();
132                 }
133             }
134         }
135         for (Map.Entry JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> oe : usages.entrySet()) {
136             List JavaDoc<String JavaDoc> ru = getClassReferences (oe.getKey());
137             Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>> oeValue = oe.getValue();
138             for (Map.Entry JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>> ue : oeValue.entrySet()) {
139                 ru.add (DocumentUtil.encodeUsage(ue.getKey(),ue.getValue()));
140             }
141         }
142     }
143     
144     void analyseUnitAndStore (final CompilationUnitTree cu, final JavacTaskImpl jt) throws IOException JavaDoc {
145         try {
146             final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> usages = new HashMap JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> ();
147             List JavaDoc<String JavaDoc> topLevels = new ArrayList JavaDoc<String JavaDoc>();
148             UsagesVisitor uv = new UsagesVisitor (jt, cu, topLevels);
149             uv.scan(cu,usages);
150             for (Map.Entry JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> oe : usages.entrySet()) {
151                 String JavaDoc className = oe.getKey();
152                 List JavaDoc<String JavaDoc> ru = getClassReferences (className);
153                 Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>> oeValue = oe.getValue();
154                 for (Map.Entry JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>> ue : oeValue.entrySet()) {
155                     ru.add (DocumentUtil.encodeUsage(ue.getKey(),ue.getValue()));
156                 }
157             }
158             this.index.store(this.references, topLevels);
159         } finally {
160             this.references.clear();
161         }
162     }
163     
164     public void delete (final String JavaDoc className) throws IOException JavaDoc {
165         if (!this.index.isValid(false)) {
166             return;
167         }
168         this.toDelete.add(className);
169     }
170     
171     
172     private List JavaDoc<String JavaDoc> getClassReferences (final String JavaDoc className) {
173         assert className != null;
174         List JavaDoc<String JavaDoc> result = this.references.get (className);
175         if (result == null) {
176             result = new LinkedList JavaDoc<String JavaDoc>();
177             this.references.put(className,result);
178         }
179         return result;
180     }
181     
182     
183     private static void dumpUsages(final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> usages) throws IOException JavaDoc {
184         assert usages != null;
185         for (Map.Entry JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> oe : usages.entrySet()) {
186             System.out.println("Usages in class: " + oe.getKey()); // NOI18N
187
for (Map.Entry JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>> ue : oe.getValue().entrySet()) {
188                 System.out.println("\t"+ue.getKey()+"\t: "+ue.getValue().toString()); // NOI18N
189
}
190         }
191     }
192
193     static class UsagesVisitor extends TreeScanner<Void JavaDoc,Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>>> {
194         
195         enum State {EXTENDS, IMPLEMENTS, GT, OTHER};
196         
197         private final Stack JavaDoc<String JavaDoc> activeClass;
198         private JavaFileManager manager;
199         private final JavacTaskImpl jt;
200         private final Name errorName;
201         private final CompilationUnitTree cu;
202         private final Types types;
203         private final javax.tools.JavaFileObject sibling;
204         private final String JavaDoc sourceName;
205         private final boolean signatureFiles;
206         private State state;
207         private Element enclosingElement = null;
208         private Set JavaDoc<String JavaDoc> rsList;
209         private List JavaDoc<? super String JavaDoc> topLevels;
210         
211         
212         public UsagesVisitor (JavacTaskImpl jt, CompilationUnitTree cu, JavaFileManager manager, javax.tools.JavaFileObject sibling) {
213             assert jt != null;
214             assert cu != null;
215             assert manager != null;
216             assert sibling != null;
217             this.activeClass = new Stack JavaDoc<String JavaDoc> ();
218             this.jt = jt;
219             this.errorName = Name.Table.instance(jt.getContext()).error;
220             this.state = State.OTHER;
221             this.types = com.sun.tools.javac.code.Types.instance(jt.getContext());
222             this.cu = cu;
223             this.signatureFiles = true;
224             this.manager = manager;
225             this.sibling = sibling;
226             this.sourceName = this.manager.inferBinaryName(StandardLocation.SOURCE_PATH, this.sibling);
227         }
228                 
229         protected UsagesVisitor (JavacTaskImpl jt, CompilationUnitTree cu, List JavaDoc<? super String JavaDoc> topLevels) {
230             assert jt != null;
231             assert cu != null;
232             
233             this.activeClass = new Stack JavaDoc<String JavaDoc> ();
234             this.jt = jt;
235             this.errorName = Name.Table.instance(jt.getContext()).error;
236             this.state = State.OTHER;
237             this.types = com.sun.tools.javac.code.Types.instance(jt.getContext());
238             this.cu = cu;
239             this.signatureFiles = false;
240             this.manager = null;
241             this.sibling = null;
242             this.sourceName = ""; //NOI18N
243
this.topLevels = topLevels;
244         }
245         
246         final Types getTypes() {
247             return types;
248         }
249         
250         public @Override JavaDoc Void JavaDoc scan(Tree node, Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
251             if (node == null) {
252                 return null;
253             }
254             super.scan (node,p);
255             return null;
256         }
257         
258         public @Override JavaDoc Void JavaDoc visitMemberSelect(final MemberSelectTree node, final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
259             handleVisitIdentSelect (((JCTree.JCFieldAccess)node).sym, p);
260             State oldState = this.state;
261             this.state = State.OTHER;
262             Void JavaDoc ret = super.visitMemberSelect (node, p);
263             this.state = oldState;
264             return ret;
265         }
266
267         public @Override JavaDoc Void JavaDoc visitIdentifier(final IdentifierTree node, final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
268             handleVisitIdentSelect (((JCTree.JCIdent)node).sym, p);
269             return super.visitIdentifier(node, p);
270         }
271         
272         private void handleVisitIdentSelect (Symbol sym, final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
273             if (!activeClass.empty()) {
274                 if (sym != null) {
275                     if (sym.getKind().isClass() || sym.getKind().isInterface()) {
276                         final String JavaDoc className = encodeClassName(sym);
277                         if (className != null) {
278                             switch (this.state) {
279                                 case EXTENDS:
280                                     addUsage(activeClass.peek(),className, p, ClassIndexImpl.UsageType.SUPER_CLASS);
281                                     break;
282                                 case IMPLEMENTS:
283                                     addUsage (activeClass.peek(),className,p, ClassIndexImpl.UsageType.SUPER_INTERFACE);
284                                     break;
285                                 case OTHER:
286                                 case GT:
287                                     addUsage (activeClass.peek(),className,p, ClassIndexImpl.UsageType.TYPE_REFERENCE);
288                                     break;
289                             }
290                         }
291                     }
292                     else if (sym.getKind().isField()) {
293                         final Symbol owner = sym.getEnclosingElement();
294                         final String JavaDoc className = encodeClassName(owner);
295                         if (className != null) {
296                             addUsage (activeClass.peek(),className,p,ClassIndexImpl.UsageType.FIELD_REFERENCE);
297                         }
298                     }
299                     else if (sym.getKind() == ElementKind.CONSTRUCTOR || sym.getKind() == ElementKind.METHOD) {
300                         final Symbol owner = sym.getEnclosingElement();
301                         final String JavaDoc className = encodeClassName(owner);
302                         if (className != null) {
303                             addUsage (activeClass.peek(),className,p,ClassIndexImpl.UsageType.METHOD_REFERENCE);
304                         }
305                     }
306                 }
307             }
308         }
309         
310         public @Override JavaDoc Void JavaDoc visitParameterizedType(ParameterizedTypeTree node, final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
311             scan(node.getType(), p);
312             State currState = this.state;
313             this.state = State.GT;
314             scan(node.getTypeArguments(), p);
315             this.state = currState;
316             return null;
317         }
318         
319         void dump(TypeElement clazz, String JavaDoc className, Element enclosingElement) {
320             PrintWriter JavaDoc output = null;
321             if (this.rsList != null) {
322                 this.rsList.add (className);
323             }
324             try {
325                 JavaFileObject jfo = manager.getJavaFileForOutput(StandardLocation.CLASS_OUTPUT, className, JavaFileObject.Kind.CLASS, sibling);
326                 
327                 output = new PrintWriter JavaDoc(new OutputStreamWriter JavaDoc(jfo.openOutputStream(), "UTF-8"));
328                 
329                 SymbolDumper.dump(output, types, clazz, enclosingElement);
330                 
331                 output.close();
332                 
333             } catch (IOException JavaDoc e) {
334                 Exceptions.printStackTrace(e);
335             } finally {
336                 if (output != null) {
337                     output.close();
338                 }
339             }
340         }
341         
342         protected boolean shouldGenerate (final String JavaDoc binaryName, ClassSymbol sym) {
343             if (!signatureFiles || binaryName == null) {
344                 return false;
345             }
346             if (sym.getQualifiedName().isEmpty()) {
347                 return true;
348             }
349             Symbol enclosing = sym.getEnclosingElement();
350             while (enclosing != null && enclosing.getKind() != ElementKind.PACKAGE) {
351                 if (!enclosing.getKind().isClass() && !enclosing.getKind().isInterface()) {
352                     return true;
353                 }
354                 enclosing = enclosing.getEnclosingElement();
355             }
356             return false;
357     }
358         
359         public @Override JavaDoc Void JavaDoc visitClass (final ClassTree node, final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
360             final ClassSymbol sym = ((JCTree.JCClassDecl)node).sym;
361             boolean errorInDecl = false;
362             boolean errorIgnorSubtree = true;
363             String JavaDoc className = null;
364             if (sym != null) {
365                 errorInDecl = hasErrorName(sym);
366                 if (errorInDecl) {
367                     if (activeClass.size()>0) {
368                         activeClass.push (activeClass.get(0));
369                         errorIgnorSubtree = false;
370                     }
371                     else {
372                         if (this.cu instanceof JCTree.JCCompilationUnit) {
373                             JavaFileObject jfo = ((JCTree.JCCompilationUnit)this.cu).sourcefile;
374                             if (jfo != null) {
375                                 URI JavaDoc uri = jfo.toUri();
376                                 if (uri != null && uri.isAbsolute()) {
377                                     try {
378                                         FileObject fo = URLMapper.findFileObject(uri.toURL());
379                                         if (fo != null) {
380                                             ClassPath cp = ClassPath.getClassPath(fo,ClassPath.SOURCE);
381                                             if (cp != null) {
382                                                 className = cp.getResourceName(fo,'.',false);
383                                             }
384                                         }
385                                     } catch (MalformedURLException JavaDoc e) {
386                                         Exceptions.printStackTrace(e);
387                                     }
388                                 }
389                             }
390                         }
391                         if (className != null) {
392                             final String JavaDoc classNameType = className + DocumentUtil.encodeKind(ElementKind.CLASS);
393                             if (topLevels != null && activeClass.isEmpty()) {
394                                 topLevels.add (className);
395                             }
396                             activeClass.push (classNameType);
397                             errorIgnorSubtree = false;
398                             addUsage (classNameType,className, p, ClassIndexImpl.UsageType.TYPE_REFERENCE);
399                         }
400                         else {
401                             Logger.getLogger("global").warning(String.format("Cannot resolve %s, ignoring whole subtree.\n",sym.toString())); //NOI18N
402
}
403                     }
404                 }
405                 else {
406                     
407                     final StringBuilder JavaDoc classNameBuilder = new StringBuilder JavaDoc ();
408                     ClassFileUtil.encodeClassName(sym, classNameBuilder, '.'); //NOI18N
409
className = classNameBuilder.toString();
410                     classNameBuilder.append(DocumentUtil.encodeKind(sym.getKind()));
411                     final String JavaDoc classNameType = classNameBuilder.toString();
412                     if (signatureFiles && activeClass.isEmpty() && !className.equals(sourceName)) {
413                         rsList = new HashSet JavaDoc<String JavaDoc>();
414                     }
415                     if (topLevels != null && activeClass.isEmpty()) {
416                         topLevels.add (className);
417                     }
418                     activeClass.push (classNameType);
419                     errorIgnorSubtree = false;
420                     addUsage (classNameType,className, p, ClassIndexImpl.UsageType.TYPE_REFERENCE);
421                 }
422                 
423             }
424             if (!errorIgnorSubtree) {
425                 Element old = enclosingElement;
426                 try {
427                     enclosingElement = sym;
428                     scan(node.getModifiers(), p);
429                     scan(node.getTypeParameters(), p);
430                     state = errorInDecl ? State.OTHER : State.EXTENDS;
431                     scan(node.getExtendsClause(), p);
432                     state = errorInDecl ? State.OTHER : State.IMPLEMENTS;
433                     scan(node.getImplementsClause(), p);
434                     state = State.OTHER;
435                     scan(node.getMembers(), p);
436                     activeClass.pop();
437                 } finally {
438                     enclosingElement = old;
439                 }
440             }
441             if (!errorInDecl && shouldGenerate(className, sym)) {
442                 dump(sym, className, enclosingElement);
443             }
444             return null;
445         }
446         
447         public @Override JavaDoc Void JavaDoc visitNewClass(NewClassTree node, Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
448             final Symbol sym = ((JCTree.JCNewClass)node).constructor;
449             if (sym != null) {
450                 final Symbol owner = sym.getEnclosingElement();
451                 if (owner != null && owner.getKind().isClass()) {
452                     final String JavaDoc className = encodeClassName(owner);
453                     if (className != null) {
454                         addUsage(activeClass.peek(),className,p,ClassIndexImpl.UsageType.METHOD_REFERENCE);
455                     }
456                 }
457             }
458             return super.visitNewClass (node,p);
459         }
460         
461         public @Override JavaDoc Void JavaDoc visitErroneous(final ErroneousTree tree, Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
462             List JavaDoc<? extends Tree> trees = tree.getErrorTrees();
463             for (Tree t : trees) {
464                 this.scan(t,p);
465             }
466             return null;
467         }
468
469         public Void JavaDoc visitMethod(MethodTree node, Map JavaDoc<String JavaDoc, Map JavaDoc<String JavaDoc, Set JavaDoc<ClassIndexImpl.UsageType>>> p) {
470             Element old = enclosingElement;
471             try {
472                 enclosingElement = ((JCMethodDecl) node).sym;
473                 return super.visitMethod(node, p);
474             } finally {
475                 enclosingElement = old;
476             }
477         }
478         
479         private void addUsage (final String JavaDoc ownerName, final String JavaDoc className, final Map JavaDoc<String JavaDoc,Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>>> map, final ClassIndexImpl.UsageType type) {
480             assert className != null;
481             assert map != null;
482             assert type != null;
483             Map JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>> tUsages = map.get(ownerName);
484             if (tUsages == null) {
485                 tUsages = new HashMap JavaDoc<String JavaDoc,Set JavaDoc<ClassIndexImpl.UsageType>> ();
486                 map.put(ownerName,tUsages);
487             }
488             Set JavaDoc<ClassIndexImpl.UsageType> usageType = tUsages.get (className);
489             if (usageType == null) {
490                 usageType = EnumSet.noneOf(ClassIndexImpl.UsageType.class);
491                 tUsages.put (className, usageType);
492             }
493             usageType.add (type);
494         }
495         
496         private boolean hasErrorName (Symbol cs) {
497             while (cs != null) {
498                 if (cs.name == errorName) {
499                     return true;
500                 }
501                 cs = cs.getEnclosingElement();
502             }
503             return false;
504         }
505         
506         private static String JavaDoc encodeClassName (final Symbol sym) {
507             assert sym instanceof Symbol.ClassSymbol;
508             TypeElement toEncode = null;
509             final TypeMirror type = ((Symbol.ClassSymbol)sym).asType();
510             if (sym.getEnclosingElement().getKind() == ElementKind.TYPE_PARAMETER) {
511                 if (type.getKind() == TypeKind.ARRAY) {
512                     TypeMirror ctype = ((ArrayType) type).getComponentType();
513                     if (ctype.getKind() == TypeKind.DECLARED) {
514                         toEncode = (TypeElement)((DeclaredType)ctype).asElement();
515                     }
516                 }
517             }
518             else {
519                 toEncode = (TypeElement) sym;
520             }
521             return toEncode == null ? null : ClassFileUtil.encodeClassName(toEncode);
522         }
523     }
524     
525 }
526
Popular Tags