Skip to content

feat: Export lsp servers - #278

Merged
angelozerr merged 70 commits into
redhat-developer:mainfrom
MituuZ:export-lsp-servers
May 31, 2024
Merged

angelozerr merged 70 commits into
redhat-developer:mainfrom
MituuZ:export-lsp-servers

Conversation

@MituuZ

@MituuZ MituuZ commented May 5, 2024

Copy link
Copy Markdown
Contributor

Fixes #213

This is still a rough draft.

Created handling for exporting a single zip that contains a folder for each exported language server.

Would there be existing ways to get the json representations for the wanted files (template.json file + settings.json + initializationOptions.json)?
The gson output was not correct so I'm guessing the json creation needs to be implemented in a more manual way.

Would the README be a static file on the root of the zip file or should each ls have its own?

There wasn't handling for selecting multiple language servers so I split the handling quick and dirty. I guess deleting multiple servers at once could be implemented later.

@codecov

codecov Bot commented May 5, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 40.10554% with 227 lines in your changes are missing coverage. Please review.

Project coverage is 23.29%. Comparing base (7caac90) to head (aaf58bb).
Report is 6 commits behind head on main.

Files Patch % Lines
...sp4ij/console/explorer/LanguageServerExplorer.java 0.00% 49 Missing ⚠️
...s/lsp4ij/launching/ui/NewLanguageServerDialog.java 0.00% 40 Missing ⚠️
...j/console/explorer/actions/ExportServerAction.java 0.00% 35 Missing ⚠️
...ching/templates/LanguageServerTemplateManager.java 67.46% 21 Missing and 6 partials ⚠️
.../templates/LanguageServerDefinitionSerializer.java 64.51% 18 Missing and 4 partials ⚠️
...ij/server/definition/LanguageServerDefinition.java 53.48% 17 Missing and 3 partials ⚠️
.../templates/LanguageServerTemplateDeserializer.java 60.60% 3 Missing and 10 partials ⚠️
...ols/lsp4ij/launching/ui/ShowInstructionDialog.java 0.00% 13 Missing ⚠️
...ij/launching/templates/LanguageServerTemplate.java 61.90% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #278      +/-   ##
==========================================
+ Coverage   22.42%   23.29%   +0.86%     
==========================================
  Files         245      262      +17     
  Lines        8362     8935     +573     
  Branches     1543     1617      +74     
==========================================
+ Hits         1875     2081     +206     
- Misses       6130     6470     +340     
- Partials      357      384      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@angelozerr

Copy link
Copy Markdown
Contributor

Today we have just one templates json files which is a bad idea.

I think we should delete this files and create a template json file per server hosted on each ls folder.

I speak about templates loaded from classpath.

Your export/import should working with the same structure than the existent loading of templates from classpath

@angelozerr

Copy link
Copy Markdown
Contributor

Would there be existing ways to get the json representations for the wanted files

No it doesnt exist. You will need to implements a serializer. One idea that I suggest is to remove the existing json files which stores all templates and move the template in each ls folder.

The idea is to provide a load method from the template manager which expects a dir folder to load.

You could use this load method to load templates from classpath like today and load templates from a given zip.

The manager should provide a save method which have a list of templates and save each template in a given zip entry which will store templzte.json settings.json etc.

Your export action should loop for selected ls définition a list of instance of template instance loaded from ls definition

@angelozerr

Copy link
Copy Markdown
Contributor

Would the README be a static file on the root of the zip file or should each ls have its own?

As I have try to explain you the README.md should be stored per ls template

@MituuZ

MituuZ commented May 9, 2024 •

Copy link
Copy Markdown
Contributor Author

Gotcha, it'll take a while to get all of this together.

Should this create both, a file type and a file name pattern?

          "fileType": {
            "name": "Rust",
            "patterns": [
              "*.rs"
            ]
          },

Just having a name creates a file type mapping and just having pattern creates a file name pattern. Currently this only creates a file name pattern.

@MituuZ
MituuZ force-pushed the export-lsp-servers branch from 5abd8ea to b8f0968 Compare May 15, 2024 04:10
@MituuZ

MituuZ commented May 15, 2024

Copy link
Copy Markdown
Contributor Author

Still a work in progress, requires cleanup and tests.

Separated the template json to folders.

Added dir selector, and loading template from a directory works and is mapped correctly.

@MituuZ MituuZ changed the title Export lsp servers feat: Export lsp servers May 15, 2024
@MituuZ
MituuZ force-pushed the export-lsp-servers branch 2 times, most recently from ad6bff0 to 64b0245 Compare May 21, 2024 17:10
@MituuZ

MituuZ commented May 21, 2024

Copy link
Copy Markdown
Contributor Author

Handled the instructions as markdown instead of pure html
image

Getting pretty close to finishing this up

@MituuZ

MituuZ commented May 21, 2024

Copy link
Copy Markdown
Contributor Author

Gotcha, it'll take a while to get all of this together.

Should this create both, a file type and a file name pattern?

          "fileType": {
            "name": "Rust",
            "patterns": [
              "*.rs"
            ]
          },

Just having a name creates a file type mapping and just having pattern creates a file name pattern. Currently this only creates a file name pattern.

@angelozerr Is this fine as is or should we get the same json back when doing import and export?

@angelozerr

Copy link
Copy Markdown
Contributor

@angelozerr Is this fine as is or should we get the same json back when doing import and export?

Sorry I don't understand what you mean, import and export should use the same JSOn structure, right?

@MituuZ

MituuZ commented May 21, 2024 •

Copy link
Copy Markdown
Contributor Author

I think that answers my question 👍

So, right now it doesn't handle the case correctly when the template.json has both "name" and "patterns" elements.
Currently it only creates one of them even though the source json has both.

I'll check this out

@angelozerr

Copy link
Copy Markdown
Contributor

If your question is about the structure of the file type, my idea was to save the same information than IJ FileType

With the file type ui settings you can create a file type with a name which is required and after that you can add some association patterns.

In LSP4IJ file patterns is used at first and name after that.

@angelozerr

Copy link
Copy Markdown
Contributor

@MituuZ your PR looks awesome, I review it very quickly.

Whe you think it is ready please tell me and I will play with your PR.

Once your code will be finished, I think it should be good to write a documentation about this great feature at the end of https://github.com/redhat-developer/lsp4ij/blob/main/docs/UserDefinedLanguageServer.md#using-template

@MituuZ

MituuZ commented May 27, 2024

Copy link
Copy Markdown
Contributor Author

My bad. Forgot to update the tests after throwing an error from the import

@angelozerr

Copy link
Copy Markdown
Contributor

This was such a nice suggestion, selecting the "Add new template..." opens a file selector where one can choose a folder to pre-fill the dialog fields with.

When you need great idea for feature, ask to @fbricon :)

Comment thread docs/UserDefinedLanguageServer.md Resolved
Comment thread docs/UserDefinedLanguageServer.md Resolved
Comment thread docs/UserDefinedLanguageServer.md Resolved
Comment thread docs/UserDefinedLanguageServer.md Resolved
@angelozerr

angelozerr commented May 28, 2024 •

Copy link
Copy Markdown
Contributor

@MituuZ why there is a new button without label (on right bottom):

image

It seems that it does the same thing than the round icon help, is it possible to remove this button?

@angelozerr

Copy link
Copy Markdown
Contributor

@MituuZ we have the intention to create a release this weekend.

It would be nice if we could embed your great PR. If you have no time to work on it (fix my suggestions for the documentation) please tell me.

@MituuZ

MituuZ commented May 29, 2024

Copy link
Copy Markdown
Contributor Author

@angelozerr

Hadn't even noticed that button. I'll check it out, I'm sure it can be removed.

I'll try to finish these changes today, but at the latest tomorrow. I'm also able to work on Friday if any tweaking is required, so I'm pretty positive this will be ready on time.

@angelozerr

Copy link
Copy Markdown
Contributor

Hadn't even noticed that button. I'll check it out, I'm sure it can be removed.

Withour your PR, we have not this button:

image

I'll try to finish these changes today, but at the latest tomorrow.

Great! But no stress please! If you have no time to work on the documentation, we could merge it and you could (or me) do that after the release, but we need to remove this strange button.

I'm also able to work on Friday if any tweaking is required, so I'm pretty positive this will be ready on time.

Thanks so much for your great work.

@angelozerr angelozerr added this to the 0.0.2 milestone May 29, 2024
@angelozerr angelozerr added lsp-console enhancement New feature or request labels May 29, 2024
@MituuZ

MituuZ commented May 30, 2024

Copy link
Copy Markdown
Contributor Author

Had to specify the actions which get their own button. When I implemented the help action it created that empty button by default. I just didn't notice it showing up.

Happy to help :)

I'll be doing some studying during the summer and probably dabbling in some other projects too, but as #279 is low prio I could work on that when I have the time

@angelozerr

Copy link
Copy Markdown
Contributor

@MituuZ thanks so much to have improved the doc. IMHO I think we should have relation between Add new template and export . Add new template doesn't add a template but use a custom template to prefill fields. Perhaps a better name should be Load from custom template or Import from custom template ?

Using Import name show the relation between import and export.

@fbricon what do you think about that?

The usecase is:

  • you export language servers
  • you import exported language servers from teh exported zip file.

The documentation doesn't show this usecase and it is hard to know which folder you need to select to import template.

So I think in the custom template section, you should show a new screenshot with the unzipped exported file which select the proper folder. You could say a sentence like, "You can load from a custom template that you have exported (and set a link to the export section).

If you have no time to do that, please tell me, wemerge your PR and I will do the changes.

@angelozerr

Copy link
Copy Markdown
Contributor

Happy to help :)

Thanks so much! Your contribution provides a very professional features.

I'll be doing some studying during the summer and probably dabbling in some other projects too, but as #279 is low prio I could work on that when I have the time

It is a kind issue which provide a more professional behavior of the plugin, it is low prio because I need to work on another features, but if you can work on it, it should be very cool.

@MituuZ

MituuZ commented May 30, 2024

Copy link
Copy Markdown
Contributor Author

I agree with linking the export/import docs and renaming the "Add new template" would make it clearer.

I think I can push new changes this evening.

@MituuZ

MituuZ commented May 30, 2024

Copy link
Copy Markdown
Contributor Author

Tried to make it a bit clearer and have a links to both directions and also prop up the directory structure required.

Also moved the selection string copy to the bundle

@angelozerr

Copy link
Copy Markdown
Contributor

Thanks so much @MituuZ for your great contribution!

I merge your PR because the main feature works pretty well.

We could improve it in another PR like:

  • Show a dialog to notify that N language servers has been exported correctly.
  • Select the exported zip file (instead of unzipped at hand) when we want to import a template
  • Add an error dialog when teh selected folder is a wrong template folder

@angelozerr
angelozerr merged commit aefcbbc into redhat-developer:main May 31, 2024
lagergren added a commit that referenced this pull request Nov 20, 2026
…plate with instructions (#2046)

Part of #1935.

A template can have a `README.md`, its instructions, which the help
button of the New Language Server dialog opens in
`ShowInstructionDialog`, as UserDefinedLanguageServer.md says. Since
fd5aed9 (#278), the dialog's `createActions()` returns OK and Cancel
only, so the dialog had no help button, and the instructions couldn't be
opened. Before that, the button showed for every template, and did
nothing for one without a README.

The dialog has the help button again, and shows it only while its
template has instructions. `getHelpAction()` returns one action, which
`createActions()` and `DialogWrapper` find again, and the dialog keeps
the button that `DialogWrapper` creates for it on its left. In an IDE
without context help, `DialogWrapper` removes help buttons, as for every
other dialog.

Not here: the choice of #1935 between the README of a template and its
docs page. Options B, C and D keep the README, at least for a custom
template, which has no docs page, and so this button; option A would
remove both.

Test: `NewLanguageServerDialogInstructionsTest` loads a template with a
README into the dialog, and one without, and checks that the help button
shows for the first only. It and `NewLanguageServerDialogTransportTest`
pass (17 tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lsp-console

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Export user defined language server as JSON template file

3 participants