eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
665 stars 61 forks source link

Remove the InitializableService interface #1381

Closed spoenemann closed 4 months ago

spoenemann commented 4 months ago

Repeating my comment from https://github.com/eclipse-langium/langium/pull/1258#discussion_r1492320068:

Looking at it again, I'd rather remove the InitializableService interface: we already have onInitialize and onInitialized events in the LanguageServer service, which are the recommended ways to hook into the LSP lifecycle. The interface is only used by two core framework classes which require to invert the dependency. The interface is not necessary because LanguageServer hard-codes the calls to these classes anyway.

sailingKieler commented 4 months ago

Actually I didn't want to pollute the service interface definitions like ConfigurationProvider and WorkspaceManager with the initialization stuff. In my customer project there's the need for more non-LSP services to be initialized with the workspace folders, so from my point of view the interface describes a standard way to implement that.

I also still have an idea in mind that is about providing an initialization hook via the constructors of DefaultConfigurationProvider and DefaultWorkspaceManager (and probably others), similar to the language server-based approach, but I didn't get to trying that, yet.

I don't have a strong opinion here.

spoenemann commented 4 months ago

In my customer project there's the need for more non-LSP services to be initialized with the workspace folders, so from my point of view the interface describes a standard way to implement that.

Do you need to separate the core part from the lsp part in that project? If not, you can simply inject LanguageServer in those non-LSP services and use the onInitialize event. IMO that is much cleaner because it puts the dependency in the right direction: from event consumer to event producer.

spoenemann commented 4 months ago

I added a change to avoid problems during initialization: WorkspaceManager and ConfigurationProvider run their initialized hook in parallel.