PsiElement (@NotNull PsiElement place, @NotNull String toolId) { if (place instanceof PsiFile) return null; return ReadAction.compute(() -> { PsiElement statement = SuppressionUtil.getStatementToolSuppressedIn(place, toolId, PsiStatement.class); if (statement != null) { return statement; } PsiElement up = PsiTreeUtil.getNonStrictParentOfType(place, PsiVariable.class, PsiJavaDocumentedElement.class); if (up instanceof PsiModifierListOwner && ((PsiModifierListOwner)up).getModifierList() == null) { up = PsiTreeUtil.getParentOfType(up, PsiVariable.class, PsiJavaDocumentedElement.class); } if (up instanceof PsiVariable) { PsiElement annotation = getAnnotationMemberSuppressedIn((PsiVariable)up, toolId); if (annotation != null) { return annotation; } } PsiJavaDocumentedElement container = up == null || up instanceof PsiJavaDocumentedElement ? (PsiJavaDocumentedElement)up : PsiTreeUtil.getNonStrictParentOfType(up, PsiJavaDocumentedElement.class); while (container instanceof PsiTypeParameter) { container = PsiTreeUtil.getParentOfType(container, PsiJavaDocumentedElement.class); } if (container != null) { PsiElement element = getElementMemberSuppressedIn(container, toolId); if (element != null) return element; } PsiJavaDocumentedElement classContainer = PsiTreeUtil.getParentOfType(container, PsiJavaDocumentedElement.class, true); if (classContainer != null) { return getElementMemberSuppressedIn(classContainer, toolId); } return null; }); }