@Override
  @RequiredDispatchThread
  public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psi) {
    CSharpExpressionStatementImpl exprStmt =
        PsiTreeUtil.getParentOfType(psi, CSharpExpressionStatementImpl.class);
    if (psi instanceof SyntheticElement || exprStmt == null) {
      return false;
    }

    DotNetExpression expression = exprStmt.getExpression();
    if (expression instanceof CSharpAssignmentExpressionImpl) {
      return false;
    }

    DotNetTypeRef ref = expression.toTypeRef(true);
    return !(ref == DotNetTypeRef.ERROR_TYPE
        || DotNetTypeRefUtil.isVmQNameEqual(ref, expression, DotNetTypes.System.Void));
  }
    @Override
    public void handleInsert(InsertionContext insertionContext, LookupElement item) {
      Editor editor = insertionContext.getEditor();
      int offset = editor.getCaretModel().getOffset();
      boolean isVoidReturnType =
          DotNetTypeRefUtil.isVmQNameEqual(
              myPseudoMethod.getReturnTypeRef(), myPseudoMethod, DotNetTypes.System.Void);
      if (!isVoidReturnType) {
        TailType.insertChar(editor, offset, ' ');
        TailType.insertChar(editor, offset + 1, ';');
      } else {
        TailType.insertChar(editor, offset, ';');
      }

      insertionContext.getEditor().getCaretModel().moveToOffset(offset + 1);
      if (!isVoidReturnType) {
        AutoPopupController.getInstance(editor.getProject()).autoPopupMemberLookup(editor, null);
      }
    }