]> git.lizzy.rs Git - rust.git/commitdiff
Rebuild ra_lsp_server and nest helper function.
authorAleksey Kladov <aleksey.kladov@gmail.com>
Fri, 20 Dec 2019 10:30:22 +0000 (11:30 +0100)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Fri, 20 Dec 2019 10:52:17 +0000 (11:52 +0100)
Completion now works again, so there's no need not to nest

crates/ra_hir/src/from_source.rs

index 4fd7c757364e04933893d82426adae79e973b7b9..3b6454a1d83edcc50b87e75da071b967e297c444 100644 (file)
@@ -212,43 +212,43 @@ pub fn from_definition(db: &impl DefDatabase, src: InFile<ModuleSource>) -> Opti
 }
 
 fn analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> DynMap {
-    _analyze_container(db, src).unwrap_or_default()
-}
+    return child_by_source(db, src).unwrap_or_default();
 
-fn _analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option<DynMap> {
-    for container in src.value.ancestors().skip(1) {
-        let res = match_ast! {
-            match container {
-                ast::TraitDef(it) => {
-                    let def = Trait::from_source(db, src.with_value(it))?;
-                    def.id.child_by_source(db)
-                },
-                ast::ImplBlock(it) => {
-                    let def = ImplBlock::from_source(db, src.with_value(it))?;
-                    def.id.child_by_source(db)
-                },
-                ast::FnDef(it) => {
-                    let def = Function::from_source(db, src.with_value(it))?;
-                    DefWithBodyId::from(def.id)
-                        .child_by_source(db)
-                },
-                ast::StaticDef(it) => {
-                    let def = Static::from_source(db, src.with_value(it))?;
-                    DefWithBodyId::from(def.id)
-                        .child_by_source(db)
-                },
-                ast::ConstDef(it) => {
-                    let def = Const::from_source(db, src.with_value(it))?;
-                    DefWithBodyId::from(def.id)
-                        .child_by_source(db)
-                },
-                _ => { continue },
-            }
-        };
-        return Some(res);
-    }
+    fn child_by_source(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option<DynMap> {
+        for container in src.value.ancestors().skip(1) {
+            let res = match_ast! {
+                match container {
+                    ast::TraitDef(it) => {
+                        let def = Trait::from_source(db, src.with_value(it))?;
+                        def.id.child_by_source(db)
+                    },
+                    ast::ImplBlock(it) => {
+                        let def = ImplBlock::from_source(db, src.with_value(it))?;
+                        def.id.child_by_source(db)
+                    },
+                    ast::FnDef(it) => {
+                        let def = Function::from_source(db, src.with_value(it))?;
+                        DefWithBodyId::from(def.id)
+                            .child_by_source(db)
+                    },
+                    ast::StaticDef(it) => {
+                        let def = Static::from_source(db, src.with_value(it))?;
+                        DefWithBodyId::from(def.id)
+                            .child_by_source(db)
+                    },
+                    ast::ConstDef(it) => {
+                        let def = Const::from_source(db, src.with_value(it))?;
+                        DefWithBodyId::from(def.id)
+                            .child_by_source(db)
+                    },
+                    _ => { continue },
+                }
+            };
+            return Some(res);
+        }
 
-    let module_source = ModuleSource::from_child_node(db, src);
-    let c = Module::from_definition(db, src.with_value(module_source))?;
-    Some(c.id.child_by_source(db))
+        let module_source = ModuleSource::from_child_node(db, src);
+        let c = Module::from_definition(db, src.with_value(module_source))?;
+        Some(c.id.child_by_source(db))
+    }
 }