Match (PsiLambdaExpression expression1, PsiLambdaExpression expression2) { final PsiParameterList parameterList1 = expression1.getParameterList(); final PsiParameterList parameterList2 = expression2.getParameterList(); final PsiParameter[] parameters1 = parameterList1.getParameters(); final PsiParameter[] parameters2 = parameterList2.getParameters(); if (parameters1.length != parameters2.length) { return EXACT_MISMATCH; } for (int i = 0, length = parameters1.length; i < length; i++) { if (!variablesAreEquivalent(parameters1[i], parameters2[i]).isExactMatch()) { return EXACT_MISMATCH; } } final PsiElement body1 = unwrapLambdaBody(expression1.getBody()); final PsiElement body2 = unwrapLambdaBody(expression2.getBody()); Match match; if (body1 instanceof PsiCodeBlock && body2 instanceof PsiCodeBlock) { match = codeBlocksMatch((PsiCodeBlock)body1, (PsiCodeBlock)body2); } else if (body1 instanceof PsiExpression && body2 instanceof PsiExpression) { match = expressionsMatch((PsiExpression)body1, (PsiExpression)body2); } else { match = EXACT_MISMATCH; } return match == EXACT_MISMATCH ? new Match(body1, body2) : match; }