Skip to content

Commit 613bc62

Browse files
committed
Refactor document data cleanup
1 parent c7cad51 commit 613bc62

3 files changed

Lines changed: 302 additions & 47 deletions

File tree

rust/rubydex/src/model/declaration.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,8 @@ impl Declaration {
357357
all_declarations!(self, it => it.definition_ids.is_empty())
358358
}
359359

360-
/// Returns true if this declaration is no longer anchored to anything
361-
/// and can be removed. For most declarations, that means having no
362-
/// definitions. Singleton classes are also kept alive by members and
363-
/// inbound constant references.
360+
/// Returns true if this declaration has no local anchors and can be removed.
361+
/// Graph-level cleanup can still keep declarations alive based on external anchors.
364362
#[must_use]
365363
pub fn is_removable(&self) -> bool {
366364
if let Some(ns) = self.as_singleton_class() {

rust/rubydex/src/model/definitions.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ impl Definition {
179179
}
180180
}
181181

182+
#[must_use]
183+
pub fn has_extend_mixin(&self) -> bool {
184+
let mixins = match self {
185+
Definition::Class(definition) => definition.mixins(),
186+
Definition::SingletonClass(definition) => definition.mixins(),
187+
Definition::Module(definition) => definition.mixins(),
188+
_ => return false,
189+
};
190+
191+
mixins.iter().any(|mixin| matches!(mixin, Mixin::Extend(_)))
192+
}
193+
182194
#[must_use]
183195
pub fn is_deprecated(&self) -> bool {
184196
all_definitions!(self, it => it.flags().is_deprecated())

0 commit comments

Comments
 (0)