boolean (@NotNull PsiElement element, @NotNull String toolId) { Property property = PsiTreeUtil.getParentOfType(element, Property.class, false); PropertiesFile file; if (property == null) { PsiFile containingFile = element.getContainingFile(); if (containingFile instanceof PropertiesFile) { file = (PropertiesFile)containingFile; } else { return false; } } else { PsiElement prev = property.getPrevSibling(); while (prev instanceof PsiWhiteSpace || prev instanceof PsiComment) { if (prev instanceof PsiComment) { @NonNls String text = prev.getText(); if (text.contains("suppress") && text.contains("\"" + toolId + "\"")) return true; } prev = prev.getPrevSibling(); } file = property.getPropertiesFile(); } PsiElement leaf = file.getContainingFile().findElementAt(0); while (leaf instanceof PsiWhiteSpace) leaf = leaf.getNextSibling(); while (leaf instanceof PsiComment) { @NonNls String text = leaf.getText(); if (text.contains("suppress") && text.contains("\"" + toolId + "\"") && text.contains("file")) { return true; } leaf = leaf.getNextSibling(); if (leaf instanceof PsiWhiteSpace) leaf = leaf.getNextSibling(); // comment before first property get bound to the file, not property if (leaf instanceof PropertiesList && leaf.getFirstChild() == property && text.contains("suppress") && text.contains("\"" + toolId + "\"")) { return true; } } return false; }