82 import com.sun.tools.javac.tree.JCTree; |
82 import com.sun.tools.javac.tree.JCTree; |
83 import com.sun.tools.javac.tree.JCTree.*; |
83 import com.sun.tools.javac.tree.JCTree.*; |
84 import com.sun.tools.javac.tree.TreeCopier; |
84 import com.sun.tools.javac.tree.TreeCopier; |
85 import com.sun.tools.javac.tree.TreeInfo; |
85 import com.sun.tools.javac.tree.TreeInfo; |
86 import com.sun.tools.javac.tree.TreeMaker; |
86 import com.sun.tools.javac.tree.TreeMaker; |
|
87 import com.sun.tools.javac.util.Abort; |
87 import com.sun.tools.javac.util.Assert; |
88 import com.sun.tools.javac.util.Assert; |
88 import com.sun.tools.javac.util.Context; |
89 import com.sun.tools.javac.util.Context; |
89 import com.sun.tools.javac.util.JCDiagnostic; |
90 import com.sun.tools.javac.util.JCDiagnostic; |
90 import com.sun.tools.javac.util.List; |
91 import com.sun.tools.javac.util.List; |
91 import com.sun.tools.javac.util.ListBuffer; |
92 import com.sun.tools.javac.util.ListBuffer; |
234 } |
235 } |
235 |
236 |
236 public Element getElement(TreePath path) { |
237 public Element getElement(TreePath path) { |
237 JCTree tree = (JCTree) path.getLeaf(); |
238 JCTree tree = (JCTree) path.getLeaf(); |
238 Symbol sym = TreeInfo.symbolFor(tree); |
239 Symbol sym = TreeInfo.symbolFor(tree); |
239 if (sym == null && TreeInfo.isDeclaration(tree)) { |
240 if (sym == null) { |
240 for (TreePath p = path; p != null; p = p.getParentPath()) { |
241 if (TreeInfo.isDeclaration(tree)) { |
241 JCTree t = (JCTree) p.getLeaf(); |
242 for (TreePath p = path; p != null; p = p.getParentPath()) { |
242 if (t.hasTag(JCTree.Tag.CLASSDEF)) { |
243 JCTree t = (JCTree) p.getLeaf(); |
243 JCClassDecl ct = (JCClassDecl) t; |
244 if (t.hasTag(JCTree.Tag.CLASSDEF)) { |
244 if (ct.sym != null) { |
245 JCClassDecl ct = (JCClassDecl) t; |
245 if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) { |
246 if (ct.sym != null) { |
246 attr.attribClass(ct.pos(), ct.sym); |
247 if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) { |
247 sym = TreeInfo.symbolFor(tree); |
248 attr.attribClass(ct.pos(), ct.sym); |
|
249 sym = TreeInfo.symbolFor(tree); |
|
250 } |
|
251 break; |
248 } |
252 } |
249 break; |
|
250 } |
253 } |
|
254 } |
|
255 } else if (tree.hasTag(Tag.TOPLEVEL)) { |
|
256 JCCompilationUnit cu = (JCCompilationUnit) tree; |
|
257 if (cu.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) { |
|
258 sym = cu.packge; |
251 } |
259 } |
252 } |
260 } |
253 } |
261 } |
254 return sym; |
262 return sym; |
255 } |
263 } |