boolean (PsiElement element) { if (element instanceof PsiComment && element.getParent() instanceof PsiCodeBlock) { // only allow comments in statement context return true; } return element instanceof PsiStatement; }