No block at the moment

This commit is contained in:
ice1000 2019-12-04 13:35:24 -05:00
parent 032eb3d68e
commit 088f50c0ab
5 changed files with 3 additions and 14 deletions

View file

@ -257,7 +257,7 @@ impl Module {
InFile { file_id: src.file_id, value: module.clone() }, InFile { file_id: src.file_id, value: module.clone() },
); );
} }
ModuleSource::SourceFile(_) | ModuleSource::Block(_) => (), ModuleSource::SourceFile(_) => (),
}; };
let original_file = src.file_id.original_file(db); let original_file = src.file_id.original_file(db);

View file

@ -109,7 +109,6 @@ pub enum ModuleOrigin {
/// Note that non-inline modules, by definition, live inside non-macro file. /// Note that non-inline modules, by definition, live inside non-macro file.
File(AstId<ast::Module>, FileId), File(AstId<ast::Module>, FileId),
Inline(AstId<ast::Module>), Inline(AstId<ast::Module>),
Block(AstId<ast::Block>),
} }
impl Default for ModuleOrigin { impl Default for ModuleOrigin {
@ -140,7 +139,7 @@ impl ModuleOrigin {
pub fn declaration(&self) -> Option<AstId<ast::Module>> { pub fn declaration(&self) -> Option<AstId<ast::Module>> {
match self { match self {
ModuleOrigin::File(m, _) | ModuleOrigin::Inline(m) => Some(*m), ModuleOrigin::File(m, _) | ModuleOrigin::Inline(m) => Some(*m),
ModuleOrigin::Root(_) | ModuleOrigin::Block(_) => None, ModuleOrigin::Root(_) => None,
} }
} }
@ -162,7 +161,6 @@ impl ModuleOrigin {
} }
ModuleOrigin::Root(None) => unreachable!(), ModuleOrigin::Root(None) => unreachable!(),
ModuleOrigin::Inline(m) => InFile::new(m.file_id, ModuleSource::Module(m.to_node(db))), ModuleOrigin::Inline(m) => InFile::new(m.file_id, ModuleSource::Module(m.to_node(db))),
ModuleOrigin::Block(b) => InFile::new(b.file_id, ModuleSource::Block(b.to_node(db))),
} }
} }
} }
@ -360,7 +358,6 @@ impl ModuleData {
pub enum ModuleSource { pub enum ModuleSource {
SourceFile(ast::SourceFile), SourceFile(ast::SourceFile),
Module(ast::Module), Module(ast::Module),
Block(ast::Block),
} }
impl ModuleSource { impl ModuleSource {
@ -384,8 +381,6 @@ impl ModuleSource {
child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi())
{ {
ModuleSource::Module(m) ModuleSource::Module(m)
} else if let Some(b) = child.value.ancestors().filter_map(ast::Block::cast).next() {
ModuleSource::Block(b)
} else { } else {
let file_id = child.file_id.original_file(db); let file_id = child.file_id.original_file(db);
let source_file = db.parse(file_id).tree(); let source_file = db.parse(file_id).tree();

View file

@ -234,7 +234,6 @@ impl ToNav for hir::Module {
let syntax = match &src.value { let syntax = match &src.value {
ModuleSource::SourceFile(node) => node.syntax(), ModuleSource::SourceFile(node) => node.syntax(),
ModuleSource::Module(node) => node.syntax(), ModuleSource::Module(node) => node.syntax(),
ModuleSource::Block(node) => node.syntax(),
}; };
let frange = original_range(db, src.with_value(syntax)); let frange = original_range(db, src.with_value(syntax));
NavigationTarget::from_syntax( NavigationTarget::from_syntax(

View file

@ -88,7 +88,7 @@ fn rename_mod(
file_system_edits.push(move_file); file_system_edits.push(move_file);
} }
} }
ModuleSource::Module(..) | ModuleSource::Block(..) => {} ModuleSource::Module(..) => {}
} }
} }

View file

@ -96,10 +96,6 @@ impl NameDefinition {
let range = Some(m.syntax().text_range()); let range = Some(m.syntax().text_range());
res.insert(file_id, range); res.insert(file_id, range);
} }
ModuleSource::Block(b) => {
let range = Some(b.syntax().text_range());
res.insert(file_id, range);
}
ModuleSource::SourceFile(_) => { ModuleSource::SourceFile(_) => {
res.insert(file_id, None); res.insert(file_id, None);
res.extend(parent_module.children(db).map(|m| { res.extend(parent_module.children(db).map(|m| {
@ -141,7 +137,6 @@ impl NameDefinition {
let mut res = FxHashMap::default(); let mut res = FxHashMap::default();
let range = match module_src.value { let range = match module_src.value {
ModuleSource::Module(m) => Some(m.syntax().text_range()), ModuleSource::Module(m) => Some(m.syntax().text_range()),
ModuleSource::Block(b) => Some(b.syntax().text_range()),
ModuleSource::SourceFile(_) => None, ModuleSource::SourceFile(_) => None,
}; };
res.insert(file_id, range); res.insert(file_id, range);