public static TypeMirror asMemberOf(Types types, DeclaredType container,
                                        VariableElement variable) {
        if (variable.getKind().equals(ElementKind.PARAMETER)) {
            ExecutableElement methodOrConstructor =
                    MoreElements.asExecutable(variable.getEnclosingElement());
            ExecutableType resolvedMethodOrConstructor = MoreTypes.asExecutable(
                    types.asMemberOf(container, methodOrConstructor));
            List<? extends VariableElement> parameters = methodOrConstructor.getParameters();
            List<? extends TypeMirror> parameterTypes =
                    resolvedMethodOrConstructor.getParameterTypes();
            checkState(parameters.size() == parameterTypes.size());
            for (int i = 0; i < parameters.size(); i++) {
                // We need to capture the parameter type of the variable we're concerned about,
                // for later printing.  This is the only way to do it since we can't use
                // types.asMemberOf on variables of methods.
                if (parameters.get(i).equals(variable)) {
                    return parameterTypes.get(i);
                }
            }
            throw new IllegalStateException("Could not find variable: " + variable);
        } else {
            return types.asMemberOf(container, variable);
        }
    }
Utilities related to {@link TypeMirror} instances.

@author Gregory Kick
@since 2.0
android/annotation_processors/xposed_hook_compiler/src/main/java/github/tornaco/permission/compiler/common/MoreTypes.java