From 08756012a5a03a2e5a474768ff1472a4fd2b9a52 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 31 Jul 2021 16:13:15 +0300 Subject: [PATCH] internal: document query implication of completion rendering --- crates/ide_completion/src/render/function.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs index a77dc6dd3d9..95244a758de 100644 --- a/crates/ide_completion/src/render/function.rs +++ b/crates/ide_completion/src/render/function.rs @@ -40,6 +40,20 @@ struct FunctionRender<'a> { name: String, receiver: Option, func: hir::Function, + /// NB: having `ast::Fn` here might or might not be a good idea. The problem + /// with it is that, to get an `ast::`, you want to parse the corresponding + /// source file. So, when flyimport completions suggest a bunch of + /// functions, we spend quite some time parsing many files. + /// + /// We need ast because we want to access parameter names (patterns). We can + /// add them to the hir of the function itself, but parameter names are not + /// something hir cares otherwise. + /// + /// Alternatively we can reconstruct params from the function body, but that + /// would require parsing anyway. + /// + /// It seems that just using `ast` is the best choice -- most of parses + /// should be cached anyway. ast_node: ast::Fn, is_method: bool, }