public void addAnnotation(@NotNull PsiModifierListOwner parameter, @NotNull Annotation annotation) { PsiModifierList modifierList = parameter.getModifierList(); if (JavaUtils.isAnnotationPresent(parameter, annotation) || null == modifierList) { return; } JavaService.getInstance(parameter.getProject()).importClazz((PsiJavaFile) parameter.getContainingFile(), annotation.getQualifiedName()); PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory(); PsiAnnotation psiAnnotation = elementFactory.createAnnotationFromText(annotation.toString(), parameter); modifierList.add(psiAnnotation); JavaCodeStyleManager.getInstance(project).shortenClassReferences(psiAnnotation.getParent()); }
PsiElement modifierList = annotation.getParent(); if (modifierList != null) { PsiElement annotationParent = modifierList.getParent();
if (CHECK_RESULT_ANNOTATION.equals(type)) { if (annotation.getParent() instanceof PsiModifierList && annotation.getParent().getParent() instanceof PsiMethod) { PsiMethod method = (PsiMethod) annotation.getParent().getParent(); if (!method.isConstructor() && PsiType.VOID.equals(method.getReturnType())) { if (annotation.getParent() instanceof PsiModifierList && annotation.getParent().getParent() instanceof PsiMethod) { String value = PermissionRequirement.getAnnotationStringValue(annotation, ATTR_VALUE); String[] anyOf = PermissionRequirement.getAnnotationStringValues(annotation, ATTR_ANY_OF);