Match (@NotNull PsiNewExpression newExpression1, @NotNull PsiNewExpression newExpression2) { final PsiJavaCodeReferenceElement classReference1 = newExpression1.getClassReference(); final PsiJavaCodeReferenceElement classReference2 = newExpression2.getClassReference(); if (classReference1 != null && classReference2 != null) { if (javaCodeReferenceElementsMatch(classReference1, classReference2) == EXACT_MISMATCH) { return EXACT_MISMATCH; } } else if (classReference1 != classReference2) { return EXACT_MISMATCH; } else if (!typesAreEquivalent(newExpression1.getType(), newExpression2.getType())) { // both classReference1 and classReference2 nulls // could be new int[0] and new long[0] return EXACT_MISMATCH; } final PsiExpression[] arrayDimensions1 = newExpression1.getArrayDimensions(); final PsiExpression[] arrayDimensions2 = newExpression2.getArrayDimensions(); if (!labelElementsAreEquivalent(arrayDimensions1, arrayDimensions2, false).isExactMatch()) { return EXACT_MISMATCH; } final PsiArrayInitializerExpression arrayInitializer1 = newExpression1.getArrayInitializer(); final PsiArrayInitializerExpression arrayInitializer2 = newExpression2.getArrayInitializer(); if (!expressionsMatch(arrayInitializer1, arrayInitializer2).isExactMatch()) { return EXACT_MISMATCH; } final PsiMethod constructor1 = newExpression1.resolveConstructor(); final PsiMethod constructor2 = newExpression2.resolveConstructor(); if (!Comparing.equal(constructor1, constructor2)) { return EXACT_MISMATCH; } final PsiExpression qualifier1 = newExpression1.getQualifier(); final PsiExpression qualifier2 = newExpression2.getQualifier(); if (!expressionsMatch(qualifier1, qualifier2).isExactMatch()) { return EXACT_MISMATCH; } final PsiExpressionList argumentList1 = newExpression1.getArgumentList(); final PsiExpression[] args1 = argumentList1 == null ? null : argumentList1.getExpressions(); final PsiExpressionList argumentList2 = newExpression2.getArgumentList(); final PsiExpression[] args2 = argumentList2 == null ? null : argumentList2.getExpressions(); PsiAnonymousClass anonymousClass1 = newExpression1.getAnonymousClass(); PsiAnonymousClass anonymousClass2 = newExpression2.getAnonymousClass(); if (anonymousClass1 != null || anonymousClass2 != null) { if (anonymousClass1 != null && anonymousClass2 != null) { return classesMatch(anonymousClass1, anonymousClass2); } return EXACT_MISMATCH; } return labelElementsAreEquivalent(args1, args2, false); }