Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 800e3af

Browse files
committed
Merge pull request facebook#86 from facebook/componentkit
Add pcomponents/dcomponents/rcomponents for debugging in ComponentKit
2 parents d447d64 + 3d961fe commit 800e3af

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

commands/FBComponentCommands.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/python
2+
3+
import os
4+
5+
import lldb
6+
import fblldbbase as fb
7+
8+
def lldbinit():
9+
# Tell LLDB to print CKComponentAction as a c-string
10+
lldb.debugger.HandleCommand('type summary add --summary-string "${var%c-string}" CKComponentAction')
11+
12+
def lldbcommands():
13+
return [
14+
FBComponentsDebugCommand(),
15+
FBComponentsPrintCommand(),
16+
FBComponentsReflowCommand(),
17+
]
18+
19+
20+
class FBComponentsDebugCommand(fb.FBCommand):
21+
def name(self):
22+
return 'dcomponents'
23+
24+
def description(self):
25+
return 'Set debugging options for components.'
26+
27+
def options(self):
28+
return [
29+
fb.FBCommandArgument(short='-s', long='--set', arg='set', help='Set debug mode for components', boolean=True),
30+
fb.FBCommandArgument(short='-u', long='--unset', arg='unset', help='Unset debug mode for components', boolean=True),
31+
]
32+
33+
def run(self, arguments, options):
34+
if options.set:
35+
lldb.debugger.HandleCommand('expr (void)[CKComponentDebugController setDebugMode:YES]')
36+
print 'Debug mode for ComponentKit has been set.'
37+
elif options.unset:
38+
lldb.debugger.HandleCommand('expr (void)[CKComponentDebugController setDebugMode:NO]')
39+
print 'Debug mode for ComponentKit has been unset.'
40+
else:
41+
print 'No option for ComponentKit Debug mode specified.'
42+
43+
class FBComponentsPrintCommand(fb.FBCommand):
44+
def name(self):
45+
return 'pcomponents'
46+
47+
def description(self):
48+
return 'Print a recursive description of components found starting from <aView>.'
49+
50+
def options(self):
51+
return [ fb.FBCommandArgument(short='-u', long='--up', arg='upwards', boolean=True, default=False, help='Print only the component hierarchy found on the first superview that has them, carrying the search up to its window.') ]
52+
53+
def args(self):
54+
return [ fb.FBCommandArgument(arg='aView', type='UIView*', help='The view to from which the search for components begins.', default='(id)[[UIApplication sharedApplication] keyWindow]') ]
55+
56+
def run(self, arguments, options):
57+
upwards = 'NO'
58+
if options.upwards:
59+
upwards = 'YES'
60+
61+
lldb.debugger.HandleCommand('po (id)[CKComponentHierarchyDebugHelper componentHierarchyDescriptionForView:(UIView *)' + arguments[0] + ' searchUpwards:' + upwards + ']')
62+
63+
class FBComponentsReflowCommand(fb.FBCommand):
64+
def name(self):
65+
return 'rcomponents'
66+
67+
def description(self):
68+
return 'Synchronously reflow and update root components found starting from <aView>.'
69+
70+
def options(self):
71+
return [ fb.FBCommandArgument(short='-u', long='--up', arg='upwards', boolean=True, default=False, help='Reflow only the root components found on the first superview that has them, carrying the search up to its window.') ]
72+
73+
def args(self):
74+
return [ fb.FBCommandArgument(arg='aView', type='UIView*', help='The view to from which the search for the root components begins.', default='(id)[[UIApplication sharedApplication] keyWindow]') ]
75+
76+
def run(self, arguments, options):
77+
upwards = 'NO'
78+
if options.upwards:
79+
upwards = 'YES'
80+
81+
lldb.debugger.HandleCommand('e (void)[CKComponentDebugController reflowComponentsForView:(UIView *)' + arguments[0] + ' searchUpwards:' + upwards + ']')

0 commit comments

Comments
 (0)