1 19 20 package org.netbeans.modules.java.parser; 21 22 import org.openide.nodes.Node; 23 import org.openide.src.*; 24 25 import java.util.WeakHashMap ; 26 27 import org.netbeans.modules.java.bridge.BindingFactory; 28 import org.netbeans.modules.java.bridge.LangModel; 29 import org.netbeans.modules.java.bridge.WrapperFactory; 30 import org.netbeans.modules.java.codegen.DocumentBinding; 31 32 38 public class LangEnvImpl implements LangModel.Env { 39 WeakHashMap cookieMap; 40 DocumentBinding binding; 41 WrapperFactory wrapper; 42 LangModel model; 43 44 public LangEnvImpl(DocumentBinding docBinding) { 45 this.binding = docBinding; 46 this.wrapper = DefaultWrapper.getInstance(); 47 cookieMap = new WeakHashMap (57); 48 } 49 50 public void setModel(LangModel model) { 51 this.model = model; 52 } 53 54 public BindingFactory getBindingFactory() { 55 return binding; 56 } 57 58 public WrapperFactory getWrapperFactory() { 59 return wrapper; 60 } 61 62 65 public void complete(Element scope, int informationKind) { 66 } 67 68 74 public Type resolveType(Element context, Type original) { 75 if (original.isPrimitive()) 76 return original; 77 Type t = original; 78 int depth = 0; 79 while (t.isArray()) { 80 t = t.getElementType(); 81 depth++; 82 } 83 if (t.isPrimitive()) 84 return original; 85 86 Identifier id = t.getTypeIdentifier(); 87 Identifier resolved = resolveTypeIdent(context, id); 88 if (resolved == id) 89 return original; 90 91 t = Type.createClass(resolved); 93 while (depth > 0) { 94 t = Type.createArray(t); 95 depth--; 96 } 97 return t; 98 } 99 100 107 public Identifier resolveTypeIdent(Element context, Identifier original) { 108 if (model.isSameContext(context, original)) 109 return original; 110 return model.createLocalIdentifier(context, original.getFullName(), 111 original.getSourceName(), Identifier.NOT_YET_RESOLVED); 112 } 113 114 public Node.Cookie findCookie(Element el, Class requested) { 115 return null; 116 } 117 } 118 | Popular Tags |