From 5d99ba1d9a5acf02a5cd50e456f164bd80b523b5 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 4 Feb 2021 20:49:24 +0100 Subject: Make `ModPath`'s representation private --- crates/completion/src/completions/flyimport.rs | 2 +- crates/completion/src/completions/unqualified_path.rs | 2 +- crates/completion/src/item.rs | 4 ++-- crates/completion/src/render.rs | 2 +- crates/completion/src/render/enum_variant.rs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/completion') 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( user_input_lowercased: &str, ) -> usize { mark::hit!(certain_fuzzy_order_test); - let proposed_import_name = match proposed_mod_path.segments.last() { + let proposed_import_name = match proposed_mod_path.segments().last() { Some(name) => name.to_string().to_lowercase(), None => return usize::MAX, }; 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 if let Some(path) = module.find_use_path(ctx.db, ModuleDef::from(variant)) { // Variants with trivial paths are already added by the existing completion logic, // so we should avoid adding these twice - if path.segments.len() > 1 { + if path.segments().len() > 1 { acc.add_qualified_enum_variant(ctx, variant, path); } } 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 { label = format!("{} ({})", label, import_to_add.import_path); } else { let mut import_path_without_last_segment = import_to_add.import_path.to_owned(); - let _ = import_path_without_last_segment.segments.pop(); + let _ = import_path_without_last_segment.pop_segment(); - if !import_path_without_last_segment.segments.is_empty() { + if !import_path_without_last_segment.segments().is_empty() { lookup = lookup.or_else(|| Some(label.clone())); insert_text = insert_text.or_else(|| Some(label.clone())); 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>( ScopeDef::ModuleDef(ModuleDef::Function(f)) => f.name(ctx.completion.db).to_string(), ScopeDef::ModuleDef(ModuleDef::Const(c)) => c.name(ctx.completion.db)?.to_string(), ScopeDef::ModuleDef(ModuleDef::TypeAlias(t)) => t.name(ctx.completion.db).to_string(), - _ => import_edit.import_path.segments.last()?.to_string(), + _ => import_edit.import_path.segments().last()?.to_string(), }; Render::new(ctx).render_resolution(local_name, Some(import_edit), resolution).map(|mut item| { 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> { let (qualified_name, short_qualified_name) = match &path { Some(path) => { let full = path.to_string(); - let short = - path.segments[path.segments.len().saturating_sub(2)..].iter().join("::"); + let segments = path.segments(); + let short = segments[segments.len().saturating_sub(2)..].iter().join("::"); (full, short) } None => (name.to_string(), name.to_string()), -- cgit v1.2.3