Skip to content

Commit 0875601

Browse files
committed
internal: document query implication of completion rendering
1 parent d4e381f commit 0875601

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crates/ide_completion/src/render/function.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ struct FunctionRender<'a> {
4040
name: String,
4141
receiver: Option<hir::Name>,
4242
func: hir::Function,
43+
/// NB: having `ast::Fn` here might or might not be a good idea. The problem
44+
/// with it is that, to get an `ast::`, you want to parse the corresponding
45+
/// source file. So, when flyimport completions suggest a bunch of
46+
/// functions, we spend quite some time parsing many files.
47+
///
48+
/// We need ast because we want to access parameter names (patterns). We can
49+
/// add them to the hir of the function itself, but parameter names are not
50+
/// something hir cares otherwise.
51+
///
52+
/// Alternatively we can reconstruct params from the function body, but that
53+
/// would require parsing anyway.
54+
///
55+
/// It seems that just using `ast` is the best choice -- most of parses
56+
/// should be cached anyway.
4357
ast_node: ast::Fn,
4458
is_method: bool,
4559
}

0 commit comments

Comments
 (0)