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

Forc completions sub commands #5671

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

crodas
Copy link
Contributor

@crodas crodas commented Feb 26, 2024

Description

Fixes #5670

Add the ability to generate completions for subcommands

Subcommands may generate completions code optionally.

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.

This is the first part of #5612, which will be split into several smaller PRs
@crodas crodas requested a review from a team February 26, 2024 18:02
@crodas crodas self-assigned this Feb 26, 2024
Copy link

Benchmark for 9bde546

Click to view benchmark
Test Base PR %
code_action 5.1±0.11ms 5.4±0.08ms +5.88%
code_lens 294.6±10.54ns 296.5±12.77ns +0.64%
compile 3.0±0.03s 3.0±0.06s 0.00%
completion 4.6±0.06ms 4.8±0.05ms +4.35%
did_change_with_caching 2.8±0.02s 2.8±0.02s 0.00%
document_symbol 988.0±15.72µs 967.1±34.22µs -2.12%
format 73.3±1.34ms 70.8±1.34ms -3.41%
goto_definition 362.4±7.06µs 376.8±6.28µs +3.97%
highlight 8.8±0.13ms 9.2±0.21ms +4.55%
hover 529.4±7.41µs 546.6±8.37µs +3.25%
idents_at_position 123.6±0.55µs 122.0±0.40µs -1.29%
inlay_hints 653.6±23.25µs 669.4±17.67µs +2.42%
on_enter 483.3±5.91ns 482.9±15.83ns -0.08%
parent_decl_at_position 3.6±0.01ms 3.7±0.02ms +2.78%
prepare_rename 361.5±13.01µs 372.4±19.73µs +3.02%
rename 9.1±0.13ms 9.5±0.13ms +4.40%
semantic_tokens 1076.5±26.78µs 1061.0±24.06µs -1.44%
token_at_position 362.0±2.33µs 363.3±2.71µs +0.36%
tokens_at_position 3.6±0.04ms 3.7±0.03ms +2.78%
tokens_for_file 413.2±2.17µs 415.5±2.20µs +0.56%
traverse 37.3±0.91ms 37.5±1.10ms +0.54%

@crodas crodas enabled auto-merge (squash) February 26, 2024 18:42
The subcommands may generate completions code optionally.

Fixes #5670
@crodas crodas force-pushed the forc-completions-sub-commands branch from 7c95355 to c1d1110 Compare February 26, 2024 18:58
Copy link

Benchmark for fbee83a

Click to view benchmark
Test Base PR %
code_action 5.2±0.09ms 5.3±0.02ms +1.92%
code_lens 290.6±7.77ns 291.1±9.52ns +0.17%
compile 2.9±0.03s 3.0±0.02s +3.45%
completion 4.8±0.20ms 4.9±0.07ms +2.08%
did_change_with_caching 2.9±0.03s 2.9±0.03s 0.00%
document_symbol 972.3±8.51µs 952.3±26.75µs -2.06%
format 73.8±1.36ms 70.3±1.17ms -4.74%
goto_definition 374.1±7.24µs 368.8±4.21µs -1.42%
highlight 8.8±0.19ms 9.1±0.02ms +3.41%
hover 551.6±18.61µs 537.8±7.80µs -2.50%
idents_at_position 123.5±0.65µs 122.0±0.39µs -1.21%
inlay_hints 657.0±19.19µs 675.2±38.81µs +2.77%
on_enter 483.9±13.08ns 476.4±12.56ns -1.55%
parent_decl_at_position 3.6±0.06ms 3.7±0.02ms +2.78%
prepare_rename 366.6±6.32µs 369.5±6.71µs +0.79%
rename 9.2±0.02ms 9.5±0.12ms +3.26%
semantic_tokens 1058.9±10.30µs 1060.3±30.38µs +0.13%
token_at_position 366.3±2.26µs 361.3±3.48µs -1.37%
tokens_at_position 3.6±0.04ms 3.7±0.02ms +2.78%
tokens_for_file 413.5±4.28µs 417.3±1.63µs +0.92%
traverse 38.5±1.44ms 37.8±0.86ms -1.82%

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.

Why is this needed? Can you give some examples of subcommands that aren't working with the completions before?

We should have some unit tests for this. This could be useful: https://docs.rs/completest/0.0.12/completest/

forc-plugins/forc-doc/Cargo.toml Show resolved Hide resolved
@crodas
Copy link
Contributor Author

crodas commented Feb 26, 2024

Can you give some examples of subcommands that aren't working with the completions before?

None of the external subcommand (the plugins) were supported

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.

Enhance forc completions
2 participants