private static boolean isAnnotated(ASTNode element) { PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement) element.getPsi(); PsiElement qualifier = ref.getQualifier(); if (qualifier instanceof PsiJavaCodeReferenceElement) { if (((PsiJavaCodeReferenceElement) qualifier).resolve() instanceof PsiPackage) { return false; } if (PsiTreeUtil.getChildOfType(qualifier, PsiAnnotation.class) != null) { return true; } } PsiModifierList modifierList = PsiImplUtil.findNeighbourModifierList(ref); if (modifierList != null) { for (PsiAnnotation annotation : modifierList.getAnnotations()) { if (AnnotationTargetUtil.findAnnotationTarget(annotation, PsiAnnotation.TargetType.TYPE_USE) != null) { return true; } } } return false; }
public static void collectTypeUseAnnotations( @NotNull PsiModifierList modifierList, @NotNull List<PsiAnnotation> annotations) { for (PsiAnnotation annotation : modifierList.getAnnotations()) { if (AnnotationTargetUtil.isTypeAnnotation(annotation)) { annotations.add(annotation); } } }
public static void markTypeAnnotations(@NotNull PsiTypeElement typeElement) { PsiElement left = PsiTreeUtil.skipSiblingsBackward( typeElement, PsiComment.class, PsiWhiteSpace.class, PsiTypeParameterList.class); if (left instanceof PsiModifierList) { for (PsiAnnotation annotation : ((PsiModifierList) left).getAnnotations()) { if (AnnotationTargetUtil.isTypeAnnotation(annotation)) { annotation.putUserData(TYPE_ANNO_MARK, Boolean.TRUE); } } } }
public static boolean isAnnotationApplicableTo( GrAnnotation annotation, @NotNull TargetType... elementTypeFields) { return elementTypeFields.length == 0 || AnnotationTargetUtil.findAnnotationTarget(annotation, elementTypeFields) != null; }
public static boolean isTypeAnnotation(@Nullable PsiElement element) { return element instanceof PsiAnnotation && AnnotationTargetUtil.isTypeAnnotation((PsiAnnotation) element); }
/** * @deprecated use {@link AnnotationTargetUtil#getTargetsForLocation(PsiAnnotationOwner)} (to be * removed ion IDEA 17) */ @SuppressWarnings("unused") public static TargetType[] getTargetsForLocation(@Nullable PsiAnnotationOwner owner) { return AnnotationTargetUtil.getTargetsForLocation(owner); }
/** * @deprecated use {@link AnnotationTargetUtil#getAnnotationTargets(PsiClass)} (to be removed ion * IDEA 17) */ @SuppressWarnings("unused") public static Set<TargetType> getAnnotationTargets(@NotNull PsiClass annotationType) { return AnnotationTargetUtil.getAnnotationTargets(annotationType); }
/** * @deprecated use {@link AnnotationTargetUtil#findAnnotationTarget(PsiClass, TargetType...)} (to * be removed ion IDEA 17) */ @SuppressWarnings("unused") public static TargetType findApplicableTarget( @NotNull PsiClass annotationType, @NotNull TargetType... types) { return AnnotationTargetUtil.findAnnotationTarget(annotationType, types); }