Stream: t-compiler/rust-analyzer

Topic: regexp in rust-analyzer codebase

Coenen Benjamin (Sep 15 2020 at 10:06, on Zulip):

Hello, quick question, is regex allowed in the rust-analyzer codebase ? For example if we want to reformat something like

    a: i32,
    b: i32


(a: i32, b: i32)
Laurențiu (Sep 15 2020 at 11:28, on Zulip):

We pull in regex via tracing-subscriber, but we don't use them to parse or rewrite source code. I'm a bit confused by your example, would that plug into a LSP formatting request, or is it more of a custom command that you end up needing often?

Laurențiu (Sep 15 2020 at 11:29, on Zulip):

There's also SSR, but I don't know if it preserves output whitespace

Jonas Schievink [he/him] (Sep 15 2020 at 11:29, on Zulip):

Sounds more like something that ra_fmt should handle once it exists

Laurențiu (Sep 15 2020 at 11:39, on Zulip):

And that's not valid syntax, is it? We don't handle it very well.


Coenen Benjamin (Sep 15 2020 at 11:55, on Zulip):

Sorry for delay, in fact it's to fix this issue

Lukas Wirth (Sep 15 2020 at 12:02, on Zulip):

Shouldn't it be enough to reconstruct the function signature with just your usual expected whitespaces between the parameters? Regex seems a bit too much for this in my eyes, though that might be personal preference :sweat_smile:

Coenen Benjamin (Sep 15 2020 at 12:51, on Zulip):

Yes maybe it could be an idea, I will think about that and try to find better solution. IMO regex is clearly too much, due to this question and to have some other solutions. Thanks for your help :)

Last update: Jul 28 2021 at 03:45UTC