lsp-java icon indicating copy to clipboard operation
lsp-java copied to clipboard

No action found when importing all libraries

Open tobiasBora opened this issue 2 years ago • 1 comments

Describe the bug When I try to run M-x lsp-java-add-import to import automatically libraries (If I understood correctly), I get an error Unable to find action.

I also tried to do M-x lsp-execute-code-action but no code action are linked related to linking:

image

Any idea what I did wrong?

To Reproduce

Copy/paste the file in ~/.emacs.d/init.el:

(condition-case nil
    (require 'use-package)
  (file-error
   (require 'package)
   (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
   (package-initialize)
   (package-refresh-contents)
   (package-install 'use-package)
   (setq use-package-always-ensure t)
   (require 'use-package)))

(use-package projectile)
(use-package flycheck)
(use-package yasnippet :config (yas-global-mode))
(use-package lsp-mode :hook ((lsp-mode . lsp-enable-which-key-integration)))
(use-package hydra)
(use-package company)
(use-package lsp-ui)
(use-package which-key :config (which-key-mode))
(use-package lsp-java :config (add-hook 'java-mode-hook 'lsp))
(use-package dap-mode :after lsp-mode :config (dap-auto-configure-mode))
(use-package dap-java :ensure nil)
(use-package helm-lsp)
(use-package helm
  :config (helm-mode))
(use-package lsp-treemacs)
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages
   '(helm-lsp lsp-java which-key lsp-ui company hydra lsp-mode yasnippet flycheck projectile use-package vterm)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

Then start emacs, create a new project (I used an existing minimalist quarkus project), open a java file, and try to run M-x lsp-java-add-import.

Expected behavior I expect the libraries to be added in the import section.

Logs

Backtrace:

Debugger entered--Lisp error: (error "Unable to find action")
  signal(error ("Unable to find action"))
  error("Unable to find action")
  lsp-java-execute-matching-action("Import '.*'")
  lsp-java-add-import()
  funcall-interactively(lsp-java-add-import)
  call-interactively(lsp-java-add-import record nil)
  command-execute(lsp-java-add-import record)
  execute-extended-command(nil "lsp-java-add-import" nil)
  funcall-interactively(execute-extended-command nil "lsp-java-add-import" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

tobiasBora avatar Jul 03 '22 00:07 tobiasBora

same error. Any suggestions?

cnglen avatar Aug 11 '23 03:08 cnglen