diff --git a/packages/container/container/README.md b/packages/container/container/README.md index aec7501..1aa9a5e 100644 --- a/packages/container/container/README.md +++ b/packages/container/container/README.md @@ -1,6 +1,6 @@ # Protevus Container -![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_container?include_prereleases) +![Pub Version (including pre-releases)](https://img.shields.io/pub/v/platform_container?include_prereleases) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/container/angel_container/LICENSE) @@ -8,9 +8,9 @@ A better IoC container for Protevus, ultimately allowing Protevus to be used with or without `dart:mirrors` package. ```dart - import 'package:angel3_container/mirrors.dart'; - import 'package:angel3_framework/angel3_framework.dart'; - import 'package:angel3_framework/http.dart'; + import 'package:platform_container/mirrors.dart'; + import 'package:platform_core/core.dart'; + import 'package:platform_core/http.dart'; @Expose('/sales', middleware: [process1]) class SalesController extends Controller { diff --git a/packages/container/container/example/main.dart b/packages/container/container/example/main.dart index 5537e74..35b1bd6 100644 --- a/packages/container/container/example/main.dart +++ b/packages/container/container/example/main.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:platform_container/mirrors.dart'; Future main() async { diff --git a/packages/container/container/example/throwing.dart b/packages/container/container/example/throwing.dart index b0bbc70..cde5d33 100644 --- a/packages/container/container/example/throwing.dart +++ b/packages/container/container/example/throwing.dart @@ -1,4 +1,4 @@ -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; void main() { var reflector = const ThrowingReflector(); diff --git a/packages/container/container/lib/platform_container.dart b/packages/container/container/lib/container.dart similarity index 51% rename from packages/container/container/lib/platform_container.dart rename to packages/container/container/lib/container.dart index f2f6a52..db227c5 100644 --- a/packages/container/container/lib/platform_container.dart +++ b/packages/container/container/lib/container.dart @@ -1,3 +1,12 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + library platform_container; export 'src/container.dart'; diff --git a/packages/container/container/lib/mirrors.dart b/packages/container/container/lib/mirrors.dart index b16cabb..848c298 100644 --- a/packages/container/container/lib/mirrors.dart +++ b/packages/container/container/lib/mirrors.dart @@ -1 +1,10 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + export 'src/mirrors/mirrors.dart'; diff --git a/packages/container/container/lib/src/container.dart b/packages/container/container/lib/src/container.dart index 5fb963a..e1c3743 100644 --- a/packages/container/container/lib/src/container.dart +++ b/packages/container/container/lib/src/container.dart @@ -1,28 +1,135 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + import 'dart:async'; import 'exception.dart'; import 'reflector.dart'; class Container { + /// The [Reflector] instance used by this container for reflection-based operations. + /// + /// This reflector is used to instantiate objects and resolve dependencies + /// when no explicit factory or singleton is registered for a given type. final Reflector reflector; + + /// A map that stores singleton instances, where the key is the Type and the value is the singleton object. + /// + /// This map is used internally by the Container to store and retrieve singleton objects + /// that have been registered using the [registerSingleton] method. final Map _singletons = {}; + + /// A map that stores factory functions for creating instances of different types. + /// + /// The key is the Type for which the factory is registered, and the value is a function + /// that takes a Container as an argument and returns an instance of that Type. + /// + /// This map is used internally by the Container to store and retrieve factory functions + /// that have been registered using the [registerFactory] method. final Map _factories = {}; + + /// A map that stores named singleton instances, where the key is a String name and the value is the singleton object. + /// + /// This map is used internally by the Container to store and retrieve named singleton objects + /// that have been registered using the [registerNamedSingleton] method. Named singletons allow + /// for multiple instances of the same type to be stored in the container with different names. final Map _namedSingletons = {}; + + /// The parent container of this container, if any. + /// + /// This property is used to create a hierarchy of containers, where child containers + /// can access dependencies registered in their parent containers. If this container + /// is a root container (i.e., it has no parent), this property will be null. + /// + /// The parent-child relationship allows for scoped dependency injection, where + /// child containers can override or add to the dependencies defined in their parents. final Container? _parent; + /// Creates a new root [Container] instance with the given [Reflector]. + /// + /// This constructor initializes a new container without a parent, making it + /// a root container in the dependency injection hierarchy. The provided + /// [reflector] will be used for all reflection-based operations within this + /// container and its child containers. + /// + /// Parameters: + /// - [reflector]: The [Reflector] instance to be used by this container + /// for reflection-based dependency resolution and object instantiation. + /// + /// The [_parent] is set to null, indicating that this is a root container. Container(this.reflector) : _parent = null; + /// Creates a child [Container] instance with the given parent container. + /// + /// This constructor is used internally to create child containers in the + /// dependency injection hierarchy. It initializes a new container with a + /// reference to its parent container and uses the same [Reflector] instance + /// as the parent. + /// + /// Parameters: + /// - [_parent]: The parent [Container] instance for this child container. + /// + /// The [reflector] is initialized with the parent container's reflector, + /// ensuring consistency in reflection operations throughout the container + /// hierarchy. Container._child(Container this._parent) : reflector = _parent.reflector; + /// Checks if this container is a root container. + /// + /// Returns `true` if this container has no parent (i.e., it's a root container), + /// and `false` otherwise. + /// + /// This property is useful for determining the position of a container in the + /// dependency injection hierarchy. Root containers are typically used as the + /// top-level containers in an application, while non-root containers are child + /// containers that may have more specific or localized dependencies. bool get isRoot => _parent == null; /// Creates a child [Container] that can define its own singletons and factories. /// - /// Use this to create children of a global "scope." + /// This method creates a new [Container] instance that is a child of the current container. + /// The child container inherits access to all dependencies registered in its parent containers, + /// but can also define its own singletons and factories that override or extend the parent's dependencies. + /// + /// Child containers are useful for creating scoped dependency injection contexts, such as + /// for specific features, modules, or request-scoped dependencies in web applications. + /// + /// The child container uses the same [Reflector] instance as its parent. + /// + /// Returns: + /// A new [Container] instance that is a child of the current container. + /// + /// Example: + /// ```dart + /// var parentContainer = Container(MyReflector()); + /// var childContainer = parentContainer.createChild(); + /// ``` Container createChild() { return Container._child(this); } - /// Determines if the container has an injection of the given type. + /// Determines if the container or any of its parent containers has an injection of the given type. + /// + /// This method checks for both singleton and factory registrations of the specified type. + /// + /// Parameters: + /// - [T]: The type to check for. If [T] is dynamic, the [t] parameter must be provided. + /// - [t]: An optional Type parameter. If provided, it overrides the type specified by [T]. + /// + /// Returns: + /// - `true` if an injection (singleton or factory) for the specified type is found in this + /// container or any of its parent containers. + /// - `false` if no injection is found for the specified type in the entire container hierarchy. + /// + /// Note: + /// - If [T] is dynamic and [t] is null, the method returns `false` immediately. + /// - The method searches the current container first, then moves up the parent hierarchy + /// until an injection is found or the root container is reached. bool has([Type? t]) { var t2 = T; if (t != null) { @@ -45,7 +152,22 @@ class Container { return false; } - /// Determines if the container has a named singleton with the given [name]. + /// Determines if the container or any of its parent containers has a named singleton with the given [name]. + /// + /// This method searches the current container and its parent hierarchy for a named singleton + /// registered with the specified [name]. + /// + /// Parameters: + /// - [name]: The name of the singleton to search for. + /// + /// Returns: + /// - `true` if a named singleton with the specified [name] is found in this container + /// or any of its parent containers. + /// - `false` if no named singleton with the specified [name] is found in the entire + /// container hierarchy. + /// + /// The method searches the current container first, then moves up the parent hierarchy + /// until a named singleton is found or the root container is reached. bool hasNamed(String name) { Container? search = this; @@ -60,10 +182,26 @@ class Container { return false; } - /// Instantiates an instance of [T], asynchronously. + /// Asynchronously instantiates an instance of [T]. /// - /// It is similar to [make], but resolves an injection of either - /// `Future` or `T`. + /// This method attempts to resolve and return a [Future] in the following order: + /// 1. If an injection of type [T] is registered, it wraps it in a [Future] and returns it. + /// 2. If an injection of type [Future] is registered, it returns it directly. + /// 3. If [T] is [dynamic] and a [Future] of the specified type is registered, it returns that. + /// 4. If none of the above conditions are met, it throws a [ReflectionException]. + /// + /// Parameters: + /// - [type]: An optional [Type] parameter that can be used to specify the type + /// when [T] is [dynamic] or when a different type than [T] needs to be used. + /// + /// Returns: + /// A [Future] representing the asynchronously resolved instance. + /// + /// Throws: + /// - [ReflectionException] if no suitable injection is found. + /// + /// This method is useful when you need to resolve dependencies that may be + /// registered as either synchronous ([T]) or asynchronous ([Future]) types. Future makeAsync([Type? type]) { var t2 = T; if (type != null) { @@ -94,8 +232,29 @@ class Container { /// Instantiates an instance of [T]. /// - /// In contexts where a static generic type cannot be used, use - /// the [type] argument, instead of [T]. + /// This method attempts to resolve and return an instance of type [T] in the following order: + /// 1. If a singleton of type [T] is registered in this container or any parent container, it returns that instance. + /// 2. If a factory for type [T] is registered in this container or any parent container, it calls the factory and returns the result. + /// 3. If no singleton or factory is found, it uses reflection to instantiate a new instance of [T]. + /// + /// For reflection-based instantiation: + /// - It looks for a default constructor or a constructor with an empty name. + /// - It recursively resolves and injects dependencies for the constructor parameters. + /// - It supports both positional and named parameters. + /// + /// Parameters: + /// - [type]: An optional [Type] parameter that can be used to specify the type + /// when [T] is [dynamic] or when a different type than [T] needs to be used. + /// + /// Returns: + /// An instance of type [T]. + /// + /// Throws: + /// - [ReflectionException] if [T] is not a class or if it has no default constructor. + /// - Any exception that might occur during the instantiation process. + /// + /// This method is central to the dependency injection mechanism, allowing for + /// flexible object creation and dependency resolution within the container hierarchy. T make([Type? type]) { Type t2 = T; if (type != null) { @@ -150,7 +309,7 @@ class Container { } } - /// Shorthand for registering a factory that injects a singleton when it runs. + /// Registers a lazy singleton factory. /// /// In many cases, you might prefer this to [registerFactory]. /// @@ -167,8 +326,7 @@ class Container { ); } - /// Registers a factory. Any attempt to resolve the - /// type within *this* container will return the result of [f]. + /// Registers a factory function for creating instances of type [T] in the container. /// /// Returns [f]. T Function(Container) registerFactory(T Function(Container) f, @@ -186,8 +344,7 @@ class Container { return f; } - /// Registers a singleton. Any attempt to resolve the - /// type within *this* container will return [object]. + /// Registers a singleton object in the container. /// /// Returns [object]. T registerSingleton(T object, {Type? as}) { @@ -207,7 +364,7 @@ class Container { return object; } - /// Finds a named singleton. + /// Retrieves a named singleton from the container or its parent containers. /// /// In general, prefer using [registerSingleton] and [registerFactory]. /// @@ -224,7 +381,7 @@ class Container { } } - /// Registers a *named* singleton. + /// Registers a named singleton object in the container. /// /// Note that this is not related to type-based injections, and exists as a mechanism /// to enable injecting multiple instances of a type within the same container hierarchy. diff --git a/packages/container/container/lib/src/container_const.dart b/packages/container/container/lib/src/container_const.dart index 5a8fcaa..f9c3572 100644 --- a/packages/container/container/lib/src/container_const.dart +++ b/packages/container/container/lib/src/container_const.dart @@ -1,8 +1,31 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/// A utility class that contains constant values related to container functionality. +/// +/// This class is not meant to be instantiated and only provides static constants. +/// It includes a default error message for reflection-related issues. class ContainerConst { + /// The default error message for reflection-related issues. + /// + /// This message is used when an attempt is made to perform a reflective action, + /// but the `ThrowingReflector` class is being used, which disables reflection. + /// Consider using the `MirrorsReflector` class if reflection is necessary. static const String defaultErrorMessage = 'You attempted to perform a reflective action, but you are using `ThrowingReflector`, ' 'a class which disables reflection. Consider using the `MirrorsReflector` ' 'class if you need reflection.'; + /// Private constructor to prevent instantiation of this utility class. + /// + /// This constructor is marked as private (with the underscore prefix) to ensure + /// that the `ContainerConst` class cannot be instantiated. This is consistent + /// with the class's purpose of only providing static constants. ContainerConst._(); } diff --git a/packages/container/container/lib/src/empty/empty.dart b/packages/container/container/lib/src/empty/empty.dart index 632acad..e0c4c43 100644 --- a/packages/container/container/lib/src/empty/empty.dart +++ b/packages/container/container/lib/src/empty/empty.dart @@ -1,45 +1,179 @@ -import '../../platform_container.dart'; +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +import 'package:platform_container/container.dart'; + +/// A cache to store symbol names. +/// +/// This map associates [Symbol] objects with their corresponding string representations. +/// It's used to avoid repeated parsing of symbol names, improving performance +/// when retrieving symbol names multiple times. final Map _symbolNames = {}; /// A [Reflector] implementation that performs no actual reflection, /// instead returning empty objects on every invocation. /// /// Use this in contexts where you know you won't need any reflective capabilities. +/// +/// This class provides a lightweight alternative to full reflection when reflection +/// functionality is not required. It returns empty or placeholder objects for all +/// reflection operations, which can be useful in scenarios where reflection is +/// expected but not actually used, or when you want to minimize the overhead of +/// reflection in certain parts of your application. +/// +/// The [EmptyReflector] includes: +/// - A static [RegExp] for extracting symbol names without reflection. +/// - Methods to return empty implementations of [ReflectedClass], [ReflectedInstance], +/// [ReflectedType], and [ReflectedFunction]. +/// - A [getName] method that uses a cache to store and retrieve symbol names. +/// +/// This implementation can be particularly useful in testing scenarios or in +/// production environments where reflection is not needed but the interface +/// expecting reflection capabilities needs to be satisfied. class EmptyReflector extends Reflector { /// A [RegExp] that can be used to extract the name of a symbol without reflection. + /// + /// This regular expression pattern matches the string representation of a Dart [Symbol], + /// which typically looks like 'Symbol("symbolName")'. It captures the symbol name + /// (the part between the quotes) in a capturing group. + /// + /// Usage: + /// ```dart + /// String symbolString = 'Symbol("exampleSymbol")'; + /// Match? match = symbolRegex.firstMatch(symbolString); + /// String? symbolName = match?.group(1); // Returns "exampleSymbol" + /// ``` + /// + /// This is particularly useful in contexts where reflection is not available + /// or desired, allowing for symbol name extraction through string manipulation. static final RegExp symbolRegex = RegExp(r'Symbol\("([^"]+)"\)'); + /// Creates an instance of [EmptyReflector]. + /// + /// This constructor doesn't take any parameters and creates a lightweight + /// reflector that provides empty implementations for all reflection operations. + /// It's useful in scenarios where reflection capabilities are expected but not + /// actually used, or when you want to minimize the overhead of reflection. const EmptyReflector(); + /// Retrieves the name of a given [Symbol]. + /// + /// This method attempts to extract the name of the provided [symbol] using + /// the [symbolRegex]. If the name hasn't been cached before, it will be + /// computed and stored in the [_symbolNames] cache for future use. + /// + /// The method works as follows: + /// 1. It checks if the symbol's name is already in the cache. + /// 2. If not found, it uses [putIfAbsent] to compute the name: + /// a. It converts the symbol to a string. + /// b. It applies the [symbolRegex] to extract the name. + /// c. If a match is found, it returns the first captured group (the name). + /// 3. The computed name (or null if not found) is stored in the cache and returned. + /// + /// @param symbol The [Symbol] whose name is to be retrieved. + /// @return The name of the symbol as a [String], or null if the name couldn't be extracted. @override String? getName(Symbol symbol) { return _symbolNames.putIfAbsent( symbol, () => symbolRegex.firstMatch(symbol.toString())?.group(1)); } + /// Returns an empty [ReflectedClass] instance for any given [Type]. + /// + /// This method is part of the [EmptyReflector] implementation and always + /// returns a constant instance of [_EmptyReflectedClass], regardless of + /// the input [clazz]. + /// + /// This behavior is consistent with the purpose of [EmptyReflector], + /// which provides non-functional placeholders for reflection operations. + /// + /// @param clazz The [Type] to reflect, which is ignored in this implementation. + /// @return A constant [_EmptyReflectedClass] instance. @override ReflectedClass reflectClass(Type clazz) { return const _EmptyReflectedClass(); } + /// Returns an empty [ReflectedInstance] for any given object. + /// + /// This method is part of the [EmptyReflector] implementation and always + /// returns a constant instance of [_EmptyReflectedInstance], regardless of + /// the input [object]. + /// + /// This behavior is consistent with the purpose of [EmptyReflector], + /// which provides non-functional placeholders for reflection operations. + /// + /// @param object The object to reflect, which is ignored in this implementation. + /// @return A constant [_EmptyReflectedInstance]. @override ReflectedInstance reflectInstance(Object object) { return const _EmptyReflectedInstance(); } + /// Returns an empty [ReflectedType] for any given [Type]. + /// + /// This method is part of the [EmptyReflector] implementation and always + /// returns a constant instance of [_EmptyReflectedType], regardless of + /// the input [type]. + /// + /// This behavior is consistent with the purpose of [EmptyReflector], + /// which provides non-functional placeholders for reflection operations. + /// + /// @param type The [Type] to reflect, which is ignored in this implementation. + /// @return A constant [_EmptyReflectedType] instance. @override ReflectedType reflectType(Type type) { return const _EmptyReflectedType(); } + /// Returns an empty [ReflectedFunction] for any given [Function]. + /// + /// This method is part of the [EmptyReflector] implementation and always + /// returns a constant instance of [_EmptyReflectedFunction], regardless of + /// the input [function]. + /// + /// This behavior is consistent with the purpose of [EmptyReflector], + /// which provides non-functional placeholders for reflection operations. + /// + /// @param function The [Function] to reflect, which is ignored in this implementation. + /// @return A constant [_EmptyReflectedFunction] instance. @override ReflectedFunction reflectFunction(Function function) { return const _EmptyReflectedFunction(); } } +/// An empty implementation of [ReflectedClass] used by [EmptyReflector]. +/// +/// This class provides a non-functional placeholder for reflection operations +/// on classes. It is designed to be used in contexts where reflection capabilities +/// are expected but not actually needed or desired. +/// +/// Key features: +/// - Extends [ReflectedClass] with minimal implementation. +/// - Constructor initializes with empty or default values for all properties. +/// - [newInstance] method throws an [UnsupportedError] if called. +/// - [isAssignableTo] method only returns true if compared with itself. +/// +/// This implementation is consistent with the purpose of [EmptyReflector], +/// providing a lightweight alternative when full reflection capabilities are not required. class _EmptyReflectedClass extends ReflectedClass { + /// Constructs an empty [_EmptyReflectedClass] instance. + /// + /// This constructor initializes the instance with empty or default values for all properties. + /// + /// @param name The name of the class, set to '(empty)'. + /// @param typeParameters The list of type parameters, set to an empty list. + /// @param instances The list of instances, set to an empty list. + /// @param functions The list of functions, set to an empty list. + /// @param declarations The list of declarations, set to an empty list. + /// @param type The underlying [Type] of the class, set to [Object]. const _EmptyReflectedClass() : super( '(empty)', @@ -49,6 +183,19 @@ class _EmptyReflectedClass extends ReflectedClass { const [], Object); + /// Creates a new instance of the reflected class. + /// + /// This method is part of the [_EmptyReflectedClass] implementation and always + /// throws an [UnsupportedError] when called. This behavior is consistent with + /// the purpose of [EmptyReflector], which provides non-functional placeholders + /// for reflection operations. + /// + /// @param constructorName The name of the constructor to invoke. + /// @param positionalArguments A list of positional arguments for the constructor. + /// @param namedArguments An optional map of named arguments for the constructor. + /// @param typeArguments An optional list of type arguments for generic classes. + /// @throws UnsupportedError Always thrown when this method is called. + /// @return This method never returns as it always throws an exception. @override ReflectedInstance newInstance( String constructorName, List positionalArguments, @@ -57,16 +204,59 @@ class _EmptyReflectedClass extends ReflectedClass { 'Classes reflected via an EmptyReflector cannot be instantiated.'); } + /// Checks if this empty reflected class is assignable to another reflected type. + /// + /// This method is part of the [_EmptyReflectedClass] implementation and always + /// returns true only if the [other] type is the same instance as this one. + /// This behavior is consistent with the purpose of [EmptyReflector], + /// which provides minimal functionality for reflection operations. + /// + /// @param other The [ReflectedType] to check against. + /// @return true if [other] is the same instance as this, false otherwise. @override bool isAssignableTo(ReflectedType? other) { return other == this; } } +/// An empty implementation of [ReflectedType] used by [EmptyReflector]. +/// +/// This class provides a non-functional placeholder for reflection operations +/// on types. It is designed to be used in contexts where reflection capabilities +/// are expected but not actually needed or desired. +/// +/// Key features: +/// - Extends [ReflectedType] with minimal implementation. +/// - Constructor initializes with empty or default values for all properties. +/// - [newInstance] method throws an [UnsupportedError] if called. +/// - [isAssignableTo] method only returns true if compared with itself. +/// +/// This implementation is consistent with the purpose of [EmptyReflector], +/// providing a lightweight alternative when full reflection capabilities are not required. class _EmptyReflectedType extends ReflectedType { + /// Constructs an empty [_EmptyReflectedType] instance. + /// + /// This constructor initializes the instance with empty or default values for all properties. + /// + /// @param name The name of the type, set to '(empty)'. + /// @param typeParameters The list of type parameters, set to an empty list. + /// @param type The underlying [Type], set to [Object]. const _EmptyReflectedType() : super('(empty)', const [], Object); + /// Creates a new instance of the reflected type. + /// + /// This method is part of the [_EmptyReflectedType] implementation and always + /// throws an [UnsupportedError] when called. This behavior is consistent with + /// the purpose of [EmptyReflector], which provides non-functional placeholders + /// for reflection operations. + /// + /// @param constructorName The name of the constructor to invoke. + /// @param positionalArguments A list of positional arguments for the constructor. + /// @param namedArguments An optional map of named arguments for the constructor. + /// @param typeArguments An optional list of type arguments for generic types. + /// @throws UnsupportedError Always thrown when this method is called. + /// @return This method never returns as it always throws an exception. @override ReflectedInstance newInstance( String constructorName, List positionalArguments, @@ -76,16 +266,55 @@ class _EmptyReflectedType extends ReflectedType { 'Types reflected via an EmptyReflector cannot be instantiated.'); } + /// Checks if this empty reflected type is assignable to another reflected type. + /// + /// This method is part of the [_EmptyReflectedType] implementation and always + /// returns true only if the [other] type is the same instance as this one. + /// This behavior is consistent with the purpose of [EmptyReflector], + /// which provides minimal functionality for reflection operations. + /// + /// @param other The [ReflectedType] to check against. + /// @return true if [other] is the same instance as this, false otherwise. @override bool isAssignableTo(ReflectedType? other) { return other == this; } } +/// An empty implementation of [ReflectedInstance] used by [EmptyReflector]. +/// +/// This class provides a non-functional placeholder for reflection operations +/// on instances. It is designed to be used in contexts where reflection capabilities +/// are expected but not actually needed or desired. +/// +/// Key features: +/// - Extends [ReflectedInstance] with minimal implementation. +/// - Constructor initializes with empty or default values for all properties. +/// - [getField] method throws an [UnsupportedError] if called. +/// +/// This implementation is consistent with the purpose of [EmptyReflector], +/// providing a lightweight alternative when full reflection capabilities are not required. class _EmptyReflectedInstance extends ReflectedInstance { + /// Constructs an empty [_EmptyReflectedInstance] instance. + /// + /// This constructor initializes the instance with empty or default values for all properties. + /// + /// @param type The reflected type of the instance, set to an empty [_EmptyReflectedType]. + /// @param reflectedClass The reflected class of the instance, set to an empty [_EmptyReflectedClass]. + /// @param value The underlying value of the instance, set to null. const _EmptyReflectedInstance() : super(const _EmptyReflectedType(), const _EmptyReflectedClass(), null); + /// Retrieves the value of a field on this empty reflected instance. + /// + /// This method is part of the [_EmptyReflectedInstance] implementation and always + /// throws an [UnsupportedError] when called. This behavior is consistent with + /// the purpose of [EmptyReflector], which provides non-functional placeholders + /// for reflection operations. + /// + /// @param name The name of the field to retrieve. + /// @throws UnsupportedError Always thrown when this method is called. + /// @return This method never returns as it always throws an exception. @override ReflectedInstance getField(String name) { throw UnsupportedError( @@ -93,7 +322,33 @@ class _EmptyReflectedInstance extends ReflectedInstance { } } +/// An empty implementation of [ReflectedFunction] used by [EmptyReflector]. +/// +/// This class provides a non-functional placeholder for reflection operations +/// on functions. It is designed to be used in contexts where reflection capabilities +/// are expected but not actually needed or desired. +/// +/// Key features: +/// - Extends [ReflectedFunction] with minimal implementation. +/// - Constructor initializes with empty or default values for all properties. +/// - [invoke] method throws an [UnsupportedError] if called. +/// +/// This implementation is consistent with the purpose of [EmptyReflector], +/// providing a lightweight alternative when full reflection capabilities are not required. class _EmptyReflectedFunction extends ReflectedFunction { + /// Constructs an empty [_EmptyReflectedFunction] instance. + /// + /// This constructor initializes the instance with empty or default values for all properties. + /// + /// @param name The name of the function, set to an empty string. + /// @param typeParameters A list of type parameters for the function, set to an empty list. + /// @param enclosingInstance A list of enclosing instances for the function, set to an empty list. + /// @param parameters A list of parameters for the function, set to an empty list. + /// @param isStatic Indicates whether the function is static, set to false. + /// @param isConst Indicates whether the function is constant, set to false. + /// @param returnType The return type of the function, set to an empty [_EmptyReflectedType]. + /// @param isOperator Indicates whether the function is an operator, set to false. + /// @param isExtensionMember Indicates whether the function is an extension member, set to false. const _EmptyReflectedFunction() : super( '(empty)', @@ -104,6 +359,16 @@ class _EmptyReflectedFunction extends ReflectedFunction { false, returnType: const _EmptyReflectedType()); + /// Invokes this empty reflected function. + /// + /// This method is part of the [_EmptyReflectedFunction] implementation and always + /// throws an [UnsupportedError] when called. This behavior is consistent with + /// the purpose of [EmptyReflector], which provides non-functional placeholders + /// for reflection operations. + /// + /// @param invocation The invocation to execute. + /// @throws UnsupportedError Always thrown when this method is called. + /// @return This method never returns as it always throws an exception. @override ReflectedInstance invoke(Invocation invocation) { throw UnsupportedError( diff --git a/packages/container/container/lib/src/exception.dart b/packages/container/container/lib/src/exception.dart index 7cedc82..9b790ef 100644 --- a/packages/container/container/lib/src/exception.dart +++ b/packages/container/container/lib/src/exception.dart @@ -1,8 +1,34 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/// A custom exception class for reflection-related errors. +/// +/// This class extends the base [Exception] class and provides a way to +/// create exceptions specific to reflection operations. It includes a +/// message that describes the nature of the exception. +/// +/// Example usage: +/// ```dart +/// throw ReflectionException('Failed to reflect on class XYZ'); +/// ``` class ReflectionException implements Exception { + /// Creates a new instance of [ReflectionException] with the specified message. + /// + /// The [message] parameter should describe the nature of the reflection error. final String message; + /// Creates a new instance of [ReflectionException] with the specified message. + /// + /// The [message] parameter should describe the nature of the reflection error. ReflectionException(this.message); + // Override the toString method to provide a custom string representation of the exception. @override String toString() => message; } diff --git a/packages/container/container/lib/src/mirrors/mirrors.dart b/packages/container/container/lib/src/mirrors/mirrors.dart index 8e07029..29c3c64 100644 --- a/packages/container/container/lib/src/mirrors/mirrors.dart +++ b/packages/container/container/lib/src/mirrors/mirrors.dart @@ -1 +1,10 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + export 'reflector.dart'; diff --git a/packages/container/container/lib/src/mirrors/reflector.dart b/packages/container/container/lib/src/mirrors/reflector.dart index e534fae..1c53546 100644 --- a/packages/container/container/lib/src/mirrors/reflector.dart +++ b/packages/container/container/lib/src/mirrors/reflector.dart @@ -1,20 +1,87 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + import 'dart:async'; import 'dart:mirrors' as dart; - -import '../exception.dart'; -import '../reflector.dart'; - +import 'package:platform_container/container.dart'; import 'package:quiver/core.dart'; /// A [Reflector] implementation that forwards to `dart:mirrors`. /// -/// Useful on the server, where reflection is supported. +/// This class provides reflection capabilities by leveraging the `dart:mirrors` library. +/// It allows for runtime introspection of classes, functions, types, and instances. +/// +/// Key features: +/// - Reflects classes, functions, types, and instances +/// - Provides access to class and function metadata +/// - Supports reflection of generic types and futures +/// - Allows invocation of reflected functions +/// +/// Note: This reflector is primarily useful on the server-side where reflection is fully supported. +/// It may not be suitable for client-side Dart applications due to limitations in reflection support. +/// +/// Usage: +/// ```dart +/// final reflector = MirrorsReflector(); +/// final classReflection = reflector.reflectClass(MyClass); +/// final functionReflection = reflector.reflectFunction(myFunction); +/// final typeReflection = reflector.reflectType(int); +/// final instanceReflection = reflector.reflectInstance(myObject); +/// ``` +/// +/// Be aware of the performance implications when using reflection extensively, +/// as it can impact runtime performance and increase code size. class MirrorsReflector extends Reflector { + /// Creates a new instance of [MirrorsReflector]. + /// + /// This constructor initializes the [MirrorsReflector] instance. const MirrorsReflector(); + /// Retrieves the name of a symbol as a string. + /// + /// This method overrides the base implementation to use the `dart:mirrors` library + /// for converting a [Symbol] to its corresponding string representation. + /// + /// Parameters: + /// - [symbol]: The [Symbol] whose name is to be retrieved. + /// + /// Returns: + /// A [String] representing the name of the given symbol. + /// + /// Example: + /// ```dart + /// final name = getName(#someSymbol); + /// print(name); // Outputs: "someSymbol" + /// ``` @override String getName(Symbol symbol) => dart.MirrorSystem.getName(symbol); + /// Reflects a class and returns a [ReflectedClass] instance. + /// + /// This method takes a [Type] parameter [clazz] and uses dart:mirrors to create + /// a reflection of the class. It returns a [_ReflectedClassMirror] which + /// implements [ReflectedClass]. + /// + /// Parameters: + /// - [clazz]: The [Type] of the class to reflect. + /// + /// Returns: + /// A [ReflectedClass] instance representing the reflected class. + /// + /// Throws: + /// - [ArgumentError] if the provided [clazz] is not a class. + /// + /// Example: + /// ```dart + /// final reflector = MirrorsReflector(); + /// final classReflection = reflector.reflectClass(MyClass); + /// ``` @override ReflectedClass reflectClass(Type clazz) { var mirror = dart.reflectType(clazz); @@ -26,12 +93,50 @@ class MirrorsReflector extends Reflector { } } + /// Reflects a function and returns a [ReflectedFunction] instance. + /// + /// This method takes a [Function] parameter [function] and uses dart:mirrors to create + /// a reflection of the function. It returns a [_ReflectedMethodMirror] which + /// implements [ReflectedFunction]. + /// + /// Parameters: + /// - [function]: The [Function] to reflect. + /// + /// Returns: + /// A [ReflectedFunction] instance representing the reflected function. + /// + /// Example: + /// ```dart + /// final reflector = MirrorsReflector(); + /// final functionReflection = reflector.reflectFunction(myFunction); + /// ``` @override ReflectedFunction reflectFunction(Function function) { var closure = dart.reflect(function) as dart.ClosureMirror; return _ReflectedMethodMirror(closure.function, closure); } + /// Reflects a given type and returns a [ReflectedType] instance. + /// + /// This method takes a [Type] parameter and uses dart:mirrors to create + /// a reflection of the type. It returns either a [_ReflectedClassMirror] + /// or a [_ReflectedTypeMirror] depending on whether the reflected type + /// is a class or not. + /// + /// Parameters: + /// - [type]: The [Type] to reflect. + /// + /// Returns: + /// A [ReflectedType] instance representing the reflected type. + /// + /// If the reflected type doesn't have a reflected type (i.e., [hasReflectedType] is false), + /// it returns a reflection of the `dynamic` type instead. + /// + /// Example: + /// ```dart + /// final reflector = MirrorsReflector(); + /// final typeReflection = reflector.reflectType(int); + /// ``` @override ReflectedType reflectType(Type type) { var mirror = dart.reflectType(type); @@ -47,6 +152,27 @@ class MirrorsReflector extends Reflector { } } + /// Reflects a Future of a given type and returns a [ReflectedType] instance. + /// + /// This method takes a [Type] parameter and creates a reflection of a Future + /// that wraps that type. It first reflects the inner type, then constructs + /// a Future type with that inner type as its type argument. + /// + /// Parameters: + /// - [type]: The [Type] to be wrapped in a Future. + /// + /// Returns: + /// A [ReflectedType] instance representing the reflected Future. + /// + /// Throws: + /// - [ArgumentError] if the provided [type] is not a class or type. + /// + /// Example: + /// ```dart + /// final reflector = MirrorsReflector(); + /// final futureIntReflection = reflector.reflectFutureOf(int); + /// // This will reflect Future + /// ``` @override ReflectedType reflectFutureOf(Type type) { var inner = reflectType(type); @@ -63,22 +189,101 @@ class MirrorsReflector extends Reflector { return _ReflectedClassMirror(future as dart.ClassMirror); } + /// Reflects an instance of an object and returns a [ReflectedInstance]. + /// + /// This method takes an [Object] parameter and uses dart:mirrors to create + /// a reflection of the object instance. It returns a [_ReflectedInstanceMirror] + /// which implements [ReflectedInstance]. + /// + /// Parameters: + /// - [object]: The object instance to reflect. + /// + /// Returns: + /// A [ReflectedInstance] representing the reflected object instance. + /// + /// Example: + /// ```dart + /// final reflector = MirrorsReflector(); + /// final instanceReflection = reflector.reflectInstance(myObject); + /// ``` @override ReflectedInstance reflectInstance(Object object) { return _ReflectedInstanceMirror(dart.reflect(object)); } } +/// Represents a reflected type parameter using dart:mirrors. +/// +/// This class extends [ReflectedTypeParameter] and wraps a [dart.TypeVariableMirror] +/// to provide reflection capabilities for type parameters in Dart. +/// +/// The class extracts the name of the type parameter from the mirror and passes +/// it to the superclass constructor. +/// +/// This is typically used internally by the reflection system to represent +/// type parameters of generic classes or methods. class _ReflectedTypeParameter extends ReflectedTypeParameter { + /// The [dart.TypeVariableMirror] instance representing the reflected type parameter. + /// + /// This mirror provides access to the details of the type parameter, such as its name, + /// bounds, and other metadata. It is used internally by the [_ReflectedTypeParameter] + /// class to implement reflection capabilities for type parameters. final dart.TypeVariableMirror mirror; + /// Constructs a [_ReflectedTypeParameter] instance. + /// + /// This constructor takes a [dart.TypeVariableMirror] and initializes the + /// [_ReflectedTypeParameter] with the name of the type parameter extracted + /// from the mirror. + /// + /// Parameters: + /// - [mirror]: A [dart.TypeVariableMirror] representing the type parameter. + /// + /// The constructor uses [dart.MirrorSystem.getName] to extract the name of the + /// type parameter from the mirror's [simpleName] and passes it to the superclass + /// constructor. _ReflectedTypeParameter(this.mirror) : super(dart.MirrorSystem.getName(mirror.simpleName)); } +/// Represents a reflected type using dart:mirrors. +/// +/// This class extends [ReflectedType] and wraps a [dart.TypeMirror] +/// to provide reflection capabilities for types in Dart. +/// +/// The class extracts the name and type variables from the mirror and passes +/// them to the superclass constructor. It also implements type comparison +/// through the [isAssignableTo] method. +/// +/// Note that this class represents types that are not classes, and therefore +/// cannot be instantiated. Attempting to call [newInstance] will throw a +/// [ReflectionException]. +/// +/// This is typically used internally by the reflection system to represent +/// non-class types like interfaces, mixins, or type aliases. class _ReflectedTypeMirror extends ReflectedType { + /// The [dart.TypeMirror] instance representing the reflected type. + /// + /// This mirror provides access to the details of the type, such as its name, + /// type variables, and other metadata. It is used internally by the + /// [_ReflectedTypeMirror] class to implement reflection capabilities for types. final dart.TypeMirror mirror; + /// Constructs a [_ReflectedTypeMirror] instance. + /// + /// This constructor takes a [dart.TypeMirror] and initializes the + /// [_ReflectedTypeMirror] with the following: + /// - The name of the type extracted from the mirror's [simpleName]. + /// - A list of [_ReflectedTypeParameter] objects created from the mirror's type variables. + /// - The reflected type of the mirror. + /// + /// Parameters: + /// - [mirror]: A [dart.TypeMirror] representing the type to be reflected. + /// + /// The constructor uses [dart.MirrorSystem.getName] to extract the name of the + /// type from the mirror's [simpleName]. It also maps the mirror's type variables + /// to [_ReflectedTypeParameter] objects and passes them along with the reflected + /// type to the superclass constructor. _ReflectedTypeMirror(this.mirror) : super( dart.MirrorSystem.getName(mirror.simpleName), @@ -86,6 +291,21 @@ class _ReflectedTypeMirror extends ReflectedType { mirror.reflectedType, ); + /// Checks if this reflected class is assignable to another reflected type. + /// + /// This method determines whether an instance of this class can be assigned + /// to a variable of the type represented by [other]. + /// + /// Parameters: + /// - [other]: The [ReflectedType] to check against. + /// + /// Returns: + /// - `true` if this class is assignable to [other]. + /// - `false` otherwise, including when [other] is not a [_ReflectedClassMirror] + /// or [_ReflectedTypeMirror]. + /// + /// The method uses dart:mirrors' [isAssignableTo] to perform the actual check + /// when [other] is either a [_ReflectedClassMirror] or [_ReflectedTypeMirror]. @override bool isAssignableTo(ReflectedType? other) { if (other is _ReflectedClassMirror) { @@ -97,6 +317,27 @@ class _ReflectedTypeMirror extends ReflectedType { } } + /// Throws a [ReflectionException] when attempting to create a new instance. + /// + /// This method is intended to be overridden by classes that represent + /// instantiable types. For non-instantiable types (like interfaces or + /// abstract classes), this method throws an exception. + /// + /// Parameters: + /// - [constructorName]: The name of the constructor to invoke. + /// - [positionalArguments]: A list of positional arguments for the constructor. + /// - [namedArguments]: An optional map of named arguments for the constructor. + /// - [typeArguments]: An optional list of type arguments for generic classes. + /// + /// Throws: + /// [ReflectionException]: Always thrown with a message indicating that + /// this type cannot be instantiated. + /// + /// Example: + /// ```dart + /// // This will always throw a ReflectionException + /// reflectedType.newInstance('defaultConstructor', []); + /// ``` @override ReflectedInstance newInstance( String constructorName, List positionalArguments, @@ -106,9 +347,46 @@ class _ReflectedTypeMirror extends ReflectedType { } } +/// Represents a reflected class using dart:mirrors. +/// +/// This class extends [ReflectedClass] and wraps a [dart.ClassMirror] +/// to provide reflection capabilities for Dart classes. +/// +/// Key features: +/// - Reflects class name, type parameters, constructors, and declarations +/// - Provides access to class metadata (annotations) +/// - Supports type comparison through [isAssignableTo] +/// - Allows creation of new instances of the reflected class +/// +/// This class is typically used internally by the reflection system to +/// represent classes and their members. class _ReflectedClassMirror extends ReflectedClass { + /// The [dart.ClassMirror] representing the reflected class. + /// + /// This mirror is used to extract information about the class, such as + /// its name, type parameters, constructors, and declarations. + /// + /// See also: + /// - [dart.ClassMirror] for more details about the mirror system. final dart.ClassMirror mirror; + /// Constructs a [_ReflectedClassMirror] instance. + /// + /// This constructor takes a [dart.ClassMirror] and initializes the + /// [_ReflectedClassMirror] with the following: + /// - The name of the class extracted from the mirror's [simpleName]. + /// - A list of [_ReflectedTypeParameter] objects created from the mirror's type variables. + /// - Empty lists for constructors and annotations (these are populated elsewhere). + /// - A list of declarations obtained from the [_declarationsOf] method. + /// - The reflected type of the mirror. + /// + /// Parameters: + /// - [mirror]: A [dart.ClassMirror] representing the class to be reflected. + /// + /// The constructor uses [dart.MirrorSystem.getName] to extract the name of the + /// class from the mirror's [simpleName]. It also maps the mirror's type variables + /// to [_ReflectedTypeParameter] objects and uses [_declarationsOf] to get the + /// class declarations. These are then passed to the superclass constructor. _ReflectedClassMirror(this.mirror) : super( dart.MirrorSystem.getName(mirror.simpleName), @@ -119,6 +397,23 @@ class _ReflectedClassMirror extends ReflectedClass { mirror.reflectedType, ); + /// Retrieves a list of reflected constructors from a given [dart.ClassMirror]. + /// + /// This static method iterates through the declarations of the provided [mirror], + /// identifies the constructor methods, and creates [ReflectedFunction] instances + /// for each constructor found. + /// + /// Parameters: + /// - [mirror]: A [dart.ClassMirror] representing the class to examine. + /// + /// Returns: + /// A [List] of [ReflectedFunction] objects, each representing a constructor + /// of the class. + /// + /// The method specifically looks for [dart.MethodMirror] instances that are + /// marked as constructors (i.e., [isConstructor] is true). Each identified + /// constructor is wrapped in a [_ReflectedMethodMirror] and added to the + /// returned list. static List _constructorsOf(dart.ClassMirror mirror) { var out = []; @@ -133,6 +428,23 @@ class _ReflectedClassMirror extends ReflectedClass { return out; } + /// Retrieves a list of reflected declarations from a given [dart.ClassMirror]. + /// + /// This static method iterates through the declarations of the provided [mirror], + /// identifies non-constructor methods, and creates [ReflectedDeclaration] instances + /// for each method found. + /// + /// Parameters: + /// - [mirror]: A [dart.ClassMirror] representing the class to examine. + /// + /// Returns: + /// A [List] of [ReflectedDeclaration] objects, each representing a non-constructor + /// method of the class. + /// + /// The method specifically looks for [dart.MethodMirror] instances that are + /// not constructors (i.e., [isConstructor] is false). Each identified + /// method is wrapped in a [_ReflectedDeclarationMirror] and added to the + /// returned list. static List _declarationsOf(dart.ClassMirror mirror) { var out = []; @@ -148,13 +460,73 @@ class _ReflectedClassMirror extends ReflectedClass { return out; } + /// Retrieves the annotations (metadata) associated with this reflected class. + /// + /// This getter method overrides the base implementation to provide access to + /// the class-level annotations using dart:mirrors. It maps each metadata mirror + /// to a [_ReflectedInstanceMirror] and returns them as a list. + /// + /// Returns: + /// A [List] of [ReflectedInstance] objects, each representing an annotation + /// applied to this class. + /// + /// Example: + /// ```dart + /// @MyAnnotation() + /// class MyClass {} + /// + /// // Assuming we have a reflection of MyClass + /// final classReflection = reflector.reflectClass(MyClass); + /// final annotations = classReflection.annotations; + /// // annotations will contain a ReflectedInstance of MyAnnotation + /// ``` + /// + /// Note: This method relies on the [dart.ClassMirror]'s metadata property + /// and creates a new [_ReflectedInstanceMirror] for each annotation. @override List get annotations => mirror.metadata.map((m) => _ReflectedInstanceMirror(m)).toList(); + /// Retrieves a list of reflected constructors for this class. + /// + /// This getter method overrides the base implementation to provide access to + /// the constructors of the reflected class using dart:mirrors. It uses the + /// static [_constructorsOf] method to extract and wrap each constructor + /// in a [ReflectedFunction] object. + /// + /// Returns: + /// A [List] of [ReflectedFunction] objects, each representing a constructor + /// of this class. + /// + /// Example: + /// ```dart + /// final classReflection = reflector.reflectClass(MyClass); + /// final constructors = classReflection.constructors; + /// // constructors will contain ReflectedFunction objects for each + /// // constructor in MyClass + /// ``` + /// + /// Note: This method relies on the [dart.ClassMirror]'s declarations and + /// the [_constructorsOf] method to identify and create reflections of + /// the class constructors. @override List get constructors => _constructorsOf(mirror); + /// Checks if this reflected type is assignable to another reflected type. + /// + /// This method determines whether an instance of this type can be assigned + /// to a variable of the type represented by [other]. + /// + /// Parameters: + /// - [other]: The [ReflectedType] to check against. + /// + /// Returns: + /// - `true` if this type is assignable to [other]. + /// - `false` otherwise, including when [other] is not a [_ReflectedClassMirror] + /// or [_ReflectedTypeMirror]. + /// + /// The method uses dart:mirrors' [isAssignableTo] to perform the actual check + /// when [other] is either a [_ReflectedClassMirror] or [_ReflectedTypeMirror]. @override bool isAssignableTo(ReflectedType? other) { if (other is _ReflectedClassMirror) { @@ -166,6 +538,28 @@ class _ReflectedClassMirror extends ReflectedClass { } } + /// Creates a new instance of the reflected class. + /// + /// This method instantiates a new object of the class represented by this + /// [_ReflectedClassMirror] using the specified constructor and arguments. + /// + /// Parameters: + /// - [constructorName]: The name of the constructor to invoke. Use an empty + /// string for the default constructor. + /// - [positionalArguments]: A list of positional arguments to pass to the constructor. + /// - [namedArguments]: An optional map of named arguments to pass to the constructor. + /// - [typeArguments]: An optional list of type arguments for generic classes. + /// + /// Returns: + /// A [ReflectedInstance] representing the newly created instance. + /// + /// Throws: + /// May throw exceptions if the constructor invocation fails, e.g., due to + /// invalid arguments or if the class cannot be instantiated. + /// + /// Note: + /// This implementation currently does not use the [namedArguments] or + /// [typeArguments] parameters. They are included for API compatibility. @override ReflectedInstance newInstance( String constructorName, List positionalArguments, @@ -174,45 +568,257 @@ class _ReflectedClassMirror extends ReflectedClass { mirror.newInstance(Symbol(constructorName), positionalArguments)); } + /// Checks if this [_ReflectedClassMirror] is equal to another object. + /// + /// This method overrides the default equality operator to provide a custom + /// equality check for [_ReflectedClassMirror] instances. + /// + /// Parameters: + /// - [other]: The object to compare with this [_ReflectedClassMirror]. + /// + /// Returns: + /// - `true` if [other] is also a [_ReflectedClassMirror] and has the same + /// [mirror] as this instance. + /// - `false` otherwise. + /// + /// This implementation ensures that two [_ReflectedClassMirror] instances + /// are considered equal if and only if they reflect the same class (i.e., + /// their underlying [dart.ClassMirror]s are the same). @override bool operator ==(other) { return other is _ReflectedClassMirror && other.mirror == mirror; } + /// Generates a hash code for this [_ReflectedClassMirror]. + /// + /// This method overrides the default [hashCode] implementation to provide + /// a consistent hash code for [_ReflectedClassMirror] instances. + /// + /// The hash code is generated using the [hash2] function from the Quiver + /// library, combining the [mirror] object and an empty string. The empty + /// string is used as a second parameter to maintain compatibility with + /// the [hash2] function, which requires two arguments. + /// + /// Returns: + /// An [int] representing the hash code of this [_ReflectedClassMirror]. + /// + /// Note: + /// This hash code implementation ensures that two [_ReflectedClassMirror] + /// instances with the same [mirror] will have the same hash code, which + /// is consistent with the equality check implemented in the [operator ==]. @override int get hashCode => hash2(mirror, " "); } +/// Represents a reflected declaration using dart:mirrors. +/// +/// This class extends [ReflectedDeclaration] and wraps a [dart.MethodMirror] +/// to provide reflection capabilities for method declarations in Dart. +/// +/// Key features: +/// - Reflects the name and static nature of the declaration +/// - Provides access to the underlying method as a [ReflectedFunction] +/// +/// This class is typically used internally by the reflection system to +/// represent method declarations within a class. class _ReflectedDeclarationMirror extends ReflectedDeclaration { + /// The [dart.MethodMirror] instance representing the reflected method. + /// + /// This mirror provides access to the details of the method, such as its name, + /// parameters, return type, and other metadata. It is used internally by the + /// [_ReflectedDeclarationMirror] class to implement reflection capabilities + /// for method declarations. final dart.MethodMirror mirror; + /// Constructs a [_ReflectedDeclarationMirror] instance. + /// + /// This constructor initializes a new [_ReflectedDeclarationMirror] with the given [name] + /// and [mirror]. It uses the [dart.MethodMirror]'s [isStatic] property to determine + /// if the declaration is static, and passes `null` as the initial value for the function. + /// + /// Parameters: + /// - [name]: A [String] representing the name of the declaration. + /// - [mirror]: A [dart.MethodMirror] representing the reflected method. + /// + /// The constructor calls the superclass constructor with the provided [name], + /// the [isStatic] property from the [mirror], and `null` for the function parameter. _ReflectedDeclarationMirror(String name, this.mirror) : super(name, mirror.isStatic, null); + /// Determines if this declaration is static. + /// + /// This getter overrides the base implementation to provide information + /// about whether the reflected declaration is static or not. It directly + /// accesses the [isStatic] property of the underlying [dart.MethodMirror]. + /// + /// Returns: + /// A [bool] value: + /// - `true` if the declaration is static. + /// - `false` if the declaration is not static (i.e., it's an instance method). + /// + /// This property is useful for determining the nature of the reflected + /// declaration, particularly when working with class methods and properties. @override bool get isStatic => mirror.isStatic; + /// Retrieves a [ReflectedFunction] representation of this declaration. + /// + /// This getter overrides the base implementation to provide a [ReflectedFunction] + /// that represents the method associated with this declaration. It creates a new + /// [_ReflectedMethodMirror] instance using the underlying [dart.MethodMirror]. + /// + /// Returns: + /// A [ReflectedFunction] object that represents the method of this declaration. + /// + /// This property is useful for accessing detailed information about the method, + /// such as its parameters, return type, and other attributes, in a way that's + /// consistent with the reflection API. @override ReflectedFunction get function => _ReflectedMethodMirror(mirror); } +/// Represents a reflected instance of an object using dart:mirrors. +/// +/// This class extends [ReflectedInstance] and wraps a [dart.InstanceMirror] +/// to provide reflection capabilities for object instances in Dart. +/// +/// Key features: +/// - Reflects the type and runtime type of the instance +/// - Provides access to the underlying object (reflectee) +/// - Allows retrieval of field values through reflection +/// +/// This class is typically used internally by the reflection system to +/// represent instances of objects and provide reflective access to their fields. class _ReflectedInstanceMirror extends ReflectedInstance { + /// The [dart.InstanceMirror] representing the reflected instance. + /// + /// This mirror provides access to the details of the object instance, such as its type, + /// fields, and methods. It is used internally by the [_ReflectedInstanceMirror] class + /// to implement reflection capabilities for object instances. + /// + /// The mirror allows for dynamic inspection and manipulation of the object's state + /// and behavior at runtime, enabling powerful reflection features. final dart.InstanceMirror mirror; + /// Constructs a [_ReflectedInstanceMirror] instance. + /// + /// This constructor initializes a new [_ReflectedInstanceMirror] with the given [mirror]. + /// It uses the [dart.InstanceMirror]'s [type] property to create [_ReflectedClassMirror] + /// instances for both the type and runtime type of the reflected instance. + /// + /// Parameters: + /// - [mirror]: A [dart.InstanceMirror] representing the reflected instance. + /// + /// The constructor calls the superclass constructor with: + /// - A [_ReflectedClassMirror] of the instance's type + /// - A [_ReflectedClassMirror] of the instance's runtime type + /// - The [reflectee] of the mirror, which is the actual object being reflected + /// + /// This setup allows the [_ReflectedInstanceMirror] to provide access to both + /// the compile-time and runtime type information of the reflected instance, + /// as well as the underlying object itself. _ReflectedInstanceMirror(this.mirror) : super(_ReflectedClassMirror(mirror.type), _ReflectedClassMirror(mirror.type), mirror.reflectee); + /// Retrieves the value of a field from the reflected instance. + /// + /// This method allows access to field values of the object represented by this + /// [_ReflectedInstanceMirror] through reflection. + /// + /// Parameters: + /// - [name]: A [String] representing the name of the field to retrieve. + /// + /// Returns: + /// A [ReflectedInstance] representing the value of the specified field. + /// This returned instance is wrapped in a [_ReflectedInstanceMirror]. + /// + /// Throws: + /// May throw exceptions if the field does not exist or if access is not allowed. + /// + /// Example: + /// ```dart + /// var fieldValue = reflectedInstance.getField('myField'); + /// ``` + /// + /// Note: + /// This method uses the underlying [dart.InstanceMirror]'s [getField] method + /// to perform the actual field access. @override ReflectedInstance getField(String name) { return _ReflectedInstanceMirror(mirror.getField(Symbol(name))); } } +/// Represents a reflected method using dart:mirrors. +/// +/// This class extends [ReflectedFunction] and wraps a [dart.MethodMirror] +/// to provide reflection capabilities for methods in Dart. +/// +/// Key features: +/// - Reflects method name, parameters, and return type +/// - Provides access to method metadata (annotations) +/// - Supports invocation of the reflected method (if a ClosureMirror is available) +/// +/// The class uses both [dart.MethodMirror] and optionally [dart.ClosureMirror] +/// to represent and potentially invoke the reflected method. +/// +/// Usage: +/// - Created internally by the reflection system to represent methods +/// - Can be used to inspect method details or invoke the method if a ClosureMirror is provided +/// +/// Note: +/// - Invocation is only possible if a ClosureMirror is provided during construction +/// - Throws a StateError if invoke is called without a ClosureMirror class _ReflectedMethodMirror extends ReflectedFunction { + /// The [dart.MethodMirror] instance representing the reflected method. + /// + /// This mirror provides access to the details of the method, such as its name, + /// parameters, return type, and other metadata. It is used internally by the + /// [_ReflectedMethodMirror] class to implement reflection capabilities + /// for methods. + /// + /// The [dart.MethodMirror] is a crucial component in the reflection process, + /// allowing for introspection of method properties and behavior at runtime. final dart.MethodMirror mirror; + + /// An optional [dart.ClosureMirror] representing the closure of the reflected method. + /// + /// This field is used to store a [dart.ClosureMirror] when the reflected method + /// is associated with a callable object (i.e., a closure). The presence of this + /// mirror enables the [invoke] method to directly call the reflected method. + /// + /// If this field is null, it indicates that the reflected method cannot be + /// directly invoked through this [_ReflectedMethodMirror] instance. + /// + /// Note: + /// - This field is crucial for supporting method invocation via reflection. + /// - It's typically set when reflecting on instance methods or standalone functions. + /// - For class-level method declarations that aren't bound to an instance, + /// this field may be null. final dart.ClosureMirror? closureMirror; + /// Constructs a [_ReflectedMethodMirror] instance. + /// + /// This constructor initializes a new [_ReflectedMethodMirror] with the given [mirror] + /// and optional [closureMirror]. It extracts various properties from the [dart.MethodMirror] + /// to populate the superclass constructor. + /// + /// Parameters: + /// - [mirror]: A [dart.MethodMirror] representing the reflected method. + /// - [closureMirror]: An optional [dart.ClosureMirror] for method invocation. + /// + /// The constructor initializes the following: + /// - Method name from the mirror's [simpleName] + /// - An empty list of reflected type parameters + /// - Metadata (annotations) as [_ReflectedInstanceMirror] objects + /// - Reflected parameters using [_reflectParameter] + /// - Getter and setter flags from the mirror + /// - Return type, using [dynamic] if the mirror doesn't have a reflected type + /// + /// This setup allows the [_ReflectedMethodMirror] to provide comprehensive + /// reflection capabilities for the method, including its signature, metadata, + /// and potential invocation (if a [closureMirror] is provided). _ReflectedMethodMirror(this.mirror, [this.closureMirror]) : super( dart.MirrorSystem.getName(mirror.simpleName), @@ -228,6 +834,26 @@ class _ReflectedMethodMirror extends ReflectedFunction { : const MirrorsReflector() .reflectType(mirror.returnType.reflectedType)); + /// Reflects a parameter of a method using dart:mirrors. + /// + /// This static method creates a [ReflectedParameter] instance from a given [dart.ParameterMirror]. + /// It extracts various properties from the mirror to construct a comprehensive reflection of the parameter. + /// + /// Parameters: + /// - [mirror]: A [dart.ParameterMirror] representing the parameter to be reflected. + /// + /// Returns: + /// A [ReflectedParameter] instance containing the reflected information of the parameter. + /// + /// The method extracts the following information: + /// - Parameter name from the mirror's [simpleName] + /// - Metadata (annotations) as [_ReflectedInstanceMirror] objects + /// - Parameter type, reflected using [MirrorsReflector] + /// - Whether the parameter is required (not optional) + /// - Whether the parameter is named + /// + /// This method is typically used internally by the reflection system to create + /// parameter reflections for method signatures. static ReflectedParameter _reflectParameter(dart.ParameterMirror mirror) { return ReflectedParameter( dart.MirrorSystem.getName(mirror.simpleName), @@ -239,6 +865,32 @@ class _ReflectedMethodMirror extends ReflectedFunction { mirror.isNamed); } + /// Invokes the reflected method with the given invocation details. + /// + /// This method allows for dynamic invocation of the reflected method using the + /// provided [Invocation] object. It requires that a [closureMirror] was provided + /// during the construction of this [_ReflectedMethodMirror]. + /// + /// Parameters: + /// - [invocation]: An [Invocation] object containing the details of the method call, + /// including the method name, positional arguments, and named arguments. + /// + /// Returns: + /// A [ReflectedInstance] representing the result of the method invocation. + /// + /// Throws: + /// - [StateError] if this [_ReflectedMethodMirror] was created without a [closureMirror], + /// indicating that direct invocation is not possible. + /// + /// Example: + /// ```dart + /// var result = reflectedMethod.invoke(Invocation.method(#methodName, [arg1, arg2])); + /// ``` + /// + /// Note: + /// This method relies on the presence of a [closureMirror] to perform the actual + /// invocation. If no [closureMirror] is available, it means the reflected method + /// cannot be directly invoked, and an error will be thrown. @override ReflectedInstance invoke(Invocation invocation) { if (closureMirror == null) { diff --git a/packages/container/container/lib/src/reflectable/reflectable.dart b/packages/container/container/lib/src/reflectable/reflectable.dart index 8b13789..615088f 100644 --- a/packages/container/container/lib/src/reflectable/reflectable.dart +++ b/packages/container/container/lib/src/reflectable/reflectable.dart @@ -1 +1,9 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/container/container/lib/src/reflector.dart b/packages/container/container/lib/src/reflector.dart index 1f65135..3b72136 100644 --- a/packages/container/container/lib/src/reflector.dart +++ b/packages/container/container/lib/src/reflector.dart @@ -1,7 +1,33 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + import 'package:collection/collection.dart'; import 'package:quiver/core.dart'; +/// Abstract class representing a reflector for introspection of Dart types and instances. +/// +/// This class provides methods to reflect on various Dart constructs such as classes, +/// functions, types, and instances. It allows for runtime inspection and manipulation +/// of code elements. +/// +/// The methods in this class are designed to be implemented by concrete reflector +/// classes, potentially using different reflection mechanisms (e.g., mirrors, code +/// generation). +/// +/// Note: The `reflectFutureOf` method throws an `UnsupportedError` by default and +/// requires `dart:mirrors` for implementation. abstract class Reflector { + /// Constructs a new [Reflector] instance. + /// + /// This constructor is declared as `const` to allow for compile-time constant creation + /// of [Reflector] instances. Subclasses of [Reflector] may override this constructor + /// to provide their own initialization logic if needed. const Reflector(); String? getName(Symbol symbol); @@ -19,6 +45,19 @@ abstract class Reflector { } } +/// Represents a reflected instance of an object. +/// +/// This abstract class provides a way to introspect and manipulate object instances +/// at runtime. It encapsulates information about the object's type, class, and the +/// actual object instance (reflectee). +/// +/// The [type] property represents the reflected type of the instance. +/// The [clazz] property represents the reflected class of the instance. +/// The [reflectee] property holds the actual object instance being reflected. +/// +/// This class also provides methods for comparing instances and accessing fields. +/// +/// Use the [getField] method to retrieve a reflected instance of a specific field. abstract class ReflectedInstance { final ReflectedType type; final ReflectedClass clazz; @@ -36,6 +75,22 @@ abstract class ReflectedInstance { ReflectedInstance getField(String name); } +/// Represents a reflected type in the Dart language. +/// +/// This abstract class encapsulates information about a Dart type, including its name, +/// type parameters, and the actual Dart [Type] it represents. +/// +/// The [name] property holds the name of the type. +/// The [typeParameters] list contains the type parameters if the type is generic. +/// The [reflectedType] property holds the actual Dart [Type] being reflected. +/// +/// This class provides methods for creating new instances of the type, comparing types, +/// and checking type assignability. +/// +/// The [newInstance] method allows for dynamic creation of new instances of the type. +/// The [isAssignableTo] method checks if this type is assignable to another type. +/// +/// This class also overrides [hashCode] and [operator ==] for proper equality comparisons. abstract class ReflectedType { final String name; final List typeParameters; @@ -62,6 +117,17 @@ abstract class ReflectedType { bool isAssignableTo(ReflectedType? other); } +/// Represents a reflected class in the Dart language. +/// +/// This abstract class extends [ReflectedType] and provides additional information +/// specific to classes, including annotations, constructors, and declarations. +/// +/// The [annotations] list contains reflected instances of annotations applied to the class. +/// The [constructors] list contains reflected functions representing the class constructors. +/// The [declarations] list contains reflected declarations (fields, methods, etc.) of the class. +/// +/// This class overrides [hashCode] and [operator ==] to include the additional properties +/// in equality comparisons and hash code calculations. abstract class ReflectedClass extends ReflectedType { final List annotations; final List constructors; @@ -92,6 +158,18 @@ abstract class ReflectedClass extends ReflectedType { .equals(other.declarations, declarations); } +/// Represents a reflected declaration in the Dart language. +/// +/// This class encapsulates information about a declaration within a class or object, +/// such as a method, field, or property. +/// +/// The [name] property holds the name of the declaration. +/// The [isStatic] property indicates whether the declaration is static. +/// The [function] property, if non-null, represents the reflected function associated +/// with this declaration (applicable for methods and some properties). +/// +/// This class provides methods for comparing declarations and calculating hash codes. +/// It overrides [hashCode] and [operator ==] for proper equality comparisons. class ReflectedDeclaration { final String name; final bool isStatic; @@ -110,6 +188,22 @@ class ReflectedDeclaration { other.function == function; } +/// Represents a reflected function in the Dart language. +/// +/// This abstract class encapsulates information about a function, including its name, +/// type parameters, annotations, return type, parameters, and whether it's a getter or setter. +/// +/// The [name] property holds the name of the function. +/// The [typeParameters] list contains the type parameters if the function is generic. +/// The [annotations] list contains reflected instances of annotations applied to the function. +/// The [returnType] property represents the function's return type (if applicable). +/// The [parameters] list contains the function's parameters. +/// The [isGetter] and [isSetter] properties indicate if the function is a getter or setter. +/// +/// This class provides methods for comparing functions and calculating hash codes. +/// It also includes an [invoke] method for dynamically calling the function. +/// +/// This class overrides [hashCode] and [operator ==] for proper equality comparisons. abstract class ReflectedFunction { final String name; final List typeParameters; @@ -150,6 +244,21 @@ abstract class ReflectedFunction { ReflectedInstance invoke(Invocation invocation); } +/// Represents a reflected parameter in the Dart language. +/// +/// This class encapsulates information about a function or method parameter, +/// including its name, annotations, type, and properties such as whether it's +/// required or named. +/// +/// Properties: +/// - [name]: The name of the parameter. +/// - [annotations]: A list of reflected instances of annotations applied to the parameter. +/// - [type]: The reflected type of the parameter. +/// - [isRequired]: Indicates whether the parameter is required. +/// - [isNamed]: Indicates whether the parameter is a named parameter. +/// +/// This class provides methods for comparing parameters and calculating hash codes. +/// It overrides [hashCode] and [operator ==] for proper equality comparisons. class ReflectedParameter { final String name; final List annotations; diff --git a/packages/container/container/lib/src/static/static.dart b/packages/container/container/lib/src/static/static.dart index 250c0f3..ff9c4df 100644 --- a/packages/container/container/lib/src/static/static.dart +++ b/packages/container/container/lib/src/static/static.dart @@ -1,20 +1,75 @@ -import '../reflector.dart'; +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -/// A [Reflector] implementation that performs simple [Map] lookups. +import 'package:platform_container/container.dart'; + +/// A static implementation of the [Reflector] class that performs simple [Map] lookups. /// /// `package:platform_container_generator` uses this to create reflectors from analysis metadata. class StaticReflector extends Reflector { + /// A map that associates [Symbol] objects with their corresponding string names. + /// + /// This map is used to store and retrieve the string representations of symbols, + /// which can be useful for reflection and debugging purposes. final Map names; + + /// A map that associates [Type] objects with their corresponding [ReflectedType] objects. + /// + /// This map is used to store and retrieve reflection information for different types, + /// allowing for runtime introspection of type metadata and structure. final Map types; + + /// A map that associates [Function] objects with their corresponding [ReflectedFunction] objects. + /// + /// This map is used to store and retrieve reflection information for functions, + /// enabling runtime introspection of function metadata, parameters, and return types. final Map functions; + + /// A map that associates [Object] instances with their corresponding [ReflectedInstance] objects. + /// + /// This map is used to store and retrieve reflection information for specific object instances, + /// allowing for runtime introspection of object properties, methods, and metadata. final Map instances; + /// Creates a new [StaticReflector] instance with optional parameters. + /// + /// The [StaticReflector] constructor allows you to initialize the reflector + /// with pre-populated maps for names, types, functions, and instances. + /// + /// Parameters: + /// - [names]: A map of [Symbol] to [String] for symbol name lookups. Defaults to an empty map. + /// - [types]: A map of [Type] to [ReflectedType] for type reflection. Defaults to an empty map. + /// - [functions]: A map of [Function] to [ReflectedFunction] for function reflection. Defaults to an empty map. + /// - [instances]: A map of [Object] to [ReflectedInstance] for instance reflection. Defaults to an empty map. + /// + /// All parameters are optional and default to empty constant maps if not provided. const StaticReflector( {this.names = const {}, this.types = const {}, this.functions = const {}, this.instances = const {}}); + /// Returns the string name associated with the given [Symbol]. + /// + /// This method looks up the string representation of the provided [symbol] + /// in the [names] map. If the symbol is found, its corresponding string + /// name is returned. If the symbol is not found in the map, an [ArgumentError] + /// is thrown. + /// + /// Parameters: + /// - [symbol]: The [Symbol] for which to retrieve the string name. + /// + /// Returns: + /// The string name associated with the given [symbol], or null if not found. + /// + /// Throws: + /// - [ArgumentError]: If the provided [symbol] is not found in the [names] map. @override String? getName(Symbol symbol) { if (!names.containsKey(symbol)) { @@ -25,10 +80,39 @@ class StaticReflector extends Reflector { return names[symbol]; } + /// Reflects a class based on its [Type]. + /// + /// This method attempts to reflect the given class [Type] by calling [reflectType] + /// and casting the result to [ReflectedClass]. If the reflection is successful + /// and the result is a [ReflectedClass], it is returned. Otherwise, null is returned. + /// + /// Parameters: + /// - [clazz]: The [Type] of the class to reflect. + /// + /// Returns: + /// A [ReflectedClass] instance if the reflection is successful and the result + /// is a [ReflectedClass], or null otherwise. @override ReflectedClass? reflectClass(Type clazz) => reflectType(clazz) as ReflectedClass?; + /// Reflects a function based on its [Function] object. + /// + /// This method attempts to retrieve reflection information for the given [function] + /// from the [functions] map. If the function is found in the map, its corresponding + /// [ReflectedFunction] object is returned. If the function is not found, an + /// [ArgumentError] is thrown. + /// + /// Parameters: + /// - [function]: The [Function] object to reflect. + /// + /// Returns: + /// A [ReflectedFunction] object containing reflection information about the + /// given function, or null if not found. + /// + /// Throws: + /// - [ArgumentError]: If there is no reflection information available for + /// the given [function]. @override ReflectedFunction? reflectFunction(Function function) { if (!functions.containsKey(function)) { @@ -39,6 +123,23 @@ class StaticReflector extends Reflector { return functions[function]; } + /// Reflects an object instance to retrieve its reflection information. + /// + /// This method attempts to retrieve reflection information for the given [object] + /// from the [instances] map. If the object is found in the map, its corresponding + /// [ReflectedInstance] object is returned. If the object is not found, an + /// [ArgumentError] is thrown. + /// + /// Parameters: + /// - [object]: The object instance to reflect. + /// + /// Returns: + /// A [ReflectedInstance] object containing reflection information about the + /// given object instance, or null if not found. + /// + /// Throws: + /// - [ArgumentError]: If there is no reflection information available for + /// the given [object]. @override ReflectedInstance? reflectInstance(Object object) { if (!instances.containsKey(object)) { @@ -49,6 +150,23 @@ class StaticReflector extends Reflector { return instances[object]; } + /// Reflects a type to retrieve its reflection information. + /// + /// This method attempts to retrieve reflection information for the given [type] + /// from the [types] map. If the type is found in the map, its corresponding + /// [ReflectedType] object is returned. If the type is not found, an + /// [ArgumentError] is thrown. + /// + /// Parameters: + /// - [type]: The [Type] to reflect. + /// + /// Returns: + /// A [ReflectedType] object containing reflection information about the + /// given type, or null if not found. + /// + /// Throws: + /// - [ArgumentError]: If there is no reflection information available for + /// the given [type]. @override ReflectedType? reflectType(Type type) { if (!types.containsKey(type)) { diff --git a/packages/container/container/lib/src/throwing.dart b/packages/container/container/lib/src/throwing.dart index 9d91c23..322940f 100644 --- a/packages/container/container/lib/src/throwing.dart +++ b/packages/container/container/lib/src/throwing.dart @@ -1,5 +1,4 @@ import 'package:platform_container/src/container_const.dart'; - import 'empty/empty.dart'; import 'reflector.dart'; @@ -18,23 +17,77 @@ class ThrowingReflector extends Reflector { 'class if you need reflection.'; */ + /// Creates a [ThrowingReflector] instance. + /// + /// [errorMessage] is the message to be used when throwing an [UnsupportedError]. + /// If not provided, it defaults to [ContainerConst.defaultErrorMessage]. const ThrowingReflector( {this.errorMessage = ContainerConst.defaultErrorMessage}); + /// Retrieves the name associated with the given [symbol]. + /// + /// This method delegates the task to an instance of [EmptyReflector]. + /// It returns the name as a [String] if found, or `null` if not found. + /// + /// [symbol] is the [Symbol] for which to retrieve the name. + /// + /// Returns a [String] representing the name of the symbol, or `null` if not found. @override String? getName(Symbol symbol) => const EmptyReflector().getName(symbol); + /// Creates and returns an [UnsupportedError] with the specified [errorMessage]. + /// + /// This method is used internally to generate consistent error messages + /// when reflection operations are attempted on this [ThrowingReflector]. + /// + /// Returns an [UnsupportedError] instance with the configured error message. UnsupportedError _error() => UnsupportedError(errorMessage); + /// Reflects on a given class type and throws an [UnsupportedError]. + /// + /// This method is part of the [ThrowingReflector] implementation and is designed + /// to prevent reflective operations. When called, it throws an [UnsupportedError] + /// with the configured error message. + /// + /// [clazz] is the [Type] of the class to reflect on. + /// + /// Throws an [UnsupportedError] when invoked, as reflection is not supported. @override ReflectedClass reflectClass(Type clazz) => throw _error(); + /// Reflects on a given object instance and throws an [UnsupportedError]. + /// + /// This method is part of the [ThrowingReflector] implementation and is designed + /// to prevent reflective operations on object instances. When called, it throws + /// an [UnsupportedError] with the configured error message. + /// + /// [object] is the object instance to reflect on. + /// + /// Throws an [UnsupportedError] when invoked, as reflection is not supported. @override ReflectedInstance reflectInstance(Object object) => throw _error(); + /// Reflects on a given type and throws an [UnsupportedError]. + /// + /// This method is part of the [ThrowingReflector] implementation and is designed + /// to prevent reflective operations on types. When called, it throws an + /// [UnsupportedError] with the configured error message. + /// + /// [type] is the [Type] to reflect on. + /// + /// Throws an [UnsupportedError] when invoked, as reflection is not supported. @override ReflectedType reflectType(Type type) => throw _error(); + /// Reflects on a given function and throws an [UnsupportedError]. + /// + /// This method is part of the [ThrowingReflector] implementation and is designed + /// to prevent reflective operations on functions. When called, it throws an + /// [UnsupportedError] with the configured error message. + /// + /// [function] is the [Function] to reflect on. + /// + /// Throws an [UnsupportedError] when invoked, as reflection is not supported. @override ReflectedFunction reflectFunction(Function function) => throw _error(); } diff --git a/packages/container/container/test/common.dart b/packages/container/container/test/common.dart index 7d5ee0a..327ef93 100644 --- a/packages/container/container/test/common.dart +++ b/packages/container/container/test/common.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:test/test.dart'; void returnVoidFromAFunction(int x) {} diff --git a/packages/container/container/test/empty_reflector_test.dart b/packages/container/container/test/empty_reflector_test.dart index ad3d8f0..a6ef382 100644 --- a/packages/container/container/test/empty_reflector_test.dart +++ b/packages/container/container/test/empty_reflector_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/container/container/test/has_test.dart b/packages/container/container/test/has_test.dart index 5dc313c..9cce770 100644 --- a/packages/container/container/test/has_test.dart +++ b/packages/container/container/test/has_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/container/container/test/lazy_test.dart b/packages/container/container/test/lazy_test.dart index 5fa6acf..9564eb7 100644 --- a/packages/container/container/test/lazy_test.dart +++ b/packages/container/container/test/lazy_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/container/container/test/mirrors_test.dart b/packages/container/container/test/mirrors_test.dart index fea687d..2b3680f 100644 --- a/packages/container/container/test/mirrors_test.dart +++ b/packages/container/container/test/mirrors_test.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:platform_container/mirrors.dart'; import 'package:test/test.dart'; import 'common.dart'; diff --git a/packages/container/container/test/named_test.dart b/packages/container/container/test/named_test.dart index e698cf6..c43f119 100644 --- a/packages/container/container/test/named_test.dart +++ b/packages/container/container/test/named_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/container/container/test/throwing_reflector_test.dart b/packages/container/container/test/throwing_reflector_test.dart index fab5265..c6a297c 100644 --- a/packages/container/container/test/throwing_reflector_test.dart +++ b/packages/container/container/test/throwing_reflector_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/container/container_generator/example/main.dart b/packages/container/container_generator/example/main.dart index ad25aff..bc24685 100644 --- a/packages/container/container_generator/example/main.dart +++ b/packages/container/container_generator/example/main.dart @@ -1,7 +1,7 @@ import 'dart:async'; -import 'package:platform_container/platform_container.dart'; -import 'package:platform_container_generator/angel3_container_generator.dart'; +import 'package:platform_container/container.dart'; +import 'package:platform_container_generator/generator.dart'; Future main() async { // Create a container instance. diff --git a/packages/container/container_generator/example/main.reflectable.dart b/packages/container/container_generator/example/main.reflectable.dart index 521298f..c05ac1e 100644 --- a/packages/container/container_generator/example/main.reflectable.dart +++ b/packages/container/container_generator/example/main.reflectable.dart @@ -3,8 +3,7 @@ import 'dart:core'; import 'dart:math' as prefix6; -import 'package:platform_container_generator/angel3_container_generator.dart' - as prefix0; +import 'package:platform_container_generator/generator.dart' as prefix0; import 'package:reflectable/capability.dart' as prefix5; import 'package:reflectable/mirrors.dart' as prefix4; import 'package:reflectable/reflectable.dart' as prefix1; diff --git a/packages/container/container_generator/lib/angel3_container_generator.dart b/packages/container/container_generator/lib/generator.dart similarity index 99% rename from packages/container/container_generator/lib/angel3_container_generator.dart rename to packages/container/container_generator/lib/generator.dart index 81d39ed..40dd09f 100644 --- a/packages/container/container_generator/lib/angel3_container_generator.dart +++ b/packages/container/container_generator/lib/generator.dart @@ -1,4 +1,4 @@ -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:reflectable/reflectable.dart'; /// A [Reflectable] instance that can be used as an annotation on types to generate metadata for them. diff --git a/packages/container/container_generator/test/reflector_test.dart b/packages/container/container_generator/test/reflector_test.dart index ffa01db..e2bd7d9 100644 --- a/packages/container/container_generator/test/reflector_test.dart +++ b/packages/container/container_generator/test/reflector_test.dart @@ -1,5 +1,5 @@ -import 'package:platform_container/platform_container.dart'; -import 'package:platform_container_generator/angel3_container_generator.dart'; +import 'package:platform_container/container.dart'; +import 'package:platform_container_generator/generator.dart'; import 'package:test/test.dart'; import 'reflector_test.reflectable.dart'; diff --git a/packages/container/container_generator/test/reflector_test.reflectable.dart b/packages/container/container_generator/test/reflector_test.reflectable.dart index 12bfb14..7bf1a47 100644 --- a/packages/container/container_generator/test/reflector_test.reflectable.dart +++ b/packages/container/container_generator/test/reflector_test.reflectable.dart @@ -4,8 +4,7 @@ import 'dart:core'; import 'dart:math' as prefix8; import 'package:platform_container/src/reflector.dart' as prefix7; -import 'package:platform_container_generator/angel3_container_generator.dart' - as prefix0; +import 'package:platform_container_generator/generator.dart' as prefix0; import 'package:reflectable/capability.dart' as prefix6; import 'package:reflectable/mirrors.dart' as prefix5; import 'package:reflectable/reflectable.dart' as prefix2; diff --git a/packages/framework/AUTHORS.md b/packages/core/AUTHORS.md similarity index 100% rename from packages/framework/AUTHORS.md rename to packages/core/AUTHORS.md diff --git a/packages/framework/CHANGELOG.md b/packages/core/CHANGELOG.md similarity index 100% rename from packages/framework/CHANGELOG.md rename to packages/core/CHANGELOG.md diff --git a/packages/framework/LICENSE b/packages/core/LICENSE similarity index 100% rename from packages/framework/LICENSE rename to packages/core/LICENSE diff --git a/packages/framework/README.md b/packages/core/README.md similarity index 100% rename from packages/framework/README.md rename to packages/core/README.md diff --git a/packages/framework/analysis_options.yaml b/packages/core/analysis_options.yaml similarity index 100% rename from packages/framework/analysis_options.yaml rename to packages/core/analysis_options.yaml diff --git a/packages/framework/dev.key b/packages/core/dev.key similarity index 100% rename from packages/framework/dev.key rename to packages/core/dev.key diff --git a/packages/framework/dev.pem b/packages/core/dev.pem similarity index 100% rename from packages/framework/dev.pem rename to packages/core/dev.pem diff --git a/packages/framework/example/controller.dart b/packages/core/example/controller.dart similarity index 92% rename from packages/framework/example/controller.dart rename to packages/core/example/controller.dart index ee1df8a..f0b136c 100644 --- a/packages/framework/example/controller.dart +++ b/packages/core/example/controller.dart @@ -1,6 +1,6 @@ import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:logging/logging.dart'; void main() async { diff --git a/packages/framework/example/handle_error.dart b/packages/core/example/handle_error.dart similarity index 87% rename from packages/framework/example/handle_error.dart rename to packages/core/example/handle_error.dart index 0f6d2d0..7c721c1 100644 --- a/packages/framework/example/handle_error.dart +++ b/packages/core/example/handle_error.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:logging/logging.dart'; void main() async { diff --git a/packages/framework/example/hostname.dart b/packages/core/example/hostname.dart similarity index 91% rename from packages/framework/example/hostname.dart rename to packages/core/example/hostname.dart index 0f6bd75..18536da 100644 --- a/packages/framework/example/hostname.dart +++ b/packages/core/example/hostname.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:logging/logging.dart'; Future apiConfigurer(Protevus app) async { diff --git a/packages/framework/example/http2/body_parsing.dart b/packages/core/example/http2/body_parsing.dart similarity index 88% rename from packages/framework/example/http2/body_parsing.dart rename to packages/core/example/http2/body_parsing.dart index 8385f18..0cf6c3b 100644 --- a/packages/framework/example/http2/body_parsing.dart +++ b/packages/core/example/http2/body_parsing.dart @@ -1,7 +1,7 @@ import 'dart:io'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_framework/http2.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_core/http2.dart'; import 'package:file/local.dart'; import 'package:logging/logging.dart'; diff --git a/packages/framework/example/http2/common.dart b/packages/core/example/http2/common.dart similarity index 100% rename from packages/framework/example/http2/common.dart rename to packages/core/example/http2/common.dart diff --git a/packages/framework/example/http2/dev.key b/packages/core/example/http2/dev.key similarity index 100% rename from packages/framework/example/http2/dev.key rename to packages/core/example/http2/dev.key diff --git a/packages/framework/example/http2/dev.pem b/packages/core/example/http2/dev.pem similarity index 100% rename from packages/framework/example/http2/dev.pem rename to packages/core/example/http2/dev.pem diff --git a/packages/framework/example/http2/main.dart b/packages/core/example/http2/main.dart similarity index 86% rename from packages/framework/example/http2/main.dart rename to packages/core/example/http2/main.dart index d661bc0..5956f2d 100644 --- a/packages/framework/example/http2/main.dart +++ b/packages/core/example/http2/main.dart @@ -1,7 +1,7 @@ import 'dart:io'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_framework/http2.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_core/http2.dart'; import 'package:logging/logging.dart'; import 'common.dart'; diff --git a/packages/framework/example/http2/public/app.js b/packages/core/example/http2/public/app.js similarity index 100% rename from packages/framework/example/http2/public/app.js rename to packages/core/example/http2/public/app.js diff --git a/packages/framework/example/http2/public/body_parsing.html b/packages/core/example/http2/public/body_parsing.html similarity index 100% rename from packages/framework/example/http2/public/body_parsing.html rename to packages/core/example/http2/public/body_parsing.html diff --git a/packages/framework/example/http2/public/index.html b/packages/core/example/http2/public/index.html similarity index 100% rename from packages/framework/example/http2/public/index.html rename to packages/core/example/http2/public/index.html diff --git a/packages/framework/example/http2/public/style.css b/packages/core/example/http2/public/style.css similarity index 100% rename from packages/framework/example/http2/public/style.css rename to packages/core/example/http2/public/style.css diff --git a/packages/framework/example/http2/server_push.dart b/packages/core/example/http2/server_push.dart similarity index 92% rename from packages/framework/example/http2/server_push.dart rename to packages/core/example/http2/server_push.dart index 7dc5dab..b142863 100644 --- a/packages/framework/example/http2/server_push.dart +++ b/packages/core/example/http2/server_push.dart @@ -1,7 +1,7 @@ import 'dart:io'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_framework/http2.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_core/http2.dart'; import 'package:file/local.dart'; import 'package:logging/logging.dart'; diff --git a/packages/framework/example/json.dart b/packages/core/example/json.dart similarity index 91% rename from packages/framework/example/json.dart rename to packages/core/example/json.dart index 1877dba..5e1b97b 100644 --- a/packages/framework/example/json.dart +++ b/packages/core/example/json.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'dart:io'; import 'dart:isolate'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; void main() async { var x = 0; diff --git a/packages/framework/example/main.dart b/packages/core/example/main.dart similarity index 93% rename from packages/framework/example/main.dart rename to packages/core/example/main.dart index cdb64e0..35e5515 100644 --- a/packages/framework/example/main.dart +++ b/packages/core/example/main.dart @@ -1,6 +1,6 @@ import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:logging/logging.dart'; void main() async { diff --git a/packages/framework/example/map_service.dart b/packages/core/example/map_service.dart similarity index 82% rename from packages/framework/example/map_service.dart rename to packages/core/example/map_service.dart index 62a25b2..548ab1d 100644 --- a/packages/framework/example/map_service.dart +++ b/packages/core/example/map_service.dart @@ -1,6 +1,6 @@ import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:logging/logging.dart'; void main() async { diff --git a/packages/framework/example/status.dart b/packages/core/example/status.dart similarity index 67% rename from packages/framework/example/status.dart rename to packages/core/example/status.dart index 9fcbeca..6435f46 100644 --- a/packages/framework/example/status.dart +++ b/packages/core/example/status.dart @@ -1,5 +1,5 @@ -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; void main() async { var app = Protevus(); diff --git a/packages/framework/example/view.dart b/packages/core/example/view.dart similarity index 82% rename from packages/framework/example/view.dart rename to packages/core/example/view.dart index f02076f..0134824 100644 --- a/packages/framework/example/view.dart +++ b/packages/core/example/view.dart @@ -1,6 +1,6 @@ import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; void main() async { var app = Protevus(reflector: MirrorsReflector()); diff --git a/packages/framework/example/views/index.jl b/packages/core/example/views/index.jl similarity index 100% rename from packages/framework/example/views/index.jl rename to packages/core/example/views/index.jl diff --git a/packages/framework/lib/platform_framework.dart b/packages/core/lib/core.dart similarity index 52% rename from packages/framework/lib/platform_framework.dart rename to packages/core/lib/core.dart index fc07f5d..eda6d0e 100644 --- a/packages/framework/lib/platform_framework.dart +++ b/packages/core/lib/core.dart @@ -1,7 +1,7 @@ /// An easily-extensible web server framework in Dart. -library angel3_framework; +library platform_core; export 'package:platform_exceptions/http_exception.dart'; -export 'package:platform_model/platform_model.dart'; -export 'package:platform_route/platform_route.dart'; +export 'package:platform_model/model.dart'; +export 'package:platform_route/route.dart'; export 'src/core/core.dart'; diff --git a/packages/framework/lib/http.dart b/packages/core/lib/http.dart similarity index 100% rename from packages/framework/lib/http.dart rename to packages/core/lib/http.dart diff --git a/packages/framework/lib/http2.dart b/packages/core/lib/http2.dart similarity index 100% rename from packages/framework/lib/http2.dart rename to packages/core/lib/http2.dart diff --git a/packages/framework/lib/src/core/anonymous_service.dart b/packages/core/lib/src/core/anonymous_service.dart similarity index 100% rename from packages/framework/lib/src/core/anonymous_service.dart rename to packages/core/lib/src/core/anonymous_service.dart diff --git a/packages/framework/lib/src/core/controller.dart b/packages/core/lib/src/core/controller.dart similarity index 98% rename from packages/framework/lib/src/core/controller.dart rename to packages/core/lib/src/core/controller.dart index 535d7e4..68d2d2b 100644 --- a/packages/framework/lib/src/core/controller.dart +++ b/packages/core/lib/src/core/controller.dart @@ -1,8 +1,8 @@ -library platform_framework.http.controller; +library platform_core.http.controller; import 'dart:async'; -import 'package:platform_container/platform_container.dart'; -import 'package:platform_route/platform_route.dart'; +import 'package:platform_container/container.dart'; +import 'package:platform_route/route.dart'; import 'package:meta/meta.dart'; import 'package:recase/recase.dart'; import '../core/core.dart'; diff --git a/packages/framework/lib/src/core/core.dart b/packages/core/lib/src/core/core.dart similarity index 100% rename from packages/framework/lib/src/core/core.dart rename to packages/core/lib/src/core/core.dart diff --git a/packages/framework/lib/src/core/driver.dart b/packages/core/lib/src/core/driver.dart similarity index 99% rename from packages/framework/lib/src/core/driver.dart rename to packages/core/lib/src/core/driver.dart index 6d36cd7..414e14b 100644 --- a/packages/framework/lib/src/core/driver.dart +++ b/packages/core/lib/src/core/driver.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io' show Cookie; import 'package:platform_exceptions/http_exception.dart'; -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:belatuk_combinator/belatuk_combinator.dart'; import 'package:stack_trace/stack_trace.dart'; import 'package:tuple/tuple.dart'; diff --git a/packages/framework/lib/src/core/env.dart b/packages/core/lib/src/core/env.dart similarity index 100% rename from packages/framework/lib/src/core/env.dart rename to packages/core/lib/src/core/env.dart diff --git a/packages/framework/lib/src/core/hooked_service.dart b/packages/core/lib/src/core/hooked_service.dart similarity index 99% rename from packages/framework/lib/src/core/hooked_service.dart rename to packages/core/lib/src/core/hooked_service.dart index 592c118..dd79e7e 100644 --- a/packages/framework/lib/src/core/hooked_service.dart +++ b/packages/core/lib/src/core/hooked_service.dart @@ -1,4 +1,4 @@ -library platform_framework.core.hooked_service; +library platform_core.core.hooked_service; import 'dart:async'; diff --git a/packages/framework/lib/src/core/hostname_parser.dart b/packages/core/lib/src/core/hostname_parser.dart similarity index 100% rename from packages/framework/lib/src/core/hostname_parser.dart rename to packages/core/lib/src/core/hostname_parser.dart diff --git a/packages/framework/lib/src/core/hostname_router.dart b/packages/core/lib/src/core/hostname_router.dart similarity index 97% rename from packages/framework/lib/src/core/hostname_router.dart rename to packages/core/lib/src/core/hostname_router.dart index b91ee58..b336808 100644 --- a/packages/framework/lib/src/core/hostname_router.dart +++ b/packages/core/lib/src/core/hostname_router.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:platform_container/platform_container.dart'; -import 'package:platform_route/platform_route.dart'; +import 'package:platform_container/container.dart'; +import 'package:platform_route/route.dart'; import 'package:logging/logging.dart'; import 'env.dart'; import 'hostname_parser.dart'; diff --git a/packages/framework/lib/src/core/injection.dart b/packages/core/lib/src/core/injection.dart similarity index 100% rename from packages/framework/lib/src/core/injection.dart rename to packages/core/lib/src/core/injection.dart diff --git a/packages/framework/lib/src/core/map_service.dart b/packages/core/lib/src/core/map_service.dart similarity index 100% rename from packages/framework/lib/src/core/map_service.dart rename to packages/core/lib/src/core/map_service.dart diff --git a/packages/framework/lib/src/core/metadata.dart b/packages/core/lib/src/core/metadata.dart similarity index 100% rename from packages/framework/lib/src/core/metadata.dart rename to packages/core/lib/src/core/metadata.dart diff --git a/packages/framework/lib/src/core/request_context.dart b/packages/core/lib/src/core/request_context.dart similarity index 99% rename from packages/framework/lib/src/core/request_context.dart rename to packages/core/lib/src/core/request_context.dart index 1f4b4a8..4bd0fa3 100644 --- a/packages/framework/lib/src/core/request_context.dart +++ b/packages/core/lib/src/core/request_context.dart @@ -6,7 +6,7 @@ import 'dart:typed_data' show BytesBuilder; import 'dart:io' show Cookie, HeaderValue, HttpHeaders, HttpSession, InternetAddress; -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:http_parser/http_parser.dart'; import 'package:belatuk_http_server/belatuk_http_server.dart'; import 'package:meta/meta.dart'; diff --git a/packages/framework/lib/src/core/response_context.dart b/packages/core/lib/src/core/response_context.dart similarity index 99% rename from packages/framework/lib/src/core/response_context.dart rename to packages/core/lib/src/core/response_context.dart index ac95c35..e1e096a 100644 --- a/packages/framework/lib/src/core/response_context.dart +++ b/packages/core/lib/src/core/response_context.dart @@ -1,4 +1,4 @@ -library platform_framework.http.response_context; +library platform_core.http.response_context; import 'dart:async'; import 'dart:convert'; @@ -6,7 +6,7 @@ import 'dart:convert' as c show json; import 'dart:io' show BytesBuilder, Cookie; import 'dart:typed_data'; -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:file/file.dart'; import 'package:http_parser/http_parser.dart'; import 'package:mime/mime.dart'; diff --git a/packages/framework/lib/src/core/routable.dart b/packages/core/lib/src/core/routable.dart similarity index 97% rename from packages/framework/lib/src/core/routable.dart rename to packages/core/lib/src/core/routable.dart index a79ea15..e4a8598 100644 --- a/packages/framework/lib/src/core/routable.dart +++ b/packages/core/lib/src/core/routable.dart @@ -2,8 +2,8 @@ library angel_framework.http.routable; import 'dart:async'; -import 'package:platform_container/platform_container.dart'; -import 'package:platform_route/platform_route.dart'; +import 'package:platform_container/container.dart'; +import 'package:platform_route/route.dart'; import '../util.dart'; import 'hooked_service.dart'; diff --git a/packages/framework/lib/src/core/server.dart b/packages/core/lib/src/core/server.dart similarity index 98% rename from packages/framework/lib/src/core/server.dart rename to packages/core/lib/src/core/server.dart index 7848a18..32dba66 100644 --- a/packages/framework/lib/src/core/server.dart +++ b/packages/core/lib/src/core/server.dart @@ -1,11 +1,11 @@ -library platform_framework.http.server; +library platform_core.http.server; import 'dart:async'; import 'dart:collection' show HashMap; import 'dart:convert'; -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:platform_exceptions/http_exception.dart'; -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:belatuk_combinator/belatuk_combinator.dart'; import 'package:http_parser/http_parser.dart'; import 'package:logging/logging.dart'; diff --git a/packages/framework/lib/src/core/service.dart b/packages/core/lib/src/core/service.dart similarity index 99% rename from packages/framework/lib/src/core/service.dart rename to packages/core/lib/src/core/service.dart index 92a0cc5..35512bf 100644 --- a/packages/framework/lib/src/core/service.dart +++ b/packages/core/lib/src/core/service.dart @@ -1,4 +1,4 @@ -library platform_framework.http.service; +library platform_core.http.service; import 'dart:async'; import 'package:platform_exceptions/http_exception.dart'; diff --git a/packages/framework/lib/src/fast_name_from_symbol.dart b/packages/core/lib/src/fast_name_from_symbol.dart similarity index 100% rename from packages/framework/lib/src/fast_name_from_symbol.dart rename to packages/core/lib/src/fast_name_from_symbol.dart diff --git a/packages/framework/lib/src/http/http.dart b/packages/core/lib/src/http/http.dart similarity index 100% rename from packages/framework/lib/src/http/http.dart rename to packages/core/lib/src/http/http.dart diff --git a/packages/framework/lib/src/http/http_request_context.dart b/packages/core/lib/src/http/http_request_context.dart similarity index 97% rename from packages/framework/lib/src/http/http_request_context.dart rename to packages/core/lib/src/http/http_request_context.dart index 6f895d9..855318c 100644 --- a/packages/framework/lib/src/http/http_request_context.dart +++ b/packages/core/lib/src/http/http_request_context.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:io'; -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; import 'package:http_parser/http_parser.dart'; import '../core/core.dart'; diff --git a/packages/framework/lib/src/http/http_response_context.dart b/packages/core/lib/src/http/http_response_context.dart similarity index 100% rename from packages/framework/lib/src/http/http_response_context.dart rename to packages/core/lib/src/http/http_response_context.dart diff --git a/packages/framework/lib/src/http/protevus_http.dart b/packages/core/lib/src/http/protevus_http.dart similarity index 98% rename from packages/framework/lib/src/http/protevus_http.dart rename to packages/core/lib/src/http/protevus_http.dart index f1c6405..5c39340 100644 --- a/packages/framework/lib/src/http/protevus_http.dart +++ b/packages/core/lib/src/http/protevus_http.dart @@ -8,7 +8,7 @@ import 'dart:io' HttpServer, Platform, SecurityContext; -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import '../core/core.dart'; import 'http_request_context.dart'; import 'http_response_context.dart'; diff --git a/packages/framework/lib/src/http2/http2_request_context.dart b/packages/core/lib/src/http2/http2_request_context.dart similarity index 96% rename from packages/framework/lib/src/http2/http2_request_context.dart rename to packages/core/lib/src/http2/http2_request_context.dart index 580b833..1e2f285 100644 --- a/packages/framework/lib/src/http2/http2_request_context.dart +++ b/packages/core/lib/src/http2/http2_request_context.dart @@ -1,11 +1,11 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:platform_container/platform_container.dart'; -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_container/container.dart'; +import 'package:platform_core/core.dart'; import 'package:collection/collection.dart' show IterableExtension; import 'package:http2/transport.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:uuid/uuid.dart'; final RegExp _comma = RegExp(r',\s*'); diff --git a/packages/framework/lib/src/http2/http2_response_context.dart b/packages/core/lib/src/http2/http2_response_context.dart similarity index 98% rename from packages/framework/lib/src/http2/http2_response_context.dart rename to packages/core/lib/src/http2/http2_response_context.dart index cbe03bc..569f10a 100644 --- a/packages/framework/lib/src/http2/http2_response_context.dart +++ b/packages/core/lib/src/http2/http2_response_context.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io' hide BytesBuilder; import 'dart:typed_data'; -import 'package:platform_framework/platform_framework.dart' hide Header; +import 'package:platform_core/core.dart' hide Header; import 'package:http2/transport.dart'; import 'http2_request_context.dart'; diff --git a/packages/framework/lib/src/http2/protevus_http2.dart b/packages/core/lib/src/http2/protevus_http2.dart similarity index 97% rename from packages/framework/lib/src/http2/protevus_http2.dart rename to packages/core/lib/src/http2/protevus_http2.dart index 7a7844f..917a89d 100644 --- a/packages/framework/lib/src/http2/protevus_http2.dart +++ b/packages/core/lib/src/http2/protevus_http2.dart @@ -1,10 +1,10 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:platform_framework/platform_framework.dart' hide Header; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart' hide Header; +import 'package:platform_core/http.dart'; import 'package:http2/transport.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_mocking/mocking.dart'; import 'http2_request_context.dart'; import 'http2_response_context.dart'; import 'package:uuid/uuid.dart'; diff --git a/packages/framework/lib/src/safe_stream_controller.dart b/packages/core/lib/src/safe_stream_controller.dart similarity index 100% rename from packages/framework/lib/src/safe_stream_controller.dart rename to packages/core/lib/src/safe_stream_controller.dart diff --git a/packages/framework/lib/src/util.dart b/packages/core/lib/src/util.dart similarity index 91% rename from packages/framework/lib/src/util.dart rename to packages/core/lib/src/util.dart index e73e6d2..53db9a0 100644 --- a/packages/framework/lib/src/util.dart +++ b/packages/core/lib/src/util.dart @@ -1,4 +1,4 @@ -import 'package:platform_container/platform_container.dart'; +import 'package:platform_container/container.dart'; final RegExp straySlashes = RegExp(r'(^/+)|(/+$)'); diff --git a/packages/framework/performance/hello/angel.md b/packages/core/performance/hello/angel.md similarity index 100% rename from packages/framework/performance/hello/angel.md rename to packages/core/performance/hello/angel.md diff --git a/packages/framework/performance/hello/main.dart b/packages/core/performance/hello/main.dart similarity index 83% rename from packages/framework/performance/hello/main.dart rename to packages/core/performance/hello/main.dart index 1fa043a..be581b1 100644 --- a/packages/framework/performance/hello/main.dart +++ b/packages/core/performance/hello/main.dart @@ -1,8 +1,8 @@ /// A basic server that prints "Hello, world!" library performance.hello; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; void main() async { var app = Protevus(); diff --git a/packages/framework/performance/hello/raw.dart b/packages/core/performance/hello/raw.dart similarity index 100% rename from packages/framework/performance/hello/raw.dart rename to packages/core/performance/hello/raw.dart diff --git a/packages/framework/performance/hello/raw.md b/packages/core/performance/hello/raw.md similarity index 100% rename from packages/framework/performance/hello/raw.md rename to packages/core/performance/hello/raw.md diff --git a/packages/framework/pubspec.lock b/packages/core/pubspec.lock similarity index 100% rename from packages/framework/pubspec.lock rename to packages/core/pubspec.lock diff --git a/packages/framework/pubspec.yaml b/packages/core/pubspec.yaml similarity index 98% rename from packages/framework/pubspec.yaml rename to packages/core/pubspec.yaml index 398b2c5..6b7aafd 100644 --- a/packages/framework/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -1,4 +1,4 @@ -name: platform_framework +name: platform_core version: 9.0.0 description: Protevus Platform high-powered HTTP server extensible framework with dependency injection, routing and much more. homepage: https://protevus.com diff --git a/packages/framework/test/accepts_test.dart b/packages/core/test/accepts_test.dart similarity index 93% rename from packages/framework/test/accepts_test.dart rename to packages/core/test/accepts_test.dart index 6e44fc1..6558ab1 100644 --- a/packages/framework/test/accepts_test.dart +++ b/packages/core/test/accepts_test.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; final Uri endpoint = Uri.parse('http://example.com/accept'); diff --git a/packages/framework/test/all.dart b/packages/core/test/all.dart similarity index 100% rename from packages/framework/test/all.dart rename to packages/core/test/all.dart diff --git a/packages/framework/test/anonymous_service_test.dart b/packages/core/test/anonymous_service_test.dart similarity index 95% rename from packages/framework/test/anonymous_service_test.dart rename to packages/core/test/anonymous_service_test.dart index 93efa9c..f0ebdc2 100644 --- a/packages/framework/test/anonymous_service_test.dart +++ b/packages/core/test/anonymous_service_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/framework/test/body_test.dart b/packages/core/test/body_test.dart similarity index 95% rename from packages/framework/test/body_test.dart rename to packages/core/test/body_test.dart index 968544e..8847dc6 100644 --- a/packages/framework/test/body_test.dart +++ b/packages/core/test/body_test.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/framework/test/common.dart b/packages/core/test/common.dart similarity index 94% rename from packages/framework/test/common.dart rename to packages/core/test/common.dart index 4d57983..5d51d3c 100644 --- a/packages/framework/test/common.dart +++ b/packages/core/test/common.dart @@ -1,6 +1,6 @@ library angel_framework.test.common; -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'package:matcher/matcher.dart'; class Todo extends Model { diff --git a/packages/framework/test/controller_test.dart b/packages/core/test/controller_test.dart similarity index 97% rename from packages/framework/test/controller_test.dart rename to packages/core/test/controller_test.dart index 7ea98de..eb1ab2c 100644 --- a/packages/framework/test/controller_test.dart +++ b/packages/core/test/controller_test.dart @@ -3,10 +3,10 @@ import 'dart:convert'; import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:http/http.dart' as http; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; import 'common.dart'; diff --git a/packages/framework/test/detach_test.dart b/packages/core/test/detach_test.dart similarity index 81% rename from packages/framework/test/detach_test.dart rename to packages/core/test/detach_test.dart index fbf2806..f042c44 100644 --- a/packages/framework/test/detach_test.dart +++ b/packages/core/test/detach_test.dart @@ -1,7 +1,7 @@ import 'dart:convert'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/framework/test/di_test.dart b/packages/core/test/di_test.dart similarity index 94% rename from packages/framework/test/di_test.dart rename to packages/core/test/di_test.dart index 7fd1077..3390e93 100644 --- a/packages/framework/test/di_test.dart +++ b/packages/core/test/di_test.dart @@ -1,12 +1,12 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:platform_container/platform_container.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_container/container.dart'; +import 'package:platform_core/http.dart'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'package:http/http.dart' as http; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; import 'common.dart'; diff --git a/packages/framework/test/encoders_buffer_test.dart b/packages/core/test/encoders_buffer_test.dart similarity index 94% rename from packages/framework/test/encoders_buffer_test.dart rename to packages/core/test/encoders_buffer_test.dart index 63d814e..9a04d2c 100644 --- a/packages/framework/test/encoders_buffer_test.dart +++ b/packages/core/test/encoders_buffer_test.dart @@ -4,9 +4,9 @@ import 'dart:io' hide BytesBuilder; import 'dart:typed_data' show BytesBuilder; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; Future> getBody(MockHttpResponse rs) async { diff --git a/packages/framework/test/env_test.dart b/packages/core/test/env_test.dart similarity index 91% rename from packages/framework/test/env_test.dart rename to packages/core/test/env_test.dart index 9fcef1d..d4ca038 100644 --- a/packages/framework/test/env_test.dart +++ b/packages/core/test/env_test.dart @@ -1,5 +1,5 @@ import 'dart:io'; -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/framework/test/exception_test.dart b/packages/core/test/exception_test.dart similarity index 97% rename from packages/framework/test/exception_test.dart rename to packages/core/test/exception_test.dart index 99eb2f9..eed34d4 100644 --- a/packages/framework/test/exception_test.dart +++ b/packages/core/test/exception_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'dart:convert'; import 'package:test/test.dart'; diff --git a/packages/framework/test/extension_test.dart b/packages/core/test/extension_test.dart similarity index 82% rename from packages/framework/test/extension_test.dart rename to packages/core/test/extension_test.dart index 6c8514c..d801341 100644 --- a/packages/framework/test/extension_test.dart +++ b/packages/core/test/extension_test.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; final Uri endpoint = Uri.parse('http://example.com'); diff --git a/packages/framework/test/find_one_test.dart b/packages/core/test/find_one_test.dart similarity index 91% rename from packages/framework/test/find_one_test.dart rename to packages/core/test/find_one_test.dart index cebbdd7..9e6df4b 100644 --- a/packages/framework/test/find_one_test.dart +++ b/packages/core/test/find_one_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'package:test/test.dart'; import 'common.dart'; diff --git a/packages/framework/test/general_test.dart b/packages/core/test/general_test.dart similarity index 90% rename from packages/framework/test/general_test.dart rename to packages/core/test/general_test.dart index 5ef2a84..4eeae1d 100644 --- a/packages/framework/test/general_test.dart +++ b/packages/core/test/general_test.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:test/test.dart'; diff --git a/packages/framework/test/hm.dart b/packages/core/test/hm.dart similarity index 100% rename from packages/framework/test/hm.dart rename to packages/core/test/hm.dart diff --git a/packages/framework/test/hooked_test.dart b/packages/core/test/hooked_test.dart similarity index 97% rename from packages/framework/test/hooked_test.dart rename to packages/core/test/hooked_test.dart index b9b28fb..8d6b65d 100644 --- a/packages/framework/test/hooked_test.dart +++ b/packages/core/test/hooked_test.dart @@ -1,8 +1,8 @@ import 'dart:convert'; import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:http/http.dart' as http; import 'package:test/test.dart'; import 'common.dart'; diff --git a/packages/framework/test/http2/adapter_test.dart b/packages/core/test/http2/adapter_test.dart similarity index 98% rename from packages/framework/test/http2/adapter_test.dart rename to packages/core/test/http2/adapter_test.dart index 4cca958..aaa859b 100644 --- a/packages/framework/test/http2/adapter_test.dart +++ b/packages/core/test/http2/adapter_test.dart @@ -3,8 +3,8 @@ import 'dart:convert'; import 'dart:io' hide BytesBuilder; import 'dart:typed_data'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart' hide Header; -import 'package:platform_framework/http2.dart'; +import 'package:platform_core/core.dart' hide Header; +import 'package:platform_core/http2.dart'; import 'package:collection/collection.dart' show IterableExtension; import 'package:http/src/multipart_file.dart' as http; import 'package:http/src/multipart_request.dart' as http; diff --git a/packages/framework/test/http2/http2_client.dart b/packages/core/test/http2/http2_client.dart similarity index 100% rename from packages/framework/test/http2/http2_client.dart rename to packages/core/test/http2/http2_client.dart diff --git a/packages/framework/test/http_404_hole_test.dart b/packages/core/test/http_404_hole_test.dart similarity index 95% rename from packages/framework/test/http_404_hole_test.dart rename to packages/core/test/http_404_hole_test.dart index c139c6c..9d45cf7 100644 --- a/packages/framework/test/http_404_hole_test.dart +++ b/packages/core/test/http_404_hole_test.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:charcode/ascii.dart'; import 'package:http/io_client.dart' as http; import 'package:logging/logging.dart'; diff --git a/packages/framework/test/jsonp_test.dart b/packages/core/test/jsonp_test.dart similarity index 91% rename from packages/framework/test/jsonp_test.dart rename to packages/core/test/jsonp_test.dart index a9dcaff..f535268 100644 --- a/packages/framework/test/jsonp_test.dart +++ b/packages/core/test/jsonp_test.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'dart:convert'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:http_parser/http_parser.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/framework/test/parameter_meta_test.dart b/packages/core/test/parameter_meta_test.dart similarity index 95% rename from packages/framework/test/parameter_meta_test.dart rename to packages/core/test/parameter_meta_test.dart index 50e4572..134a064 100644 --- a/packages/framework/test/parameter_meta_test.dart +++ b/packages/core/test/parameter_meta_test.dart @@ -2,9 +2,9 @@ import 'dart:async'; import 'dart:convert'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:logging/logging.dart'; import 'package:test/test.dart'; diff --git a/packages/framework/test/parse_id_test.dart b/packages/core/test/parse_id_test.dart similarity index 92% rename from packages/framework/test/parse_id_test.dart rename to packages/core/test/parse_id_test.dart index f494de9..95f6732 100644 --- a/packages/framework/test/parse_id_test.dart +++ b/packages/core/test/parse_id_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/framework/test/precontained_test.dart b/packages/core/test/precontained_test.dart similarity index 82% rename from packages/framework/test/precontained_test.dart rename to packages/core/test/precontained_test.dart index cf58a10..01a1a3c 100644 --- a/packages/framework/test/precontained_test.dart +++ b/packages/core/test/precontained_test.dart @@ -1,9 +1,9 @@ import 'dart:convert'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; diff --git a/packages/framework/test/pretty_log.dart b/packages/core/test/pretty_log.dart similarity index 100% rename from packages/framework/test/pretty_log.dart rename to packages/core/test/pretty_log.dart diff --git a/packages/framework/test/primitives_test.dart b/packages/core/test/primitives_test.dart similarity index 92% rename from packages/framework/test/primitives_test.dart rename to packages/core/test/primitives_test.dart index d6db906..4c670d3 100644 --- a/packages/framework/test/primitives_test.dart +++ b/packages/core/test/primitives_test.dart @@ -2,9 +2,9 @@ import 'dart:convert'; import 'dart:io' show stderr; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; diff --git a/packages/framework/test/repeat_request_test.dart b/packages/core/test/repeat_request_test.dart similarity index 85% rename from packages/framework/test/repeat_request_test.dart rename to packages/core/test/repeat_request_test.dart index e636b44..886f0e1 100644 --- a/packages/framework/test/repeat_request_test.dart +++ b/packages/core/test/repeat_request_test.dart @@ -2,9 +2,9 @@ import 'dart:async'; import 'dart:convert'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/framework/test/req_shutdown_test.dart b/packages/core/test/req_shutdown_test.dart similarity index 90% rename from packages/framework/test/req_shutdown_test.dart rename to packages/core/test/req_shutdown_test.dart index 00a6e80..3a26613 100644 --- a/packages/framework/test/req_shutdown_test.dart +++ b/packages/core/test/req_shutdown_test.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:http/io_client.dart' as http; import 'package:logging/logging.dart'; import 'package:test/test.dart'; diff --git a/packages/framework/test/response_header_test.dart b/packages/core/test/response_header_test.dart similarity index 92% rename from packages/framework/test/response_header_test.dart rename to packages/core/test/response_header_test.dart index 52f42af..63c0b13 100644 --- a/packages/framework/test/response_header_test.dart +++ b/packages/core/test/response_header_test.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/src/http/protevus_http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/src/http/protevus_http.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/framework/test/routing_test.dart b/packages/core/test/routing_test.dart similarity index 98% rename from packages/framework/test/routing_test.dart rename to packages/core/test/routing_test.dart index 9919fa2..e749d5e 100644 --- a/packages/framework/test/routing_test.dart +++ b/packages/core/test/routing_test.dart @@ -2,8 +2,8 @@ import 'dart:convert'; import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:http/http.dart' as http; import 'package:io/ansi.dart'; import 'package:logging/logging.dart'; diff --git a/packages/framework/test/serialize_test.dart b/packages/core/test/serialize_test.dart similarity index 91% rename from packages/framework/test/serialize_test.dart rename to packages/core/test/serialize_test.dart index 0b0c0c8..48a1f94 100644 --- a/packages/framework/test/serialize_test.dart +++ b/packages/core/test/serialize_test.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:http/http.dart' as http; import 'package:http_parser/http_parser.dart'; import 'package:test/test.dart'; diff --git a/packages/framework/test/server_test.dart b/packages/core/test/server_test.dart similarity index 97% rename from packages/framework/test/server_test.dart rename to packages/core/test/server_test.dart index d1d5c60..69206b5 100644 --- a/packages/framework/test/server_test.dart +++ b/packages/core/test/server_test.dart @@ -3,9 +3,9 @@ import 'dart:convert'; import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; diff --git a/packages/framework/test/service_map_test.dart b/packages/core/test/service_map_test.dart similarity index 96% rename from packages/framework/test/service_map_test.dart rename to packages/core/test/service_map_test.dart index 11db8c2..3c08c2b 100644 --- a/packages/framework/test/service_map_test.dart +++ b/packages/core/test/service_map_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'package:test/test.dart'; import 'package:quiver/core.dart'; diff --git a/packages/framework/test/services_test.dart b/packages/core/test/services_test.dart similarity index 97% rename from packages/framework/test/services_test.dart rename to packages/core/test/services_test.dart index 217fca5..64b0131 100644 --- a/packages/framework/test/services_test.dart +++ b/packages/core/test/services_test.dart @@ -1,6 +1,6 @@ import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:stack_trace/stack_trace.dart'; diff --git a/packages/framework/test/streaming_test.dart b/packages/core/test/streaming_test.dart similarity index 94% rename from packages/framework/test/streaming_test.dart rename to packages/core/test/streaming_test.dart index a5b6a1b..808fb38 100644 --- a/packages/framework/test/streaming_test.dart +++ b/packages/core/test/streaming_test.dart @@ -3,10 +3,10 @@ import 'dart:convert'; import 'dart:io'; import 'package:platform_container/mirrors.dart'; -import 'package:platform_framework/platform_framework.dart'; -import 'package:platform_framework/http.dart'; +import 'package:platform_core/core.dart'; +import 'package:platform_core/http.dart'; import 'package:logging/logging.dart'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_mocking/mocking.dart'; import 'package:test/test.dart'; diff --git a/packages/framework/test/view_generator_test.dart b/packages/core/test/view_generator_test.dart similarity index 79% rename from packages/framework/test/view_generator_test.dart rename to packages/core/test/view_generator_test.dart index 09f147a..e3db648 100644 --- a/packages/framework/test/view_generator_test.dart +++ b/packages/core/test/view_generator_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_framework/platform_framework.dart'; +import 'package:platform_core/core.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/mocking/example/main.dart b/packages/mocking/example/main.dart index 74ad5cb..084975b 100644 --- a/packages/mocking/example/main.dart +++ b/packages/mocking/example/main.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:platform_mocking/platform_mocking.dart'; +import 'package:platform_mocking/mocking.dart'; Future main() async { var rq = diff --git a/packages/mocking/lib/platform_mocking.dart b/packages/mocking/lib/mocking.dart similarity index 100% rename from packages/mocking/lib/platform_mocking.dart rename to packages/mocking/lib/mocking.dart diff --git a/packages/mocking/pubspec.yaml b/packages/mocking/pubspec.yaml index eb5a422..f456072 100644 --- a/packages/mocking/pubspec.yaml +++ b/packages/mocking/pubspec.yaml @@ -13,7 +13,7 @@ dev_dependencies: test: ^1.24.0 lints: ^4.0.0 # dependency_overrides: -# platform_framework: +# platform_core: # path: ../framework # platform_route: # path: ../route diff --git a/packages/model/example/main.dart b/packages/model/example/main.dart index fec85b1..9c86106 100644 --- a/packages/model/example/main.dart +++ b/packages/model/example/main.dart @@ -1,4 +1,4 @@ -import 'package:platform_model/platform_model.dart'; +import 'package:platform_model/model.dart'; void main() { var todo = Todo(id: '34', isComplete: false); diff --git a/packages/model/lib/platform_model.dart b/packages/model/lib/model.dart similarity index 100% rename from packages/model/lib/platform_model.dart rename to packages/model/lib/model.dart diff --git a/packages/route/example/main.dart b/packages/route/example/main.dart index 6a3c363..dc351a1 100644 --- a/packages/route/example/main.dart +++ b/packages/route/example/main.dart @@ -1,6 +1,6 @@ import 'dart:math'; -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; void main() { final router = Router(); diff --git a/packages/route/lib/browser.dart b/packages/route/lib/browser.dart index e8e995f..29268eb 100644 --- a/packages/route/lib/browser.dart +++ b/packages/route/lib/browser.dart @@ -2,7 +2,7 @@ import 'dart:async' show Stream, StreamController; import 'dart:html'; import 'package:path/path.dart' as p; -import 'platform_route.dart'; +import 'route.dart'; final RegExp _hash = RegExp(r'^#/'); final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)'); diff --git a/packages/route/lib/platform_route.dart b/packages/route/lib/route.dart similarity index 100% rename from packages/route/lib/platform_route.dart rename to packages/route/lib/route.dart diff --git a/packages/route/pubspec.yaml b/packages/route/pubspec.yaml index ae26030..4f458fd 100644 --- a/packages/route/pubspec.yaml +++ b/packages/route/pubspec.yaml @@ -1,6 +1,6 @@ name: platform_route version: 9.0.0 -description: A powerful, isomorphic routing library for Dart. It is mainly used in the Protevus framework, but can be used in Flutter and on the Web. +description: A powerful, isomorphic routing library for Dart. It is mainly used in the Protevus Platform, but can be used in Flutter and on the Web. homepage: https://protevus.com documentation: https://docs.protevus.com repository: https://git.protevus.com/protevus/platform/src/branch/main/packages/route diff --git a/packages/route/test/chain_nest_test.dart b/packages/route/test/chain_nest_test.dart index 6ac5446..c136cb4 100644 --- a/packages/route/test/chain_nest_test.dart +++ b/packages/route/test/chain_nest_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/route/test/navigate_test.dart b/packages/route/test/navigate_test.dart index 135d0d8..e9bfe45 100644 --- a/packages/route/test/navigate_test.dart +++ b/packages/route/test/navigate_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/route/test/params_test.dart b/packages/route/test/params_test.dart index f39da1d..cc0f111 100644 --- a/packages/route/test/params_test.dart +++ b/packages/route/test/params_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/route/test/parse_test.dart b/packages/route/test/parse_test.dart index f976f6c..c691697 100644 --- a/packages/route/test/parse_test.dart +++ b/packages/route/test/parse_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/route/test/root_test.dart b/packages/route/test/root_test.dart index 163b091..651e0e1 100644 --- a/packages/route/test/root_test.dart +++ b/packages/route/test/root_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/route/test/server_test.dart b/packages/route/test/server_test.dart index e3bb725..0aaa66f 100644 --- a/packages/route/test/server_test.dart +++ b/packages/route/test/server_test.dart @@ -1,6 +1,6 @@ import 'dart:convert'; import 'dart:io'; -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:http/http.dart' as http; import 'package:test/test.dart'; diff --git a/packages/route/test/uri_decode_test.dart b/packages/route/test/uri_decode_test.dart index 58b1637..c3d543d 100644 --- a/packages/route/test/uri_decode_test.dart +++ b/packages/route/test/uri_decode_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/route/test/wildcard_test.dart b/packages/route/test/wildcard_test.dart index cb3f752..862e37b 100644 --- a/packages/route/test/wildcard_test.dart +++ b/packages/route/test/wildcard_test.dart @@ -1,4 +1,4 @@ -import 'package:platform_route/platform_route.dart'; +import 'package:platform_route/route.dart'; import 'package:test/test.dart'; void main() {