boolean (final Project project, final Collection<PsiElement> occurrences, final boolean isClosure) { boolean result = true; final StringBuilder msg = new StringBuilder(); msg.append( isClosure ? GroovyBundle.message("conversion.closure.not.allowed.in.non.groovy.files") : GroovyBundle.message("conversion.method.not.allowed.in.non.groovy.files") ); for (PsiElement element : occurrences) { final PsiFile file = element.getContainingFile(); if (!(file instanceof GroovyFileBase)) { result = false; msg.append("\n").append(file.getName()); } } if (!result) { @NlsSafe String message = msg.toString(); showErrorMessage(message, project); return false; } return true; }