mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
remove SearchScope
This commit is contained in:
parent
88ff88d318
commit
328be5721a
2 changed files with 6 additions and 10 deletions
|
@ -99,7 +99,7 @@ fn find_name<'a>(
|
||||||
|
|
||||||
fn process_definition(db: &RootDatabase, def: NameDefinition, name: String) -> Vec<FileRange> {
|
fn process_definition(db: &RootDatabase, def: NameDefinition, name: String) -> Vec<FileRange> {
|
||||||
let pat = name.as_str();
|
let pat = name.as_str();
|
||||||
let scope = def.scope(db).files;
|
let scope = def.search_scope(db);
|
||||||
let mut refs = vec![];
|
let mut refs = vec![];
|
||||||
|
|
||||||
let is_match = |file_id: FileId, name_ref: &ast::NameRef| -> bool {
|
let is_match = |file_id: FileId, name_ref: &ast::NameRef| -> bool {
|
||||||
|
|
|
@ -8,12 +8,8 @@ use crate::db::RootDatabase;
|
||||||
|
|
||||||
use super::{NameDefinition, NameKind};
|
use super::{NameDefinition, NameKind};
|
||||||
|
|
||||||
pub(crate) struct SearchScope {
|
|
||||||
pub files: Vec<(FileId, Option<TextRange>)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NameDefinition {
|
impl NameDefinition {
|
||||||
pub(crate) fn scope(&self, db: &RootDatabase) -> SearchScope {
|
pub(crate) fn search_scope(&self, db: &RootDatabase) -> Vec<(FileId, Option<TextRange>)> {
|
||||||
let module_src = self.container.definition_source(db);
|
let module_src = self.container.definition_source(db);
|
||||||
let file_id = module_src.file_id.original_file(db);
|
let file_id = module_src.file_id.original_file(db);
|
||||||
|
|
||||||
|
@ -23,7 +19,7 @@ impl NameDefinition {
|
||||||
DefWithBody::Const(c) => c.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::Static(s) => s.source(db).ast.syntax().text_range(),
|
||||||
};
|
};
|
||||||
return SearchScope { files: vec![(file_id, Some(range))] };
|
return vec![(file_id, Some(range))];
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref vis) = self.visibility {
|
if let Some(ref vis) = self.visibility {
|
||||||
|
@ -32,7 +28,7 @@ impl NameDefinition {
|
||||||
let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<Vec<_>>();
|
let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<Vec<_>>();
|
||||||
|
|
||||||
if vis.syntax().to_string().as_str() == "pub(crate)" {
|
if vis.syntax().to_string().as_str() == "pub(crate)" {
|
||||||
return SearchScope { files };
|
return files;
|
||||||
}
|
}
|
||||||
if vis.syntax().to_string().as_str() == "pub" {
|
if vis.syntax().to_string().as_str() == "pub" {
|
||||||
let krate = self.container.krate(db).unwrap();
|
let krate = self.container.krate(db).unwrap();
|
||||||
|
@ -49,7 +45,7 @@ impl NameDefinition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SearchScope { files };
|
return files;
|
||||||
}
|
}
|
||||||
// FIXME: "pub(super)", "pub(in path)"
|
// FIXME: "pub(super)", "pub(in path)"
|
||||||
}
|
}
|
||||||
|
@ -58,6 +54,6 @@ impl NameDefinition {
|
||||||
ModuleSource::Module(m) => Some(m.syntax().text_range()),
|
ModuleSource::Module(m) => Some(m.syntax().text_range()),
|
||||||
ModuleSource::SourceFile(_) => None,
|
ModuleSource::SourceFile(_) => None,
|
||||||
};
|
};
|
||||||
SearchScope { files: vec![(file_id, range)] }
|
vec![(file_id, range)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue