@Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
    PsiExpression qualifier = myRefExpr.getQualifierExpression();

    PsiExpression expression = (myRefExpr.getParent() instanceof PsiMethodCallExpression call) ? call : myRefExpr;
    if (qualifier != null && qualifier.getType() instanceof PsiPrimitiveType && !ExpressionUtils.isVoidContext(expression)) {
      new CommentTracker().replaceAndRestoreComments(expression, qualifier);
      return;
    }

    PsiReferenceExpression[] refs = CreateFromUsageUtils.collectExpressions(myRefExpr, PsiMember.class, PsiFile.class);
    PsiElement element = PsiTreeUtil.getParentOfType(myRefExpr, PsiMember.class, PsiFile.class);
    if (element == null) return;
    LookupElement[] items = collectItems();
    ReferenceNameExpression refExpr = new ReferenceNameExpression(items, myRefExpr.getReferenceName());

    TemplateBuilder builder = new TemplateBuilderImpl(element);
    for (PsiReferenceExpression expr : refs) {
      if (!expr.equals(myRefExpr)) {
        builder.replaceElement(expr.getReferenceNameElement(), OTHER_VARIABLE_NAME, INPUT_VARIABLE_NAME, false);
      }
      else {
        builder.replaceElement(expr.getReferenceNameElement(), INPUT_VARIABLE_NAME, refExpr, true);
      }
    }
    final float proportion = EditorUtil.calcVerticalScrollProportion(editor);
    builder.run(editor, true);
    if (file.isPhysical()) {
      EditorUtil.setVerticalScrollProportion(editor, proportion);
    }
  }
@Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file)