Prototyping a runtime strategy to allow different runtime behaviours in the language server #247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently with our vscode extension, we have 2 instances on the schema poller.. 1 in the vscode extension, that is used for connecting to and listing databases and their properties. The other is in the language server itself, and is used by the language server for database aware features.
The vscode extension brokers messages via the language client for language server to update its own schema poller instance when the connection in the extension is modified.
There are a few problems with this approach;
In this prototype I am;
Creating the concept of a 'Runtime' in the language server
This does make the language server somewhat less client agnostic, as this approach makes it aware of the client that is consuming it.
However it does allow us to configure the language server to manage its own instance of the schema poller, or allow schema updates to be deferred to the consumer.
In the standalone runtime, we construct a schema poller instance and establish a persistent connection to it.
In the extension runtime, we establish a single listener to a
schemaFetched
message, that updates an internal dbSchema instance which the database aware features will use. This message will be dispatched from the vscode extension when it receives an event from its schema poller instance.schema poller:emit('schemaFetched') -> vscode extension:languageServer.sendNotification('schemaFetched', {}) -> language server:onNotification('schemaFetched', (dbSchema) => {})
It would be nice to share the actual schema poller instance that the vscode extension creates between the vscode extension and the language server to avoid the need for having to rebroadcast a message from the extension, but this does not seem possible.. parameters may be passed via the
initializationOptions
, however these are serialized and deserialized, and the event emitter doesn't pick up messages inside of the language server.