emacs-lsp / lsp-java

lsp-mode :heart: java
https://emacs-lsp.github.io/lsp-java
GNU General Public License v3.0
642 stars 89 forks source link

No definitions found for third party dependencies #321

Closed XiangQingW closed 3 years ago

XiangQingW commented 3 years ago

I'm using the latest melpa packages and latest jdtls, and Xref-find-definitions works well with the Java standard library. However, Xref-find-definitions doesn't work for third-party dependencies, and it will display the error message: No definitions found for **. Thanks. 截屏2021-04-10 下午1 05 22

yyoncho commented 3 years ago

Try M-x lsp-find-definitions. Also, is the rest of functionality working fine, like M-x lsp-describe-thing-at-point .

XiangQingW commented 3 years ago

lsp-find-definitions also doesn't work, and it'll show the error message Not found for **. lsp-describe-thing-at-point works fine with some annotation. Lark20210410-162802

lsp-log as follows:


[Trace - 04:41:42 PM] Sending request 'textDocument/definition - (501)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/bob/java/spring-in-action-5-samples/ch02/tacos/src/main/java/tacos/web/DesignTacoController.java"
  },
  "position": {
    "line": 76,
    "character": 43
  }
}

[Trace - 04:41:42 PM] Received notification 'window/logMessage'.
Params: {
  "message": "2021 4 10 pm. 4:41:42 >> document/definition",
  "type": 3
}

[Trace - 04:41:42 PM] Received response 'textDocument/definition - (501)' in 40ms.
Result: []
yyoncho commented 3 years ago

AFAICS your project has errors, what are they? Also, check if you have picked the proper project root, do M-x lsp-describe-session and check if the project root has pom/Gradle file.

XiangQingW commented 3 years ago

I fix the errors, and then move the demo project from ~/bob/spring-in-action-5-samples/ch02/tacos to ~/bob/tacos, so that the project root is ~/bob/tacos. The lsp-java works as expected. Thank you very much.