@@ -664,11 +664,17 @@ server."
664664
665665(defun lsp-java--find-project-uri (file-uri )
666666 " Return the java project corresponding FILE-URI."
667- (->> (lsp--uri-to-path file-uri)
668- (lsp-find-workspace 'jdtls )
669- lsp-java--get-project-uris
670- (--filter (s-starts-with? (lsp--uri-to-path it) (lsp--uri-to-path file-uri)))
671- (--max-by (> (length it) (length other)))))
667+ (let ((workspace (lsp-java--current-workspace-or-lose))
668+ (session-folder (lsp-find-session-folder (lsp-session) (buffer-file-name ))))
669+ (with-lsp-workspace workspace
670+ ; ; look for a maven nested project or fallback to the session folder root.
671+ (let ((project-folder (or (->> session-folder
672+ lsp--path-to-uri
673+ (lsp-send-execute-command " che.jdt.ls.extension.mavenProjects" )
674+ (--filter (f-ancestor-of? (lsp--uri-to-path (file-name-as-directory it)) buffer-file-name))
675+ (--max-by (> (length it) (length other))))
676+ (lsp--path-to-uri (file-name-as-directory session-folder)))))
677+ project-folder))))
672678
673679(defun lsp-java--nearest-widget ()
674680 " Return widget at point or next nearest widget."
@@ -682,7 +688,7 @@ server."
682688(defun lsp-java--tree-under-cursor ()
683689 " Get tree under cursor."
684690 (-when-let (widget-under-cursor (lsp-java--nearest-widget))
685- (if (tree-widget-p widget-under-cursor )
691+ (if (tree-widget-p widget-under-cursor)
686692 widget-under-cursor
687693 (widget-get widget-under-cursor :parent ))))
688694
@@ -877,7 +883,7 @@ PROJECT-URI uri of the item."
877883 (buffer-string ))))))
878884 :initialized-fn (lambda (workspace )
879885 (with-lsp-workspace workspace
880- (lsp-java-update-project-uris )))))
886+ (lsp-java-update-user-settings )))))
881887
882888(defun lsp-java-spring-initializr ()
883889 " Emacs frontend for https://start.spring.io/."
0 commit comments