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

Adapt to new location format #1153

Merged
merged 1 commit into from
Oct 1, 2024
Merged

Adapt to new location format #1153

merged 1 commit into from
Oct 1, 2024

Conversation

anderseknert
Copy link
Member

Wow, this took quite some time to finish! But looking at the end result, I'd say it was worth it. Having Roast represent locations as row:col:end_row:end_col means quite a reduction in AST size, and Regal's own JSON AST goes from 12 Mb to 10 Mb (in OPA AST that is 24 Mb for comparison).

Running regal lint bundle is also ~100 ms faster, and improvement of about 5%. Nice!

But this wasn't only about performance. Having end locations available for any node means we can now easily show e.g. violations with a precise location in LSP editors, and won't have to default to end-of-line, as we previously did for most rules. This also meant that we were able to remove all code in Regal that tried to calculate end position based on the text attribute. Nice!

NOTE: this should be merged after anderseknert/roast#11 so that we can depend on a tagged roast version.

@anderseknert anderseknert force-pushed the no-location-text branch 2 times, most recently from f8d0407 to 9c4dd67 Compare October 1, 2024 08:05
mem.pprof Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Presume this was not meant to be committed.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was left to see if someone would actually scroll through :P No, thanks! Removing before merge.

Copy link
Member

@charlieegan3 charlieegan3 left a comment

Choose a reason for hiding this comment

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

Great work! this is a really nice improvement

Wow, this took quite some time to finish! But looking at the end
result, I'd say it was worth it. Having Roast represent locations
as `row:col:end_row:end_col` means quite a reduction in AST size,
and Regal's own JSON AST goes from 12 Mb to 10 Mb (in OPA AST that
is 24 Mb for comparison).

Running `regal lint bundle` is also ~100 ms faster, and improvement
of about 5%. Nice!

But this wasn't only about performance. Having end locations available
for any node means we can now easily show e.g. violations with a precise
location in LSP editors, and won't have to default to end-of-line, as
we previously did for most rules. This also meant that we were able to
remove all code in Regal that tried to calculate end position based
on the text attribute. Nice!

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert anderseknert merged commit 4a97b56 into main Oct 1, 2024
4 checks passed
@anderseknert anderseknert deleted the no-location-text branch October 1, 2024 09:11
srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
Wow, this took quite some time to finish! But looking at the end
result, I'd say it was worth it. Having Roast represent locations
as `row:col:end_row:end_col` means quite a reduction in AST size,
and Regal's own JSON AST goes from 12 Mb to 10 Mb (in OPA AST that
is 24 Mb for comparison).

Running `regal lint bundle` is also ~100 ms faster, and improvement
of about 5%. Nice!

But this wasn't only about performance. Having end locations available
for any node means we can now easily show e.g. violations with a precise
location in LSP editors, and won't have to default to end-of-line, as
we previously did for most rules. This also meant that we were able to
remove all code in Regal that tried to calculate end position based
on the text attribute. Nice!

Signed-off-by: Anders Eknert <anders@styra.com>
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

Successfully merging this pull request may close these issues.

2 participants