From 8fc20b65035d93bcc1b3a89127916bd165a8d938 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 11:59:50 +0100 Subject: Rename ContainerId -> AssocContainerId --- crates/ra_hir_def/src/body/lower.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def/src/body/lower.rs') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 17efa10e2..afd5231cc 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -25,7 +25,7 @@ use crate::{ path::GenericArgs, path::Path, type_ref::{Mutability, TypeRef}, - ContainerId, DefWithBodyId, FunctionLoc, Intern, + AssocContainerId, DefWithBodyId, FunctionLoc, Intern, }; pub(super) fn lower( @@ -490,7 +490,7 @@ where } fn collect_block_items(&mut self, block: &ast::Block) { - let container = ContainerId::DefWithBodyId(self.def); + let container = AssocContainerId::DefWithBodyId(self.def); for item in block.items() { match item { ast::ModuleItem::FnDef(def) => { -- cgit v1.2.3 From 94ad07af4bef6a70602e315bf315c6fce95618dd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 12:07:23 +0100 Subject: Introduce `ContainerId` --- crates/ra_hir_def/src/body/lower.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def/src/body/lower.rs') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index afd5231cc..0103a1aab 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -25,7 +25,7 @@ use crate::{ path::GenericArgs, path::Path, type_ref::{Mutability, TypeRef}, - AssocContainerId, DefWithBodyId, FunctionLoc, Intern, + ContainerId, DefWithBodyId, FunctionLoc, Intern, }; pub(super) fn lower( @@ -490,7 +490,7 @@ where } fn collect_block_items(&mut self, block: &ast::Block) { - let container = AssocContainerId::DefWithBodyId(self.def); + let container = ContainerId::DefWithBodyId(self.def).into(); for item in block.items() { match item { ast::ModuleItem::FnDef(def) => { -- cgit v1.2.3 From ac5a3f611b05dbedd286169539335ae9f0fbb7b0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 12:20:49 +0100 Subject: Support for nested ADT --- crates/ra_hir_def/src/body/lower.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'crates/ra_hir_def/src/body/lower.rs') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 0103a1aab..0d3f946df 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -25,7 +25,7 @@ use crate::{ path::GenericArgs, path::Path, type_ref::{Mutability, TypeRef}, - ContainerId, DefWithBodyId, FunctionLoc, Intern, + ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StructLoc, UnionLoc, }; pub(super) fn lower( @@ -490,16 +490,28 @@ where } fn collect_block_items(&mut self, block: &ast::Block) { - let container = ContainerId::DefWithBodyId(self.def).into(); + let container = ContainerId::DefWithBodyId(self.def); for item in block.items() { - match item { + let def: ModuleDefId = match item { ast::ModuleItem::FnDef(def) => { let ast_id = self.expander.ast_id(&def); - self.body.defs.push(FunctionLoc { container, ast_id }.intern(self.db).into()) + FunctionLoc { container: container.into(), ast_id }.intern(self.db).into() } - // FIXME: handle other items - _ => (), - } + ast::ModuleItem::StructDef(def) => { + let ast_id = self.expander.ast_id(&def); + StructLoc { container, ast_id }.intern(self.db).into() + } + ast::ModuleItem::EnumDef(def) => { + let ast_id = self.expander.ast_id(&def); + EnumLoc { container, ast_id }.intern(self.db).into() + } + ast::ModuleItem::UnionDef(def) => { + let ast_id = self.expander.ast_id(&def); + UnionLoc { container, ast_id }.intern(self.db).into() + } + _ => continue, + }; + self.body.defs.push(def) } } -- cgit v1.2.3 From fe1b160dcfdeb3f582ccae1440c9580ade0beb39 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 12:22:55 +0100 Subject: Support for nested statics, consts and type aliases --- crates/ra_hir_def/src/body/lower.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_def/src/body/lower.rs') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 0d3f946df..b61f924b7 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -25,7 +25,8 @@ use crate::{ path::GenericArgs, path::Path, type_ref::{Mutability, TypeRef}, - ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StructLoc, UnionLoc, + ConstLoc, ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StaticLoc, + StructLoc, TypeAliasLoc, UnionLoc, }; pub(super) fn lower( @@ -497,6 +498,18 @@ where let ast_id = self.expander.ast_id(&def); FunctionLoc { container: container.into(), ast_id }.intern(self.db).into() } + ast::ModuleItem::TypeAliasDef(def) => { + let ast_id = self.expander.ast_id(&def); + TypeAliasLoc { container: container.into(), ast_id }.intern(self.db).into() + } + ast::ModuleItem::ConstDef(def) => { + let ast_id = self.expander.ast_id(&def); + ConstLoc { container: container.into(), ast_id }.intern(self.db).into() + } + ast::ModuleItem::StaticDef(def) => { + let ast_id = self.expander.ast_id(&def); + StaticLoc { container, ast_id }.intern(self.db).into() + } ast::ModuleItem::StructDef(def) => { let ast_id = self.expander.ast_id(&def); StructLoc { container, ast_id }.intern(self.db).into() -- cgit v1.2.3 From f42697e54b9d0a040011cb04c266d51710e249f1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 12:29:25 +0100 Subject: Support for nested traits --- crates/ra_hir_def/src/body/lower.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def/src/body/lower.rs') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index b61f924b7..853e17bae 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -26,7 +26,7 @@ use crate::{ path::Path, type_ref::{Mutability, TypeRef}, ConstLoc, ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StaticLoc, - StructLoc, TypeAliasLoc, UnionLoc, + StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, }; pub(super) fn lower( @@ -522,7 +522,14 @@ where let ast_id = self.expander.ast_id(&def); UnionLoc { container, ast_id }.intern(self.db).into() } - _ => continue, + ast::ModuleItem::TraitDef(def) => { + let ast_id = self.expander.ast_id(&def); + TraitLoc { container, ast_id }.intern(self.db).into() + } + ast::ModuleItem::ImplBlock(_) + | ast::ModuleItem::UseItem(_) + | ast::ModuleItem::ExternCrateItem(_) + | ast::ModuleItem::Module(_) => continue, }; self.body.defs.push(def) } -- cgit v1.2.3