mirror of
https://github.com/enso-org/enso.git
synced 2025-01-01 02:01:35 +03:00
Hide private entries in Component Browser (#7497)
As in description. Fixes #7464
This commit is contained in:
parent
0e20644e47
commit
5d6f902383
@ -1229,7 +1229,7 @@ pub mod test {
|
||||
searcher.reload_list();
|
||||
fixture.test.run_until_stalled();
|
||||
// There are two virtual entries and two top-modules.
|
||||
assert_eq!(dbg!(searcher.components().displayed()).len(), 4);
|
||||
assert_eq!(searcher.components().displayed().len(), 4);
|
||||
|
||||
let mut subscriber = searcher.subscribe();
|
||||
searcher.enter_entry(3).expect("Entering entry failed");
|
||||
|
@ -13,6 +13,8 @@ use crate::model::suggestion_database;
|
||||
use double_representation::name::project::STANDARD_NAMESPACE;
|
||||
use double_representation::name::QualifiedName;
|
||||
use double_representation::name::QualifiedNameRef;
|
||||
use enso_doc_parser::DocSection;
|
||||
use enso_doc_parser::Tag;
|
||||
use enso_suggestion_database::SuggestionDatabase;
|
||||
|
||||
|
||||
@ -238,6 +240,17 @@ impl WhenDisplayed {
|
||||
// Currently, the engine does the filtering.
|
||||
Self::Always
|
||||
}
|
||||
|
||||
fn consider_tags(self, entry: &suggestion_database::Entry) -> Self {
|
||||
let is_private_tag =
|
||||
|doc: &DocSection| matches!(doc, DocSection::Tag { tag: Tag::Private, .. });
|
||||
let is_private = entry.documentation.iter().any(is_private_tag);
|
||||
if is_private {
|
||||
Self::Never
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Builder<'a> {
|
||||
@ -272,6 +285,7 @@ impl<'a> Builder<'a> {
|
||||
None if self.this_type.is_some() => WhenDisplayed::with_self_type(),
|
||||
None => WhenDisplayed::in_base_mode(&entry, group_id.is_some()),
|
||||
};
|
||||
let when_displayed = when_displayed.consider_tags(&entry);
|
||||
let component = Component::new_from_database_entry(id, entry, group_id);
|
||||
if matches!(when_displayed, WhenDisplayed::Always) {
|
||||
self.built_list.displayed_by_default.push(component.clone());
|
||||
@ -338,6 +352,7 @@ mod tests {
|
||||
use crate::controller::searcher::component::tests::check_groups;
|
||||
|
||||
use double_representation::name::project;
|
||||
use enso_suggestion_database::doc_section;
|
||||
use enso_suggestion_database::mock_suggestion_database;
|
||||
use ide_view::component_browser::component_list_panel::icon;
|
||||
|
||||
@ -348,6 +363,9 @@ mod tests {
|
||||
#[in_group("First Group")]
|
||||
fn fun2() -> Standard.Base.Any;
|
||||
|
||||
#[with_doc_section(doc_section!(@ Private, ""))]
|
||||
fn private() -> Standard.Base.Any;
|
||||
|
||||
mod SubModule1 {
|
||||
fn fun4() -> Standard.Base.Any;
|
||||
}
|
||||
@ -422,7 +440,8 @@ mod tests {
|
||||
"test.Test.TopModule1",
|
||||
"test.Test.TopModule2",
|
||||
]);
|
||||
assert_eq!(list.components.len(), database.keys().len());
|
||||
// We subtract a single private component.
|
||||
assert_eq!(list.components.len(), database.keys().len() - 1);
|
||||
|
||||
assert_eq!(list.groups.len(), 2);
|
||||
check_groups(&list, vec![Some(0), Some(0), Some(0), Some(1), None, None]);
|
||||
|
@ -351,6 +351,8 @@ macro_rules! mock_suggestion_database_entries {
|
||||
/// Each statement may be preceded by one or more attributes looking like in Rust. The attribute
|
||||
/// content is just a call to the [`Entry`] modifier - a method of [`Entry`] taking and returning
|
||||
/// modified `self`.
|
||||
///
|
||||
/// See also [`doc_section!`] macro for defining documentation sections for entries.
|
||||
#[macro_export]
|
||||
macro_rules! mock_suggestion_database {
|
||||
($($(#[$($attr_setter:tt)*])* $ns:ident.$project:ident { $($content:tt)* })*) => {
|
||||
|
Loading…
Reference in New Issue
Block a user