From 81a45ca1b3606d2c328740aa7e2dc989b9e128a5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 16 Jan 2020 16:08:46 +0100 Subject: Make FromSource private --- crates/ra_hir_def/src/keys.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index d844f7a62..5913f12b1 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs @@ -2,7 +2,7 @@ use std::marker::PhantomData; -use hir_expand::InFile; +use hir_expand::{InFile, MacroDefId}; use ra_syntax::{ast, AstNode, AstPtr}; use rustc_hash::FxHashMap; @@ -29,6 +29,8 @@ pub const TUPLE_FIELD: Key = Key::new(); pub const RECORD_FIELD: Key = Key::new(); pub const TYPE_PARAM: Key = Key::new(); +pub const MACRO: Key = Key::new(); + /// XXX: AST Nodes and SyntaxNodes have identity equality semantics: nodes are /// equal if they point to exactly the same object. /// -- cgit v1.2.3 From 3ceb9a941a9dbb3c4dfa3a217ee3f4de792df0dc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 16 Jan 2020 17:56:14 +0100 Subject: Remove dead code --- crates/ra_hir_def/src/nameres.rs | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index e1a6a46df..27c12e46c 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -59,12 +59,9 @@ use std::sync::Arc; use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; use ra_arena::Arena; -use ra_db::{CrateId, Edition, FileId, FilePosition}; +use ra_db::{CrateId, Edition, FileId}; use ra_prof::profile; -use ra_syntax::{ - ast::{self, AstNode}, - SyntaxNode, -}; +use ra_syntax::ast; use rustc_hash::FxHashMap; use crate::{ @@ -255,35 +252,6 @@ pub enum ModuleSource { Module(ast::Module), } -impl ModuleSource { - // FIXME: this methods do not belong here - pub fn from_position(db: &impl DefDatabase, position: FilePosition) -> ModuleSource { - let parse = db.parse(position.file_id); - match &ra_syntax::algo::find_node_at_offset::( - parse.tree().syntax(), - position.offset, - ) { - Some(m) if !m.has_semi() => ModuleSource::Module(m.clone()), - _ => { - let source_file = parse.tree(); - ModuleSource::SourceFile(source_file) - } - } - } - - pub fn from_child_node(db: &impl DefDatabase, child: InFile<&SyntaxNode>) -> ModuleSource { - if let Some(m) = - child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) - { - ModuleSource::Module(m) - } else { - let file_id = child.file_id.original_file(db); - let source_file = db.parse(file_id).tree(); - ModuleSource::SourceFile(source_file) - } - } -} - mod diagnostics { use hir_expand::diagnostics::DiagnosticSink; use ra_db::RelativePathBuf; -- cgit v1.2.3