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

View File

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

View File

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

View File

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