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
Add client-server mode with API #168
Comments
The example how one of the IDEs is handling integration with rflint: |
It would enable us to create restful API service like so (flask used in example):
It could hosted as localhost (and used like in RED example) or in separate docker container |
That is really great idea. Cannot wait to introduce it to our tool 😎 |
@bhirsz if it's possible to do, one nice thing may be passing the RobotFramework ast directly.
This would allow existing language servers to call it without the overhead of actually parsing it again, which I think would be quite nice and would also solve being able to collect data from dirty buffers all at once ;) Do you think that's possible? |
Yes it's possible. Although there are two problems:
It's readed directly from the file (the file is open from disk). But I can think of way of consuming ast in class that is looking for disablers
Regarding this issue currently it's possible to do this:
I could create separate method for testing passed ast, ie |
Maybe pass everything you need then? i.e.:
The detail is that although the filename usually maps to the filesystem, it's also possible to be for some file that wasn't even saved and exists only in-memory. For the config, it'd be nice to load from the filesystem (so, it'd look for something as a
For the in-memory case it'd probably just use the workspace root as the place to load info from. As for the output, a |
In proposed method:
I understand that source is loaded file (or in-memory equivalent). In what format? ie it could be one big string, or list of lines, or some generator.. it's important to know so I can code around it. Would source be always present or only in case if it's only present in memory? filename is then used just for supplying information to warning lines ie:
And as for configuration, we already use config files so we can reuse that. For example we have concept of 'automatic config files' like .editorconfig. If you have |
It can be whatever works best for you... (I think one big string may be more common, but if you need it in a different format that'd be ok too). I think it'd always be present. |
Great ;) |
PR #287 should cover what we discussed. I went with one string for source. Typically we should create instance of Robocop once (ie when opening the project) then supply files for checking: Setup:
Later on:
If I need to add any other code or something is not working (I just created it, I will add tests before release) then let me know. I will also try to add documentation for this API. |
Seems great for me ;) I'm finishing something and I plan on integrating with that API tomorrow... |
I'm testing it here. In general the API seems to work pretty nice, but it is failing on the use-case where I only have in-memory contents. i.e.: even though the in-memory file contents were passed, some checkers still try to load from the disk doing:
-- The other minor is that the line numbers should be 0-based (so, I did apply fixes to those to the copy I'm testing with and it seemed to work well (robocorp/robotframework-lsp@1a061fb) -- I'm not sure it's the best approach in the case for the in-memory contents, so, I'm leaving it up to you how you'd like to tackle those officially ;) Also, do you have a timeline on when an official release with that API would be released? |
Ah right, I've forgot to update that part of the code related with checkers and only in-memory content. All our lines are starting from 1 so I can decrease it by one. What about column / char? Your changes in branch looks quite decent, I can apply them (with some minor changes). I can make release even today - I will try to to apply those changes and create some tests & docs (testing part will probably take more time than developing it..). Do you have any screen shot how it works in IDE? Out of curiosity - if you have any at this point. |
Is it some kind of a standard in linters/lsp or is it how you've written your tool? We decided to use1-based because that's how lines are marked in IDE. Do you need 0-based just for the purpose of the LSP? Then maybe we can just provide you the data how you want to have it but we would keep using 1-based lines. Is that ok? BTW This (the screenshot) looks fantastic :) |
The language server protocol expects 0-based... i.e.: In https://microsoft.github.io/language-server-protocol/specifications/specification-current/ it says: Also, the request is just to change -- Apart from that particular API, you're surely free to have it 1-based and work anyway you'd like internally. |
Yes, since issues_to_lsp_diagnostic is converting between our internal type to external type it's totally fine to have it 0 based here. |
I've created release 1.6 together with above changes |
Folks, Is there any doc guiding us to get this working on vscode? |
Wait a few more hours and then update/install the It should work out of the box (there will be a setting to disable it if you'd rather not use it). |
Client-server mode with API could be used by IDEs or separate programs for file scanning "on the fly" without need to wrap Robocop.
Example:
Returned output would need to be different than std.out (for example json object) so it would be handled by other tools.
The text was updated successfully, but these errors were encountered: