PsiField (@NotNull PsiParameter methodParameter, @NotNull PsiMethod method) { PsiCodeBlock methodBody = method.getBody(); if (methodBody == null) return null; PsiClass containingClass = method.getContainingClass(); Ref<Pair<PsiField, PsiType>> assignedToField = Ref.create(); ReferencesSearch.search(methodParameter, new LocalSearchScope(methodBody)).forEach(ref -> { ProgressManager.checkCanceled(); Pair<PsiField, PsiType> assigned = isAssignedToField(ref, containingClass); if (assigned != null) { if (!assignedToField.isNull() && !assigned.equals(assignedToField.get())) { assignedToField.set(null); return false; } assignedToField.set(assigned); } return true; }); return Pair.getFirst(assignedToField.get()); }