diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-31 14:21:31 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-31 14:21:31 +0100 |
commit | e6ec860363a140b8aa3dcaafaf6e9d7327838610 (patch) | |
tree | cacaf711d01ce64074ecf675287ab03c85487ec1 /crates/ide_completion/src/completions.rs | |
parent | e9a797748daa7e25cde66927b8907b2d976201a5 (diff) | |
parent | fb7105a5801ab1d0ede830cd53bbc3ccbf0b5e2c (diff) |
Merge #9039
9039: feat: Complete fields and methods with `self.` prefixed when inside methods r=matklad a=Veykril
![w65NbjkZiG](https://user-images.githubusercontent.com/3757771/119984385-a0111700-bfc1-11eb-9dbf-52fdaa4d72b5.gif)
Closes #7173
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_completion/src/completions.rs')
-rw-r--r-- | crates/ide_completion/src/completions.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/crates/ide_completion/src/completions.rs b/crates/ide_completion/src/completions.rs index 151bf3783..ffdcdc930 100644 --- a/crates/ide_completion/src/completions.rs +++ b/crates/ide_completion/src/completions.rs | |||
@@ -69,18 +69,25 @@ impl Completions { | |||
69 | items.into_iter().for_each(|item| self.add(item.into())) | 69 | items.into_iter().for_each(|item| self.add(item.into())) |
70 | } | 70 | } |
71 | 71 | ||
72 | pub(crate) fn add_field(&mut self, ctx: &CompletionContext, field: hir::Field, ty: &hir::Type) { | 72 | pub(crate) fn add_field( |
73 | let item = render_field(RenderContext::new(ctx), field, ty); | 73 | &mut self, |
74 | ctx: &CompletionContext, | ||
75 | receiver: Option<hir::Name>, | ||
76 | field: hir::Field, | ||
77 | ty: &hir::Type, | ||
78 | ) { | ||
79 | let item = render_field(RenderContext::new(ctx), receiver, field, ty); | ||
74 | self.add(item); | 80 | self.add(item); |
75 | } | 81 | } |
76 | 82 | ||
77 | pub(crate) fn add_tuple_field( | 83 | pub(crate) fn add_tuple_field( |
78 | &mut self, | 84 | &mut self, |
79 | ctx: &CompletionContext, | 85 | ctx: &CompletionContext, |
86 | receiver: Option<hir::Name>, | ||
80 | field: usize, | 87 | field: usize, |
81 | ty: &hir::Type, | 88 | ty: &hir::Type, |
82 | ) { | 89 | ) { |
83 | let item = render_tuple_field(RenderContext::new(ctx), field, ty); | 90 | let item = render_tuple_field(RenderContext::new(ctx), receiver, field, ty); |
84 | self.add(item); | 91 | self.add(item); |
85 | } | 92 | } |
86 | 93 | ||
@@ -132,9 +139,11 @@ impl Completions { | |||
132 | &mut self, | 139 | &mut self, |
133 | ctx: &CompletionContext, | 140 | ctx: &CompletionContext, |
134 | func: hir::Function, | 141 | func: hir::Function, |
142 | receiver: Option<hir::Name>, | ||
135 | local_name: Option<hir::Name>, | 143 | local_name: Option<hir::Name>, |
136 | ) { | 144 | ) { |
137 | if let Some(item) = render_method(RenderContext::new(ctx), None, local_name, func) { | 145 | if let Some(item) = render_method(RenderContext::new(ctx), None, receiver, local_name, func) |
146 | { | ||
138 | self.add(item) | 147 | self.add(item) |
139 | } | 148 | } |
140 | } | 149 | } |