@@ -217,10 +217,7 @@ in a buffer"
217
217
(defun psc-ide-show-type (expand )
218
218
" Show type of the symbol under cursor."
219
219
(interactive " P" )
220
- (let ((ident (psc-ide-ident-at-point)))
221
- (-if-let (type-description (psc-ide-show-type-impl ident expand))
222
- (message " %s " (psc-ide-string-fontified type-description))
223
- (message " Know nothing about type of `%s' . " ident))))
220
+ (psc-ide-show-type-impl (psc-ide-ident-at-point) t expand))
224
221
225
222
(defun psc-ide-goto-definition ()
226
223
" Go to definition of the symbol under cursor."
@@ -303,9 +300,7 @@ nicely displayed inside a compilation buffer."
303
300
304
301
(defun psc-ide-show-type-eldoc ()
305
302
" Show type of the symbol under cursor, but be quiet about failures"
306
- (let ((ident (psc-ide-ident-at-point)))
307
- (-when-let (type-description (psc-ide-show-type-impl ident))
308
- (message " %s " (psc-ide-string-fontified type-description)))))
303
+ (psc-ide-show-type-impl (psc-ide-ident-at-point)))
309
304
310
305
(defun psc-ide-case-split-impl (type )
311
306
" Case Split on identifier under cursor"
@@ -549,18 +544,22 @@ passes it into the callback"
549
544
(forward-char (1- column)))
550
545
(message (format " No position information for %s " search)))))))
551
546
552
- (defun psc-ide-show-type-impl (search &optional expand )
553
- " Returns a string that describes the type of SEARCH.
554
- Returns NIL if the type of SEARCH is not found."
555
- (let* ((resp (psc-ide-send-sync
556
- (psc-ide-build-type-command search)))
557
- (result (psc-ide-unwrap-result resp)))
558
- (when (not (zerop (length result)))
559
- (let* ((completion (aref result 0 ))
560
- (type (cdr (assoc (if expand 'expandedType 'type ) completion)))
561
- (module (cdr (assoc 'module completion)))
562
- (identifier (cdr (assoc 'identifier completion))))
563
- (s-concat module " ." identifier " :: \n " type)))))
547
+ (defun psc-ide-show-type-impl (search &optional warn expand )
548
+ " Prints a message that describes the type of SEARCH.
549
+ If the type of SEARCH is not found it prints a warning depending
550
+ on whether WARN is true."
551
+ (let ((handler
552
+ (lambda (resp )
553
+ (let ((result (psc-ide-unwrap-result resp)))
554
+ (if (not (zerop (length result)))
555
+ (let-alist (aref result 0 )
556
+ (message (psc-ide-string-fontified
557
+ (format " %s .%s ::\n %s "
558
+ .module
559
+ .identifier
560
+ (if expand .expandedType .type)))))
561
+ (when warn (message " Know nothing about type of `%s' . " search)))))))
562
+ (psc-ide-send (psc-ide-build-type-command search) handler)))
564
563
565
564
(defun psc-ide-build-type-command (search )
566
565
" Builds a type command from SEARCH."
0 commit comments