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

Add support for fig completions #5669

Merged
merged 8 commits into from Apr 4, 2024
Merged

Add support for fig completions #5669

merged 8 commits into from Apr 4, 2024

Conversation

crodas
Copy link
Contributor

@crodas crodas commented Feb 26, 2024

Description

This fixes #5474

This is the first part of #5612, which will be split into several smaller PRs

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.

@crodas crodas requested a review from a team February 26, 2024 16:56
@crodas crodas self-assigned this Feb 26, 2024
@crodas crodas enabled auto-merge (squash) February 26, 2024 17:00
Copy link

Benchmark for 2f6d84a

Click to view benchmark
Test Base PR %
code_action 5.2±0.17ms 5.2±0.15ms 0.00%
code_lens 291.6±12.47ns 290.2±10.47ns -0.48%
compile 3.0±0.03s 3.0±0.04s 0.00%
completion 4.8±0.37ms 4.8±0.29ms 0.00%
did_change_with_caching 2.8±0.03s 2.9±0.03s +3.57%
document_symbol 1044.3±62.79µs 973.7±14.36µs -6.76%
format 73.9±1.21ms 73.9±1.60ms 0.00%
goto_definition 368.3±6.43µs 371.4±7.46µs +0.84%
highlight 8.9±0.21ms 8.9±0.36ms 0.00%
hover 538.5±9.24µs 539.5±8.98µs +0.19%
idents_at_position 121.5±0.74µs 124.6±0.78µs +2.55%
inlay_hints 658.7±31.46µs 650.4±18.28µs -1.26%
on_enter 481.5±12.58ns 481.0±14.73ns -0.10%
parent_decl_at_position 3.6±0.05ms 3.6±0.20ms 0.00%
prepare_rename 364.2±7.25µs 363.4±9.00µs -0.22%
rename 9.2±0.22ms 9.2±0.19ms 0.00%
semantic_tokens 1064.6±32.15µs 1048.2±22.03µs -1.54%
token_at_position 372.7±2.83µs 361.9±11.69µs -2.90%
tokens_at_position 3.6±0.08ms 3.6±0.12ms 0.00%
tokens_for_file 412.4±3.05µs 409.7±5.14µs -0.65%
traverse 38.1±0.89ms 38.9±1.19ms +2.10%

forc-plugins/forc-crypto/src/main.rs Outdated Show resolved Hide resolved
Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Could you share the steps for manually testing this with fig?

Is it possible to write unit tests for this? It would be good to assert that the correct autocompletions file is created for each target.

Copy link

Benchmark for 1ee427a

Click to view benchmark
Test Base PR %
code_action 5.2±0.14ms 5.2±0.19ms 0.00%
code_lens 289.9±8.44ns 290.5±10.32ns +0.21%
compile 3.1±0.04s 3.1±0.03s 0.00%
completion 4.9±0.13ms 4.8±0.14ms -2.04%
did_change_with_caching 3.0±0.03s 2.9±0.06s -3.33%
document_symbol 972.1±15.72µs 975.4±8.43µs +0.34%
format 73.5±0.74ms 74.2±0.73ms +0.95%
goto_definition 562.0±6.19µs 374.1±8.58µs -33.43%
highlight 8.9±0.23ms 9.1±0.71ms +2.25%
hover 539.5±7.65µs 547.4±10.29µs +1.46%
idents_at_position 122.4±0.34µs 123.2±1.02µs +0.65%
inlay_hints 664.4±40.79µs 667.6±30.54µs +0.48%
on_enter 495.4±19.34ns 479.6±14.18ns -3.19%
parent_decl_at_position 3.6±0.04ms 3.6±0.05ms 0.00%
prepare_rename 567.7±5.68µs 371.5±8.20µs -34.56%
rename 9.3±0.30ms 9.5±0.13ms +2.15%
semantic_tokens 1064.0±12.34µs 1049.8±16.60µs -1.33%
token_at_position 364.5±2.85µs 360.7±3.19µs -1.04%
tokens_at_position 3.6±0.03ms 3.6±0.03ms 0.00%
tokens_for_file 507.0±3.08µs 421.3±1.80µs -16.90%
traverse 39.1±1.44ms 39.4±0.60ms +0.77%

Copy link

Benchmark for 4d43fde

Click to view benchmark
Test Base PR %
code_action 5.4±0.01ms 5.4±0.02ms 0.00%
code_lens 288.1±7.52ns 287.2±8.19ns -0.31%
compile 6.1±0.10s 6.2±0.08s +1.64%
completion 5.0±0.10ms 5.0±0.03ms 0.00%
did_change_with_caching 5.5±0.14s 5.6±0.13s +1.82%
document_symbol 1007.0±37.55µs 1064.8±42.66µs +5.74%
format 70.5±0.99ms 69.9±1.20ms -0.85%
goto_definition 367.8±8.78µs 371.2±5.98µs +0.92%
highlight 9.2±0.13ms 9.1±0.10ms -1.09%
hover 590.8±8.56µs 604.4±15.92µs +2.30%
idents_at_position 122.4±0.40µs 123.4±1.09µs +0.82%
inlay_hints 665.1±18.50µs 672.7±24.20µs +1.14%
on_enter 470.1±18.96ns 482.0±25.34ns +2.53%
parent_decl_at_position 3.7±0.03ms 3.7±0.06ms 0.00%
prepare_rename 362.7±3.97µs 439.5±5.60µs +21.17%
rename 9.6±0.21ms 9.6±0.06ms 0.00%
semantic_tokens 1065.3±18.84µs 1068.4±16.66µs +0.29%
token_at_position 365.6±3.74µs 366.3±2.52µs +0.19%
tokens_at_position 3.7±0.03ms 3.7±0.05ms 0.00%
tokens_for_file 418.7±1.72µs 416.5±1.20µs -0.53%
traverse 44.5±1.38ms 45.1±1.81ms +1.35%

Copy link

Benchmark for 33c14da

Click to view benchmark
Test Base PR %
code_action 5.4±0.15ms 5.4±0.12ms 0.00%
code_lens 288.1±9.15ns 287.8±5.49ns -0.10%
compile 6.0±0.08s 6.0±0.09s 0.00%
completion 4.9±0.12ms 4.9±0.15ms 0.00%
did_change_with_caching 5.4±0.03s 5.5±0.09s +1.85%
document_symbol 1001.4±36.14µs 968.7±49.46µs -3.27%
format 70.0±1.40ms 70.1±0.94ms +0.14%
goto_definition 364.3±3.20µs 367.4±3.81µs +0.85%
highlight 9.1±0.22ms 9.0±0.25ms -1.10%
hover 604.4±40.13µs 594.8±11.12µs -1.59%
idents_at_position 122.1±0.36µs 122.3±1.27µs +0.16%
inlay_hints 674.2±18.37µs 667.2±52.76µs -1.04%
on_enter 483.2±18.65ns 483.3±12.18ns +0.02%
parent_decl_at_position 3.7±0.02ms 3.7±0.06ms 0.00%
prepare_rename 371.5±6.31µs 371.5±10.03µs 0.00%
rename 9.5±0.03ms 9.5±0.26ms 0.00%
semantic_tokens 1037.1±16.93µs 1055.9±19.24µs +1.81%
token_at_position 405.4±2.20µs 369.4±2.37µs -8.88%
tokens_at_position 3.7±0.03ms 3.7±0.07ms 0.00%
tokens_for_file 502.0±10.32µs 414.0±5.60µs -17.53%
traverse 44.1±1.26ms 44.8±1.50ms +1.59%

@crodas
Copy link
Contributor Author

crodas commented Apr 1, 2024

Could you share the steps for manually testing this with fig?

The following command prints the typescript code add completion support (as it was added in a PR)

cargo run -- completions --target fig

A following PR will add support for optional introspection with plugins (I have it working in the old PR)

I also added unit tests and added the foundation for adding more tests for each command (for instance to test the upcoming PR with complete scripts for plugins). It will also skip if a given shell is not supported at runtime.

@crodas crodas requested review from JoshuaBatty, sdankel and a team April 1, 2024 16:46
Copy link

github-actions bot commented Apr 1, 2024

Benchmark for 6ff4eb3

Click to view benchmark
Test Base PR %
code_action 5.5±0.12ms 5.4±0.04ms -1.82%
code_lens 292.7±9.05ns 290.3±13.66ns -0.82%
compile 5.9±0.09s 5.9±0.07s 0.00%
completion 4.9±0.10ms 5.0±0.04ms +2.04%
did_change_with_caching 5.4±0.05s 5.4±0.03s 0.00%
document_symbol 989.9±40.59µs 1043.0±22.44µs +5.36%
format 90.9±1.31ms 88.2±1.96ms -2.97%
goto_definition 361.7±6.33µs 359.7±10.46µs -0.55%
highlight 9.1±0.10ms 9.1±0.27ms 0.00%
hover 610.8±20.51µs 703.7±22.32µs +15.21%
idents_at_position 124.5±0.40µs 122.0±0.70µs -2.01%
inlay_hints 664.0±12.02µs 680.8±54.88µs +2.53%
on_enter 503.9±5.95ns 507.7±14.50ns +0.75%
parent_decl_at_position 3.7±0.02ms 3.7±0.02ms 0.00%
prepare_rename 359.0±2.96µs 355.9±6.63µs -0.86%
rename 9.6±0.13ms 9.6±0.35ms 0.00%
semantic_tokens 1029.2±11.52µs 1043.1±46.35µs +1.35%
token_at_position 356.5±2.09µs 357.3±4.20µs +0.22%
tokens_at_position 3.7±0.04ms 3.7±0.03ms 0.00%
tokens_for_file 409.6±2.89µs 413.9±3.34µs +1.05%
traverse 44.3±1.60ms 44.6±1.74ms +0.68%

@crodas crodas force-pushed the fig-support branch 2 times, most recently from e81558f to ded72b0 Compare April 1, 2024 18:09
Copy link

github-actions bot commented Apr 1, 2024

Benchmark for 45c0a7e

Click to view benchmark
Test Base PR %
code_action 5.5±0.15ms 5.8±0.25ms +5.45%
code_lens 289.3±5.31ns 290.5±7.75ns +0.41%
compile 6.1±0.20s 6.1±0.12s 0.00%
completion 5.0±0.19ms 5.0±0.19ms 0.00%
did_change_with_caching 5.6±0.12s 5.6±0.16s 0.00%
document_symbol 959.0±24.43µs 1021.5±56.95µs +6.52%
format 89.9±1.20ms 87.4±1.41ms -2.78%
goto_definition 355.2±8.26µs 359.4±7.62µs +1.18%
highlight 9.0±0.12ms 9.3±0.25ms +3.33%
hover 615.3±25.51µs 694.4±9.17µs +12.86%
idents_at_position 121.5±1.00µs 122.4±0.36µs +0.74%
inlay_hints 658.5±24.77µs 667.8±20.43µs +1.41%
on_enter 506.9±12.41ns 505.0±42.72ns -0.37%
parent_decl_at_position 3.7±0.06ms 3.8±0.10ms +2.70%
prepare_rename 352.1±6.36µs 355.1±17.15µs +0.85%
rename 9.6±0.14ms 9.7±0.27ms +1.04%
semantic_tokens 1031.1±33.37µs 1071.8±18.91µs +3.95%
token_at_position 354.3±3.46µs 356.0±3.27µs +0.48%
tokens_at_position 3.8±0.08ms 3.8±0.11ms 0.00%
tokens_for_file 410.5±3.61µs 410.5±8.42µs 0.00%
traverse 45.6±1.60ms 45.5±1.39ms -0.22%

Copy link

github-actions bot commented Apr 1, 2024

Benchmark for fc5d770

Click to view benchmark
Test Base PR %
code_action 5.5±0.16ms 5.5±0.08ms 0.00%
code_lens 293.2±9.17ns 292.3±8.61ns -0.31%
compile 5.9±0.08s 5.9±0.10s 0.00%
completion 4.9±0.13ms 4.9±0.07ms 0.00%
did_change_with_caching 5.4±0.05s 5.4±0.07s 0.00%
document_symbol 974.5±30.64µs 1027.5±31.10µs +5.44%
format 87.8±1.28ms 86.8±1.12ms -1.14%
goto_definition 352.5±7.08µs 359.4±6.53µs +1.96%
highlight 9.1±0.23ms 9.2±0.13ms +1.10%
hover 609.9±16.30µs 615.3±32.25µs +0.89%
idents_at_position 121.8±0.33µs 122.4±0.61µs +0.49%
inlay_hints 667.5±20.92µs 680.6±34.60µs +1.96%
on_enter 497.3±16.56ns 503.0±16.40ns +1.15%
parent_decl_at_position 3.7±0.03ms 3.7±0.03ms 0.00%
prepare_rename 362.1±31.52µs 358.2±5.53µs -1.08%
rename 9.5±0.07ms 9.6±0.24ms +1.05%
semantic_tokens 1027.0±28.14µs 1067.1±18.96µs +3.90%
token_at_position 352.8±2.86µs 359.8±3.15µs +1.98%
tokens_at_position 3.7±0.02ms 3.7±0.04ms 0.00%
tokens_for_file 408.5±2.75µs 417.3±2.57µs +2.15%
traverse 44.5±1.75ms 44.3±1.55ms -0.45%

JoshuaBatty
JoshuaBatty previously approved these changes Apr 2, 2024
@JoshuaBatty JoshuaBatty requested a review from a team April 2, 2024 00:46
kayagokalp
kayagokalp previously approved these changes Apr 2, 2024
Copy link
Member

@kayagokalp kayagokalp left a comment

Choose a reason for hiding this comment

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

Copy link

github-actions bot commented Apr 2, 2024

Benchmark for df2a65f

Click to view benchmark
Test Base PR %
code_action 5.5±0.11ms 5.5±0.15ms 0.00%
code_lens 293.3±5.90ns 293.5±12.00ns +0.07%
compile 6.1±0.10s 6.2±0.11s +1.64%
completion 5.1±0.21ms 4.9±0.10ms -3.92%
did_change_with_caching 5.6±0.09s 5.6±0.11s 0.00%
document_symbol 991.6±45.80µs 1010.1±35.84µs +1.87%
format 89.3±2.39ms 90.5±1.55ms +1.34%
goto_definition 360.1±6.23µs 360.0±12.90µs -0.03%
highlight 9.1±0.11ms 9.1±0.14ms 0.00%
hover 595.8±18.22µs 593.8±4.07µs -0.34%
idents_at_position 122.9±0.41µs 123.1±0.95µs +0.16%
inlay_hints 671.8±19.80µs 664.0±23.50µs -1.16%
on_enter 517.7±20.57ns 501.6±12.91ns -3.11%
parent_decl_at_position 3.7±0.03ms 3.7±0.03ms 0.00%
prepare_rename 363.5±3.91µs 356.7±5.26µs -1.87%
rename 9.7±0.51ms 9.7±0.22ms 0.00%
semantic_tokens 1044.9±33.41µs 1056.8±23.90µs +1.14%
token_at_position 347.4±2.21µs 360.4±2.44µs +3.74%
tokens_at_position 3.7±0.06ms 3.7±0.02ms 0.00%
tokens_for_file 405.9±2.42µs 414.6±7.60µs +2.14%
traverse 45.0±1.65ms 45.3±1.10ms +0.67%

Copy link

github-actions bot commented Apr 2, 2024

Benchmark for 7dcd5b9

Click to view benchmark
Test Base PR %
code_action 5.5±0.07ms 5.5±0.13ms 0.00%
code_lens 292.0±9.86ns 295.3±7.50ns +1.13%
compile 6.1±0.10s 6.1±0.11s 0.00%
completion 5.0±0.05ms 5.1±0.13ms +2.00%
did_change_with_caching 5.6±0.05s 5.6±0.04s 0.00%
document_symbol 959.3±25.84µs 973.4±13.77µs +1.47%
format 91.9±2.61ms 91.3±1.67ms -0.65%
goto_definition 367.0±8.71µs 358.5±5.80µs -2.32%
highlight 9.2±0.36ms 9.2±0.16ms 0.00%
hover 605.4±6.26µs 606.0±23.18µs +0.10%
idents_at_position 123.1±0.77µs 124.3±0.78µs +0.97%
inlay_hints 673.8±9.53µs 678.4±23.66µs +0.68%
on_enter 498.5±7.45ns 504.8±12.10ns +1.26%
parent_decl_at_position 3.7±0.03ms 3.8±0.03ms +2.70%
prepare_rename 364.2±6.23µs 363.6±3.42µs -0.16%
rename 9.6±0.07ms 9.6±0.09ms 0.00%
semantic_tokens 1051.0±21.04µs 1073.0±27.76µs +2.09%
token_at_position 356.0±1.78µs 364.4±3.01µs +2.36%
tokens_at_position 3.8±0.03ms 3.8±0.04ms 0.00%
tokens_for_file 412.6±3.94µs 409.6±2.13µs -0.73%
traverse 45.8±2.12ms 44.8±1.91ms -2.18%

@JoshuaBatty JoshuaBatty dismissed stale reviews from kayagokalp and themself via 8334640 April 3, 2024 23:13
Copy link

github-actions bot commented Apr 3, 2024

Benchmark for a68dd66

Click to view benchmark
Test Base PR %
code_action 5.5±0.08ms 5.5±0.10ms 0.00%
code_lens 291.3±8.32ns 292.9±11.18ns +0.55%
compile 6.0±0.11s 6.0±0.10s 0.00%
completion 5.0±0.09ms 5.0±0.07ms 0.00%
did_change_with_caching 5.4±0.04s 5.6±0.10s +3.70%
document_symbol 983.3±34.81µs 940.8±18.87µs -4.32%
format 91.6±2.40ms 91.8±2.09ms +0.22%
goto_definition 357.6±13.43µs 367.4±15.50µs +2.74%
highlight 9.1±0.02ms 9.2±0.18ms +1.10%
hover 609.7±11.22µs 621.8±13.03µs +1.98%
idents_at_position 123.4±0.67µs 124.0±0.80µs +0.49%
inlay_hints 656.0±20.45µs 664.3±20.95µs +1.27%
on_enter 481.4±10.39ns 483.1±8.29ns +0.35%
parent_decl_at_position 3.7±0.02ms 3.7±0.01ms 0.00%
prepare_rename 356.9±6.81µs 360.2±7.80µs +0.92%
rename 9.7±0.21ms 9.7±0.12ms 0.00%
semantic_tokens 1048.8±20.31µs 1030.1±21.76µs -1.78%
token_at_position 353.3±5.16µs 356.7±6.54µs +0.96%
tokens_at_position 3.7±0.13ms 3.7±0.02ms 0.00%
tokens_for_file 435.1±4.71µs 409.3±8.73µs -5.93%
traverse 43.7±2.19ms 45.2±1.61ms +3.43%

@crodas crodas dismissed sdankel’s stale review April 4, 2024 18:39

Already fixed

@crodas crodas merged commit bc2e603 into master Apr 4, 2024
36 checks passed
@crodas crodas deleted the fig-support branch April 4, 2024 18:39
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.

fig.io CLI auto-complete for plugins
4 participants