aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/runnables.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/runnables.rs')
-rw-r--r--crates/ide/src/runnables.rs28
1 files changed, 1 insertions, 27 deletions
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index bea020b06..5b488e2c5 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -7,17 +7,13 @@ use hir::{AsAssocItem, HasAttrs, HasSource, HirDisplay, Semantics};
7use ide_assists::utils::test_related_attribute; 7use ide_assists::utils::test_related_attribute;
8use ide_db::{ 8use ide_db::{
9 base_db::{FilePosition, FileRange}, 9 base_db::{FilePosition, FileRange},
10 defs::Definition,
11 helpers::visit_file_defs, 10 helpers::visit_file_defs,
12 search::SearchScope, 11 search::SearchScope,
13 RootDatabase, SymbolKind, 12 RootDatabase, SymbolKind,
14}; 13};
15use itertools::Itertools; 14use itertools::Itertools;
16use rustc_hash::FxHashSet; 15use rustc_hash::FxHashSet;
17use syntax::{ 16use syntax::ast::{self, AstNode, AttrsOwner};
18 ast::{self, AstNode, AttrsOwner},
19 match_ast, SyntaxNode,
20};
21 17
22use crate::{ 18use crate::{
23 display::{ToNav, TryToNav}, 19 display::{ToNav, TryToNav},
@@ -271,28 +267,6 @@ pub(crate) fn runnable_mod(sema: &Semantics<RootDatabase>, def: hir::Module) ->
271 Some(Runnable { nav, kind: RunnableKind::TestMod { path }, cfg }) 267 Some(Runnable { nav, kind: RunnableKind::TestMod { path }, cfg })
272} 268}
273 269
274// FIXME: figure out a proper API here.
275pub(crate) fn doc_owner_to_def(
276 sema: &Semantics<RootDatabase>,
277 item: SyntaxNode,
278) -> Option<Definition> {
279 let res: hir::ModuleDef = match_ast! {
280 match item {
281 ast::SourceFile(_it) => sema.scope(&item).module()?.into(),
282 ast::Fn(it) => sema.to_def(&it)?.into(),
283 ast::Struct(it) => sema.to_def(&it)?.into(),
284 ast::Enum(it) => sema.to_def(&it)?.into(),
285 ast::Union(it) => sema.to_def(&it)?.into(),
286 ast::Trait(it) => sema.to_def(&it)?.into(),
287 ast::Const(it) => sema.to_def(&it)?.into(),
288 ast::Static(it) => sema.to_def(&it)?.into(),
289 ast::TypeAlias(it) => sema.to_def(&it)?.into(),
290 _ => return None,
291 }
292 };
293 Some(Definition::ModuleDef(res))
294}
295
296fn module_def_doctest(sema: &Semantics<RootDatabase>, def: hir::ModuleDef) -> Option<Runnable> { 270fn module_def_doctest(sema: &Semantics<RootDatabase>, def: hir::ModuleDef) -> Option<Runnable> {
297 let attrs = match def { 271 let attrs = match def {
298 hir::ModuleDef::Module(it) => it.attrs(sema.db), 272 hir::ModuleDef::Module(it) => it.attrs(sema.db),