[ty] Add "qualify ..." code fix for undefined references#21968
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
crates/ty_ide/src/code_action.rs
Outdated
There was a problem hiding this comment.
This fix here looks off. Any chance we're not using dedent on the source?
| // Request qualifications we could apply to the symbol to make it resolve | ||
| let mut completions = Completions::exactly(db, symbol); | ||
| add_unimported_completions( | ||
| db, | ||
| file, | ||
| parsed, | ||
| scoped, | ||
| |module_name: &ModuleName, symbol: &str| { | ||
| ImportRequest::import(module_name.as_str(), symbol).force() | ||
| }, | ||
| &mut completions, | ||
| ); |
There was a problem hiding this comment.
Do we apply any upper bound on how many actions we show? I'm a bit worried that we now show twice as many code actions in non-trivial cases (e.g. multiple modules exporting the same module), and this can quickly become very noisy for users.
There was a problem hiding this comment.
In practice the "qualify..." options will be much rarer because the implementation refuses to show them if it would require editing your imports. As future work we could look into implementing rust-analyzer's more complex UX where you only ever get "import X" and "qualify X" and then e.g. when you select "import" if there was actually multiple possible imports it brings up a secondary menu to select which one you meant.
* origin/main: Fluent formatting of method chains (#21369) [ty] Avoid stack overflow when calculating inferable typevars (#21971) [ty] Add "qualify ..." code fix for undefined references (#21968) [ty] Use jemalloc on linux (#21975) Update MSRV to 1.90 (#21987) [ty] Improve check enforcing that an overloaded function must have an implementation (#21978) Update actions/checkout digest to 8e8c483 (#21982) [ty] Use `ParamSpec` without the attr for inferable check (#21934) [ty] Emit diagnostic when a type variable with a default is followed by one without a default (#21787)
Summary
If
import warningsexists in the file, we will suggest an edit ofdeprecated -> warnings.deprecatedas "qualify warnings.deprecated"Test Plan
Should test more cases...