From 36e3fc9d5413f7e6e17e82867aae1318645880a3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 Nov 2019 09:40:36 +0300 Subject: Rename Source::ast -> Source::value --- .../src/completion/completion_context.rs | 2 +- crates/ra_ide_api/src/completion/presentation.rs | 8 +++--- crates/ra_ide_api/src/diagnostics.rs | 2 +- .../ra_ide_api/src/display/function_signature.rs | 8 +++--- crates/ra_ide_api/src/display/navigation_target.rs | 28 ++++++++++---------- crates/ra_ide_api/src/expand.rs | 18 ++++++++----- crates/ra_ide_api/src/expand_macro.rs | 8 +++--- crates/ra_ide_api/src/goto_definition.rs | 8 +++--- crates/ra_ide_api/src/goto_type_definition.rs | 2 +- crates/ra_ide_api/src/hover.rs | 12 ++++----- crates/ra_ide_api/src/impls.rs | 8 +++--- crates/ra_ide_api/src/parent_module.rs | 5 ++-- crates/ra_ide_api/src/references/classify.rs | 8 +++--- .../ra_ide_api/src/references/name_definition.rs | 30 +++++++++++----------- crates/ra_ide_api/src/references/rename.rs | 4 +-- crates/ra_ide_api/src/references/search_scope.rs | 10 ++++---- 16 files changed, 83 insertions(+), 78 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 0906a4e1b..b8345c91d 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -54,7 +54,7 @@ impl<'a> CompletionContext<'a> { let src = hir::ModuleSource::from_position(db, position); let module = hir::Module::from_definition( db, - hir::Source { file_id: position.file_id.into(), ast: src }, + hir::Source { file_id: position.file_id.into(), value: src }, ); let token = original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?; diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 501b7da4e..b20329459 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -169,7 +169,7 @@ impl Completions { None => return, }; - let ast_node = macro_.source(ctx.db).ast; + let ast_node = macro_.source(ctx.db).value; let detail = macro_label(&ast_node); let docs = macro_.docs(ctx.db); @@ -201,7 +201,7 @@ impl Completions { ) { let data = func.data(ctx.db); let name = name.unwrap_or_else(|| data.name().to_string()); - let ast_node = func.source(ctx.db).ast; + let ast_node = func.source(ctx.db).value; let detail = function_label(&ast_node); let mut builder = @@ -234,7 +234,7 @@ impl Completions { } pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) { - let ast_node = constant.source(ctx.db).ast; + let ast_node = constant.source(ctx.db).value; let name = match ast_node.name() { Some(name) => name, _ => return, @@ -250,7 +250,7 @@ impl Completions { } pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) { - let type_def = type_alias.source(ctx.db).ast; + let type_def = type_alias.source(ctx.db).value; let name = match type_def.name() { Some(name) => name, _ => return, diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs index e52ffefb3..cc1ccab4b 100644 --- a/crates/ra_ide_api/src/diagnostics.rs +++ b/crates/ra_ide_api/src/diagnostics.rs @@ -96,7 +96,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec }); let source_file = db.parse(file_id).tree(); let src = - hir::Source { file_id: file_id.into(), ast: hir::ModuleSource::SourceFile(source_file) }; + hir::Source { file_id: file_id.into(), value: hir::ModuleSource::SourceFile(source_file) }; if let Some(m) = hir::Module::from_definition(db, src) { m.diagnostics(db, &mut sink); }; diff --git a/crates/ra_ide_api/src/display/function_signature.rs b/crates/ra_ide_api/src/display/function_signature.rs index 9075ca443..f42dffc87 100644 --- a/crates/ra_ide_api/src/display/function_signature.rs +++ b/crates/ra_ide_api/src/display/function_signature.rs @@ -48,12 +48,12 @@ impl FunctionSignature { pub(crate) fn from_hir(db: &db::RootDatabase, function: hir::Function) -> Self { let doc = function.docs(db); - let ast_node = function.source(db).ast; + let ast_node = function.source(db).value; FunctionSignature::from(&ast_node).with_doc_opt(doc) } pub(crate) fn from_struct(db: &db::RootDatabase, st: hir::Struct) -> Option { - let node: ast::StructDef = st.source(db).ast; + let node: ast::StructDef = st.source(db).value; match node.kind() { ast::StructKind::Named(_) => return None, _ => (), @@ -87,7 +87,7 @@ impl FunctionSignature { db: &db::RootDatabase, variant: hir::EnumVariant, ) -> Option { - let node: ast::EnumVariant = variant.source(db).ast; + let node: ast::EnumVariant = variant.source(db).value; match node.kind() { ast::StructKind::Named(_) | ast::StructKind::Unit => return None, _ => (), @@ -126,7 +126,7 @@ impl FunctionSignature { } pub(crate) fn from_macro(db: &db::RootDatabase, macro_def: hir::MacroDef) -> Option { - let node: ast::MacroCall = macro_def.source(db).ast; + let node: ast::MacroCall = macro_def.source(db).value; let params = vec![]; diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index b30ef8e05..50accafd0 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs @@ -86,9 +86,9 @@ impl NavigationTarget { name, None, frange.range, - src.ast.syntax().kind(), - src.ast.doc_comment_text(), - src.ast.short_label(), + src.value.syntax().kind(), + src.value.doc_comment_text(), + src.value.short_label(), ); } module.to_nav(db) @@ -146,9 +146,9 @@ impl NavigationTarget { description: Option, ) -> NavigationTarget { //FIXME: use `_` instead of empty string - let name = node.ast.name().map(|it| it.text().clone()).unwrap_or_default(); + let name = node.value.name().map(|it| it.text().clone()).unwrap_or_default(); let focus_range = - node.ast.name().map(|it| original_range(db, node.with_ast(it.syntax())).range); + node.value.name().map(|it| original_range(db, node.with_ast(it.syntax())).range); let frange = original_range(db, node.map(|it| it.syntax())); NavigationTarget::from_syntax( @@ -156,7 +156,7 @@ impl NavigationTarget { name, focus_range, frange.range, - node.ast.syntax().kind(), + node.value.syntax().kind(), docs, description, ) @@ -220,8 +220,8 @@ where NavigationTarget::from_named( db, src.as_ref().map(|it| it as &dyn ast::NameOwner), - src.ast.doc_comment_text(), - src.ast.short_label(), + src.value.doc_comment_text(), + src.value.short_label(), ) } } @@ -230,7 +230,7 @@ impl ToNav for hir::Module { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { let src = self.definition_source(db); let name = self.name(db).map(|it| it.to_string().into()).unwrap_or_default(); - match &src.ast { + match &src.value { ModuleSource::SourceFile(node) => { let frange = original_range(db, src.with_ast(node.syntax())); @@ -271,7 +271,7 @@ impl ToNav for hir::ImplBlock { "impl".into(), None, frange.range, - src.ast.syntax().kind(), + src.value.syntax().kind(), None, None, ) @@ -282,7 +282,7 @@ impl ToNav for hir::StructField { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { let src = self.source(db); - match &src.ast { + match &src.value { FieldSource::Named(it) => NavigationTarget::from_named( db, src.with_ast(it), @@ -308,11 +308,11 @@ impl ToNav for hir::StructField { impl ToNav for hir::MacroDef { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { let src = self.source(db); - log::debug!("nav target {:#?}", src.ast.syntax()); + log::debug!("nav target {:#?}", src.value.syntax()); NavigationTarget::from_named( db, src.as_ref().map(|it| it as &dyn ast::NameOwner), - src.ast.doc_comment_text(), + src.value.doc_comment_text(), None, ) } @@ -341,7 +341,7 @@ impl ToNav for hir::AssocItem { impl ToNav for hir::Local { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { let src = self.source(db); - let (full_range, focus_range) = match src.ast { + let (full_range, focus_range) = match src.value { Either::A(it) => { (it.syntax().text_range(), it.name().map(|it| it.syntax().text_range())) } diff --git a/crates/ra_ide_api/src/expand.rs b/crates/ra_ide_api/src/expand.rs index 7f59e46d2..0228bced9 100644 --- a/crates/ra_ide_api/src/expand.rs +++ b/crates/ra_ide_api/src/expand.rs @@ -12,7 +12,7 @@ pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> Fi None => { return FileRange { file_id: node.file_id.original_file(db), - range: node.ast.text_range(), + range: node.value.text_range(), } } Some(it) => it, @@ -25,14 +25,18 @@ pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> Fi // *Second*, we should handle recurside macro expansions let token = node - .ast + .value .descendants_with_tokens() .filter_map(|it| it.into_token()) .find_map(|it| expansion.map_token_up(node.with_ast(&it))); match token { - Some(it) => FileRange { file_id: it.file_id.original_file(db), range: it.ast.text_range() }, - None => FileRange { file_id: node.file_id.original_file(db), range: node.ast.text_range() }, + Some(it) => { + FileRange { file_id: it.file_id.original_file(db), range: it.value.text_range() } + } + None => { + FileRange { file_id: node.file_id.original_file(db), range: node.value.text_range() } + } } } @@ -44,13 +48,13 @@ pub(crate) fn descend_into_macros( let src = Source::new(file_id.into(), token); successors(Some(src), |token| { - let macro_call = token.ast.ancestors().find_map(ast::MacroCall::cast)?; + let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; let tt = macro_call.token_tree()?; - if !token.ast.text_range().is_subrange(&tt.syntax().text_range()) { + if !token.value.text_range().is_subrange(&tt.syntax().text_range()) { return None; } let source_analyzer = - hir::SourceAnalyzer::new(db, token.with_ast(token.ast.parent()).as_ref(), None); + hir::SourceAnalyzer::new(db, token.with_ast(token.value.parent()).as_ref(), None); let exp = source_analyzer.expand(db, ¯o_call)?; exp.map_token_down(db, token.as_ref()) }) diff --git a/crates/ra_ide_api/src/expand_macro.rs b/crates/ra_ide_api/src/expand_macro.rs index e9eb2a7fb..2d478ec09 100644 --- a/crates/ra_ide_api/src/expand_macro.rs +++ b/crates/ra_ide_api/src/expand_macro.rs @@ -46,7 +46,7 @@ fn expand_macro_recur( let mut replaces = FxHashMap::default(); for child in children.into_iter() { - let source = hir::Source::new(macro_file_id, source.ast); + let source = hir::Source::new(macro_file_id, source.value); let new_node = expand_macro_recur(db, source, &child)?; replaces.insert(child.syntax().clone().into(), new_node.into()); @@ -139,7 +139,7 @@ mod tests { } macro_rules! baz { () => { foo!(); } - } + } f<|>oo!(); "#, ); @@ -156,7 +156,7 @@ fn b(){} r#" //- /lib.rs macro_rules! foo { - () => { + () => { fn some_thing() -> u32 { let a = 0; a + 10 @@ -172,7 +172,7 @@ fn b(){} fn some_thing() -> u32 { let a = 0; a+10 -} +} "###); } } diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 3f16e9566..ed9d99a7f 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs @@ -23,7 +23,7 @@ pub(crate) fn goto_definition( let token = descend_into_macros(db, position.file_id, token); let res = match_ast! { - match (token.ast.parent()) { + match (token.value.parent()) { ast::NameRef(name_ref) => { let navs = reference_definition(db, token.with_ast(&name_ref)).to_vec(); RangeInfo::new(name_ref.syntax().text_range(), navs.to_vec()) @@ -84,7 +84,7 @@ pub(crate) fn reference_definition( }; // Fallback index based approach: - let navs = crate::symbol_index::index_resolve(db, name_ref.ast) + let navs = crate::symbol_index::index_resolve(db, name_ref.value) .into_iter() .map(|s| s.to_nav(db)) .collect(); @@ -95,7 +95,7 @@ pub(crate) fn name_definition( db: &RootDatabase, name: Source<&ast::Name>, ) -> Option> { - let parent = name.ast.syntax().parent()?; + let parent = name.value.syntax().parent()?; if let Some(module) = ast::Module::cast(parent.clone()) { if module.has_semi() { @@ -116,7 +116,7 @@ pub(crate) fn name_definition( fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option { match_ast! { - match (node.ast) { + match (node.value) { ast::StructDef(it) => { Some(NavigationTarget::from_named( db, diff --git a/crates/ra_ide_api/src/goto_type_definition.rs b/crates/ra_ide_api/src/goto_type_definition.rs index 7d694e1f6..6aeeefa1f 100644 --- a/crates/ra_ide_api/src/goto_type_definition.rs +++ b/crates/ra_ide_api/src/goto_type_definition.rs @@ -16,7 +16,7 @@ pub(crate) fn goto_type_definition( let token = file.token_at_offset(position.offset).filter(|it| !it.kind().is_trivia()).next()?; let token = descend_into_macros(db, position.file_id, token); - let node = token.ast.ancestors().find_map(|token| { + let node = token.value.ancestors().find_map(|token| { token .ancestors() .find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some()) diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 787b714b3..e8a340ba4 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs @@ -101,11 +101,11 @@ fn hover_text_from_name_kind( return match name_kind { Macro(it) => { let src = it.source(db); - hover_text(src.ast.doc_comment_text(), Some(macro_label(&src.ast))) + hover_text(src.value.doc_comment_text(), Some(macro_label(&src.value))) } Field(it) => { let src = it.source(db); - match src.ast { + match src.value { hir::FieldSource::Named(it) => hover_text(it.doc_comment_text(), it.short_label()), _ => None, } @@ -116,7 +116,7 @@ fn hover_text_from_name_kind( hir::AssocItem::TypeAlias(it) => from_def_source(db, it), }, Def(it) => match it { - hir::ModuleDef::Module(it) => match it.definition_source(db).ast { + hir::ModuleDef::Module(it) => match it.definition_source(db).value { hir::ModuleSource::Module(it) => { hover_text(it.doc_comment_text(), it.short_label()) } @@ -158,7 +158,7 @@ fn hover_text_from_name_kind( A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel, { let src = def.source(db); - hover_text(src.ast.doc_comment_text(), src.ast.short_label()) + hover_text(src.value.doc_comment_text(), src.value.short_label()) } } @@ -170,7 +170,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option { let mut no_fallback = false; if let Some(name_kind) = @@ -211,7 +211,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option(&syntax, position.offset) { @@ -42,11 +42,11 @@ fn impls_for_def( ) -> Option> { let ty = match node { ast::NominalDef::StructDef(def) => { - let src = hir::Source { file_id: position.file_id.into(), ast: def.clone() }; + let src = hir::Source { file_id: position.file_id.into(), value: def.clone() }; hir::Struct::from_source(db, src)?.ty(db) } ast::NominalDef::EnumDef(def) => { - let src = hir::Source { file_id: position.file_id.into(), ast: def.clone() }; + let src = hir::Source { file_id: position.file_id.into(), value: def.clone() }; hir::Enum::from_source(db, src)?.ty(db) } }; @@ -69,7 +69,7 @@ fn impls_for_trait( node: &ast::TraitDef, module: hir::Module, ) -> Option> { - let src = hir::Source { file_id: position.file_id.into(), ast: node.clone() }; + let src = hir::Source { file_id: position.file_id.into(), value: node.clone() }; let tr = hir::Trait::from_source(db, src)?; let krate = module.krate(); diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide_api/src/parent_module.rs index 4c57566e2..fa232a379 100644 --- a/crates/ra_ide_api/src/parent_module.rs +++ b/crates/ra_ide_api/src/parent_module.rs @@ -10,7 +10,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec return Vec::new(), Some(it) => it, @@ -23,7 +23,8 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec Vec { let src = hir::ModuleSource::from_file_id(db, file_id); let module = - match hir::Module::from_definition(db, hir::Source { file_id: file_id.into(), ast: src }) { + match hir::Module::from_definition(db, hir::Source { file_id: file_id.into(), value: src }) + { Some(it) => it, None => return Vec::new(), }; diff --git a/crates/ra_ide_api/src/references/classify.rs b/crates/ra_ide_api/src/references/classify.rs index ea9d20e71..333264540 100644 --- a/crates/ra_ide_api/src/references/classify.rs +++ b/crates/ra_ide_api/src/references/classify.rs @@ -13,7 +13,7 @@ use crate::db::RootDatabase; pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Option { let _p = profile("classify_name"); - let parent = name.ast.syntax().parent()?; + let parent = name.value.syntax().parent()?; match_ast! { match parent { @@ -121,7 +121,7 @@ pub(crate) fn classify_name_ref( ) -> Option { let _p = profile("classify_name_ref"); - let parent = name_ref.ast.syntax().parent()?; + let parent = name_ref.value.syntax().parent()?; let analyzer = SourceAnalyzer::new(db, name_ref.map(|it| it.syntax()), None); if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { @@ -142,7 +142,7 @@ pub(crate) fn classify_name_ref( tested_by!(goto_definition_works_for_record_fields); if let Some(record_lit) = record_field.syntax().ancestors().find_map(ast::RecordLit::cast) { let variant_def = analyzer.resolve_record_literal(&record_lit)?; - let hir_path = Path::from_name_ref(name_ref.ast); + let hir_path = Path::from_name_ref(name_ref.value); let hir_name = hir_path.as_ident()?; let field = variant_def.field(db, hir_name)?; return Some(from_struct_field(db, field)); @@ -162,7 +162,7 @@ pub(crate) fn classify_name_ref( } } - let path = name_ref.ast.syntax().ancestors().find_map(ast::Path::cast)?; + let path = name_ref.value.syntax().ancestors().find_map(ast::Path::cast)?; let resolved = analyzer.resolve_path(db, &path)?; match resolved { PathResolution::Def(def) => Some(from_module_def(db, def, Some(container))), diff --git a/crates/ra_ide_api/src/references/name_definition.rs b/crates/ra_ide_api/src/references/name_definition.rs index ccd75278a..aca23f79e 100644 --- a/crates/ra_ide_api/src/references/name_definition.rs +++ b/crates/ra_ide_api/src/references/name_definition.rs @@ -32,9 +32,9 @@ pub(crate) struct NameDefinition { pub(super) fn from_assoc_item(db: &RootDatabase, item: AssocItem) -> NameDefinition { let container = item.module(db); let visibility = match item { - AssocItem::Function(f) => f.source(db).ast.visibility(), - AssocItem::Const(c) => c.source(db).ast.visibility(), - AssocItem::TypeAlias(a) => a.source(db).ast.visibility(), + AssocItem::Function(f) => f.source(db).value.visibility(), + AssocItem::Const(c) => c.source(db).value.visibility(), + AssocItem::TypeAlias(a) => a.source(db).value.visibility(), }; let kind = NameKind::AssocItem(item); NameDefinition { kind, container, visibility } @@ -45,8 +45,8 @@ pub(super) fn from_struct_field(db: &RootDatabase, field: StructField) -> NameDe let parent = field.parent_def(db); let container = parent.module(db); let visibility = match parent { - VariantDef::Struct(s) => s.source(db).ast.visibility(), - VariantDef::EnumVariant(e) => e.source(db).ast.parent_enum().visibility(), + VariantDef::Struct(s) => s.source(db).value.visibility(), + VariantDef::EnumVariant(e) => e.source(db).value.parent_enum().visibility(), }; NameDefinition { kind, container, visibility } } @@ -60,22 +60,22 @@ pub(super) fn from_module_def( let (container, visibility) = match def { ModuleDef::Module(it) => { let container = it.parent(db).or_else(|| Some(it)).unwrap(); - let visibility = it.declaration_source(db).and_then(|s| s.ast.visibility()); + let visibility = it.declaration_source(db).and_then(|s| s.value.visibility()); (container, visibility) } ModuleDef::EnumVariant(it) => { let container = it.module(db); - let visibility = it.source(db).ast.parent_enum().visibility(); + let visibility = it.source(db).value.parent_enum().visibility(); (container, visibility) } - ModuleDef::Function(it) => (it.module(db), it.source(db).ast.visibility()), - ModuleDef::Const(it) => (it.module(db), it.source(db).ast.visibility()), - ModuleDef::Static(it) => (it.module(db), it.source(db).ast.visibility()), - ModuleDef::Trait(it) => (it.module(db), it.source(db).ast.visibility()), - ModuleDef::TypeAlias(it) => (it.module(db), it.source(db).ast.visibility()), - ModuleDef::Adt(Adt::Struct(it)) => (it.module(db), it.source(db).ast.visibility()), - ModuleDef::Adt(Adt::Union(it)) => (it.module(db), it.source(db).ast.visibility()), - ModuleDef::Adt(Adt::Enum(it)) => (it.module(db), it.source(db).ast.visibility()), + ModuleDef::Function(it) => (it.module(db), it.source(db).value.visibility()), + ModuleDef::Const(it) => (it.module(db), it.source(db).value.visibility()), + ModuleDef::Static(it) => (it.module(db), it.source(db).value.visibility()), + ModuleDef::Trait(it) => (it.module(db), it.source(db).value.visibility()), + ModuleDef::TypeAlias(it) => (it.module(db), it.source(db).value.visibility()), + ModuleDef::Adt(Adt::Struct(it)) => (it.module(db), it.source(db).value.visibility()), + ModuleDef::Adt(Adt::Union(it)) => (it.module(db), it.source(db).value.visibility()), + ModuleDef::Adt(Adt::Enum(it)) => (it.module(db), it.source(db).value.visibility()), ModuleDef::BuiltinType(..) => (module.unwrap(), None), }; NameDefinition { kind, container, visibility } diff --git a/crates/ra_ide_api/src/references/rename.rs b/crates/ra_ide_api/src/references/rename.rs index 11f81cbb3..4ea372e6f 100644 --- a/crates/ra_ide_api/src/references/rename.rs +++ b/crates/ra_ide_api/src/references/rename.rs @@ -55,11 +55,11 @@ fn rename_mod( ) -> Option { let mut source_file_edits = Vec::new(); let mut file_system_edits = Vec::new(); - let module_src = hir::Source { file_id: position.file_id.into(), ast: ast_module.clone() }; + let module_src = hir::Source { file_id: position.file_id.into(), value: ast_module.clone() }; if let Some(module) = hir::Module::from_declaration(db, module_src) { let src = module.definition_source(db); let file_id = src.file_id.original_file(db); - match src.ast { + match src.value { ModuleSource::SourceFile(..) => { let mod_path: RelativePathBuf = db.file_relative_path(file_id); // mod is defined in path/to/dir/mod.rs diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide_api/src/references/search_scope.rs index 2907787c2..f5c9589f4 100644 --- a/crates/ra_ide_api/src/references/search_scope.rs +++ b/crates/ra_ide_api/src/references/search_scope.rs @@ -73,9 +73,9 @@ impl NameDefinition { if let NameKind::Local(var) = self.kind { let range = match var.parent(db) { - DefWithBody::Function(f) => f.source(db).ast.syntax().text_range(), - DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(), - DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(), + DefWithBody::Function(f) => f.source(db).value.syntax().text_range(), + DefWithBody::Const(c) => c.source(db).value.syntax().text_range(), + DefWithBody::Static(s) => s.source(db).value.syntax().text_range(), }; let mut res = FxHashMap::default(); res.insert(file_id, Some(range)); @@ -91,7 +91,7 @@ impl NameDefinition { let parent_src = parent_module.definition_source(db); let file_id = parent_src.file_id.original_file(db); - match parent_src.ast { + match parent_src.value { ModuleSource::Module(m) => { let range = Some(m.syntax().text_range()); res.insert(file_id, range); @@ -135,7 +135,7 @@ impl NameDefinition { } let mut res = FxHashMap::default(); - let range = match module_src.ast { + let range = match module_src.value { ModuleSource::Module(m) => Some(m.syntax().text_range()), ModuleSource::SourceFile(_) => None, }; -- cgit v1.2.3