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

print all parsed LSP tokens as warnings in VScode #1148

Merged
merged 8 commits into from
Apr 7, 2022

Conversation

JoshuaBatty
Copy link
Member

@JoshuaBatty JoshuaBatty commented Apr 5, 2022

This enables a flag to be set when developing and debugging the sway-lsp server. See issue #1123 for more context, but essentially it visually shows the successfully parsed tokens in VSCode. This allows for quickly scanning a bunch of sway files to see what tokens are being ignored by our current implementation of the sway-lsp parser. See the below image for how this looks in the editor when enabled. For example, In the image below we can see that the entire impl block is being ignored.

parsed_tokens_as_warnings

closes #1123

mitchmindtree
mitchmindtree previously approved these changes Apr 5, 2022
Copy link
Contributor

@mitchmindtree mitchmindtree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks handy! LGTM

}

impl Backend {
pub fn new(client: Client) -> Self {
let session = Arc::new(Session::new());
Backend { client, session }
let debug = debug::DebugFlags {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could potentially derive Default for DebugFlags and use debug::DebugFlags::default(); here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think of doing that. This way though it makes it really quick while developing to just set the variable to true and then back to false when you're finished.

@adlerjohn
Copy link
Contributor

Is it possible to make this configurable at run time with a toggle in the Vscode settings page? Under a "debug" or "advanced" section maybe.

@JoshuaBatty
Copy link
Member Author

Is it possible to make this configurable at run time with a toggle in the Vscode settings page? Under a "debug" or "advanced" section maybe.

That's a really good idea. Not sure how to set this up but will look into it today. This method of enabling flags could be really beneficial though going forward!

sezna
sezna previously approved these changes Apr 6, 2022
@JoshuaBatty JoshuaBatty dismissed stale reviews from sezna and mitchmindtree via c38ba72 April 6, 2022 06:47
@JoshuaBatty JoshuaBatty force-pushed the josh/lsp_token_warnings branch from c38ba72 to 8df3ce5 Compare April 6, 2022 06:50
@JoshuaBatty JoshuaBatty marked this pull request as draft April 6, 2022 06:57
@JoshuaBatty JoshuaBatty force-pushed the josh/lsp_token_warnings branch from 1f01423 to 4b07205 Compare April 7, 2022 01:55
@JoshuaBatty
Copy link
Member Author

@adlerjohn this should be good now. I've opened up a PR here that enables this functionality for the VScode plugin as well. Have tested on my end and everything works nicely.

sway-lsp/src/lib.rs Outdated Show resolved Hide resolved
@@ -1966,9 +1966,9 @@ dependencies = [

[[package]]
name = "lsp-types"
version = "0.92.0"
version = "0.92.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the lockfile updated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting local build errors with 0.92.0 after adding #[derive(Default)] for the new DebugFlags struct. updating to 0.92.1 fixed this.

@JoshuaBatty JoshuaBatty merged commit 6d8ff71 into master Apr 7, 2022
@JoshuaBatty JoshuaBatty deleted the josh/lsp_token_warnings branch April 7, 2022 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Visually Debug Parsed Tokens
4 participants