From 27cadcd531c017aa7c78c6f7a36f2b7f2ce8a196 Mon Sep 17 00:00:00 2001 From: Nick Spain Date: Fri, 1 Jan 2021 13:05:28 +1100 Subject: HasSource::source -> HasSource::source_old To start migrating HasSource::source to return an Option. --- crates/ide/src/diagnostics/fixes.rs | 6 +++--- crates/ide/src/display/navigation_target.rs | 12 ++++++------ crates/ide/src/hover.rs | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index d79f5c170..702e8239d 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -156,20 +156,20 @@ fn missing_record_expr_field_fix( let record_fields = match VariantDef::from(def_id) { VariantDef::Struct(s) => { module = s.module(sema.db); - let source = s.source(sema.db); + let source = s.source_old(sema.db); def_file_id = source.file_id; let fields = source.value.field_list()?; record_field_list(fields)? } VariantDef::Union(u) => { module = u.module(sema.db); - let source = u.source(sema.db); + let source = u.source_old(sema.db); def_file_id = source.file_id; source.value.record_field_list()? } VariantDef::Variant(e) => { module = e.module(sema.db); - let source = e.source(sema.db); + let source = e.source_old(sema.db); def_file_id = source.file_id; let fields = source.value.field_list()?; record_field_list(fields)? diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index bcde2b6f1..de4c0fa12 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -285,7 +285,7 @@ where D::Ast: ast::NameOwner + ShortLabel, { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { - let src = self.source(db); + let src = self.source_old(db); let mut res = NavigationTarget::from_named( db, src.as_ref().map(|it| it as &dyn ast::NameOwner), @@ -314,7 +314,7 @@ impl ToNav for hir::Module { impl ToNav for hir::Impl { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { - let src = self.source(db); + let src = self.source_old(db); let derive_attr = self.is_builtin_derive(db); let frange = if let Some(item) = &derive_attr { item.syntax().original_file_range(db) @@ -339,7 +339,7 @@ impl ToNav for hir::Impl { impl ToNav for hir::Field { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { - let src = self.source(db); + let src = self.source_old(db); match &src.value { FieldSource::Named(it) => { @@ -365,7 +365,7 @@ impl ToNav for hir::Field { impl ToNav for hir::MacroDef { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { - let src = self.source(db); + let src = self.source_old(db); log::debug!("nav target {:#?}", src.value.syntax()); let mut res = NavigationTarget::from_named( db, @@ -448,7 +448,7 @@ impl ToNav for hir::Label { impl ToNav for hir::TypeParam { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { - let src = self.source(db); + let src = self.source_old(db); let full_range = match &src.value { Either::Left(it) => it.syntax().text_range(), Either::Right(it) => it.syntax().text_range(), @@ -472,7 +472,7 @@ impl ToNav for hir::TypeParam { impl ToNav for hir::LifetimeParam { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { - let src = self.source(db); + let src = self.source_old(db); let full_range = src.value.syntax().text_range(); NavigationTarget { file_id: src.file_id.original_file(db), diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 98c7bfbe5..90781ea34 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -206,7 +206,7 @@ fn runnable_action( _ => None, }, ModuleDef::Function(it) => { - let src = it.source(sema.db); + let src = it.source_old(sema.db); if src.file_id != file_id.into() { mark::hit!(hover_macro_generated_struct_fn_doc_comment); mark::hit!(hover_macro_generated_struct_fn_doc_attr); @@ -332,11 +332,11 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option { if it.is_proc_macro() { return None; } - let label = macro_label(&it.source(db).value); + let label = macro_label(&it.source_old(db).value); from_def_source_labeled(db, it, Some(label), mod_path) } Definition::Field(def) => { - let src = def.source(db).value; + let src = def.source_old(db).value; if let FieldSource::Named(it) = src { from_def_source_labeled(db, def, it.short_label(), mod_path) } else { @@ -385,7 +385,7 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option { D: HasSource + HasAttrs + Copy, A: ShortLabel, { - let short_label = def.source(db).value.short_label(); + let short_label = def.source_old(db).value.short_label(); from_def_source_labeled(db, def, short_label, mod_path) } -- cgit v1.2.3