Remove dead code: _createDependencyKey (no longer used, cycle detection not affected)

This commit is contained in:
Sergey Penkovsky
2025-07-30 08:17:49 +03:00
parent 5630efccfe
commit d4af82ba01
4 changed files with 11 additions and 4 deletions

View File

@@ -151,6 +151,7 @@ void main() {
CherryPick.closeRootScope(); CherryPick.closeRootScope();
// Создаем скоуп без обнаружения // Создаем скоуп без обнаружения
// ignore: unused_local_variable
final specificScope = CherryPick.openRootScope(); final specificScope = CherryPick.openRootScope();
print(' Detection in root scope: ${CherryPick.isCycleDetectionEnabledForScope()}'); print(' Detection in root scope: ${CherryPick.isCycleDetectionEnabledForScope()}');
@@ -159,6 +160,7 @@ void main() {
print('✅ Detection enabled for root scope: ${CherryPick.isCycleDetectionEnabledForScope()}'); print('✅ Detection enabled for root scope: ${CherryPick.isCycleDetectionEnabledForScope()}');
// Создаем дочерний скоуп // Создаем дочерний скоуп
// ignore: unused_local_variable
final featureScope = CherryPick.openScope(scopeName: 'feature.auth'); final featureScope = CherryPick.openScope(scopeName: 'feature.auth');
print(' Detection in feature.auth scope: ${CherryPick.isCycleDetectionEnabledForScope(scopeName: 'feature.auth')}'); print(' Detection in feature.auth scope: ${CherryPick.isCycleDetectionEnabledForScope(scopeName: 'feature.auth')}');
@@ -191,6 +193,7 @@ void main() {
print(' Chain before resolve: ${CherryPick.getCurrentResolutionChain()}'); print(' Chain before resolve: ${CherryPick.getCurrentResolutionChain()}');
// The chain is populated during resolution, but cleared after completion // The chain is populated during resolution, but cleared after completion
// ignore: unused_local_variable
final trackedUserService = trackingScope.resolve<UserService>(); final trackedUserService = trackingScope.resolve<UserService>();
print(' Chain after resolve: ${CherryPick.getCurrentResolutionChain()}'); print(' Chain after resolve: ${CherryPick.getCurrentResolutionChain()}');
print(''); print('');

View File

@@ -142,15 +142,17 @@ class GlobalCycleDetector {
void clear() { void clear() {
_globalResolutionStack.clear(); _globalResolutionStack.clear();
_globalResolutionHistory.clear(); _globalResolutionHistory.clear();
_scopeDetectors.values.forEach((detector) => detector.clear()); _scopeDetectors.values.forEach(_detectorClear);
_scopeDetectors.clear(); _scopeDetectors.clear();
} }
void _detectorClear(detector) => detector.clear();
/// RU: Создать уникальный ключ для зависимости с учетом скоупа. /// RU: Создать уникальный ключ для зависимости с учетом скоупа.
/// ENG: Create unique key for dependency including scope. /// ENG: Create unique key for dependency including scope.
String _createDependencyKey<T>(String? named, String? scopeId) { //String _createDependencyKey<T>(String? named, String? scopeId) {
return _createDependencyKeyFromType(T, named, scopeId); // return _createDependencyKeyFromType(T, named, scopeId);
} //}
/// RU: Создать уникальный ключ для зависимости по типу с учетом скоупа. /// RU: Создать уникальный ключ для зависимости по типу с учетом скоупа.
/// ENG: Create unique key for dependency by type including scope. /// ENG: Create unique key for dependency by type including scope.

View File

@@ -60,6 +60,7 @@ void main() {
// В текущей реализации это может не обнаружить циклическую зависимость // В текущей реализации это может не обнаружить циклическую зависимость
// если детекторы работают независимо в каждом скоупе // если детекторы работают независимо в каждом скоупе
try { try {
// ignore: unused_local_variable
final service = parentScope.resolve<CrossScopeServiceA>(); final service = parentScope.resolve<CrossScopeServiceA>();
// Если мы дошли сюда, значит циклическая зависимость не была обнаружена // Если мы дошли сюда, значит циклическая зависимость не была обнаружена
print('Циклическая зависимость между скоупами не обнаружена'); print('Циклическая зависимость между скоупами не обнаружена');

View File

@@ -142,6 +142,7 @@ void main() {
test('should clear global cycle detector state', () { test('should clear global cycle detector state', () {
CherryPick.enableGlobalCrossScopeCycleDetection(); CherryPick.enableGlobalCrossScopeCycleDetection();
// ignore: unused_local_variable
final scope = CherryPick.openGlobalSafeRootScope(); final scope = CherryPick.openGlobalSafeRootScope();
expect(CherryPick.getGlobalResolutionChain(), isEmpty); expect(CherryPick.getGlobalResolutionChain(), isEmpty);