findAllMixins method

  1. @override
List<Class> findAllMixins(
  1. Class parentClass, [
  2. bool declared = true
])
override

Finds all mixins applied to the specified class with caching.

Parameters:

  • mixedClass: The class to find mixins for
  • declared: Whether to include mixins from superclasses (default: true)

Returns:

  • List of applied mixins in application order
  • Empty list if no mixins are applied
  • Cached results for subsequent calls

Mixin Resolution

  • Transitive (default): Includes mixins from entire class hierarchy
  • Direct only: Only mixins directly applied to this class
  • Application Order: Mixins are returned in the order they were applied

Example

class MyClass extends BaseClass with MixinA, MixinB {}

final myClass = await loader.loadClass<MyClass>('com.example.MyClass');
final mixins = await loader.findMixins(myClass);
// Returns: [MixinA, MixinB] (in application order)

Caching Strategy

  • Results cached by class and transitivity flag
  • Preserves mixin application order in cache
  • Efficient lookup for mixin composition analysis

Implementation

@override
List<Class> findAllMixins(Class parentClass, [bool declared = true]) {
  _checkClosed();

  final cacheKey = "${_buildCacheKey(parentClass)}:mixins:$declared";

  // Check cache first
  final cached = _mixinCache[cacheKey];
  if (cached != null) {
    _hitCount++;
    return List.from(cached);
  }

  _missCount++;

  // Compute classes
  final classes = _computeAllMixins(parentClass, declared);

  // Cache result
  _mixinCache[cacheKey] = classes;

  return List.from(classes.toSet().toList());
}