* Inspect an injection * @param injection - Injection information
(injection: Readonly<Injection<unknown>>)
| 745 | * @param injection - Injection information |
| 746 | */ |
| 747 | function inspectInjection(injection: Readonly<Injection<unknown>>) { |
| 748 | const injectionInfo = ResolutionSession.describeInjection(injection); |
| 749 | const descriptor: JSONObject = {}; |
| 750 | if (injectionInfo.targetName) { |
| 751 | descriptor.targetName = injectionInfo.targetName; |
| 752 | } |
| 753 | if (isBindingAddress(injectionInfo.bindingSelector)) { |
| 754 | // Binding key |
| 755 | descriptor.bindingKey = injectionInfo.bindingSelector.toString(); |
| 756 | } else if (isBindingTagFilter(injectionInfo.bindingSelector)) { |
| 757 | // Binding tag filter |
| 758 | descriptor.bindingTagPattern = JSON.parse( |
| 759 | JSON.stringify(injectionInfo.bindingSelector.bindingTagPattern), |
| 760 | ); |
| 761 | } else { |
| 762 | // Binding filter function |
| 763 | descriptor.bindingFilter = |
| 764 | injectionInfo.bindingSelector?.name ?? '<function>'; |
| 765 | } |
| 766 | // Inspect metadata |
| 767 | if (injectionInfo.metadata) { |
| 768 | if ( |
| 769 | injectionInfo.metadata.decorator && |
| 770 | injectionInfo.metadata.decorator !== '@inject' |
| 771 | ) { |
| 772 | descriptor.decorator = injectionInfo.metadata.decorator; |
| 773 | } |
| 774 | if (injectionInfo.metadata.optional) { |
| 775 | descriptor.optional = injectionInfo.metadata.optional; |
| 776 | } |
| 777 | } |
| 778 | return descriptor; |
| 779 | } |
| 780 | |
| 781 | /** |
| 782 | * Check if the given class has `@inject` or other decorations that map to |
no test coverage detected