Search in sources :

Example 21 with TypeSymbol

use of com.sun.tools.javac.code.Symbol.TypeSymbol in project lombok by rzwitserloot.

the class HandleDelegate method addMethodBindings.

public void addMethodBindings(List<MethodSig> signatures, ClassType ct, JavacTypes types, Set<String> banList) throws DelegateRecursion {
    TypeSymbol tsym = ct.asElement();
    if (tsym == null)
        return;
    for (Symbol member : tsym.getEnclosedElements()) {
        for (Compound am : member.getAnnotationMirrors()) {
            String name = null;
            try {
                name = am.type.tsym.flatName().toString();
            } catch (Exception ignore) {
            }
            if ("lombok.Delegate".equals(name) || "lombok.experimental.Delegate".equals(name)) {
                throw new DelegateRecursion(ct.tsym.name.toString(), member.name.toString());
            }
        }
        if (member.getKind() != ElementKind.METHOD)
            continue;
        if (member.isStatic())
            continue;
        if (member.isConstructor())
            continue;
        ExecutableElement exElem = (ExecutableElement) member;
        if (!exElem.getModifiers().contains(Modifier.PUBLIC))
            continue;
        ExecutableType methodType = (ExecutableType) types.asMemberOf(ct, member);
        String sig = printSig(methodType, member.name, types);
        //If add returns false, it was already in there
        if (!banList.add(sig))
            continue;
        boolean isDeprecated = (member.flags() & DEPRECATED) != 0;
        signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem));
    }
    if (ct.supertype_field instanceof ClassType)
        addMethodBindings(signatures, (ClassType) ct.supertype_field, types, banList);
    if (ct.interfaces_field != null)
        for (Type iface : ct.interfaces_field) {
            if (iface instanceof ClassType)
                addMethodBindings(signatures, (ClassType) iface, types, banList);
        }
}
Also used : ExecutableType(javax.lang.model.type.ExecutableType) ClassType(com.sun.tools.javac.code.Type.ClassType) Type(com.sun.tools.javac.code.Type) ExecutableType(javax.lang.model.type.ExecutableType) TypeSymbol(com.sun.tools.javac.code.Symbol.TypeSymbol) Symbol(com.sun.tools.javac.code.Symbol) ExecutableElement(javax.lang.model.element.ExecutableElement) TypeSymbol(com.sun.tools.javac.code.Symbol.TypeSymbol) Compound(com.sun.tools.javac.code.Attribute.Compound) ClassType(com.sun.tools.javac.code.Type.ClassType) TypeNotConvertibleException(lombok.javac.JavacResolution.TypeNotConvertibleException)

Aggregations

TypeSymbol (com.sun.tools.javac.code.Symbol.TypeSymbol)21 Symbol (com.sun.tools.javac.code.Symbol)11 MethodSymbol (com.sun.tools.javac.code.Symbol.MethodSymbol)11 Type (com.sun.tools.javac.code.Type)11 MethodTree (com.sun.source.tree.MethodTree)6 ClassSymbol (com.sun.tools.javac.code.Symbol.ClassSymbol)6 PackageSymbol (com.sun.tools.javac.code.Symbol.PackageSymbol)4 JCTree (com.sun.tools.javac.tree.JCTree)4 VisitorState (com.google.errorprone.VisitorState)3 ClassTree (com.sun.source.tree.ClassTree)3 Tree (com.sun.source.tree.Tree)3 CompletionFailure (com.sun.tools.javac.code.Symbol.CompletionFailure)3 ArrayList (java.util.ArrayList)3 UnknownType (com.redhat.ceylon.model.typechecker.model.UnknownType)2 IdentifierTree (com.sun.source.tree.IdentifierTree)2 MemberSelectTree (com.sun.source.tree.MemberSelectTree)2 MethodInvocationTree (com.sun.source.tree.MethodInvocationTree)2 TreePath (com.sun.source.util.TreePath)2 Scope (com.sun.tools.javac.code.Scope)2 ClassType (com.sun.tools.javac.code.Type.ClassType)2