Java Code Examples for com.sun.tools.javac.code.Symbol.MethodSymbol#getDefaultValue()

The following examples show how to use com.sun.tools.javac.code.Symbol.MethodSymbol#getDefaultValue() . 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: AnnotationProxyMaker.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a map from element symbols to their values.
 * Includes all elements, whether explicit or defaulted.
 */
private Map<MethodSymbol, Attribute> getAllValues() {
    Map<MethodSymbol, Attribute> res =
        new LinkedHashMap<MethodSymbol, Attribute>();

    // First find the default values.
    ClassSymbol sym = (ClassSymbol) anno.type.tsym;
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol m = (MethodSymbol) e.sym;
            Attribute def = m.getDefaultValue();
            if (def != null)
                res.put(m, def);
        }
    }
    // Next find the explicit values, possibly overriding defaults.
    for (Pair<MethodSymbol, Attribute> p : anno.values)
        res.put(p.fst, p.snd);
    return res;
}
 
Example 2
Source File: AnnotationProxyMaker.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns a map from element symbols to their values.
 * Includes all elements, whether explicit or defaulted.
 */
private Map<MethodSymbol, Attribute> getAllValues() {
    Map<MethodSymbol, Attribute> res = new LinkedHashMap<>();

    // First find the default values.
    ClassSymbol sym = (ClassSymbol) anno.type.tsym;
    for (Symbol s : sym.members().getSymbols(NON_RECURSIVE)) {
        if (s.kind == MTH) {
            MethodSymbol m = (MethodSymbol) s;
            Attribute def = m.getDefaultValue();
            if (def != null)
                res.put(m, def);
        }
    }
    // Next find the explicit values, possibly overriding defaults.
    for (Pair<MethodSymbol, Attribute> p : anno.values)
        res.put(p.fst, p.snd);
    return res;
}
 
Example 3
Source File: JavacElements.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@DefinedBy(Api.LANGUAGE_MODEL)
public Map<MethodSymbol, Attribute> getElementValuesWithDefaults(
                                                    AnnotationMirror a) {
    Attribute.Compound anno = cast(Attribute.Compound.class, a);
    DeclaredType annotype = a.getAnnotationType();
    Map<MethodSymbol, Attribute> valmap = anno.getElementValues();

    for (ExecutableElement ex :
             methodsIn(annotype.asElement().getEnclosedElements())) {
        MethodSymbol meth = (MethodSymbol) ex;
        Attribute defaultValue = meth.getDefaultValue();
        if (defaultValue != null && !valmap.containsKey(meth)) {
            valmap.put(meth, defaultValue);
        }
    }
    return valmap;
}
 
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 symbols to their values.
 * Includes all elements, whether explicit or defaulted.
 */
private Map<MethodSymbol, Attribute> getAllValues() {
    Map<MethodSymbol, Attribute> res =
        new LinkedHashMap<MethodSymbol, Attribute>();

    // First find the default values.
    ClassSymbol sym = (ClassSymbol) anno.type.tsym;
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol m = (MethodSymbol) e.sym;
            Attribute def = m.getDefaultValue();
            if (def != null)
                res.put(m, def);
        }
    }
    // Next find the explicit values, possibly overriding defaults.
    for (Pair<MethodSymbol, Attribute> p : anno.values)
        res.put(p.fst, p.snd);
    return res;
}