Skip to content

Commit 19c1067

Browse files
committed
Reorganize completions structure
1 parent bf84e49 commit 19c1067

23 files changed

+99
-109
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pub(crate) mod attribute;
2+
pub(crate) mod dot;
3+
pub(crate) mod record;
4+
pub(crate) mod pattern;
5+
pub(crate) mod fn_param;
6+
pub(crate) mod keyword;
7+
pub(crate) mod snippet;
8+
pub(crate) mod qualified_path;
9+
pub(crate) mod unqualified_path;
10+
pub(crate) mod postfix;
11+
pub(crate) mod macro_in_item_position;
12+
pub(crate) mod trait_impl;
13+
pub(crate) mod mod_;

crates/completion/src/complete_attribute.rs renamed to crates/completion/src/completions/attribute.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use rustc_hash::FxHashSet;
77
use syntax::{ast, AstNode, SyntaxKind};
88

99
use crate::{
10-
completion_context::CompletionContext,
11-
completion_item::{CompletionItem, CompletionItemKind, CompletionKind, Completions},
10+
context::CompletionContext,
1211
generated_lint_completions::{CLIPPY_LINTS, FEATURES},
12+
item::{CompletionItem, CompletionItemKind, CompletionKind, Completions},
1313
};
1414

15-
pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
15+
pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
1616
if ctx.mod_declaration_under_caret.is_some() {
1717
return None;
1818
}
@@ -262,9 +262,9 @@ const DEFAULT_DERIVE_COMPLETIONS: &[DeriveCompletion] = &[
262262
DeriveCompletion { label: "Ord", dependencies: &["PartialOrd", "Eq", "PartialEq"] },
263263
];
264264

265-
pub(super) struct LintCompletion {
266-
pub(super) label: &'static str,
267-
pub(super) description: &'static str,
265+
pub(crate) struct LintCompletion {
266+
pub(crate) label: &'static str,
267+
pub(crate) description: &'static str,
268268
}
269269

270270
#[rustfmt::skip]

crates/completion/src/complete_dot.rs renamed to crates/completion/src/completions/dot.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use hir::{HasVisibility, Type};
44
use rustc_hash::FxHashSet;
55
use test_utils::mark;
66

7-
use crate::{completion_context::CompletionContext, completion_item::Completions};
7+
use crate::{context::CompletionContext, item::Completions};
88

99
/// Complete dot accesses, i.e. fields or methods.
10-
pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
10+
pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
1111
let dot_receiver = match &ctx.dot_receiver {
1212
Some(expr) => expr,
1313
_ => return,
@@ -141,7 +141,7 @@ mod inner {
141141
private_field: u32,
142142
pub pub_field: u32,
143143
pub(crate) crate_field: u32,
144-
pub(super) super_field: u32,
144+
pub(crate) super_field: u32,
145145
}
146146
}
147147
fn foo(a: inner::A) { a.<|> }
@@ -159,13 +159,13 @@ struct A {}
159159
mod m {
160160
impl super::A {
161161
fn private_method(&self) {}
162-
pub(super) fn the_method(&self) {}
162+
pub(crate) fn the_method(&self) {}
163163
}
164164
}
165165
fn foo(a: A) { a.<|> }
166166
"#,
167167
expect![[r#"
168-
me the_method() pub(super) fn the_method(&self)
168+
me the_method() pub(crate) fn the_method(&self)
169169
"#]],
170170
);
171171
}

crates/completion/src/complete_fn_param.rs renamed to crates/completion/src/completions/fn_param.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{CompletionContext, CompletionItem, CompletionKind, Completions};
1212
/// functions in a file have a `spam: &mut Spam` parameter, a completion with
1313
/// `spam: &mut Spam` insert text/label and `spam` lookup string will be
1414
/// suggested.
15-
pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) {
15+
pub(crate) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) {
1616
if !ctx.is_param {
1717
return;
1818
}

crates/completion/src/complete_keyword.rs renamed to crates/completion/src/completions/keyword.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use test_utils::mark;
55

66
use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions};
77

8-
pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) {
8+
pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) {
99
// complete keyword "crate" in use stmt
1010
let source_range = ctx.source_range();
1111

@@ -39,7 +39,7 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
3939
}
4040
}
4141

42-
pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) {
42+
pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) {
4343
if ctx.token.kind() == SyntaxKind::COMMENT {
4444
mark::hit!(no_keyword_completion_in_comments);
4545
return;

crates/completion/src/complete_macro_in_item_position.rs renamed to crates/completion/src/completions/macro_in_item_position.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::{CompletionContext, Completions};
44

5-
pub(super) fn complete_macro_in_item_position(acc: &mut Completions, ctx: &CompletionContext) {
5+
pub(crate) fn complete_macro_in_item_position(acc: &mut Completions, ctx: &CompletionContext) {
66
// Show only macros in top level.
77
if ctx.is_new_item {
88
ctx.scope.process_all_names(&mut |name, res| {

crates/completion/src/complete_mod.rs renamed to crates/completion/src/completions/mod_.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ use rustc_hash::FxHashSet;
77

88
use crate::{CompletionItem, CompletionItemKind};
99

10-
use super::{
11-
completion_context::CompletionContext, completion_item::CompletionKind,
12-
completion_item::Completions,
13-
};
10+
use crate::{context::CompletionContext, item::CompletionKind, item::Completions};
1411

1512
/// Complete mod declaration, i.e. `mod <|> ;`
16-
pub(super) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
13+
pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
1714
let mod_under_caret = match &ctx.mod_declaration_under_caret {
1815
Some(mod_under_caret) if mod_under_caret.item_list().is_some() => return None,
1916
Some(mod_under_caret) => mod_under_caret,

crates/completion/src/complete_pattern.rs renamed to crates/completion/src/completions/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::{CompletionContext, Completions};
44

55
/// Completes constats and paths in patterns.
6-
pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
6+
pub(crate) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
77
if !ctx.is_pat_binding_or_const {
88
return;
99
}

crates/completion/src/complete_postfix.rs renamed to crates/completion/src/completions/postfix.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ use text_edit::TextEdit;
1111

1212
use self::format_like::add_format_like_completions;
1313
use crate::{
14-
completion_config::SnippetCap,
15-
completion_context::CompletionContext,
16-
completion_item::{Builder, CompletionKind, Completions},
14+
config::SnippetCap,
15+
context::CompletionContext,
16+
item::{Builder, CompletionKind, Completions},
1717
CompletionItem, CompletionItemKind,
1818
};
1919

20-
pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
20+
pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
2121
if !ctx.config.enable_postfix_completions {
2222
return;
2323
}

crates/completion/src/complete_postfix/format_like.rs renamed to crates/completion/src/completions/postfix/format_like.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
// + `loge` -> `log::error!(...)`
1616

1717
use crate::{
18-
complete_postfix::postfix_snippet, completion_config::SnippetCap,
19-
completion_context::CompletionContext, completion_item::Completions,
18+
completions::postfix::postfix_snippet, config::SnippetCap, context::CompletionContext,
19+
item::Completions,
2020
};
2121
use syntax::ast::{self, AstToken};
2222

@@ -33,7 +33,7 @@ static KINDS: &[(&str, &str)] = &[
3333
("loge", "log::error!"),
3434
];
3535

36-
pub(super) fn add_format_like_completions(
36+
pub(crate) fn add_format_like_completions(
3737
acc: &mut Completions,
3838
ctx: &CompletionContext,
3939
dot_receiver: &ast::Expr,

0 commit comments

Comments
 (0)