ios - Is there any way I can fold all methods in Xcode project? -


xcode provides method folding option current file. there way apply .m files in project ?

enter image description here

p.s: tried xcode run scripts & xcode plugin development, failed comeup proper solution

here's applescript purpose. caveat:

  • system events required.
  • the script needs changes if have multiple workspaces open or workspace contains multiple projects.
  • you may need have else .m file selected in project navigator.
    -- collect objective-c file references given group.     on handlegroup(thegroup, coderefs)         tell application "xcode"             set filerefs thegroup's file references             repeat x in filerefs                 if x's file kind equal "sourcecode.c.objc"                     copy x end of coderefs                 end if             end repeat              set subgroups thegroup's groups             repeat x in subgroups                 handlegroup(x, coderefs)             end repeat         end tell     end handlegroup       on movefocustoprojectnavigator()         tell application "system events"             tell process "xcode"                 set frontmost true                 tell menu bar item "navigate" of menu bar 1                     tell menu 1                         click menu item "reveal in project navigator"                     end tell                 end tell             end tell         end tell     end movefocustoprojectnavigator       on movefocustonextarea()         tell application "system events"             tell process "xcode"                 set frontmost true                 tell menu bar item "navigate" of menu bar 1                     tell menu 1                         click menu item "move focus next area"                     end tell                 end tell             end tell         end tell     end movefocustonextarea       -- simulate pressing arrow.     on selectnextitem()         tell application "system events"             tell process "xcode"                 key code 126             end tell         end tell     end selectnextitem       on fold(shouldfold)         set thecommand "fold methods & functions"         if shouldfold equal 0             set thecommand "unfold all"         end if          -- fold code using menu item.         tell application "system events"             tell process "xcode"                 set frontmost true                  tell menu bar item "editor" of menu bar 1                     tell menu 1                         tell menu item "code folding"                             tell menu 1                                 click menu item thecommand                             end tell                         end tell                     end tell                 end tell             end tell         end tell     end fold       on run         -- set 1 fold, 0 unfold.         set shouldfold 1          tell application "xcode"             set ws every workspace document             set theworkspace item 1 of ws             tell theworkspace                 set pr item 1 of projects                 set coderefs {}                 handlegroup(pr, coderefs)                  -- open each document , fold code.                 set thepaths {}                 repeat x in coderefs                     copy x's full path end of thepaths                 end repeat             end tell              -- if have 1 path, new workspace won't opened.             if 1 equal (count of thepaths)                 open item 1 of thepaths                 movefocustonextarea()                 fold(shouldfold)             else                 open thepaths                  set ws every workspace document                 set theworkspace item 1 of ws                 fold(shouldfold)                 repeat (count of theworkspace's file references) - 1 times                     movefocustoprojectnavigator()                     selectnextitem()                     movefocustonextarea()                     fold(shouldfold)                 end repeat                  -- if don't wait before closing window, last document                 -- won't folded.                 tell application "system events" delay 3                  tell theworkspace close             end if         end tell     end run 

for sake of completeness, here's earlier attempt. quite slow since needs open 1 document url @ time.

    -- collect objective-c file references given group.     on handlegroup(thegroup, coderefs)         tell application "xcode"             set filerefs thegroup's file references             repeat x in filerefs                 if x's file kind equal "sourcecode.c.objc"                     copy x end of coderefs                 end if             end repeat              set subgroups thegroup's groups             repeat x in subgroups                 handlegroup(x, coderefs)             end repeat         end tell     end handlegroup      on run         tell application "xcode"             set ws every workspace document             tell item 1 of ws                 set pr item 1 of projects                 set coderefs {}                 handlegroup(pr, coderefs)                  -- open each document , fold code.                 repeat x in coderefs                     set thepath x's full path                     set doc open thepath                      tell doc                         activate                     end tell                      -- fold code using menu item.                     tell application "system events"                         tell process "xcode"                             set frontmost true                              tell menu bar item "editor" of menu bar 1                                 tell menu 1                                     tell menu item "code folding"                                         tell menu 1                                             click menu item "fold methods & functions"                                         end tell                                     end tell                                 end tell                             end tell                         end tell                     end tell                  end repeat             end tell         end tell     end run 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -