aboutsummaryrefslogtreecommitdiff
path: root/crates/completion
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-02-04 19:49:24 +0000
committerJonas Schievink <[email protected]>2021-02-04 19:49:24 +0000
commit5d99ba1d9a5acf02a5cd50e456f164bd80b523b5 (patch)
tree073b41689b789308030b4df4344c3aa147cba195 /crates/completion
parent36191543a679d4e01c206d2e98a2d7ae170a25e2 (diff)
Make `ModPath`'s representation private
Diffstat (limited to 'crates/completion')
-rw-r--r--crates/completion/src/completions/flyimport.rs2
-rw-r--r--crates/completion/src/completions/unqualified_path.rs2
-rw-r--r--crates/completion/src/item.rs4
-rw-r--r--crates/completion/src/render.rs2
-rw-r--r--crates/completion/src/render/enum_variant.rs4
5 files changed, 7 insertions, 7 deletions
diff --git a/crates/completion/src/completions/flyimport.rs b/crates/completion/src/completions/flyimport.rs
index 9c6a5a40c..c9f928483 100644
--- a/crates/completion/src/completions/flyimport.rs
+++ b/crates/completion/src/completions/flyimport.rs
@@ -175,7 +175,7 @@ fn compute_fuzzy_completion_order_key(
175 user_input_lowercased: &str, 175 user_input_lowercased: &str,
176) -> usize { 176) -> usize {
177 mark::hit!(certain_fuzzy_order_test); 177 mark::hit!(certain_fuzzy_order_test);
178 let proposed_import_name = match proposed_mod_path.segments.last() { 178 let proposed_import_name = match proposed_mod_path.segments().last() {
179 Some(name) => name.to_string().to_lowercase(), 179 Some(name) => name.to_string().to_lowercase(),
180 None => return usize::MAX, 180 None => return usize::MAX,
181 }; 181 };
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs
index 5d62fab97..e2482f959 100644
--- a/crates/completion/src/completions/unqualified_path.rs
+++ b/crates/completion/src/completions/unqualified_path.rs
@@ -63,7 +63,7 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
63 if let Some(path) = module.find_use_path(ctx.db, ModuleDef::from(variant)) { 63 if let Some(path) = module.find_use_path(ctx.db, ModuleDef::from(variant)) {
64 // Variants with trivial paths are already added by the existing completion logic, 64 // Variants with trivial paths are already added by the existing completion logic,
65 // so we should avoid adding these twice 65 // so we should avoid adding these twice
66 if path.segments.len() > 1 { 66 if path.segments().len() > 1 {
67 acc.add_qualified_enum_variant(ctx, variant, path); 67 acc.add_qualified_enum_variant(ctx, variant, path);
68 } 68 }
69 } 69 }
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs
index 8ec4ac65e..884711f11 100644
--- a/crates/completion/src/item.rs
+++ b/crates/completion/src/item.rs
@@ -332,9 +332,9 @@ impl Builder {
332 label = format!("{} ({})", label, import_to_add.import_path); 332 label = format!("{} ({})", label, import_to_add.import_path);
333 } else { 333 } else {
334 let mut import_path_without_last_segment = import_to_add.import_path.to_owned(); 334 let mut import_path_without_last_segment = import_to_add.import_path.to_owned();
335 let _ = import_path_without_last_segment.segments.pop(); 335 let _ = import_path_without_last_segment.pop_segment();
336 336
337 if !import_path_without_last_segment.segments.is_empty() { 337 if !import_path_without_last_segment.segments().is_empty() {
338 lookup = lookup.or_else(|| Some(label.clone())); 338 lookup = lookup.or_else(|| Some(label.clone()));
339 insert_text = insert_text.or_else(|| Some(label.clone())); 339 insert_text = insert_text.or_else(|| Some(label.clone()));
340 label = format!("{}::{}", import_path_without_last_segment, label); 340 label = format!("{}::{}", import_path_without_last_segment, label);
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs
index e11b881ca..eddaaa6f3 100644
--- a/crates/completion/src/render.rs
+++ b/crates/completion/src/render.rs
@@ -57,7 +57,7 @@ pub(crate) fn render_resolution_with_import<'a>(
57 ScopeDef::ModuleDef(ModuleDef::Function(f)) => f.name(ctx.completion.db).to_string(), 57 ScopeDef::ModuleDef(ModuleDef::Function(f)) => f.name(ctx.completion.db).to_string(),
58 ScopeDef::ModuleDef(ModuleDef::Const(c)) => c.name(ctx.completion.db)?.to_string(), 58 ScopeDef::ModuleDef(ModuleDef::Const(c)) => c.name(ctx.completion.db)?.to_string(),
59 ScopeDef::ModuleDef(ModuleDef::TypeAlias(t)) => t.name(ctx.completion.db).to_string(), 59 ScopeDef::ModuleDef(ModuleDef::TypeAlias(t)) => t.name(ctx.completion.db).to_string(),
60 _ => import_edit.import_path.segments.last()?.to_string(), 60 _ => import_edit.import_path.segments().last()?.to_string(),
61 }; 61 };
62 Render::new(ctx).render_resolution(local_name, Some(import_edit), resolution).map(|mut item| { 62 Render::new(ctx).render_resolution(local_name, Some(import_edit), resolution).map(|mut item| {
63 item.completion_kind = CompletionKind::Magic; 63 item.completion_kind = CompletionKind::Magic;
diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs
index adcddebd1..9214193b4 100644
--- a/crates/completion/src/render/enum_variant.rs
+++ b/crates/completion/src/render/enum_variant.rs
@@ -45,8 +45,8 @@ impl<'a> EnumRender<'a> {
45 let (qualified_name, short_qualified_name) = match &path { 45 let (qualified_name, short_qualified_name) = match &path {
46 Some(path) => { 46 Some(path) => {
47 let full = path.to_string(); 47 let full = path.to_string();
48 let short = 48 let segments = path.segments();
49 path.segments[path.segments.len().saturating_sub(2)..].iter().join("::"); 49 let short = segments[segments.len().saturating_sub(2)..].iter().join("::");
50 (full, short) 50 (full, short)
51 } 51 }
52 None => (name.to_string(), name.to_string()), 52 None => (name.to_string(), name.to_string()),