void (final @NotNull PsiReferenceExpression expression) { super.visitReferenceExpression(expression); final PsiElement element = expression.resolve(); if (element instanceof PsiLocalVariable localVariable) { final PsiElement[] elements = DefUseUtil.getDefs(myCallingBlock, localVariable, expression); if (elements.length == 1) { PsiExpression localInitializer = null; if (elements[0] instanceof PsiLocalVariable) { localInitializer = ((PsiLocalVariable)elements[0]).getInitializer(); } else if (elements[0] instanceof PsiAssignmentExpression) { localInitializer = ((PsiAssignmentExpression)elements[0]).getRExpression(); } else if (elements[0] instanceof PsiReferenceExpression refElement) { final PsiElement parent = refElement.getParent(); if (parent instanceof PsiAssignmentExpression && ((PsiAssignmentExpression)parent).getLExpression() == refElement) { localInitializer = ((PsiAssignmentExpression)parent).getRExpression(); } } if (localInitializer != null) { final PsiElement replacement; if (localToParamRef.containsKey(localVariable)) { replacement = localToParamRef.get(localVariable); } else { replacement = replaceArgs(localToParamRef, localInitializer.copy()); } result.add(new LocalReplacementUsageInfo(expression, replacement)); } } } }