@Override
 public void doFix(Project project, ProblemDescriptor descriptor)
     throws IncorrectOperationException {
   final PsiIdentifier name = (PsiIdentifier) descriptor.getPsiElement();
   final PsiReferenceExpression expression = (PsiReferenceExpression) name.getParent();
   if (expression == null) {
     return;
   }
   final PsiMethodCallExpression call = (PsiMethodCallExpression) expression.getParent();
   final String methodName = expression.getReferenceName();
   if (call == null) {
     return;
   }
   final PsiMethod method = call.resolveMethod();
   if (method == null) {
     return;
   }
   final PsiClass containingClass = method.getContainingClass();
   final PsiExpressionList argumentList = call.getArgumentList();
   if (containingClass == null) {
     return;
   }
   final String containingClassName = containingClass.getQualifiedName();
   final String argText = argumentList.getText();
   PsiReplacementUtil.replaceExpressionAndShorten(
       call, containingClassName + '.' + methodName + argText);
 }
  @Override
  public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
    if (!super.isAvailable(project, editor, element)) {
      return false;
    }

    final PsiNewExpression expression =
        PsiTreeUtil.getParentOfType(element, PsiNewExpression.class, false);
    if (expression == null) {
      return false;
    }

    final PsiExpressionList arguments = expression.getArgumentList();
    if (arguments == null) {
      return false;
    }

    final PsiMethod constructor = expression.resolveConstructor();
    if (constructor == null) {
      return false;
    }

    final PsiExpressionList newArguments =
        createNewArguments(
            JavaPsiFacade.getElementFactory(project),
            constructor.getParameterList().getParameters(),
            arguments.getExpressions());

    if (newArguments == null) {
      return false;
    }

    setText(
        CodeInsightBundle.message(
            "intention.convert.color.representation.text", newArguments.getText()));

    return true;
  }