Match (PsiReferenceExpression first, PsiReferenceExpression second) { PsiElement firstElement = first.resolve(); PsiElement secondElement = second.resolve(); if (firstElement instanceof PsiLocalVariable firstVar && secondElement instanceof PsiLocalVariable secondVar && myLocalVariables.contains(firstElement) && myLocalVariables.contains(secondElement)) { if (firstVar.getType().equals(secondVar.getType())) { String firstVarName = firstVar.getName(); String secondVarName = secondVar.getName(); String substitutedName = mySubstitutionTable.get(secondVar); if (substitutedName == null) { return firstVarName.equals(secondVarName) ? EXACT_MATCH : EXACT_MISMATCH; } return firstVarName.equals(substitutedName) ? EXACT_MATCH : EXACT_MISMATCH; } } return super.referenceExpressionsMatch(first, second); }