FLEXBlockShortcuts.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // FLEXBlockShortcuts.m
  3. // FLEX
  4. //
  5. // Created by Tanner on 1/30/20.
  6. // Copyright © 2020 FLEX Team. All rights reserved.
  7. //
  8. #import "FLEXBlockShortcuts.h"
  9. #import "FLEXShortcut.h"
  10. #import "FLEXBlockDescription.h"
  11. #import "FLEXObjectExplorerFactory.h"
  12. #pragma mark -
  13. @implementation FLEXBlockShortcuts
  14. #pragma mark Overrides
  15. + (instancetype)forObject:(id)block {
  16. NSParameterAssert([block isKindOfClass:NSClassFromString(@"NSBlock")]);
  17. FLEXBlockDescription *blockInfo = [FLEXBlockDescription describing:block];
  18. NSMethodSignature *signature = blockInfo.signature;
  19. NSArray *blockShortcutRows = @[blockInfo.summary];
  20. if (signature) {
  21. blockShortcutRows = @[
  22. blockInfo.summary,
  23. blockInfo.sourceDeclaration,
  24. signature.debugDescription,
  25. [FLEXActionShortcut title:@"View Method Signature"
  26. subtitle:^NSString *(id block) {
  27. return signature.description ?: @"unsupported signature";
  28. }
  29. viewer:^UIViewController *(id block) {
  30. return [FLEXObjectExplorerFactory explorerViewControllerForObject:signature];
  31. }
  32. accessoryType:^UITableViewCellAccessoryType(id view) {
  33. if (signature) {
  34. return UITableViewCellAccessoryDisclosureIndicator;
  35. }
  36. return UITableViewCellAccessoryNone;
  37. }
  38. ]
  39. ];
  40. }
  41. return [self forObject:block additionalRows:blockShortcutRows];
  42. }
  43. - (NSString *)title {
  44. return @"Metadata";
  45. }
  46. - (NSInteger)numberOfLines {
  47. return 0;
  48. }
  49. @end