PsiElement (@NotNull PsiElement place) { PsiElement parent = place.getParent(); while (parent != null) { if (parent instanceof PsiClass) return null; if (parent instanceof GroovyFile && !(PsiUtil.isInDummyFile(parent))) return null; if (parent instanceof GrClosableBlock) return parent; parent = parent.getContext(); } return null; }