@@ -175,21 +175,18 @@ NAMES arg is optional and are the group of tests representing a test name."
175175 (unless (seq-empty-p children)
176176 (lsp-dart-code-lens--add-test buffer children concatened-names)))))
177177
178-
179- ; ; Public
180-
181- (lsp-defun lsp-dart-code-lens-check-main (uri (&Outline :children ))
178+ (lsp-defun lsp-dart--main-code-lens-check ((&OutlineNotification :uri :outline (&Outline :children )))
182179 " Check URI and outline for main method adding lens to it."
183180 (-let* ((buffer (find-buffer-visiting (lsp--uri-to-path uri)))
184181 (main-outline (lsp-dart-code-lens--find-main-outline children)))
185182 (when buffer
186183 (with-current-buffer buffer
187184 (remove-overlays (point-min ) (point-max ) 'lsp-dart-main-code-lens t )
188- (save-excursion
189- (when main-outline
185+ (when main-outline
186+ (save-excursion
190187 (lsp-dart-code-lens--build-main-overlay buffer main-outline)))))))
191188
192- (lsp-defun lsp-dart-code-lens-check-test ( uri (&Outline :children ))
189+ (lsp-defun lsp-dart--test- code-lens-check ((&OutlineNotification : uri :outline (&Outline :children ) ))
193190 " Check URI and outline for test adding lens to it."
194191 (when (lsp-dart-test-file-p uri)
195192 (when-let (buffer (find-buffer-visiting (lsp--uri-to-path uri)))
@@ -198,5 +195,30 @@ NAMES arg is optional and are the group of tests representing a test name."
198195 (save-excursion
199196 (lsp-dart-code-lens--add-test buffer children))))))
200197
198+
199+ ; ; Public
200+
201+ (define-minor-mode lsp-dart-main-code-lens-mode
202+ " Mode for displaying code lens on main methods."
203+ nil nil nil
204+ (cond
205+ (lsp-dart-main-code-lens-mode
206+ (add-hook 'lsp-dart-outline-arrived-hook #'lsp-dart--main-code-lens-check nil t ))
207+ (t
208+ (progn
209+ (remove-overlays (point-min ) (point-max ) 'lsp-dart-main-code-lens t )
210+ (remove-hook 'lsp-dart-outline-arrived-hook #'lsp-dart--main-code-lens-check t )))))
211+
212+ (define-minor-mode lsp-dart-test-code-lens-mode
213+ " Mode for displaying code lens on main methods."
214+ nil nil nil
215+ (cond
216+ (lsp-dart-test-code-lens-mode
217+ (add-hook 'lsp-dart-outline-arrived-hook #'lsp-dart--test-code-lens-check nil t ))
218+ (t
219+ (progn
220+ (remove-overlays (point-min ) (point-max ) 'lsp-dart-test-code-lens t )
221+ (remove-hook 'lsp-dart-outline-arrived-hook #'lsp-dart--test-code-lens-check t )))))
222+
201223(provide 'lsp-dart-code-lens )
202224; ;; lsp-dart-code-lens.el ends here
0 commit comments