Skip to content
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

VS Code client for Mo|E using LSP #40

Closed
CSchoel opened this issue Jun 8, 2021 · 8 comments
Closed

VS Code client for Mo|E using LSP #40

CSchoel opened this issue Jun 8, 2021 · 8 comments
Assignees

Comments

@CSchoel
Copy link
Contributor

CSchoel commented Jun 8, 2021

After our discussion yesterday I thought a little more about the pros and cons of a VS Code extension. I can fully understand why you would like to have one for testing. I still think that the development effort would detract too much from the core server features, but maybe I can offer you to develop the client myself while you are working on the server. I did some first experiments yesterday and got a "hello world"-version of the extension running in a few hours, so I think it could be realistic to have a first working version on Friday evening. From my point of view this would have the following benefits:

  • It would incentivize you to design and document a well-defined interface for your LSP calls. Basically I could replace the second team that was initially planned for this SWTP project. 😆
  • It would allow you to do "real-world" tests of your server and give you a better sense of how LSP is supposed to work normally (i.e. which messages are sent on which occasions) without increasing your workload.

Let me know what you think.

If you do not have any objections, I would continue the development on Friday and add the client as a public repository to the group.

@CSchoel CSchoel self-assigned this Jun 8, 2021
@manuEbg
Copy link
Contributor

manuEbg commented Jun 9, 2021

We think this would be really great!
Especially since this would allow us to check if we return the Errors and Completions the right way. So that they are correctly interpreted by a working LSP client.

@CSchoel
Copy link
Contributor Author

CSchoel commented Jun 10, 2021

On it. 👍

Yesterday evening I used a bit of my spare time after work to implement a diagnostic server in MopeSWTP-SS21/LSP4J-test-CS, which logs all the messages it receives from the client.

The client itself is still in the "Hello World"-stage and I therefore have not published it yet, but I think I will be able to do so tomorrow.

Side note and question to all of you who might be more familiar with the LSP protocol than me: Do you know what happens, when I add a folder to my workspace on the client side of LSP? Currently, this is an operation that crashes my client - I guess because the server does not implement some relevant message type or answers with a null result where it shouldn't. I suspect it could have something to do with the ServerCapabilities object. Unfortunately there is no clear error message and the only message I see from the client is the shutdown message.

@manuEbg
Copy link
Contributor

manuEbg commented Jun 10, 2021

I am not sure what actually happens during workspace changes.

But i think the Idea is that the Client sends a didChangeWorkspaceFolders Notification to the Server so the server might load the files of the new workspace (https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_didChangeWorkspaceFolders)

From my understanding this notification should only be sent if the server specified that in ServerCapabilities, which needs to be returned in the InitializeResult during InitializeRequest. You are not doing that, so... no Idea:)

@CSchoel
Copy link
Contributor Author

CSchoel commented Jun 10, 2021

I think we are both on the right track: Adding the capabilities in the initialize call did allow me to log the didChangeWorkspaceFolders event, but the client still shuts down the server. Seems like I have to learn how to define breakpoints in the vscode-languageclient package. 🤔

@CSchoel
Copy link
Contributor Author

CSchoel commented Jun 11, 2021

As promised, you can now find the first version of the extension in MopeSWTP-SS21/vs-code-client including a README that explains how to setup a connection between client and server. I have not currently tested the extension with your Mo|E server, but only with the new DiagnosticServer implemented in MopeSWTP-SS21/LSP4J-test-CS.

Current features:

  • Activate via Mo|E: connect command (allows to choose port)
  • Deactivate via Mo|E: disconnect command
  • Send change events for .mo files opened in the editor
  • Send a loadModel request using the Mo|E: loadModel command

The error due to adding workspace folders still persists. I will open a separate issue for this.

@CSchoel
Copy link
Contributor Author

CSchoel commented Jun 11, 2021

Update: Issue has been created here: MopeSWTP-SS21/LSP4J-test-CS#2 (I suspect the error is on the server side.)

@CSchoel
Copy link
Contributor Author

CSchoel commented Jun 28, 2021

This issue is still open, because it needs a review. I want to be sure that somebody else besides me can start and use the client. 😉

Hopefully #51 will provide a test case.

@manuEbg
Copy link
Contributor

manuEbg commented Jul 7, 2021

I managed to connect the VSCode-Client with our MopeServer (see #51) . I didn't have a lot problems:)

@manuEbg manuEbg closed this as completed Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants