boolean (PsiElement @NotNull [] elements) { for (PsiElement element : elements) { final PsiFile containingFile = element.getContainingFile(); if (!(containingFile instanceof GroovyFile) || isScriptFile((GroovyFile)containingFile)) { return false; } } return true; }