Set<GroovyFile> (PsiElement @NotNull [] elements) { Set<GroovyFile> files = new HashSet<>(); for (PsiElement element : elements) { PsiFile containingFile = element.getContainingFile(); if (containingFile instanceof GroovyFile) { files.add((GroovyFile)containingFile); } } return files; }