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

Send command across different workspace folders

Open noboruma opened this issue 5 years ago • 6 comments

Hello there,

Thanks for your awesome work. coc-java works great! I am wondering if it is possible to specify another workspace when issuing a command with Coc plugin? Or is there anyway of changing temporarily the workspace folder in use?

The workflow I try to do is: Given that workspaceA and workspaceB are loaded as workspace folders. From workspaceA, I want to goto the definition of a class Foo, but its definition is only available inside workspaceB. I would like to issue the command temporarily on workspaceB instead of workspaceA from a file contained in workspaceA.

Why? jdtls tries to decompile the jar instead of jumping to the code. Even if I configure the thing properly via eclipse, I can see the code of Foo, but it does not point at the source file in workspaceB (it generates a new source file). Which I find annoying, I want to jump inside the other workspace instead.

noboruma avatar Jun 09 '19 10:06 noboruma

Checkout https://github.com/neoclide/coc.nvim/wiki/Using-workspaceFolders

chemzqm avatar Jun 09 '19 10:06 chemzqm

I think it's something that can be implemented by jdt.ls, coc-java can't help since it doesn't parse your code.

chemzqm avatar Jun 09 '19 10:06 chemzqm

@chemzqm thank you for your answers! Regarding workspace folders, I think my setup is working correctly, unless I am missing something obvious? I have 4 different projects, they all work fine individually within the same neovim instance and using the same jdt.ls. Problem comes when I want to go from projectA to projectB. jdtls do not jump to the source code, but show a generated source code (that is identical to the actual source). My current workaround is to copy the word to search from projectA, go on a file in projectB, paste it, trigger goto definition. Is there no better way?

It sounds to me as well that this should be handled by jdt.ls. But I think this is a decision they made to keep the jar file and the source code independent. ie: they want to show the jar content rather than the source, as the source can be modified without the jar being recompiled. So they prefer showing the jar content rather than the source to avoid inconsistency. At least, this is my understanding..

noboruma avatar Jun 09 '19 11:06 noboruma

The language server need to provide such kind of feature, let me know if jdt.ls could.

chemzqm avatar Jun 16 '19 11:06 chemzqm

Isn't this the -data argument? Quoting https://github.com/eclipse/eclipse.jdt.ls:

Choosing a value for -data: the value for your data directory, should be the directory where your active workspace is, and you wish for the java langserver to add in its default files. Should also be the absolute path to this directory, ie., /home/username/workspace

At least with Eclipse (the IDE, not the LS), -data was also used for this purpose, and allowed jumping to other project files if they are defined in .classpath with kind="src": <classpathentry kind="src" path="/a_project"/>

ipkiss42 avatar Oct 14 '20 21:10 ipkiss42

From [email protected], there is shared index support.

Try configurations java.sharedIndexes.enabled and java.sharedIndexes.location

chemzqm avatar Jan 29 '23 06:01 chemzqm