diff --git a/packages/mirrors/lib/mirrors.dart b/packages/mirrors/lib/mirrors.dart index 76ecd8c..aed6981 100644 --- a/packages/mirrors/lib/mirrors.dart +++ b/packages/mirrors/lib/mirrors.dart @@ -13,8 +13,9 @@ export 'src/core/mirror_system.dart'; /// Discovery export 'src/discovery/type_analyzer.dart'; -export 'src/discovery/library_scanner.dart'; -export 'src/discovery/scanner.dart'; +export 'src/discovery/library_analyzer.dart'; +export 'src/discovery/runtime_library_discoverer.dart'; +export 'src/discovery/runtime_type_discoverer.dart'; /// Discovery Models export 'src/discovery/models/models.dart'; diff --git a/packages/mirrors/lib/src/discovery/library_scanner.dart b/packages/mirrors/lib/src/discovery/library_analyzer.dart similarity index 88% rename from packages/mirrors/lib/src/discovery/library_scanner.dart rename to packages/mirrors/lib/src/discovery/library_analyzer.dart index e9e64cb..4d53a14 100644 --- a/packages/mirrors/lib/src/discovery/library_scanner.dart +++ b/packages/mirrors/lib/src/discovery/library_analyzer.dart @@ -1,27 +1,6 @@ -import 'dart:core'; import 'package:platform_contracts/contracts.dart'; import 'package:platform_mirrors/mirrors.dart'; -/// Runtime scanner that analyzes libraries and extracts their metadata. -class LibraryScanner { - // Private constructor to prevent instantiation - LibraryScanner._(); - - // Cache for library metadata - static final Map _libraryCache = {}; - - /// Scans a library and extracts its metadata. - static LibraryInfo scanLibrary(Uri uri) { - if (_libraryCache.containsKey(uri)) { - return _libraryCache[uri]!; - } - - final libraryInfo = LibraryAnalyzer.analyze(uri); - _libraryCache[uri] = libraryInfo; - return libraryInfo; - } -} - /// Analyzes libraries at runtime to extract their metadata. class LibraryAnalyzer { // Private constructor to prevent instantiation diff --git a/packages/mirrors/lib/src/discovery/runtime_library_discoverer.dart b/packages/mirrors/lib/src/discovery/runtime_library_discoverer.dart new file mode 100644 index 0000000..0b2e1e2 --- /dev/null +++ b/packages/mirrors/lib/src/discovery/runtime_library_discoverer.dart @@ -0,0 +1,22 @@ +import 'dart:core'; +import 'package:platform_mirrors/mirrors.dart'; + +/// Runtime scanner that analyzes libraries and extracts their metadata. +class RuntimeLibraryDiscoverer { + // Private constructor to prevent instantiation + RuntimeLibraryDiscoverer._(); + + // Cache for library metadata + static final Map _libraryCache = {}; + + /// Scans a library and extracts its metadata. + static LibraryInfo scanLibrary(Uri uri) { + if (_libraryCache.containsKey(uri)) { + return _libraryCache[uri]!; + } + + final libraryInfo = LibraryAnalyzer.analyze(uri); + _libraryCache[uri] = libraryInfo; + return libraryInfo; + } +} diff --git a/packages/mirrors/lib/src/discovery/scanner.dart b/packages/mirrors/lib/src/discovery/runtime_type_discoverer.dart similarity index 97% rename from packages/mirrors/lib/src/discovery/scanner.dart rename to packages/mirrors/lib/src/discovery/runtime_type_discoverer.dart index 0fe33cf..b38f3df 100644 --- a/packages/mirrors/lib/src/discovery/scanner.dart +++ b/packages/mirrors/lib/src/discovery/runtime_type_discoverer.dart @@ -2,9 +2,9 @@ import 'dart:core'; import 'package:platform_mirrors/mirrors.dart'; /// Runtime scanner that analyzes types and extracts their metadata. -class Scanner { +class RuntimeTypeDiscoverer { // Private constructor to prevent instantiation - Scanner._(); + RuntimeTypeDiscoverer._(); // Cache for type metadata static final Map _typeCache = {}; diff --git a/packages/mirrors/lib/src/mirrors/library_mirror.dart b/packages/mirrors/lib/src/mirrors/library_mirror.dart index 8bd081c..125ba11 100644 --- a/packages/mirrors/lib/src/mirrors/library_mirror.dart +++ b/packages/mirrors/lib/src/mirrors/library_mirror.dart @@ -37,7 +37,7 @@ class LibraryMirror extends TypedMirror implements LibraryMirrorContract { List metadata = const [], }) { // Scan library to get declarations - final libraryInfo = LibraryScanner.scanLibrary(uri); + final libraryInfo = RuntimeLibraryDiscoverer.scanLibrary(uri); final declarations = {}; final topLevelValues = {}; diff --git a/packages/mirrors/test/scanner_test.dart b/packages/mirrors/test/scanner_test.dart index 825df13..e7b856e 100644 --- a/packages/mirrors/test/scanner_test.dart +++ b/packages/mirrors/test/scanner_test.dart @@ -78,7 +78,7 @@ void main() { isWritable: false); // Scan type - Scanner.scanType(TestClass); + RuntimeTypeDiscoverer.scanType(TestClass); final metadata = ReflectionRegistry.getPropertyMetadata(TestClass); expect(metadata, isNotNull); @@ -130,7 +130,7 @@ void main() { ); // Scan type - Scanner.scanType(TestClass); + RuntimeTypeDiscoverer.scanType(TestClass); final metadata = ReflectionRegistry.getMethodMetadata(TestClass); expect(metadata, isNotNull); @@ -187,7 +187,7 @@ void main() { ); // Scan type - Scanner.scanType(TestClass); + RuntimeTypeDiscoverer.scanType(TestClass); final metadata = ReflectionRegistry.getConstructorMetadata(TestClass); expect(metadata, isNotNull); @@ -255,7 +255,7 @@ void main() { ); // Scan type - Scanner.scanType(TestClass); + RuntimeTypeDiscoverer.scanType(TestClass); final reflector = RuntimeReflector.instance; @@ -320,7 +320,7 @@ void main() { ); // Scan type - Scanner.scanType(GenericTestClass); + RuntimeTypeDiscoverer.scanType(GenericTestClass); final metadata = ReflectionRegistry.getPropertyMetadata(GenericTestClass); expect(metadata, isNotNull); @@ -364,8 +364,8 @@ void main() { ); // Scan types - Scanner.scanType(ParentTestClass); - Scanner.scanType(ChildTestClass); + RuntimeTypeDiscoverer.scanType(ParentTestClass); + RuntimeTypeDiscoverer.scanType(ChildTestClass); final parentMeta = ReflectionRegistry.getPropertyMetadata(ParentTestClass);