rust-analyzer/crates
bors[bot] 0ac7a19d0c
Merge #8008
8008: Completion context expected type r=matklad a=JoshMcguigan

Currently there are two ways completions use to determine the expected type. There is the `expected_type` field on the `CompletionContext`, as well as the `expected_name_and_type` method on the `RenderContext`. These two things returned slightly different results, and their results were only valid if you had pre-checked some (undocumented) invariants. A simple combination of the two approaches doesn't work because they are both too willing to go far up the syntax tree to find something that fits what they are looking for.

This PR makes the following changes:

1. Updates the algorithm that sets `expected_type` on `CompletionContext`
2. Adds `expected_name` field to `CompletionContext`
3. Re-writes the `expected_name_and_type` method to simply return the underlying fields from `CompletionContext` (I'd like to save actually removing this method for a follow up PR just to keep the scope of the changes down)
4. Adds unit tests for the `expected_type`/`expected_name` fields

All the existing unit tests still pass (unmodified), but this new algorithm certainly has some gaps (although I believe all the `FIXME` introduced in this PR are also flaws in the current code). I wanted to stop here and get some feedback though - is this approach fundamentally sound? 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2021-03-15 12:59:47 +00:00
..
base_db Fixed remaining references to AnalysisChange (now: Change) 2021-02-28 12:57:41 +01:00
cfg Add runnables::related_tests 2021-02-27 18:00:17 +03:00
flycheck Bump cargo_metadata 2021-03-02 14:27:29 +02:00
hir Merge #8018 2021-03-15 12:51:27 +00:00
hir_def Simplify source maps for fields 2021-03-15 15:38:50 +03:00
hir_expand some clippy::performance fixes 2021-03-15 10:19:59 +01:00
hir_ty Merge #8018 2021-03-15 12:51:27 +00:00
ide Goto definition works for S { a: } case 2021-03-15 15:12:39 +03:00
ide_assists Allow applying De Morgan's law to multiple terms at once 2021-03-12 10:19:54 -05:00
ide_completion update algorithm for determining expected type of completion 2021-03-15 05:38:19 -07:00
ide_db Merge #8021 #8022 2021-03-15 10:05:49 +00:00
ide_ssr Merge #7961 2021-03-10 17:06:11 +00:00
mbe some clippy::performance fixes 2021-03-15 10:19:59 +01:00
parser Fix remaining references to cargo xtask codegen 2021-03-12 15:10:33 +01:00
paths Document paths items 2021-01-22 15:38:33 +01:00
proc_macro_api some clippy::performance fixes 2021-03-15 10:19:59 +01:00
proc_macro_srv Compilation speed 2021-03-09 22:30:58 +03:00
proc_macro_test Add description for crates that will be published 2020-08-24 13:07:22 +02:00
profile add more counts 2021-01-27 12:39:19 +03:00
project_model some clippy::performance fixes 2021-03-15 10:19:59 +01:00
rust-analyzer Merge #8021 #8022 2021-03-15 10:05:49 +00:00
stdx Cleanup decl_check 2021-02-05 16:09:45 +01:00
syntax Attach trivia to ast::Union nodes 2021-03-14 11:11:01 +01:00
test_utils Use upstream cov-mark 2021-03-08 22:19:44 +02:00
text_edit Avoid turning completion objects into builders 2020-11-16 23:16:41 +02:00
toolchain Add description for crates that will be published 2020-08-24 13:07:22 +02:00
tt add expand log 2021-03-13 20:14:21 +08:00
vfs Fix slow tests sometimes failing 2021-02-12 16:31:16 +01:00
vfs-notify Fix slow tests sometimes failing 2021-02-12 16:31:16 +01:00