fix(emacs/lean-info): handle when both identifier and symbol info exist
Example: library/data/int/basic.lean file (398, 22) The '+' symbol is attached with both of identifier info and symbol info -- SYMBOL|398|22 + -- ACK -- IDENTIFIER|398|22 int.add -- ACK
This commit is contained in:
parent
b9c1b1e186
commit
a1a14cf425
1 changed files with 37 additions and 24 deletions
|
@ -399,23 +399,30 @@ Take out \"BEGININFO\" and \"ENDINFO\" and Use \"ACK\" as a delim."
|
||||||
(--filter (or (lean-info-identifier-p it)
|
(--filter (or (lean-info-identifier-p it)
|
||||||
(lean-info-symbol-p it))
|
(lean-info-symbol-p it))
|
||||||
info-list)))
|
info-list)))
|
||||||
(candidate
|
;; candidate = list of info
|
||||||
(--last (<= (lean-info-column it) column-number)
|
(candidate-list
|
||||||
sorted-id-symbol-list))
|
(-last-item
|
||||||
|
(-partition-by 'lean-info-column
|
||||||
|
(--filter (<= (lean-info-column it) column-number)
|
||||||
|
sorted-id-symbol-list))))
|
||||||
matched-name
|
matched-name
|
||||||
start-column
|
start-column
|
||||||
full-name)
|
full-name
|
||||||
|
candidate)
|
||||||
|
(setq candidate
|
||||||
|
(-first (lambda (info)
|
||||||
|
(let* ((start-column (lean-info-column info))
|
||||||
|
(full-name (lean-info-id-symbol-body-str info))
|
||||||
|
(matched-name (lean-match-full-name-at-pos
|
||||||
|
file-name
|
||||||
|
(lean-info-line-number info)
|
||||||
|
start-column
|
||||||
|
full-name)))
|
||||||
|
(< column-number
|
||||||
|
(+ start-column (length matched-name)))))
|
||||||
|
candidate-list))
|
||||||
(when candidate
|
(when candidate
|
||||||
(setq start-column (lean-info-column candidate))
|
(lean-info-column candidate))))
|
||||||
(setq full-name (lean-info-id-symbol-body-str candidate))
|
|
||||||
(setq matched-name (lean-match-full-name-at-pos
|
|
||||||
file-name
|
|
||||||
(lean-info-line-number candidate)
|
|
||||||
start-column
|
|
||||||
full-name))
|
|
||||||
(when (< column-number
|
|
||||||
(+ start-column (length matched-name)))
|
|
||||||
start-column))))
|
|
||||||
|
|
||||||
(defun lean-info-list-parse (str &optional file-name column-number)
|
(defun lean-info-list-parse (str &optional file-name column-number)
|
||||||
"Parse input string and return info-list."
|
"Parse input string and return info-list."
|
||||||
|
@ -458,22 +465,28 @@ Take out \"BEGININFO\" and \"ENDINFO\" and Use \"ACK\" as a delim."
|
||||||
(let* ((type (cl-first (lean-info-record-type info-record)))
|
(let* ((type (cl-first (lean-info-record-type info-record)))
|
||||||
(overload (cl-first (lean-info-record-overload info-record)))
|
(overload (cl-first (lean-info-record-overload info-record)))
|
||||||
(synth (cl-first (lean-info-record-synth info-record)))
|
(synth (cl-first (lean-info-record-synth info-record)))
|
||||||
(id-sym (cl-first
|
(id (cl-first (lean-info-record-identifier info-record)))
|
||||||
(append
|
(sym (cl-first (lean-info-record-symbol info-record)))
|
||||||
(lean-info-record-identifier info-record)
|
|
||||||
(lean-info-record-symbol info-record))))
|
|
||||||
name-str type-str overload-str str)
|
name-str type-str overload-str str)
|
||||||
(when id-sym
|
(setq name-str
|
||||||
(setq name-str (lean-info-id-symbol-body-str id-sym)))
|
(cond
|
||||||
(when synth
|
(synth (lean-info-synth-body-str synth))
|
||||||
(setq name-str (lean-info-synth-body-str synth)))
|
((and id sym)
|
||||||
|
(format "[%s] %s"
|
||||||
|
(lean-info-id-symbol-body-str sym)
|
||||||
|
(lean-info-id-symbol-body-str id)))
|
||||||
|
(id (lean-info-id-symbol-body-str id))
|
||||||
|
(sym (lean-info-id-symbol-body-str sym))))
|
||||||
(when type
|
(when type
|
||||||
(setq type-str (lean-info-type-body-str type)))
|
(setq type-str (lean-info-type-body-str type)))
|
||||||
(when (and name-str overload)
|
(when (and name-str overload)
|
||||||
(setq overload-str
|
(setq overload-str
|
||||||
(string-join
|
(string-join
|
||||||
(--remove (string= it name-str)
|
(--remove
|
||||||
(lean-info-overload-names overload))
|
(or
|
||||||
|
(and id (string-prefix-p (lean-info-id-symbol-body-str id) it))
|
||||||
|
(and sym (string-prefix-p (lean-info-id-symbol-body-str sym) it)))
|
||||||
|
(lean-info-overload-names overload))
|
||||||
", ")))
|
", ")))
|
||||||
(when (and name-str type-str)
|
(when (and name-str type-str)
|
||||||
(setq str (format "%s : %s"
|
(setq str (format "%s : %s"
|
||||||
|
|
Loading…
Reference in a new issue