Bootstrap

如何使用idea看注解的实现

如何使用idea看注解的实现

需求

想看看注解 @AliasFor 是如何实现的

精彩文章

全局寻找

ALT + F7在这里插入图片描述

选择.class

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CzzChy6y-1626148400349)(/2021/img/选择class就可以了.png)]

点击查看这两个方法

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cyA59fMq-1626148400352)(/2021/img/点击查看这两个方法.png)]

 

查看具体的实现

    /**
        * Create an {@code AliasDescriptor} <em>from</em> the declaration
        * of {@code @AliasFor} on the supplied annotation attribute and
        * validate the configuration of {@code @AliasFor}.
        * @param attribute the annotation attribute that is annotated with
        * {@code @AliasFor}
        * @return an alias descriptor, or {@code null} if the attribute
        * is not annotated with {@code @AliasFor}
        * @see #validateAgainst
        */
    @Nullable
    public static AliasDescriptor from(Method attribute) {
        AliasDescriptor descriptor = aliasDescriptorCache.get(attribute);
        if (descriptor != null) {
            return descriptor;
        }

        AliasFor aliasFor = attribute.getAnnotation(AliasFor.class);
        if (aliasFor == null) {
            return null;
        }

        descriptor = new AliasDescriptor(attribute, aliasFor);
        descriptor.validate();
        aliasDescriptorCache.put(attribute, descriptor);
        return descriptor;
    }

;