Closed lars-reimann closed 4 months ago
This is working as expected, see here for the intended solution:
We cannot really identify in the ConfigurationProvider
whether we are running inside of a language server (which will eventually make the provider ready) or not. You need to call initialized
explicitly to make the provider ready.
Makes sense, thanks. I'm going to add the initialization of the configuration provider to our createSafeDsServices
function and control this via an optional parameter.
Would it make sense to alter the Yeoman template to include such a parameter? Something like
export function create<%= LanguageName %>Services(context: DefaultSharedModuleContext, options?: ModuleOptions): {
shared: LangiumSharedServices,
<%= LanguageName %>: <%= LanguageName %>Services
} {
const shared = inject(
createDefaultSharedModule(context),
<%= LanguageName %>GeneratedSharedModule
);
const <%= LanguageName %> = inject(
createDefaultModule({ shared }),
<%= LanguageName %>GeneratedModule,
<%= LanguageName %>Module
);
shared.ServiceRegistry.register(<%= LanguageName %>);
registerValidationChecks(<%= LanguageName %>);
if (options?.initializeWithEmptyConfiguration) {
shared.workspace.ConfigurationProvider.initialized({});
}
return { shared, <%= LanguageName %> };
}
interface ModuleOptions {
initializeWithEmptyConfiguration?: boolean
}
Or is this something that should be handled purely by adopters?
We should be able to do something similar to this, yes:
if (!context.connection) {
// We don't run inside of a language server
// Therefore, initialize the configuration provider instantly
shared.workspace.ConfigurationProvider.initialized({});
}
@lars-reimann Do you want to contribute this?
Sure, I'll get to it right away.
After upgrading from langium 3.0.0-next.e78aeba to langium 3.0.0, many of the tests in Safe-DS time out. In particular, it's all tests that validate documents. This happens because some of our validation rules can be turned off using VS Code settings, so they contain code like
The
settingsProvider
is just a thin wrapper around theDefaultConfigurationProvider
and calls itsgetConfiguration
method.➡️ #1388 is likely related to this.
Langium version: 3.0.0 Package name: langium
Steps To Reproduce
Substitute
SafeDs
with some other language in the following code and run the tests withvitest
:Output:
Link to code example:
The current behavior
Tests time out because the service never readies up.
The expected behavior
Tests should pass.