diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-12 21:18:14 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-12 21:18:14 +0000 |
commit | eb931c0d9e0877e573622253ae5b05563841037b (patch) | |
tree | 653ef81450a4d39c5b46f98c97c23fa8586dd7f8 /crates/ra_ide_api/src/completion/completion_item.rs | |
parent | e56072bfa3e5af69a4c293a38de6e1350ada3573 (diff) | |
parent | 1ed7fbfc1badd2c2a42b4dc2feb1b4bf7835d3ef (diff) |
Merge #505
505: Inherent methods r=matklad a=flodiebold
This adds resolution, type checking and completion for inherent methods.
The main open question here is the caching, I think. I'm not sure whether we should be caching method resolutions in a more fine grained way (currently we just build a hash map of types -> impl blocks, and iterate through all potential impl blocks when looking for a method).
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_item.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index e7fa967a0..b75d65de3 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -37,6 +37,7 @@ pub enum CompletionItemKind { | |||
37 | Const, | 37 | Const, |
38 | Trait, | 38 | Trait, |
39 | TypeAlias, | 39 | TypeAlias, |
40 | Method, | ||
40 | } | 41 | } |
41 | 42 | ||
42 | #[derive(Debug, PartialEq, Eq)] | 43 | #[derive(Debug, PartialEq, Eq)] |
@@ -183,10 +184,14 @@ impl Builder { | |||
183 | self | 184 | self |
184 | } | 185 | } |
185 | 186 | ||
186 | fn from_function(mut self, ctx: &CompletionContext, function: hir::Function) -> Builder { | 187 | pub(super) fn from_function( |
188 | mut self, | ||
189 | ctx: &CompletionContext, | ||
190 | function: hir::Function, | ||
191 | ) -> Builder { | ||
187 | // If not an import, add parenthesis automatically. | 192 | // If not an import, add parenthesis automatically. |
188 | if ctx.use_item_syntax.is_none() && !ctx.is_call { | 193 | if ctx.use_item_syntax.is_none() && !ctx.is_call { |
189 | if function.signature(ctx.db).args().is_empty() { | 194 | if function.signature(ctx.db).params().is_empty() { |
190 | self.snippet = Some(format!("{}()$0", self.label)); | 195 | self.snippet = Some(format!("{}()$0", self.label)); |
191 | } else { | 196 | } else { |
192 | self.snippet = Some(format!("{}($0)", self.label)); | 197 | self.snippet = Some(format!("{}($0)", self.label)); |