-
Notifications
You must be signed in to change notification settings - Fork 90
/
lsp-jt.el
635 lines (572 loc) · 26.4 KB
/
lsp-jt.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
;;; lsp-jt.el --- Java test support -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Ivan Yonchovski
;; Version: 2.0
;; Author: Ivan Yonchovski <yyoncho@gmail.com>
;; Package-Requires: ((emacs "25.1") (lsp-mode "6.0"))
;; Keywords: language, tools
;; URL: https://github.com/emacs-lsp/lsp-java
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Emacs frontend of https://github.com/Microsoft/vscode-java-test
;;; Code:
(require 'cl-lib)
(require 'lsp-mode)
(require 'lsp-java)
(require 'treemacs)
(eval-when-compile
(require 'lsp-treemacs))
(declare-function dap-debug "ext:dap-mode")
(defvar lsp-jt--refresh-timer nil)
(defconst lsp-jt-kind-root 0)
(defconst lsp-jt-kind-folder 1)
(defconst lsp-jt-kind-package 2)
(defconst lsp-jt-kind-class 3)
(defconst lsp-jt-kind-method 4)
(defvar lsp-jt-results (ht))
(defun lsp-jt-browser--scedule-refresh ()
(when lsp-jt--refresh-timer
(cancel-timer lsp-jt--refresh-timer))
(setq lsp-jt--refresh-timer (run-with-idle-timer 0.5 nil 'lsp-jt-browser-refresh)))
(defcustom lsp-jt-status-updated-hook nil
"List of functions to be called after test status has changed."
:type 'hook
:group 'lsp-java)
(defcustom lsp-jt-test-run-finished-hook nil
"List of functions to be called after all tests have finished."
:type 'hook
:group 'lsp-java)
(defcustom lsp-jt-theme "Default"
"The `lsp-jt' theme."
:type 'string
:group 'lsp-java)
(defcustom lsp-jt-root (expand-file-name (locate-user-emacs-file "eclipse.jdt.ls/server/java-test/server"))
"The `lsp-jt' root."
:type 'string
:group 'lsp-java)
(eval-and-compile
(lsp-interface
(jt:TestItem (:id :displayName :fullName :children :level :kind :project :location))
(jt:Argument (:uri :classFullName :testName :project :scope :testKind :start :end))
(jt:JUnitLaunchArguments (:workingDirectory :mainClass :projectName :classpath :modulepath :vmArguments :programArguments))))
(defconst lsp-jt-test-kind-none -1)
(defconst lsp-jt-test-kind-junit 0)
(defconst lsp-jt-test-kind-junit5 1)
(defconst lsp-jt-test-kind-testng 2)
(defvar lsp-jt-browser-position-params
`((side . ,treemacs-position)
(slot . 4)
(window-width . ,treemacs-width)))
(defun lsp-jt--process-test-lens (lens)
(-let [(test-data &as &jt:TestItem :location (&Location :range)) lens]
(-doto test-data
(lsp-put :range range))))
(defface lsp-jt-error-face
'((t :height 1.0 :inherit error))
"The face used for code lens overlays."
:group 'lsp-faces)
(defface lsp-jt-success-face
'((t :height 1.0 :inherit success))
"The face used for code lens overlays."
:group 'lsp-faces)
(defface lsp-jt-in-progress-face
'((t :height 1.0 :inherit warn))
"The face used for code lens overlays."
:group 'lsp-faces)
(defvar-local lsp-jt--last-callback nil)
(lsp-defun lsp-jt--start-test ((node &as &jt:TestItem :location (&Location :uri)
:full-name :level)
no-debug?)
(lsp-java-with-jdtls
(-let* ((full-name (if (>= level lsp-jt-kind-package) full-name ""))
(tests (cond
((= level lsp-jt-kind-method) `((,node)))
(t (->>
(or (lsp--send-execute-command
"vscode.java.test.search.items.all"
(vector
(lsp--json-serialize
(list :uri uri :level level :fullName full-name))))
(user-error "Unable to find tests under %s." node))
;; unique tests
(-reduce-from (-lambda ((result covered-set)
(item &as &jt:TestItem :id :children))
(list (if (-contains? result id)
result
(cons item result))
(append children covered-set (list id))))
nil)
(cl-first)
;; group by kind/executor
(-group-by (-lambda ((&jt:TestItem :kind :project)) (cons project kind)))
(-map #'cl-rest)))))
launch-configs launch-config)
;; we should start each group and then start the next one when the previous
;; one has finished.
(-setq (launch-config . launch-configs)
(-map
(lambda (test-group)
(let ((kind (or (lsp:jt-test-item-kind (cl-first test-group)) lsp-jt-test-kind-junit))
(project (lsp:jt-test-item-project (cl-first test-group))))
(cons
test-group
(cond
((= kind lsp-jt-test-kind-testng) (user-error "TestNG is not implemented!"))
(t (lsp-jt--create-launch-config
(lsp--send-execute-command
"vscode.java.test.junit.argument"
(vector
(lsp--json-serialize
(lsp-make-jt-argument
:class-full-name (when full-name
(if (s-contains? "#" full-name)
(cl-first (s-split "#" full-name ))
full-name))
:scope level
:testName (or (when (and full-name (s-contains? "#" full-name))
(cl-second (s-split "#" full-name )))
"")
:test-kind (or kind lsp-jt-test-kind-junit)
:project project
:uri uri
:start (when (and (eq kind lsp-jt-test-kind-junit5)
(eq level lsp-jt-kind-method))
(->> test-group cl-first lsp:jt-test-item-location lsp:location-range lsp:range-start))
:end (when (and (eq kind lsp-jt-test-kind-junit5)
(eq level lsp-jt-kind-method))
(->> test-group cl-first lsp:jt-test-item-location lsp:location-range lsp:range-end))))))
no-debug?
(lsp-jt--create-analyzer project lsp-jt-results)
(lambda ()
;; mark all pending/running in undefined status
(let (needs-update)
(mapc (-lambda ((test-result &as &plist :status))
(when (or (eq status :running)
(eq status :pending))
(plist-put test-result :status nil)
(setq needs-update t)))
(ht-values lsp-jt-results))
(when needs-update (run-hooks 'lsp-jt-status-updated-hook)))
(-setq (launch-config . launch-configs) launch-configs)
;; start next group if present
(when launch-config
(lsp-jt--start-group launch-config))
(run-hooks 'lsp-jt-test-run-finished-hook))))))))
tests))
;; start the first group
(ht-clear lsp-jt-results)
(lsp-jt--start-group launch-config))))
(lsp-defun lsp-jt--start-group ((test-group . launch-config))
(mapc (-lambda ((&jt:TestItem :id :level :children))
(when (equal level lsp-jt-kind-method)
(puthash id (list :status :pending)
lsp-jt-results))
(mapc (lambda (id)
(puthash id (list :status :pending) lsp-jt-results))
children))
test-group)
(dap-debug launch-config)
(run-hooks 'lsp-jt-status-updated-hook))
(defun lsp-jt-lens-backend (_modified? callback)
(setq-local lsp-jt--last-callback callback)
(lsp-request-async
"workspace/executeCommand"
(list :command "vscode.java.test.search.codelens"
:arguments (vector (lsp--buffer-uri)))
(lambda (result)
(let* ((lenses (-map #'lsp-jt--process-test-lens result))
(all-lenses
(append
(mapc
(lambda (lens)
(lsp-put
lens
:command (lsp-make-command
:title "Debug"
:command (lambda ()
(interactive)
(lsp-jt--start-test lens nil)))))
lenses)
(mapc
(lambda (lens)
(lsp-put
lens
:command (lsp-make-command
:title "Run"
:command (lambda ()
(interactive)
(lsp-jt--start-test lens t)))))
(-map #'lsp-copy lenses))
(-keep
(lambda (lens)
(-when-let ((title . face) (lsp-jt--status lens))
(lsp-put lens
:command (lsp-put
(lsp-make-command
:title title
:command #'lsp-jt-report-open)
:_face face))))
(-map #'lsp-copy lenses)))))
(funcall callback all-lenses lsp--cur-version)))
:mode 'detached))
(defvar lsp-lens-backends)
(declare-function lsp-lens-refresh "lsp-lens" (buffer-modified? &optional buffer))
;;;###autoload
(define-minor-mode lsp-jt-lens-mode
"Toggle code-lens overlays."
:group 'lsp-jt
:global nil
:init-value nil
:lighter nil
(let ((buffer (current-buffer)))
(cond
(lsp-jt-lens-mode
(require 'lsp-lens)
(setq-local lsp-lens-backends (cl-pushnew 'lsp-jt-lens-backend lsp-lens-backends))
(lsp-lens-refresh t)
(add-hook 'lsp-jt-status-updated-hook
(lambda ()
(with-current-buffer buffer
(lsp-lens-refresh nil)))))
(t
(setq-local lsp-lens-backends (delete 'lsp-jt-lens-backend lsp-lens-backends))
(remove-hook 'lsp-jt-status-updated-hook
(lambda ()
(with-current-buffer buffer
(lsp-lens-refresh nil))))))))
(defun lsp-jt-search (root level full-name callback)
(lsp-java-with-jdtls
(lsp-request-async
"workspace/executeCommand"
(list :command "vscode.java.test.search.items"
:arguments
(vector (lsp--json-serialize `(:uri ,root
:level ,level
,@(when full-name (list :fullName full-name))))))
callback)))
(defun lsp-jt-goto (&rest _)
"Goto the symbol at point."
(interactive)
(-if-let ((&jt:TestItem :location (&Location :uri :range (&Range? :start))) (-some-> (treemacs-node-at-point)
(button-get :data)))
(progn
(select-window (get-mru-window (selected-frame) nil :not-selected))
(find-file (lsp--uri-to-path uri))
(when start
(goto-char (lsp--position-to-point start))))
(user-error "No test under point.")))
(defun lsp-jt--roots ()
(-uniq (gethash 'jdtls (lsp-session-server-id->folders (lsp-session)))))
(treemacs-modify-theme "Default"
:icon-directory (f-join (f-dirname (or load-file-name buffer-file-name)) "icons/vscode/")
:config
(progn
(treemacs-create-icon :file "class.png" :extensions (java-test-class) :fallback "-")
(treemacs-create-icon :file "debug.png" :extensions (java-test-debug) :fallback "-")
(treemacs-create-icon :file "method.png" :extensions (java-test-method) :fallback "-")
(treemacs-create-icon :file "package.png" :extensions (java-test-package) :fallback "-")
(treemacs-create-icon :file "placeholder.png" :extensions (java-test-placeholder) :fallback "-")
(treemacs-create-icon :file "refresh.png" :extensions (java-test-refresh) :fallback "-")
(treemacs-create-icon :file "run.png" :extensions (java-test-run) :fallback "-")
(treemacs-create-icon :file "running.png" :extensions (java-test-running) :fallback "-")
(treemacs-create-icon :file "pass.png" :extensions (java-test-pass) :fallback "-")
(treemacs-create-icon :file "test-error.png" :extensions (java-test-error) :fallback "-")
(treemacs-create-icon :file "history.png" :extensions (java-test-pending) :fallback "-")))
(lsp-treemacs-define-action lsp-jt-run (:data)
"Run test from browser."
(lsp-jt--start-test data t))
(defvar lsp-jt-mode-map
(-doto (make-sparse-keymap)
(define-key (kbd "x") #'lsp-jt-run)
(define-key (kbd "d") #'lsp-jt-debug)
(define-key (kbd "R") #'lsp-jt-browser-refresh))
"Keymap for `lsp-jt-mode'.")
(define-minor-mode lsp-jt-mode "Java Test Mode"
:keymap lsp-jt-mode-map)
(lsp-treemacs-define-action lsp-jt-debug (:data)
"Debug from browser."
(lsp-jt--start-test data nil))
(defvar lsp-jt--refresh-lens-timer nil)
(defun lsp-jt--do-refresh-lenses ()
(->>
(lsp-find-workspace 'jdtls nil)
(lsp--workspace-buffers)
(-map (lambda (buffer)
(with-current-buffer buffer
(when (and lsp-jt-lens-mode lsp-jt--last-callback)
(lsp-jt-lens-backend nil lsp-jt--last-callback)))))))
(defun lsp-jt--schedule-refresh-lens ()
(when lsp-jt--refresh-lens-timer
(cancel-timer lsp-jt--refresh-lens-timer))
(setq lsp-jt--refresh-lens-timer
(run-at-time 0.2 nil #'lsp-jt--do-refresh-lenses)))
(defun lsp-jt--create-launch-config (args no-debug? analyzer finished-function)
(with-lsp-workspace (lsp-find-workspace 'jdtls nil)
(require 'dap-java)
(-let (((all &as &jt:JUnitLaunchArguments :working-directory :main-class
:project-name :classpath :vm-arguments :program-arguments) args)
tcp-server-process)
(list :type "java"
:mainClass main-class
:projectName project-name
:noDebug no-debug?
:debugOnEntry t
:cwd working-directory
:vmArgs (s-join " " vm-arguments)
:classPaths classpath
:startup-function
(lambda (launch-args)
(setf tcp-server-process
(make-network-process
:name "*java-tests-tcp-server*"
:buffer " *java-tests-tcp-server*"
:family 'ipv4
:service 0
:sentinel (lambda (proc _string)
(set-process-filter
proc
(lambda (_ string)
(funcall analyzer string))))
:server 't))
(aset program-arguments 3 (number-to-string (cl-second (process-contact tcp-server-process))))
(plist-put launch-args :args (s-join " " program-arguments)))
:cleanup-function
(lambda (_session)
;; cleanup after some time to ensure notifications over
;; tcp-server-process are received
(run-with-idle-timer
0.5
nil
(lambda ()
(when tcp-server-process
(delete-process tcp-server-process))
(funcall finished-function))))))))
(lsp-defun lsp-jt--render-test-node ((test-item &as &jt:TestItem :display-name :level :id
:location (loc &as &Location :uri) :full-name))
`(:key ,id
:label ,display-name
:icon ,(lsp-jt--get-test-icon id level)
,@(unless (eq level 4)
(list :children-async (lambda (_ callback)
(lsp-jt-search
uri
level
full-name
(lambda (items)
(funcall callback
(-map
#'lsp-jt--render-test-node
items)))))))
:ret-action ,(lambda ()
(interactive)
(lsp-goto-location loc))
:actions (["Run Test" lsp-jt-run]
["Debug Test" lsp-jt-debug]
["Refresh" lsp-jt-browser-refresh])
:data ,test-item))
(declare-function lsp-treemacs-generic-refresh "lsp-treemacs" ())
(declare-function
lsp-treemacs-render "lsp-treemacs"
(tree title expand-depth &optional buffer-name right-click-actions))
(defun lsp-jt-browser-refresh ()
(interactive)
(with-current-buffer "*Java Tests*"
(require 'lsp-treemacs)
(lsp-treemacs-generic-refresh)))
;;;###autoload
(defun lsp-jt-browser ()
(interactive)
(require 'lsp-treemacs)
(select-window
(display-buffer-in-side-window
(lsp-treemacs-render
(-map
(-lambda (root)
(list :key root
:label (f-filename root)
:icon 'root
:children-async (lambda (_ callback)
(lsp-jt-search (lsp--path-to-uri root) 1 nil
(lambda (items)
(funcall callback
(-map
#'lsp-jt--render-test-node
items)))))
:ret-action (lambda () (find-file root))
:actions `(["Run Test" lsp-jt-run]
["Debug Test" lsp-jt-debug]
["Refresh" lsp-jt-browser-refresh])
:data (lsp-make-jt-test-item :project (lsp--path-to-uri root)
:level 1
:location (lsp-make-location
:uri (lsp--path-to-uri root)))))
(lsp-jt--roots)) "Java Test Browser" nil "*Java Tests*"
`(["Refresh" lsp-jt-browser-refresh]))
lsp-jt-browser-position-params))
(add-hook 'lsp-jt-status-updated-hook #'lsp-jt-browser--scedule-refresh)
(add-hook 'kill-buffer-hook (lambda ()
(remove-hook 'lsp-jt-status-updated-hook
#'lsp-jt-browser--scedule-refresh))
nil t)
(lsp-jt-mode 1))
(lsp-defun lsp-jt--status ((&jt:TestItem :id :level))
(if (eq level lsp-jt-kind-method)
(pcase (plist-get (gethash id lsp-jt-results) :status)
(:failed (cons "❌" 'lsp-jt-error-face))
(:pass (cons "✔" 'lsp-jt-success-face))
(:running (cons "⌛" 'lsp-jt-in-progress-face))
(:pending (cons "⌚" 'lsp-jt-in-progress-face)))
(pcase (plist-get (gethash id lsp-jt-results) :status)
(:failed (cons "❌" 'lsp-jt-error-face))
(:pass (cons "✔" 'lsp-jt-success-face))
(:running (cons "⌛" 'lsp-jt-in-progress-face))
(:pending (cons "⌚" 'lsp-jt-in-progress-face)))))
(defun lsp-jt--update-report ()
(when (buffer-live-p (get-buffer "*Java Tests Results*"))
(with-current-buffer (get-buffer "*Java Tests Results*")
(lsp-jt-test-report-refresh))))
(defun lsp-jt--extract-name (item project)
(or
(-when-let ((_ _ name _ class) (s-match
(rx
(+ digit )
","
(group (opt (or "@AssumptionFailure: " "@Ignore: ")))
(group (*? any))
(group (opt (*? digit)))
"(" (group (* any)) ")")
item))
(format "%s@%s#%s" project class name))
(when-let ((class (last (s-split "," item))))
(format "%s@$%s#<TestError>" project class))
(lsp--warn "Unable to extract id from %s" item)
""))
(defvar lsp-jt--junit-test-start "%TESTS")
(defvar lsp-jt--junit-test-end "%TESTE")
(defvar lsp-jt--junit-test-failed "%FAILED")
(defvar lsp-jt--junit-test-error "%ERROR")
(defvar lsp-jt--junit-trace-start "%TRACES")
(defvar lsp-jt--junit-trace-end "%TRACEE")
(defvar lsp-jt--junit-ignore-test-prefix "@Ignore: ")
(defvar lsp-jt--junit-assumption-failed-test-prefix "@AssumptionFailure: ")
(lsp-defun lsp-jt--create-analyzer (project result)
(let (recording-traces traces chunk parts)
(lambda (item)
(setf chunk (concat chunk item)
parts (s-lines chunk)
chunk (cl-first (last parts)))
(mapc
(lambda (item)
(cond
((s-starts-with? lsp-jt--junit-test-start item)
(-let* ((test-id (lsp-jt--extract-name item project))
((&plist :status old-status :traces old-traces) (gethash test-id lsp-jt-results)))
(puthash test-id
(list :start (time-to-seconds (current-time))
:status (or
;; parameterized test - keep failed status
(when (eq old-status :failed) :failed)
;; skipped
(when (s-contains? lsp-jt--junit-ignore-test-prefix
item)
:skipped)
:running)
:traces old-traces)
result))
(run-hooks 'lsp-jt-status-updated-hook))
((s-starts-with? lsp-jt--junit-trace-start item)
(setf recording-traces t))
((s-starts-with? lsp-jt--junit-trace-end item))
((s-starts-with? lsp-jt--junit-test-end item)
(-when-let ((test-data &as &plist :start :status) (gethash
(lsp-jt--extract-name item project)
result))
(-> test-data
(plist-put :duration (- (time-to-seconds (current-time))
start))
(plist-put :status (if (or (eq status :running)
(null status))
:pass
status))
(plist-put :traces (when traces (s-join "\n" (nreverse traces)))))
(setf recording-traces nil
traces nil)
(run-hooks 'lsp-jt-status-updated-hook)))
((or (s-starts-with? lsp-jt--junit-test-failed item)
(s-starts-with? lsp-jt--junit-test-error item))
(-when-let ((test-data &as &plist :start) (gethash
(lsp-jt--extract-name item project)
result))
(-> test-data
(plist-put :duration (- (time-to-seconds (current-time))
start))
(plist-put :status
(if (s-contains? lsp-jt--junit-assumption-failed-test-prefix item)
:skipped
:failed)))
(run-hooks 'lsp-jt-status-updated-hook)))
(recording-traces (push item traces))))
(butlast parts)))))
(defun lsp-jt--get-test-status (id)
(plist-get (gethash id lsp-jt-results) :status))
(defun lsp-jt--get-test-icon (id level)
(cl-case (lsp-jt--get-test-status id)
(:running 'java-test-running)
(:pass 'java-test-pass)
(:failed 'java-test-error)
(:pending 'java-test-pending)
(t (alist-get level '((1 . java-test-package)
(2 . java-test-package)
(3 . java-test-class)
(4 . java-test-method))))))
(defun lsp-jt-test-report-refresh ()
(lsp-treemacs-render
(->> lsp-jt-results
(ht-keys)
(-sort #'string-lessp)
(-map
(lambda (test-id)
(-let (((_ _ test name)
(s-match (rx (group (* any)) "@"
(group (* any)) "#"
(group (* any)))
test-id)))
`(:key ,test-id
:label
,(format "%s %s %s"
name
(propertize test 'face 'lsp-lens-face)
(or (when-let ((duration (plist-get (ht-get lsp-jt-results test-id)
:duration)))
(propertize (format "%0.2fs" duration)
'face 'lsp-lens-face))
""))
:icon ,(lsp-jt--get-test-icon test-id 4)
,@(when (eq (lsp-jt--get-test-status test-id) :failed)
`(:children ((:key "stacktrace"
:label ,(concat "Stack trace: \n"
(plist-get
(gethash test-id lsp-jt-results)
:traces))
:icon none)))))))))
"Java Test Results" nil "*Java Tests Results*"))
(defun lsp-jt--report-buffer-hook ()
(remove-hook 'lsp-jt-status-updated-hook #'lsp-jt--update-report))
(defun lsp-jt-report-open ()
(interactive)
(pop-to-buffer (lsp-jt-test-report-refresh))
(add-hook 'lsp-jt-status-updated-hook #'lsp-jt--update-report)
(add-hook 'kill-buffer-hook #'lsp-jt--report-buffer-hook nil t))
(provide 'lsp-jt)
;;; lsp-jt.el ends here
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End: