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

Complete for imported java class

Open rickywu opened this issue 6 years ago • 7 comments

Works well for the method in the same project

image

But if import com.github.pagehelper.PageHelper, then I want to complete method for PageHelper, works well in IDEA, but not popup in coc-java

image

This is IDEA image

rickywu avatar Sep 16 '19 09:09 rickywu

Could be the language server failed to load your .env file or it's getting too slow to response.

chemzqm avatar Sep 16 '19 10:09 chemzqm

@chemzqm Not sure where is the problem, and VS Code works well for 3rd party lib, see this issue https://github.com/eclipse/eclipse.jdt.ls/issues/967

I still have this problem even setup env var for Gradle

rickywu avatar Sep 17 '19 01:09 rickywu

It works as expected for me, try checkout output from language server https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

chemzqm avatar Sep 17 '19 01:09 chemzqm

ls.zip

I found one error about invalid path [Error - 9:50:38 AM] 2019-9-17 9:50:38 Initialization failed Failed to scan D:\emp org.eclipse.core.runtime.CoreException: Failed to scan D:\emp

The correct path should be D:\Work\emp

rickywu avatar Sep 17 '19 01:09 rickywu

@chemzqm the same project but got diff rootPath, I think this is the problem

WSL:

"rootPath": "/mnt/d/Work/ops",
"rootUri": "file:///mnt/d/Work/ops",

Windows:

"rootPath": "d:\\Work\\ops\\src\\main\\java\\com\\xxx\\ops\\controller",
"rootUri": "file:///d%3A/Work/ops/src/main/java/com/xxx/ops/controller",

rickywu avatar Sep 17 '19 10:09 rickywu

Unlike vscode-java, coc-java doesn't have support for wsl.

chemzqm avatar Sep 17 '19 12:09 chemzqm

@chemzqm But WSL works well, Windows got invalid root path

If I use gvim open project on Windows, the messages like this:

D:\Work\ops "src\main\java\com\xxx\controller\BlockIpController.java" [unix] 60L, 2198C [coc.nvim] Using java from d:\Program Files\Java\jdk1.8.0_161, version: 8 [coc.nvim] JDT Language Server starting at ops [coc.nvim] JDT Language Server error Failed to scan D:\ops

Seems the JDT not work on the right workspace, that cause complete not works well

If chdir to project folder in vim, still got JDT Language Server error Failed to scan D:\ops

Finally, I solved this problem by these steps:

  1. use teminal chdir to project folder, open gvim
  2. open source files then JDT can scan for whole project correctly, then can complete for 3rd party class

The problem is I cannot use chdir in vim, otherwise will cause JDT scan failed error, so the rootPath detect mechanism and JDT parameter should be improved to support open project directly in vim when I need to change current workspace

rickywu avatar Sep 18 '19 00:09 rickywu

Use command:

  • java.project.addToSourcePath.command: Add Folder to Java Source Path: adds the selected folder to its project source path.

The workspace root resolve issue should be fixed on coc.nvim.

chemzqm avatar Jan 29 '23 09:01 chemzqm