PsiMethodCallExpression (PsiReferenceExpression target, PsiElement element) { if (element instanceof PsiDeclarationStatement declaration) { PsiElement[] elements = declaration.getDeclaredElements(); if (elements.length > 0) { PsiElement lastDeclaration = elements[elements.length - 1]; if (lastDeclaration instanceof PsiLocalVariable var && target.isReferenceTo(lastDeclaration)) { return extractMapMethodCall(var.getInitializer(), "get"); } } } PsiAssignmentExpression assignment = ExpressionUtils.getAssignment(element); if (assignment != null) { PsiExpression lValue = assignment.getLExpression(); if (lValue instanceof PsiReferenceExpression && EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(target, lValue)) { return extractMapMethodCall(assignment.getRExpression(), "get"); } } return null; }