void (@NotNull HighlightInfo.Builder highlightInfo, PsiType lType, PsiExpression thenExpression) { final JavaResolveResult result = ((PsiMethodCallExpression)thenExpression).resolveMethodGenerics(); final PsiMethod method = (PsiMethod)result.getElement(); if (method != null) { final PsiType returnType = method.getReturnType(); final PsiClass aClass = method.getContainingClass(); if (returnType != null && aClass != null && aClass.getQualifiedName() != null) { final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(method.getProject()); final PsiDeclarationStatement variableDeclarationStatement = javaPsiFacade.getElementFactory().createVariableDeclarationStatement("xxx", lType, thenExpression, thenExpression); final PsiExpression initializer = ((PsiLocalVariable)variableDeclarationStatement.getDeclaredElements()[0]).getInitializer(); LOG.assertTrue(initializer != null); final PsiSubstitutor substitutor = javaPsiFacade.getResolveHelper() .inferTypeArguments(method.getTypeParameters(), method.getParameterList().getParameters(), ((PsiMethodCallExpression)thenExpression).getArgumentList().getExpressions(), PsiSubstitutor.EMPTY, initializer, DefaultParameterTypeInferencePolicy.INSTANCE); PsiType substitutedType = substitutor.substitute(returnType); if (substitutedType != null && TypeConversionUtil.isAssignable(lType, substitutedType)) { highlightInfo.registerFix(new AddTypeArgumentsConditionalFix(substitutor, (PsiMethodCallExpression)thenExpression, method), null, null, thenExpression.getTextRange(), null); } } } }