com.sun.tools.javac.code.Symbol.MethodSymbol Java Examples

The following examples show how to use com.sun.tools.javac.code.Symbol.MethodSymbol. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Attribute.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a string representation of this annotation.
 * String is of one of the forms:
 *     @com.example.foo(name1=val1, name2=val2)
 *     @com.example.foo(val)
 *     @com.example.foo
 * Omit parens for marker annotations, and omit "value=" when allowed.
 */
public String toString() {
    StringBuilder buf = new StringBuilder();
    buf.append("@");
    buf.append(type);
    int len = values.length();
    if (len > 0) {
        buf.append('(');
        boolean first = true;
        for (Pair<MethodSymbol, Attribute> value : values) {
            if (!first) buf.append(", ");
            first = false;

            Name name = value.fst.name;
            if (len > 1 || name != name.table.names.value) {
                buf.append(name);
                buf.append('=');
            }
            buf.append(value.snd);
        }
        buf.append(')');
    }
    return buf.toString();
}
 
Example #2
Source File: SerializedForm.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example #3
Source File: TransTypes.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
        Type bridgeType) {
    List<VarSymbol> bridgeParams = null;
    if (impl.params != null) {
        bridgeParams = List.nil();
        List<VarSymbol> implParams = impl.params;
        Type.MethodType mType = (Type.MethodType)bridgeType;
        List<Type> argTypes = mType.argtypes;
        while (implParams.nonEmpty() && argTypes.nonEmpty()) {
            VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
                    implParams.head.name, argTypes.head, bridge);
            param.setAttributes(implParams.head);
            bridgeParams = bridgeParams.append(param);
            implParams = implParams.tail;
            argTypes = argTypes.tail;
        }
    }
    return bridgeParams;
}
 
Example #4
Source File: AnnotationProxyMaker.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a map from element names to their values in "dynamic
 * proxy return form".  Includes all elements, whether explicit or
 * defaulted.
 */
private Map<String, Object> getAllReflectedValues() {
    Map<String, Object> res = new LinkedHashMap<String, Object>();

    for (Map.Entry<MethodSymbol, Attribute> entry :
                                              getAllValues().entrySet()) {
        MethodSymbol meth = entry.getKey();
        Object value = generateValue(meth, entry.getValue());
        if (value != null) {
            res.put(meth.name.toString(), value);
        } else {
            // Ignore this element.  May (properly) lead to
            // IncompleteAnnotationException somewhere down the line.
        }
    }
    return res;
}
 
Example #5
Source File: JavacTrees.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) {
    Symbol javadocSymbol = getElement(path);
    if (javadocSymbol == null)
        return null;
    ElementKind kind = javadocSymbol.getKind();
    List<? extends Symbol> params = List.nil();
    if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
        MethodSymbol ee = (MethodSymbol) javadocSymbol;
        params = ptag.isTypeParameter()
                ? ee.getTypeParameters()
                : ee.getParameters();
    } else if (kind.isClass() || kind.isInterface()) {
        ClassSymbol te = (ClassSymbol) javadocSymbol;
        params = te.getTypeParameters();
    }

    for (Symbol param : params) {
        if (param.getSimpleName() == ptag.getName().getName()) {
            return param;
        }
    }
    return null;
}
 
Example #6
Source File: SerializedForm.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) {
        if (sym.kind == MTH) {
            MethodSymbol md = (MethodSymbol)sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example #7
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Validate the proposed container 'repeatable' on the
 * annotation type symbol 's'. Report errors at position
 * 'pos'.
 *
 * @param s The (annotation)type declaration annotated with a @Repeatable
 * @param repeatable the @Repeatable on 's'
 * @param pos where to report errors
 */
public void validateRepeatable(TypeSymbol s, Attribute.Compound repeatable, DiagnosticPosition pos) {
    Assert.check(types.isSameType(repeatable.type, syms.repeatableType));

    Type t = null;
    List<Pair<MethodSymbol,Attribute>> l = repeatable.values;
    if (!l.isEmpty()) {
        Assert.check(l.head.fst.name == names.value);
        t = ((Attribute.Class)l.head.snd).getValue();
    }

    if (t == null) {
        // errors should already have been reported during Annotate
        return;
    }

    validateValue(t.tsym, s, pos);
    validateRetention(t.tsym, s, pos);
    validateDocumented(t.tsym, s, pos);
    validateInherited(t.tsym, s, pos);
    validateTarget(t.tsym, s, pos);
    validateDefault(t.tsym, pos);
}
 
Example #8
Source File: SerializedForm.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example #9
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
void checkNonCyclicElementsInternal(DiagnosticPosition pos, TypeSymbol tsym) {
    if ((tsym.flags_field & ACYCLIC_ANN) != 0)
        return;
    if ((tsym.flags_field & LOCKED) != 0) {
        log.error(pos, Errors.CyclicAnnotationElement(tsym));
        return;
    }
    try {
        tsym.flags_field |= LOCKED;
        for (Symbol s : tsym.members().getSymbols(NON_RECURSIVE)) {
            if (s.kind != MTH)
                continue;
            checkAnnotationResType(pos, ((MethodSymbol)s).type.getReturnType());
        }
    } finally {
        tsym.flags_field &= ~LOCKED;
        tsym.flags_field |= ACYCLIC_ANN;
    }
}
 
Example #10
Source File: JavacTrees.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) {
    Symbol javadocSymbol = getElement(path);
    if (javadocSymbol == null)
        return null;
    ElementKind kind = javadocSymbol.getKind();
    List<? extends Symbol> params = List.nil();
    if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
        MethodSymbol ee = (MethodSymbol) javadocSymbol;
        params = ptag.isTypeParameter()
                ? ee.getTypeParameters()
                : ee.getParameters();
    } else if (kind.isClass() || kind.isInterface()) {
        ClassSymbol te = (ClassSymbol) javadocSymbol;
        params = te.getTypeParameters();
    }

    for (Symbol param : params) {
        if (param.getSimpleName() == ptag.getName().getName()) {
            return param;
        }
    }
    return null;
}
 
Example #11
Source File: TreeLoader.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void fillArtificalParamNames(final ClassSymbol clazz) {
    for (Symbol s : clazz.getEnclosedElements()) {
        if (s instanceof MethodSymbol) {
            MethodSymbol ms = (MethodSymbol) s;

            if (ms.getParameters().isEmpty()) {
                continue;
            }
            
            Set<String> usedNames = new HashSet<String>();
            
            for (VarSymbol vs : ms.getParameters()) {
                String name = JavaSourceAccessor.getINSTANCE().generateReadableParameterName(vs.asType().toString(), usedNames);

                vs.setName(clazz.name.table.fromString(name));
            }
        }
    }
}
 
Example #12
Source File: JavacTrees.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) {
    Symbol javadocSymbol = getElement(path);
    if (javadocSymbol == null)
        return null;
    ElementKind kind = javadocSymbol.getKind();
    List<? extends Symbol> params = List.nil();
    if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
        MethodSymbol ee = (MethodSymbol) javadocSymbol;
        params = ptag.isTypeParameter()
                ? ee.getTypeParameters()
                : ee.getParameters();
    } else if (kind.isClass() || kind.isInterface()) {
        ClassSymbol te = (ClassSymbol) javadocSymbol;
        params = te.getTypeParameters();
    }

    for (Symbol param : params) {
        if (param.getSimpleName() == ptag.getName().getName()) {
            return param;
        }
    }
    return null;
}
 
Example #13
Source File: JavacTrees.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) {
    Symbol javadocSymbol = getElement(path);
    if (javadocSymbol == null)
        return null;
    ElementKind kind = javadocSymbol.getKind();
    List<? extends Symbol> params = List.nil();
    if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
        MethodSymbol ee = (MethodSymbol) javadocSymbol;
        params = ptag.isTypeParameter()
                ? ee.getTypeParameters()
                : ee.getParameters();
    } else if (kind.isClass() || kind.isInterface()) {
        ClassSymbol te = (ClassSymbol) javadocSymbol;
        params = te.getTypeParameters();
    }

    for (Symbol param : params) {
        if (param.getSimpleName() == ptag.getName().getName()) {
            return param;
        }
    }
    return null;
}
 
Example #14
Source File: AnnotationProxyMaker.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a map from element names to their values in "dynamic
 * proxy return form".  Includes all elements, whether explicit or
 * defaulted.
 */
private Map<String, Object> getAllReflectedValues() {
    Map<String, Object> res = new LinkedHashMap<String, Object>();

    for (Map.Entry<MethodSymbol, Attribute> entry :
                                              getAllValues().entrySet()) {
        MethodSymbol meth = entry.getKey();
        Object value = generateValue(meth, entry.getValue());
        if (value != null) {
            res.put(meth.name.toString(), value);
        } else {
            // Ignore this element.  May (properly) lead to
            // IncompleteAnnotationException somewhere down the line.
        }
    }
    return res;
}
 
Example #15
Source File: JCTree.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
protected JCMethodDecl(JCModifiers mods,
                       Name name,
                       JCExpression restype,
                       List<JCTypeParameter> typarams,
                       List<JCVariableDecl> params,
                       List<JCExpression> thrown,
                       JCBlock body,
                       JCExpression defaultValue,
                       MethodSymbol sym) {
    this.mods = mods;
    this.name = name;
    this.restype = restype;
    this.typarams = typarams;
    this.params = params;
    this.thrown = thrown;
    this.body = body;
    this.defaultValue = defaultValue;
    this.sym = sym;
}
 
Example #16
Source File: LVTRanges.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String toString() {
    String result = "";
    for (Entry<MethodSymbol, Map<JCTree, List<VarSymbol>>> mainEntry: aliveRangeClosingTrees.entrySet()) {
        result += "Method: \n" + mainEntry.getKey().flatName() + "\n";
        int i = 1;
        for (Entry<JCTree, List<VarSymbol>> treeEntry: mainEntry.getValue().entrySet()) {
            result += "    Tree " + i + ": \n" + treeEntry.getKey().toString() + "\n";
            result += "        Variables closed:\n";
            for (VarSymbol var: treeEntry.getValue()) {
                result += "            " + var.toString();
            }
            result += "\n";
            i++;
        }
    }
    return result;
}
 
Example #17
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Is s a method symbol that overrides a method in a superclass? */
boolean isOverrider(Symbol s) {
    if (s.kind != MTH || s.isStatic())
        return false;
    MethodSymbol m = (MethodSymbol)s;
    TypeSymbol owner = (TypeSymbol)m.owner;
    for (Type sup : types.closure(owner.type)) {
        if (sup == owner.type)
            continue; // skip "this"
        Scope scope = sup.tsym.members();
        for (Symbol sym : scope.getSymbolsByName(m.name)) {
            if (!sym.isStatic() && m.overrides(sym, owner, types, true))
                return true;
        }
    }
    return false;
}
 
Example #18
Source File: JCTree.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
protected JCMethodDecl(JCModifiers mods,
                       Name name,
                       JCExpression restype,
                       List<JCTypeParameter> typarams,
                       List<JCVariableDecl> params,
                       List<JCExpression> thrown,
                       JCBlock body,
                       JCExpression defaultValue,
                       MethodSymbol sym) {
    this.mods = mods;
    this.name = name;
    this.restype = restype;
    this.typarams = typarams;
    this.params = params;
    this.thrown = thrown;
    this.body = body;
    this.defaultValue = defaultValue;
    this.sym = sym;
}
 
Example #19
Source File: MemberEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
void checkReceiver(JCVariableDecl tree, Env<AttrContext> localEnv) {
    attr.attribExpr(tree.nameexpr, localEnv);
    MethodSymbol m = localEnv.enclMethod.sym;
    if (m.isConstructor()) {
        Type outertype = m.owner.owner.type;
        if (outertype.hasTag(TypeTag.METHOD)) {
            // we have a local inner class
            outertype = m.owner.owner.owner.type;
        }
        if (outertype.hasTag(TypeTag.CLASS)) {
            checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type");
            checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name");
        } else {
            log.error(tree, Errors.ReceiverParameterNotApplicableConstructorToplevelClass);
        }
    } else {
        checkType(tree.vartype, m.owner.type, "incorrect.receiver.type");
        checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name");
    }
}
 
Example #20
Source File: WorkArounds.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the type containing the method that this method overrides.
 * It may be a <code>TypeElement</code> or a <code>TypeParameterElement</code>.
 * @param method target
 * @return a type
 */
public TypeMirror overriddenType(ExecutableElement method) {
    if (utils.isStatic(method)) {
        return null;
    }
    MethodSymbol sym = (MethodSymbol)method;
    ClassSymbol origin = (ClassSymbol) sym.owner;
    for (com.sun.tools.javac.code.Type t = toolEnv.getTypes().supertype(origin.type);
            t.hasTag(com.sun.tools.javac.code.TypeTag.CLASS);
            t = toolEnv.getTypes().supertype(t)) {
        ClassSymbol c = (ClassSymbol) t.tsym;
        for (com.sun.tools.javac.code.Symbol sym2 : c.members().getSymbolsByName(sym.name)) {
            if (sym.overrides(sym2, origin, toolEnv.getTypes(), true)) {
                return t;
            }
        }
    }
    return null;
}
 
Example #21
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * "It is also a compile-time error if any method declared in an
 * annotation type has a signature that is override-equivalent to
 * that of any public or protected method declared in class Object
 * or in the interface annotation.Annotation."
 *
 * @jls 9.6 Annotation Types
 */
void validateAnnotationMethod(DiagnosticPosition pos, MethodSymbol m) {
    for (Type sup = syms.annotationType; sup.hasTag(CLASS); sup = types.supertype(sup)) {
        Scope s = sup.tsym.members();
        for (Symbol sym : s.getSymbolsByName(m.name)) {
            if (sym.kind == MTH &&
                (sym.flags() & (PUBLIC | PROTECTED)) != 0 &&
                types.overrideEquivalent(m.type, sym.type))
                log.error(pos, Errors.IntfAnnotationMemberClash(sym, sup));
        }
    }
}
 
Example #22
Source File: LVTRanges.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public List<VarSymbol> removeEntry(MethodSymbol method, JCTree tree) {
    Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
    if (varMap != null) {
        List<VarSymbol> result = varMap.remove(tree);
        if (varMap.isEmpty()) {
            aliveRangeClosingTrees.remove(method);
        }
        return result;
    }
    return null;
}
 
Example #23
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void validateDefault(Symbol container, DiagnosticPosition pos) {
    // validate that all other elements of containing type has defaults
    Scope scope = container.members();
    for(Symbol elm : scope.getSymbols()) {
        if (elm.name != names.value &&
            elm.kind == MTH &&
            ((MethodSymbol)elm).defaultValue == null) {
            log.error(pos,
                      Errors.InvalidRepeatableAnnotationElemNondefault(container, elm));
        }
    }
}
 
Example #24
Source File: Lint.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitCompound(Attribute.Compound compound) {
    if (compound.type.tsym == syms.suppressWarningsType.tsym) {
        for (List<Pair<MethodSymbol,Attribute>> v = compound.values;
             v.nonEmpty(); v = v.tail) {
            Pair<MethodSymbol,Attribute> value = v.head;
            if (value.fst.name.toString().equals("value"))
                value.snd.accept(this);
        }

    }
}
 
Example #25
Source File: JavacTrees.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** @see com.sun.tools.javadoc.ClassDocImpl */
private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) {
    if (paramTypes == null)
        return true;

    if (method.params().size() != paramTypes.size())
        return false;

    List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes();

    return (Type.isErroneous(paramTypes))
        ? fuzzyMatch(paramTypes, methodParamTypes)
        : types.isSameTypes(paramTypes, methodParamTypes);
}
 
Example #26
Source File: JavacTrees.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** @see com.sun.tools.javadoc.ClassDocImpl */
private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) {
    if (paramTypes == null)
        return true;

    if (method.params().size() != paramTypes.size())
        return false;

    List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes();

    return (Type.isErroneous(paramTypes))
        ? fuzzyMatch(paramTypes, methodParamTypes)
        : types.isSameTypes(paramTypes, methodParamTypes);
}
 
Example #27
Source File: DocEnv.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Check whether this member should be documented. */
public boolean shouldDocument(MethodSymbol sym) {
    long mod = sym.flags();

    if ((mod & Flags.SYNTHETIC) != 0) {
        return false;
    }

    return showAccess.checkModifier(translateModifiers(mod));
}
 
Example #28
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void checkDefaultMethodClashes(DiagnosticPosition pos, Type site) {
    DefaultMethodClashFilter dcf = new DefaultMethodClashFilter(site);
    for (Symbol m : types.membersClosure(site, false).getSymbols(dcf)) {
        Assert.check(m.kind == MTH);
        List<MethodSymbol> prov = types.interfaceCandidates(site, (MethodSymbol)m);
        if (prov.size() > 1) {
            ListBuffer<Symbol> abstracts = new ListBuffer<>();
            ListBuffer<Symbol> defaults = new ListBuffer<>();
            for (MethodSymbol provSym : prov) {
                if ((provSym.flags() & DEFAULT) != 0) {
                    defaults = defaults.append(provSym);
                } else if ((provSym.flags() & ABSTRACT) != 0) {
                    abstracts = abstracts.append(provSym);
                }
                if (defaults.nonEmpty() && defaults.size() + abstracts.size() >= 2) {
                    //strong semantics - issue an error if two sibling interfaces
                    //have two override-equivalent defaults - or if one is abstract
                    //and the other is default
                    String errKey;
                    Symbol s1 = defaults.first();
                    Symbol s2;
                    if (defaults.size() > 1) {
                        errKey = "types.incompatible.unrelated.defaults";
                        s2 = defaults.toList().tail.head;
                    } else {
                        errKey = "types.incompatible.abstract.default";
                        s2 = abstracts.first();
                    }
                    log.error(pos, errKey,
                            Kinds.kindName(site.tsym), site,
                            m.name, types.memberType(site, m).getParameterTypes(),
                            s1.location(), s2.location());
                    break;
                }
            }
        }
    }
}
 
Example #29
Source File: LVTRanges.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean containsKey(MethodSymbol method, JCTree tree) {
    Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
    if (varMap == null) {
        return false;
    }
    return varMap.containsKey(tree);
}
 
Example #30
Source File: TypeVariableImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the class, interface, method, or constructor within
 * which this type variable is declared.
 */
public ProgramElementDoc owner() {
    Symbol osym = type.tsym.owner;
    if ((osym.kind & Kinds.TYP) != 0) {
        return env.getClassDoc((ClassSymbol)osym);
    }
    Names names = osym.name.table.names;
    if (osym.name == names.init) {
        return env.getConstructorDoc((MethodSymbol)osym);
    } else {
        return env.getMethodDoc((MethodSymbol)osym);
    }
}