rust/crates/syntax/src
bors[bot] 989de9e309
Merge #6172
6172: Add qualify path assist r=matklad a=Veykril

This implements a `qualify_path` assist which works quite similar to the `auto_import` assist but instead of adding imports to the file it well, qualifies the path. This PR also moves out the `AutoImportAssets` struct and functions from `auto_import` into a utils submodule as most of this is now shared between `auto_import` and `qualify_path`.

Changes made to `AutoImportAssets` are solely in its `search_for_imports` function which now takes a prefixed parameter to discern between using `find_use_path_prefixed` and `find_use_path` as the former is the required behavior by `auto_import` and the latter by this assist.

For missing imported traits instead of importing this will qualify the path with a trait cast as in:
```rust
test_mod::TestStruct::TEST_CONST<|>
```
becomes
```rust
<test_mod::TestStruct as test_mod::TestTrait>::TEST_CONST
```

and for trait methods ideally it would do the following:
```rust
let test_struct = test_mod::TestStruct {};
test_struct.test_meth<|>od()
```
becomes
```rust
let test_struct = test_mod::TestStruct {};
test_mod::TestTrait::test_method(&test_struct)
```

Fixes #4124.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-20 17:03:19 +00:00
..
ast Properly qualify trait methods in qualify_path assist 2020-10-15 18:31:33 +02:00
parsing Cleanup 2020-10-07 11:55:20 +02:00
validation
algo.rs Omit lenses for not runnable doctests 2020-08-22 22:03:02 +03:00
ast.rs
display.rs Extract call_info and completion into separate crates 2020-10-18 13:09:00 +03:00
fuzz.rs
lib.rs Extract call_info and completion into separate crates 2020-10-18 13:09:00 +03:00
parsing.rs
ptr.rs Document privacy invariant of SyntaxPtr 2020-10-06 20:06:14 +02:00
syntax_error.rs
syntax_node.rs
tests.rs Switch to expect_test from crates.io 2020-08-21 13:19:31 +02:00
validation.rs Add validation check for ambiguous trait objects 2020-10-06 23:52:00 +02:00