void (Project project, PsiElement[] elements, Editor editor) { Set<GroovyFile> files = new HashSet<>(); for (PsiElement element : elements) { if (!(element instanceof PsiFile)) { element = element.getContainingFile(); } if (element instanceof GroovyFile) { files.add((GroovyFile)element); } else { if (!ApplicationManager.getApplication().isUnitTestMode()) { CommonRefactoringUtil.showErrorHint( project, editor, GroovyRefactoringBundle.message("convert.to.java.can.work.only.with.groovy"), GroovyRefactoringBundle.message("convert.to.java.refactoring.name"), null ); return; } } } new ConvertToJavaProcessor(project, files.toArray(GroovyFile.EMPTY_ARRAY)).run(); }