List<PsiElement> (@NotNull PsiClass targetClass, @NotNull GrVariable field) { if (myContext.getStringPart() != null) { final GrExpression expr = myContext.getStringPart().replaceLiteralWithConcatenation(field.getName()); final PsiElement occurrence = replaceOccurrence(field, expr, targetClass); updateCaretPosition(occurrence); return Collections.singletonList(occurrence); } if (mySettings.replaceAllOccurrences()) { GroovyRefactoringUtil.sortOccurrences(myContext.getOccurrences()); ArrayList<PsiElement> result = new ArrayList<>(); for (PsiElement occurrence : myContext.getOccurrences()) { result.add(replaceOccurrence(field, occurrence, targetClass)); } return result; } GrVariable var = myContext.getVar(); if (var != null) { GrExpression initializer = var.getInitializerGroovy(); if (initializer != null) { return Collections.singletonList(replaceOccurrence(field, initializer, targetClass)); } else { return Collections.emptyList(); } } final GrExpression expression = myContext.getExpression(); assert expression != null; return Collections.singletonList(replaceOccurrence(field, expression, targetClass)); }