boolean (@NotNull PsiMethod initial, @NotNull PsiMethod suggestedReplacement, @NotNull PsiMethodCallExpression call) { boolean isInitialStatic = initial.hasModifierProperty(PsiModifier.STATIC); String qualifierText; if (isInitialStatic) { qualifierText = Objects.requireNonNull(suggestedReplacement.getContainingClass()).getQualifiedName() + "."; } else { PsiExpression qualifierExpression = call.getMethodExpression().getQualifierExpression(); qualifierText = qualifierExpression == null ? "" : qualifierExpression.getText() + "."; PsiExpression qualifier = ExpressionUtils.getEffectiveQualifier(call.getMethodExpression()); if (qualifier == null) return false; PsiClass qualifierClass = PsiUtil.resolveClassInType(qualifier.getType()); if (qualifierClass == null) return false; PsiClass suggestedClass = suggestedReplacement.getContainingClass(); if (suggestedClass == null || !InheritanceUtil.isInheritorOrSelf(qualifierClass, suggestedClass, true)) return false; } PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(initial.getProject()); PsiExpressionList arguments = call.getArgumentList(); PsiMethodCallExpression suggestedCall = (PsiMethodCallExpression)elementFactory .createExpressionFromText(qualifierText + suggestedReplacement.getName() + arguments.getText(), call); PsiType type = ExpectedTypeUtils.findExpectedType(call, true); if (type != null && !type.equals(PsiTypes.voidType())) { PsiType suggestedCallType = suggestedCall.getType(); if (!ExpressionUtils.isVoidContext(call) && suggestedCallType != null && !TypeConversionUtil.isAssignable(type, suggestedCallType)) { return false; } } MethodCandidateInfo result = ObjectUtils.tryCast(suggestedCall.resolveMethodGenerics(), MethodCandidateInfo.class); return result != null && result.isApplicable(); }