Skip to content

Commit 312fa6a

Browse files
committed
Fix lsp-treemacs-deps-list to work with plists
Fixes #106
1 parent 2a64981 commit 312fa6a

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

lsp-treemacs.el

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,12 @@ will be rendered an empty line between them."
397397
(lsp-treemacs--expand-recursively btn (if (booleanp depth) depth (1- depth))))
398398
(treemacs-collect-child-nodes root)))))
399399

400+
401+
;; deps
402+
(eval-and-compile
403+
(lsp-interface
404+
(java:Node (:projectUri :rootPath :path :kind :name :uri :entryKind))))
405+
400406
(defmacro lsp-treemacs-deps-with-jdtls (&rest body)
401407
"Helper macro for invoking BODY against WORKSPACE context."
402408
(declare (debug (form body))
@@ -409,17 +415,17 @@ will be rendered an empty line between them."
409415
(if-let ((dep (-some-> (treemacs-node-at-point)
410416
(button-get :dep))))
411417
(lsp-treemacs--open-file-in-mru
412-
(or (-some-> (gethash "uri" dep)
418+
(or (-some-> (lsp-get dep :uri)
413419
(lsp--uri-to-path))
414-
(when (f-exists? (gethash "path" dep))
415-
(gethash "path" dep))
416-
(concat (f-parent (lsp--uri-to-path (gethash "projectUri" dep)))
417-
(gethash "path" dep))))
420+
(when (f-exists? (lsp-get dep :path))
421+
(lsp-get dep :path))
422+
(concat (f-parent (lsp--uri-to-path (lsp-get dep :projectUri)))
423+
(lsp-get dep :path))))
418424
(user-error "No element under point.")))
419425

420426
(defun lsp-treemacs-deps--icon (dep expanded)
421427
"Get the symbol for the the kind."
422-
(-let (((&hash "uri" "kind" "entryKind" entry-kind) dep))
428+
(-let (((&java:Node :uri :kind :entry-kind) dep))
423429
(concat
424430
(if expanded "" "")
425431
(if (or (= kind 8)
@@ -439,7 +445,7 @@ will be rendered an empty line between them."
439445

440446
(defun lsp-treemacs-deps--get-children (dep)
441447
(lsp-treemacs-deps-with-jdtls
442-
(-let* (((&hash "projectUri" project-uri "rootPath" root-path "path" "kind" "name" "uri") dep)
448+
(-let* (((&java:Node :project-uri :root-path :path :kind :name :uri) dep)
443449
(project-uri (if (eq kind 2) uri project-uri)))
444450
(unless (or (= kind 6)
445451
(= kind 8))
@@ -454,68 +460,64 @@ will be rendered an empty line between them."
454460
(or root-path path)))
455461
("projectUri" project-uri))))
456462
(-mapcat (lambda (inner-dep)
457-
(puthash "projectUri" project-uri inner-dep)
463+
(lsp-put inner-dep :projectUri project-uri)
458464
(when (= kind 4)
459-
(puthash "rootPath" path inner-dep))
460-
(if (eq (gethash "entryKind" inner-dep) 3)
465+
(lsp-put inner-dep :rootPath path))
466+
(if (eq (lsp-get inner-dep :entryKind) 3)
461467
(lsp-treemacs-deps--get-children inner-dep)
462468
(list inner-dep)))))))))
463469

464470
(defun lsp-treemacs-deps--java-file? (dep)
465-
(-let [(&hash "kind" "entryKind" entry-kind) dep]
471+
(-let [(&java:Node :kind :entry-kind) dep]
466472
(and (eq kind 6)
467473
(or (eq entry-kind 1)
468474
(eq entry-kind 2)))))
469475

470476
(treemacs-define-expandable-node lsp-treemacs-deps
471477
:icon-open-form (lsp-treemacs-deps--icon (treemacs-button-get node :dep) t)
472478
:icon-closed-form (lsp-treemacs-deps--icon (treemacs-button-get node :dep) nil)
473-
:query-function (-let (((dep &as &hash "uri") (treemacs-button-get node :dep)))
479+
:query-function (-let (((dep &as &java:Node :uri) (treemacs-button-get node :dep)))
474480
(if (lsp-treemacs-deps--java-file? dep)
475481
(lsp-treemacs-deps-with-jdtls
476482
(lsp-request "textDocument/documentSymbol"
477483
(lsp-make-document-symbol-params :text-document
478484
(lsp-make-text-document-item :uri uri))))
479485
(lsp-treemacs-deps--get-children dep)))
480486
:ret-action 'lsp-treemacs-deps--goto-element
481-
:render-action (if (lsp-treemacs-deps--java-file? (treemacs-button-get node :dep))
487+
:render-action (-let (((&java:Node :name :uri :path) item))
488+
(if (lsp-treemacs-deps--java-file? (treemacs-button-get node :dep))
489+
(treemacs-render-node
490+
:icon (lsp-treemacs--symbol-icon item nil)
491+
:label-form (propertize name 'face 'default)
492+
:state treemacs-lsp-symbol-closed-state
493+
:key-form (list name uri path)
494+
:more-properties (:symbol item))
482495
(treemacs-render-node
483-
:icon (lsp-treemacs--symbol-icon item nil)
484-
:label-form (propertize (gethash "name" item) 'face 'default)
485-
:state treemacs-lsp-symbol-closed-state
486-
:key-form (list (gethash "name" item)
487-
(gethash "uri" item)
488-
(gethash "path" item))
489-
:more-properties (:symbol item))
490-
(treemacs-render-node
491-
:icon (lsp-treemacs-deps--icon item nil)
492-
:label-form (propertize (gethash "name" item) 'face 'default)
493-
:state treemacs-lsp-treemacs-deps-closed-state
494-
:key-form (list (gethash "name" item)
495-
(gethash "uri" item)
496-
(gethash "path" item))
497-
:more-properties (:dep item))))
496+
:icon (lsp-treemacs-deps--icon item nil)
497+
:label-form (propertize name 'face 'default)
498+
:state treemacs-lsp-treemacs-deps-closed-state
499+
:key-form (list name uri path)
500+
:more-properties (:dep item)))))
498501

499502
(defun lsp-treemacs-deps--root-folders ()
500503
(lsp-treemacs-deps-with-jdtls
501504
(-mapcat (lambda (root-path)
502505
(let ((project-uri (lsp--path-to-uri root-path)))
503506
(->> project-uri
504507
(lsp-send-execute-command "java.project.list")
505-
(--map (--doto it (puthash "projectUri" project-uri it))))))
508+
(--map (--doto it (lsp-put it :projectUri project-uri))))))
506509
(lsp-session-folders (lsp-session)))))
507510

508511
(treemacs-define-variadic-node lsp-treemacs-deps-list
509512
:query-function (lsp-treemacs-deps--root-folders)
510513
:render-action
511-
(treemacs-render-node
512-
:icon (lsp-treemacs-deps--icon item nil)
513-
:label-form (propertize (gethash "name" item) 'face 'default)
514-
:state treemacs-lsp-treemacs-deps-closed-state
515-
:key-form (list (gethash "name" item)
516-
(gethash "uri" item)
517-
(gethash "path" item))
518-
:more-properties (:dep item))
514+
(-let (((&java:Node :name :uri :path) item))
515+
(treemacs-render-node
516+
:icon (lsp-treemacs-deps--icon item nil)
517+
:label-form (propertize name 'face 'default)
518+
:state treemacs-lsp-treemacs-deps-closed-state
519+
:key-form (list name uri path)
520+
:more-properties (:dep item)))
519521
:root-key-form 'LSP-Java-Dependency)
520522

521523
(defun lsp-treemacs-java-deps-refresh ()
@@ -578,7 +580,7 @@ will be rendered an empty line between them."
578580
(get-buffer-window)
579581
(marker-position
580582
(-reduce-from
581-
(-lambda (node (&hash "path" "name" "uri"))
583+
(-lambda (node (&java:Node :path :name :uri))
582584
(unless (treemacs-is-node-expanded? node)
583585
(save-excursion
584586
(goto-char (marker-position node))
@@ -590,7 +592,6 @@ will be rendered an empty line between them."
590592
(get-buffer-window)))
591593
(recenter nil))))
592594

593-
594595

595596
;; treemacs synchronization
596597

0 commit comments

Comments
 (0)