Skip to content

Commit 07c7f35

Browse files
bors[bot]popzxc
andauthored
Merge #6430
6430: Move completions rendering into a separate module r=popzxc a=popzxc This PR extracts rendering-related things from `Completions` structure to the new `render` module. `render` module declares a `Render` structure (which is a generic renderer interface), `RenderContext` (interface for data/methods not required for completions generating, but required for rendering), and a bunch of smaller `*Render` structures which encapsulate logic behind rendering a certain item. This is just a step in full separation direction, since the following this are still to be done: - Move some data from `CompletionContext` to the `RenderContext`; - Forbid any kind of rendering outside of `render` module; - Extract score computing into a separate module. This PR is already pretty big, so not to make it even harder to review I decided to split this process into several subsequent PRs. Co-authored-by: Igor Aleksanov <[email protected]>
2 parents 658e97a + 8efe432 commit 07c7f35

File tree

10 files changed

+1781
-1355
lines changed

10 files changed

+1781
-1355
lines changed

crates/completion/src/completions.rs

Lines changed: 29 additions & 1342 deletions
Large diffs are not rendered by default.

crates/completion/src/context.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,6 @@ impl<'a> CompletionContext<'a> {
245245
}
246246
}
247247

248-
pub(crate) fn active_name_and_type(&self) -> Option<(String, Type)> {
249-
if let Some(record_field) = &self.record_field_syntax {
250-
mark::hit!(record_field_type_match);
251-
let (struct_field, _local) = self.sema.resolve_record_field(record_field)?;
252-
Some((struct_field.name(self.db).to_string(), struct_field.signature_ty(self.db)))
253-
} else if let Some(active_parameter) = &self.active_parameter {
254-
mark::hit!(active_param_type_match);
255-
Some((active_parameter.name.clone(), active_parameter.ty.clone()))
256-
} else {
257-
None
258-
}
259-
}
260-
261248
fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) {
262249
let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap();
263250
let syntax_element = NodeOrToken::Token(fake_ident_token);

crates/completion/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod patterns;
77
mod generated_lint_completions;
88
#[cfg(test)]
99
mod test_utils;
10+
mod render;
1011

1112
mod completions;
1213

0 commit comments

Comments
 (0)