Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of several maven projects in the single workspace #311

Open
PavelSosin opened this issue Jul 23, 2017 · 13 comments
Open

Support of several maven projects in the single workspace #311

PavelSosin opened this issue Jul 23, 2017 · 13 comments

Comments

@PavelSosin
Copy link

SAP WebIDE supports workspaces with several maven projects. It causes the situation when initialize is sent for every open project in the workspace to trigger maven build and indexing. Although it doesn't cause any reported error, almost all LSP functions work only for the 1st opened project. Is it limitation caused by LSP implementation or by JDT? In the eclipse IDE environment JDT successfuly serves such configuration.

@fbricon
Copy link
Contributor

fbricon commented Jul 24, 2017

jdt.ls expects https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#initialize to be called once with a root uri, from which the projects are discovered

At the moment though, we're not discovering new projects after that initial initialization call, see #144.

Can you give us more details about your initialization process? How are your projects organized?

@amiramw
Copy link
Contributor

amiramw commented Jul 25, 2017

The setting is one workspace that contains several projects. Each project is an independent reactor. Currently LSP should be restarted whenever wanting to get language services for another project in the workspace.
It is similar to the way eclipse workspace can contain several independent java projects for which language services are available.

@fbricon
Copy link
Contributor

fbricon commented Jul 25, 2017

Ok so this one is tricky. vscode is introducing the concept of multiple root workspaces so we'll have to figure out how to cope with that in jdt.ls.

One basic solution could be to run an instance of jdt.ls per root folder, but you couldn't have workspace resolution between modules of different reactors in the same workspace.

Alternatively, running a single jdt.ls instance for multiple root folders would save on used resources and provide global workspace resolution but that could also be seen as reactors leaking modules to one another. Still, that's the way Eclipse works so it's probably ok.

@aeschli any advice?

@aeschli
Copy link
Contributor

aeschli commented Aug 3, 2017

It would be great if we can support multiple root folders by looking for projects in all of them.
If I understand the current code correctly, the Maven import already scans the folder hierarchy and imports any folder with a pom file. So it should just be an extension to the scanning code.
There's still more work to do of course to support multi roots, but running a single LS would be most efficient.

@amiramw
Copy link
Contributor

amiramw commented Aug 4, 2017

Do you have any idea how other implementations of the LSP (for other languages) treat several projects in a workspace?

@gorkem
Copy link
Contributor

gorkem commented Aug 7, 2017

We probably should have one language server per workspace. I presume the reason for collecting multiple root folders to a workspace is that they are somewhat related and a language server should follow suit. I think we need extensions to LSP to properly support this. Filed microsoft/language-server-protocol#281 to follow up.

@aeschli
Copy link
Contributor

aeschli commented Aug 7, 2017

IMO we should try to avoid multiple servers for the following reasons:

  • performance, double the memory footprint
  • maintainability: Eclipse workspaces means multiple, likely overlapping progress reports, multiple error log files...
  • unhappy user experience towards symbols in shared libraries such as the JRE:
    • duplicated entries in workspace symbols
    • reference/implementers code lens on these elements will be limited to an Eclipse workspace

I don't see any real issues with sharing the same Eclipse workspace for all root folders. Some challenges:

  • Need to pay extra attention to project names as they can need to be unique in a workspace. I'd suggest qualify them with the root name. Project names can show up error messages and, I guess, are used by the maven classpath container.
  • In VSCode, currently, switching from simple folder to multiple folders will result in a new storage area location and therefore a new Eclipse workspace that will be initialized. I'll check what we can do in VSCode to avoid that.

@aeschli
Copy link
Contributor

aeschli commented Aug 7, 2017

@amiramw We try to encourage all language server try to add support so that multiple roots can be supported by the same server. For most languages that works well. The only language I'm aware right now which conclused they need a server per folder approach is C++.

@PavelSosin
Copy link
Author

Personally, I would prefer that "initialize" will refer Workspace root and project type specific functions like build and Symbol table initial building will be triggered by "didOpen" of project meta files like pom.xml, package.json, etc.
IDE has to inform LSP Server that certain project came to scope via didOpen of project meta file - it handles workspace anyway and knows what is the "project" at all. From other hand LSP server implementations knows better what to do in the case of new project is created or existing project meta is updated.

@PavelSosin PavelSosin reopened this Aug 7, 2017
@PavelSosin
Copy link
Author

Sorry, closed by mistake

@gorkem
Copy link
Contributor

gorkem commented Feb 27, 2018

Now that we have multi-root workspaces fully supported is there anything else left here to do ? @fbricon

@ghost
Copy link

ghost commented Mar 18, 2018

@gorkem how it works? run in the root directory?

@tsmaeder
Copy link
Contributor

@fbricon @gorkem I still don't think multi-root support completely covers the case of new projects. They could also be created as a subfolder of a preexisting project (for maven, for example). Methinks the only way to really solve this is to react to the creation of relavant files (pom.xml, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants