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

Refactor: Move import name resolution to Root #5916

Merged
merged 5 commits into from
May 1, 2024

Conversation

jjcnn
Copy link
Contributor

@jjcnn jjcnn commented Apr 25, 2024

Description

Fixes #5913 .

Name resolution for imports and top-level items in module currently happens at the module level, in part by traversing the submodules of the current module.

This PR moves name resolution to the root of the module structure.

This refactoring is needed to enable fixes to the following issues:

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@jjcnn jjcnn requested review from tritao and a team April 25, 2024 09:22
Copy link

Benchmark for afc32de

Click to view benchmark
Test Base PR %
code_action 5.3±0.04ms 5.4±0.24ms +1.89%
code_lens 319.1±7.82ns 299.2±19.41ns -6.24%
compile 6.5±0.08s 6.1±0.06s -6.15%
completion 4.8±0.14ms 4.8±0.05ms 0.00%
did_change_with_caching 6.1±0.11s 6.2±0.13s +1.64%
document_symbol 964.9±23.69µs 1018.4±34.63µs +5.54%
format 77.3±1.26ms 78.6±2.03ms +1.68%
goto_definition 361.6±11.80µs 369.2±4.22µs +2.10%
highlight 8.7±0.05ms 8.8±0.20ms +1.15%
hover 596.1±18.78µs 614.5±32.24µs +3.09%
idents_at_position 123.8±0.26µs 122.8±1.47µs -0.81%
inlay_hints 674.5±7.37µs 662.2±23.53µs -1.82%
on_enter 493.4±11.04ns 519.9±13.51ns +5.37%
parent_decl_at_position 3.6±0.06ms 3.6±0.03ms 0.00%
prepare_rename 361.5±4.60µs 365.0±4.67µs +0.97%
rename 9.3±0.36ms 9.3±0.03ms 0.00%
semantic_tokens 1042.8±11.27µs 1031.4±28.21µs -1.09%
token_at_position 358.2±3.73µs 354.8±4.64µs -0.95%
tokens_at_position 3.6±0.07ms 3.6±0.04ms 0.00%
tokens_for_file 421.2±6.30µs 421.9±12.01µs +0.17%
traverse 50.6±1.95ms 51.4±1.45ms +1.58%

Copy link

Benchmark for 046555a

Click to view benchmark
Test Base PR %
code_action 5.3±0.02ms 6.0±0.19ms +13.21%
code_lens 296.8±14.10ns 290.2±7.66ns -2.22%
compile 6.2±0.14s 6.7±0.09s +8.06%
completion 4.8±0.10ms 5.9±0.41ms +22.92%
did_change_with_caching 6.3±0.17s 6.2±0.13s -1.59%
document_symbol 1024.5±59.05µs 954.4±29.56µs -6.84%
format 78.4±3.69ms 79.3±0.75ms +1.15%
goto_definition 366.4±17.62µs 372.5±12.54µs +1.66%
highlight 8.7±0.04ms 9.1±0.27ms +4.60%
hover 602.4±20.71µs 623.4±34.31µs +3.49%
idents_at_position 122.0±0.48µs 123.1±1.04µs +0.90%
inlay_hints 659.9±38.56µs 680.4±24.93µs +3.11%
on_enter 529.7±89.03ns 495.5±5.48ns -6.46%
parent_decl_at_position 3.6±0.07ms 3.7±0.05ms +2.78%
prepare_rename 364.9±17.10µs 371.4±10.06µs +1.78%
rename 9.2±0.09ms 9.9±0.40ms +7.61%
semantic_tokens 1027.4±12.14µs 1059.8±12.03µs +3.15%
token_at_position 358.5±3.15µs 373.4±5.99µs +4.16%
tokens_at_position 3.6±0.20ms 3.7±0.06ms +2.78%
tokens_for_file 422.8±5.59µs 419.3±1.41µs -0.83%
traverse 50.8±2.07ms 52.3±2.94ms +2.95%

@IGI-111 IGI-111 requested a review from a team April 30, 2024 15:40
Copy link

Benchmark for 50dbfde

Click to view benchmark
Test Base PR %
code_action 5.5±0.07ms 5.5±0.05ms 0.00%
code_lens 329.2±4.71ns 287.2±8.91ns -12.76%
compile 6.2±0.08s 6.4±0.08s +3.23%
completion 5.0±0.11ms 5.1±0.43ms +2.00%
did_change_with_caching 6.3±0.15s 6.3±0.10s 0.00%
document_symbol 991.5±45.60µs 955.9±16.95µs -3.59%
format 70.2±1.10ms 71.3±1.17ms +1.57%
goto_definition 356.7±6.27µs 427.1±3.28µs +19.74%
highlight 9.0±0.02ms 9.1±0.03ms +1.11%
hover 624.6±22.60µs 600.8±17.94µs -3.81%
idents_at_position 123.5±0.34µs 122.8±0.96µs -0.57%
inlay_hints 659.5±20.73µs 666.9±20.75µs +1.12%
on_enter 489.3±3.92ns 490.9±12.69ns +0.33%
parent_decl_at_position 3.7±0.03ms 3.7±0.01ms 0.00%
prepare_rename 354.6±9.74µs 356.0±8.14µs +0.39%
rename 9.6±0.03ms 9.7±0.23ms +1.04%
semantic_tokens 1046.6±36.38µs 1034.5±18.42µs -1.16%
token_at_position 363.5±3.54µs 355.7±2.03µs -2.15%
tokens_at_position 3.7±0.02ms 3.7±0.03ms 0.00%
tokens_for_file 421.0±2.82µs 418.4±1.62µs -0.62%
traverse 51.1±2.65ms 49.6±1.02ms -2.94%

Copy link

Benchmark for 3ec3858

Click to view benchmark
Test Base PR %
code_action 5.4±0.03ms 5.3±0.13ms -1.85%
code_lens 285.2±4.89ns 294.1±8.03ns +3.12%
compile 6.3±0.05s 6.2±0.03s -1.59%
completion 5.0±0.02ms 4.8±0.11ms -4.00%
did_change_with_caching 6.1±0.07s 6.2±0.11s +1.64%
document_symbol 979.8±22.63µs 1026.9±35.57µs +4.81%
format 87.7±1.16ms 86.3±0.74ms -1.60%
goto_definition 365.5±6.20µs 361.9±3.75µs -0.98%
highlight 9.0±0.20ms 8.7±0.02ms -3.33%
hover 606.0±22.96µs 608.2±14.34µs +0.36%
idents_at_position 125.2±0.55µs 124.3±0.69µs -0.72%
inlay_hints 665.4±13.02µs 649.7±21.23µs -2.36%
on_enter 480.0±10.75ns 476.8±11.56ns -0.67%
parent_decl_at_position 3.8±0.04ms 3.6±0.03ms -5.26%
prepare_rename 364.3±6.95µs 359.5±5.44µs -1.32%
rename 9.5±0.17ms 9.2±0.21ms -3.16%
semantic_tokens 1061.8±34.50µs 1043.1±22.00µs -1.76%
token_at_position 364.9±1.63µs 363.2±3.57µs -0.47%
tokens_at_position 3.8±0.04ms 3.6±0.02ms -5.26%
tokens_for_file 427.1±1.56µs 425.5±3.41µs -0.37%
traverse 50.8±1.37ms 50.3±1.60ms -0.98%

@JoshuaBatty JoshuaBatty merged commit 2a98742 into master May 1, 2024
37 checks passed
@JoshuaBatty JoshuaBatty deleted the jjcnn/move-name-resolution-to-root branch May 1, 2024 01:13
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.

Move name resolution to Root
4 participants