Yes thanks a lot! It is working now.
What I did is this (it is a little bit hacky because I desired a quick solution):
Create a custom WorkspaceManager:
I extended the WorkspaceManager overriding the initialize method so that it includes the desired workspacefolder by default
class CustomWorkspaceManager extends WorkspaceManager {
static final Logger LOG = Logger::getLogger(typeof(CustomWorkspaceManager))
@Inject UriExtensions uriExtensions
override void initialize(List<WorkspaceFolder> workspaceFolders,
Procedure2<? super URI, ? super Iterable<Issue>> issueAcceptor, CancelIndicator cancelIndicator) {
val _workspaceFolders = new ArrayList(workspaceFolders)
val mydslHome = System.getenv("MYDSL_HOME")
if (mydslHome === null) {
LOG.warn("the system env MYDSL_HOME is not set")
} else {
val mydslHomeDir = new File(mydslHome)
val uri = uriExtensions.toUriString(mydslHomeDir.toURI)
_workspaceFolders += new WorkspaceFolder(uri, "mydsllib")
}
super.initialize(_workspaceFolders, issueAcceptor, cancelIndicator)
}
}
Create a custom ProjectDescriptionFactory:
Here I add the dependency to the library-project which is inside the workspace by default (see above).
The dependency is only added when it is not the library-project itself.
class MyDslProjectDescriptionFactory implements IProjectDescriptionFactory {
override getProjectDescription(IProjectConfig config) {
val result = new ProjectDescription();
result.setName(config.getName());
if (config.name != "mydsllib") {
result.dependencies += "mydsllib"
}
return result;
}
}
Create a custom ServerModule that binds the MyDslProjectDescriptionFactory and the CustomWorkspaceManager:
Here the custom ProjectDescriptionFactory instead of the Default one is bound.
And the CustomWorkspaceManager instead of the default one is bound
class MyDslServerModule extends AbstractModule {
override protected configure() {
binder.bind(ExecutorService).toProvider(ExecutorServiceProvider)
bind(LanguageServer).to(LanguageServerImpl)
bind(IResourceServiceProvider.Registry).toProvider(ResourceServiceProviderServiceLoader)
bind(IWorkspaceConfigFactory).to(ProjectWorkspaceConfigFactory)
bind(ProjectWorkspaceConfigFactory).to(MultiRootWorkspaceConfigFactory)
// custom factory for project descriptions as specified above
bind(IProjectDescriptionFactory).to(MyDslProjectDescriptionFactory)
bind(IContainer.Manager).to(ProjectDescriptionBasedContainerManager)
// custom workspace manager for WorkspaceFolder initialization
bind(WorkspaceManager).to(CustomWorkspaceManager)
}
}
Load the custom ServerModule in the RunServer:
So the correct injections are used I need to load the new servermodule
public class RunServer {
public static void main(String[] args) throws InterruptedException, IOException {
Injector injector = Guice.createInjector(new MyDslServerModule());
// ... rest stays as before
}
// ...
}
So thanks very much for the leading into the right direction. Everything works as desired now.
[Updated on: Sun, 20 September 2020 07:03]
Report message to a moderator