|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.java.parser; import org.openide.nodes.Node; import org.openide.src.*; import org.netbeans.modules.java.bridge.BindingFactory; import org.netbeans.modules.java.bridge.LangModel; import org.netbeans.modules.java.bridge.WrapperFactory; import org.netbeans.modules.java.codegen.DocumentBinding; /** * * @author sdedic * @version */ public class LangEnvironmentImpl implements LangModel.Env { DocumentBinding binding; WrapperFactory wrapper; LangModel model; public LangEnvironmentImpl(DocumentBinding docBinding) { this.binding = docBinding; this.wrapper = DefaultWrapper.getInstance(); } /** * Finishes creation of the environment's impl -- since it needs to communicate * with its model. */ public void setModel(LangModel model) { this.model = model; } /** * Returns the factory for Binding object for individual model elements. */ public BindingFactory getBindingFactory() { return binding; } /** * Returns the factory that wraps individual elements of the model. */ public WrapperFactory getWrapperFactory() { return wrapper; } /** * Currently no-op implementation. */ public void complete(Element scope, int informationKind) { } /** The environment is called to resolve type name according to the context it * is used in. The current implementation will return all primitives and * array of primitives unchanged, but will delegate resolution of class names * to the {@link #resolveTypeIdent}. If the resolved type identifier is different * than the original, it reconstructs the type and returns it. */ public Type resolveType(Element context, Type original) { if (original.isPrimitive()) return original; Type t = original; int depth = 0; while (t.isArray()) { t = t.getElementType(); depth++; } if (t.isPrimitive()) return original; Identifier id = t.getTypeIdentifier(); Identifier resolved = resolveTypeIdent(context, id); if (resolved == id) return original; // build up the type again. t = Type.createClass(resolved); while (depth > 0) { t = Type.createArray(t); } return t; } /** * This is called to resolve/transform a name of a type for this context. * Assume the context will only be ClassElement or SourceElement. This implementation * does not attempt to resolve identifiers, it only marks them as * {@link org.openide.src.Identifier#NOT_YET_RESOLVED} to distinguish them from * resolved ones. */ public Identifier resolveTypeIdent(Element context, Identifier original) { if (model.isSameContext(context, original)) return original; return model.createLocalIdentifier(context, original.getFullName(), original.getSourceName(), Identifier.NOT_YET_RESOLVED); } public Node.Cookie findCookie(Element el, Class c) { return null; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.