-
Notifications
You must be signed in to change notification settings - Fork 89
VSCODE-79: move playground to the language server #53
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
VSCODE-79: move playground to the language server #53
Conversation
Hey @imlucas, after our whiteboarding meeting, I have realized, that I need to try it right away, instead of getting deeper into theory. It will help me to better understand the concept. This is how I see the moving of playground to the language server. And what do you think about using CliServiceProvider instead of DataService? Looking forward to your feedback. |
faa4460
to
b4ce48e
Compare
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.
Awesome. One comment on error messaging, and one on infinite loops then should be good to go.
This runs smooth on my local - I think using the cli service provider is fine, I don't think there should be any limitations?
I think one of the benefits of running on a separate process is protection from infinite loops. Should we look at how we can handle those in a new ticket? Currently if the server gets locked up it's kind of silently failing. I'm thinking maybe we can have a series of messaging when executing playgrounds to ensure first that the server is ready to run a command before trying to run it. That way we can timeout or cancel a playground if the server is already locked up.
I have noticed that the "Extension + Server Inspector" and "Attach to Language Server" runners from Launch file do not work.
Anything we should do here? I haven't used that feature before.
/** | ||
* Opens the MongoDB playground | ||
*/ | ||
export async function openPlayground(docUri: vscode.Uri) { |
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.
Is this used elsewhere - or can we remove export
(so lint can pick up if we stop using it).
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.
Removing it!
src/language/server.ts
Outdated
await CliServiceProvider.connect(params.connectionString, connectionOptions) | ||
); | ||
|
||
return await runtime.evaluate(params.codeToEvaluate); |
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.
I think we could move the evaluate
call into a separate try
from the connection that way a code error can be better handled. Currently if there's an error in a playground's code, like calling a method that doesn't exist the error message is Unable to connect to MongoDB instance. Make sure it is started correctly.
. Does the runtime throw an error that we can use?
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.
Removed try-catch at all, since they are being caught in the playground controller anyway.
Created a ticket for cancellation token: https://jira.mongodb.org/browse/VSCODE-82 |
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.
lgtm. This is a good step to getting some functionality using a language server. Thanks for creating that ticket on interrupting the server on a long task - I think we can get a good user experience out of it.
Description
In this PR I added instantiation of Language Server to the mdbExtensionController and moved playground execution to this Language Server.
The playground makes a call to the Language Server Client and sends two parameters: code that needs to be evaluated and driverUrl.
The Language Server Client sends a request with these values to the Language Server Server.
Looks like we can't use DataService in the Language Server Server. Probably because it extends from EventEmitter. But we can use CliServiceProvider from '@mongosh/service-provider-server' instead. It accepts 2 params driverUrl and driverOptions. It provides similar methods as DataService does: https://github.com/mongodb-js/mongosh/blob/master/packages/service-provider-server/src/cli-service-provider.ts. Please let me know if you have any objections? The investigation ticket was created: https://jira.mongodb.org/browse/VSCODE-81
I have noticed that the "Extension + Server Inspector" and "Attach to Language Server" runners from Launch file do not work. The first thing it should be 6009 instead of 6005, but even if I change it, Vscode complains anyway that a connection is refused.
Moved code from the
activate
method of the Language Server to theconstructor
in order to setthis.client
value in the constructor and get rid of later checks on undefined in each method with sendRequest.Checklist
Motivation and Context
Types of changes