Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/ide/src/references.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index c35e3dc3aa..199dea5e86 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs @@ -181,6 +181,9 @@ pub(crate) fn find_all_refs( is_mut: matches!(def, Definition::Local(l) if l.is_mut(sema.db)), nav, } + }) + .filter(|decl| { + !(config.exclude_library_refs && is_library_file(sema.db, decl.nav.file_id)) }); ReferenceSearchResult { declaration, references } } @@ -222,6 +225,11 @@ pub(crate) fn find_all_refs( } } +fn is_library_file(db: &RootDatabase, file_id: FileId) -> bool { + let source_root = db.file_source_root(file_id).source_root_id(db); + db.source_root(source_root).source_root(db).is_library +} + pub(crate) fn find_defs( sema: &Semantics<'_, RootDatabase>, syntax: &SyntaxNode, |