PsiElement (final PsiElement place, @NotNull String toolId) { if (place == null) return null; if (GroovyUnusedDeclarationInspection.SHORT_NAME.equals(toolId)) { PsiElement forUnused = getElementToolSuppressedIn(place, UNUSED_SYMBOL_SHORT_NAME); if (forUnused != null) { return forUnused; } else { // fallback to checking for old toolId to avoid introducing warnings into old code } } return ReadAction.compute(()->{ final PsiElement statement = PsiUtil.findEnclosingStatement(place); if (statement != null) { PsiElement prev = statement.getPrevSibling(); while (prev != null && StringUtil.isEmpty(prev.getText().trim())) { prev = prev.getPrevSibling(); } if (prev instanceof PsiComment) { String text = prev.getText(); Matcher matcher = SuppressionUtil.SUPPRESS_IN_LINE_COMMENT_PATTERN.matcher(text); if (matcher.matches() && SuppressionUtil.isInspectionToolIdMentioned(matcher.group(1), toolId)) { return prev; } } } PsiElement fileLevelSuppression = SuppressByGroovyFileCommentFixKt.fileLevelSuppression(place, toolId); if (fileLevelSuppression != null) { return fileLevelSuppression; } GrMember member = null; GrDocComment docComment = PsiTreeUtil.getParentOfType(place, GrDocComment.class); if (docComment != null) { GrDocCommentOwner owner = docComment.getOwner(); if (owner instanceof GrMember) { member = (GrMember)owner; } } if (member == null) { member = PsiTreeUtil.getNonStrictParentOfType(place, GrMember.class); } while (member != null) { GrModifierList modifierList = member.getModifierList(); for (String ids : getInspectionIdsSuppressedInAnnotation(modifierList)) { if (SuppressionUtil.isInspectionToolIdMentioned(ids, toolId)) { return modifierList; } } member = PsiTreeUtil.getParentOfType(member, GrMember.class); } return null; }); }