 (defconst fstar-subp--info-response-regex
   "^(defined at \\(.+?\\)(\\([0-9]+\\),\\([0-9]+\\)-\\([0-9]+\\),\\([0-9]+\\)))")
 
+(cl-defstruct fstar-pos-info
+  source-file def-start def-end type)
+
 (defun fstar-subp--info-continuation (continuation pos success response)
   "Handle the results (SUCCESS and RESPONSE) of an #info query at POS.
 If response is valid, forward results (only type information for

  (when (and success
             (eq (point) pos) ;; Point didn't move since request
             (string-match fstar-subp--info-response-regex response))
    (funcall continuation (string-trim (substring response (match-end 0))))))

(defun fstar-subp--eldoc-continuation (info)
  "Display INFO as an eldoc message."
  (eldoc-message (fstar-highlight-string info)))

(defun fstar-subp--eldoc-function ()
  "Issue a #info query for current point.
Results are displayed asynchronously, so this function returns
nil and the corresponding continuation calls `eldoc-message'."
  (when (and fstar-compat--can-use-info (fstar-subp-available-p))
    (fstar-subp--query (fstar-subp--info-query (point))
                  (apply-partially #'fstar-subp--info-continuation
                                   #'fstar-subp--eldoc-continuation (point)))
    nil))

(defun fstar-setup-eldoc ()
  "Set up eldoc support."
  ;; Incompatible with Emacs < 25
  ;; (add-function :before-until (local 'eldoc-documentation-function)
  ;;               #'fstar-subp--eldoc-function)
  (setq-local eldoc-documentation-function #'fstar-subp--eldoc-function)
  (eldoc-mode))

(defun fstar-teardown-eldoc ()
  "Tear down eldoc support."
  ;; Incompatible with Emacs < 25
  ;; (remove-function (local 'eldoc-documentation-function)
  ;;                  #'fstar-subp--eldoc-function)
  (kill-local-variable 'eldoc-documentation-function))

;;;; Starting the F* subprocess

(defun fstar-subp-highlight-issue (issue)
  "Highlight ISSUE in current buffer."
  (let* ((from (fstar--row-col-offset (fstar-issue-line-from issue)
                                      (fstar-issue-col-from issue)))
         (to (fstar--row-col-offset (fstar-issue-line-to issue)
                                    (fstar-issue-col-to issue)))
         (overlay (make-overlay from (max to (1+ from)) (current-buffer) t nil)))
    (overlay-put overlay 'fstar-subp-issue t)
    (overlay-put overlay 'face (fstar-subp-issue-face issue))
