2121
2222(require 'lsp-mode )
2323
24+ (require 'lsp-dart-protocol )
25+
2426(defcustom lsp-dart-closing-labels t
2527 " Enable the analysis server closing labels feature.
2628When set to non-nil, dart/textDocument/publishClosingLabel notifications will
@@ -38,28 +40,23 @@ be sent with information to render editor closing labels."
3840 :type 'float
3941 :group 'lsp-dart )
4042
41- (defun lsp-dart-closing-labels-handle (_workspace params )
42- " Closing labels notification handling.
43- PARAMS closing labels notification data sent from WORKSPACE."
44- (-let* (((&hash " uri" " labels" ) params)
45- (buffer (lsp--buffer-for-file (lsp--uri-to-path uri))))
46- (when buffer
47- (with-current-buffer buffer
48- (remove-overlays (point-min ) (point-max ) 'lsp-dart-closing-labels t )
49- (seq-doseq (label-ht labels)
50- (save-excursion
51- (-let* ((label (gethash " label" label-ht))
52- (range (gethash " range" label-ht))
53- ((beg . end) (lsp--range-to-region range))
54- (end-line (progn
55- (goto-char end)
56- (line-end-position )))
57- (overlay (make-overlay beg end-line buffer)))
58- (overlay-put overlay 'lsp-dart-closing-labels t )
59- (overlay-put overlay 'after-string (propertize (concat lsp-dart-closing-labels-prefix " " label)
60- 'display `((height , lsp-dart-closing-labels-size ))
61- 'cursor t
62- 'font-lock-face 'font-lock-comment-face )))))))))
43+ (lsp-defun lsp-dart-closing-labels-handle (_workspace (&ClosingLabelsNotification :uri :labels ))
44+ " Closing labels notification handler."
45+ (when-let (buffer (lsp--buffer-for-file (lsp--uri-to-path uri)))
46+ (with-current-buffer buffer
47+ (remove-overlays (point-min ) (point-max ) 'lsp-dart-closing-labels t )
48+ (seq-doseq (label labels)
49+ (save-excursion
50+ (-let* (((beg . end) (lsp--range-to-region (lsp:closing-label-range label)))
51+ (end-line (progn
52+ (goto-char end)
53+ (line-end-position )))
54+ (overlay (make-overlay beg end-line buffer)))
55+ (overlay-put overlay 'lsp-dart-closing-labels t )
56+ (overlay-put overlay 'after-string (propertize (concat lsp-dart-closing-labels-prefix " " (lsp:closing-label-label label))
57+ 'display `((height , lsp-dart-closing-labels-size ))
58+ 'cursor t
59+ 'font-lock-face 'font-lock-comment-face ))))))))
6360
6461(provide 'lsp-dart-closing-labels )
6562; ;; lsp-dart-closing-labels.el ends here
0 commit comments