1 19 24 25 package org.netbeans.modules.javacore.parser; 26 27 import java.util.HashMap ; 28 import java.util.Iterator ; 29 import java.util.Map ; 30 import org.netbeans.jmi.javamodel.JavaClass; 31 import org.netbeans.jmi.javamodel.JavaModelPackage; 32 import org.netbeans.modules.javacore.ClassIndex; 33 import org.netbeans.modules.javacore.jmiimpl.javamodel.JavaClassImpl; 34 35 39 public class MemberClassScope implements ScopeMember { 40 private String fqn; 41 private ClassIndex index; 42 private Map inners; 43 44 MemberClassScope(JavaClass jclass) { 45 if (jclass instanceof JavaClassImpl && ((JavaClassImpl)jclass).isTransient()) { JavaClassImpl jclsImpl=(JavaClassImpl)jclass; 47 Iterator iter = jclsImpl.getInnerClasses().iterator(); 48 49 inners=new HashMap (); 50 while (iter.hasNext()) { 51 JavaClass obj = (JavaClass)iter.next (); 52 53 inners.put(obj.getSimpleName(),obj); 54 } 56 } else { 57 JavaModelPackage pck=(JavaModelPackage)jclass.refImmediatePackage(); 58 59 index=ClassIndex.getIndex(pck); 60 fqn=jclass.getName().concat("."); } 62 } 63 64 public Object lookup(Object key) { 65 if (fqn!=null) { 66 String className=fqn.concat((String )key); 67 68 if (index.hasClass(className)) 69 return className; 70 return null; 71 } 72 return inners.get(key); 73 } 74 } 75 | Popular Tags |