PsiElement[] (GrIntroduceParameterSettings settings) { final GrParameterListOwner scope = settings.getToReplaceIn(); final GrExpression expression = settings.getExpression(); if (expression != null) { final PsiElement expr = PsiUtil.skipParentheses(expression, false); if (expr == null) return PsiElement.EMPTY_ARRAY; final PsiElement[] occurrences = GroovyRefactoringUtil.getExpressionOccurrences(expr, scope); if (occurrences.length == 0) { throw new GrRefactoringError(GroovyRefactoringBundle.message("no.occurrences.found")); } return occurrences; } else { final GrVariable var = settings.getVar(); LOG.assertTrue(var != null); final List<PsiElement> list = Collections.synchronizedList(new ArrayList<>()); ReferencesSearch.search(var, new LocalSearchScope(scope)).forEach(psiReference -> { list.add(psiReference.getElement()); return true; }); return list.toArray(PsiElement.EMPTY_ARRAY); } }