-
Notifications
You must be signed in to change notification settings - Fork 11
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
Multiple LS server instances per workspace #25
Conversation
a22f720
to
654c683
Compare
I think there is no certain need to run one language server per C/C++project, because clangd determines the respective compile_comands.json for each project file. Either by defining a path to it in a .clangd file in the source folder or by copying the compile_commands.json from build folder into the source tree after building. These actions should be part of the toolchain and/or builder. |
9a805b4
to
c029313
Compare
bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/server/ICompileCommandsDirLocator.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.cdt.lsp.editor.ui/src/org/eclipse/cdt/lsp/editor/ui/LspEditorUiPlugin.java
Show resolved
Hide resolved
...lipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/server/CompileCommandsDirLocatorRegistry.java
Outdated
Show resolved
Hide resolved
...lipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/server/CompileCommandsDirLocatorRegistry.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/internal/server/RegistryBase.java
Outdated
Show resolved
Hide resolved
....cdt.lsp.editor.ui/src/org/eclipse/cdt/lsp/editor/ui/preference/LsPreferenceInitializer.java
Show resolved
Hide resolved
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.preferences.IEclipsePreferences; | ||
|
||
public class PropertiesCompileCommandsDirLocator implements ICompileCommandsDirLocator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this class was an OSGi component, it could just bind required IWorkspace service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seem to be not a simple add:
@Reference
private IWorkspace workspace;
does not work. (from doc https://help.eclipse.org/latest/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IWorkspace.html)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also when adding @ Component:
@Component
public class PropertiesCompileCommandsDirLocator implements ICompileCommandsDirLocator {
@Reference
private IWorkspace workspace;
I think it has something to do how the class is instantiated by org.eclipse.core.runtime.IConfigurationElement.createExecutableExtension(String)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seem to be not a simple add
Yes, you are right, it requires a bit deeper redesign. We need to:
- define an interface that does what we need
- provide implementation for this interface via
@Component
- obtain in instance of this interface and use it
For 1) I would expect an interface that has a method similar with current LSPPlugin#getCompileCommandsDirLocators
, like
public interface CompileCommandsLocations {
List<CompileCommandsLocation> locations();
}
that uses
public interface CompileCommandsLocation {
Optional<IPath> resolve(URI document);
}
Then 2) in this case we may add one component to implement CompileCommandsLocations
(currently it is CompileCommandsDirLocatorRegistry
) and a few components to implement CompileCommandsLocation
(currently it is PropertiesCompileCommandsDirLocator
). We may optionally keep extension point as an alternative way to fulfill CompileCommandsLocations
And, 3) we can use ServiceCaller
to interact with an instance of CompileCommandsLocations
interface. No need to have these public synchronized methods in *Plugin classes. No need to obtain and keep an instance of IWorkspace
...tor.ui/src/org/eclipse/cdt/lsp/editor/ui/properties/PropertiesCompileCommandsDirLocator.java
Show resolved
Hide resolved
ServiceTracker<IWorkspace, IWorkspace> workspaceTracker = new ServiceTracker<>(context, IWorkspace.class, null); | ||
workspaceTracker.open(); | ||
workspace = workspaceTracker.getService(); | ||
getCLanguageServerProvider(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have a mix of low level OSGi API with public accessors to stateful activator. It looks more consistent to use OSGi components for CLanguageServerRegistry
and CompileCommandsDirLocatorRegistry
c029313
to
27e06c0
Compare
I've to find a solution for opening external files (e.g. system header files) which will be opened by LSP4E in case of a Go-to-declaration event (F3). Currently LSP4E starts a new server for every external file. This server has no idea where to find a compile_commands.json since there is no in the system include path. My initial approach to change the LSP4E behavior in a way that external files will be opened in the same server context as the origin file has been rejected, because it's too server specific. A possible solution has been proposed here by @ddscharfe |
This comment was marked as duplicate.
This comment was marked as duplicate.
Shouldn't it go to PR description? |
@ghentschke should I try to restart this work using current state of the code? |
Any work is appreciated here! As I wrote yesterday, there should be some work done on LSP4E to support multiple language server properly. See LSP4E issue #694 |
A solution for the The external file problem for multiple servers could be solved by setting the path to the compile_commands.json in the clangd |
@ghentschke is it still relevant? |
No, I think this feature has actually a very low priority. And I cannot see any advantage of multiple LS per workspace anymore. |
This PR would be a basic implementation for #43