kinwahlai / XcodeRefactoringPlus

Xcode Refactoring extention
50 stars 12 forks source link

Xcode Refactoring Plus

Build Status

I miss the refactoring function in eclipse so i create this plugin to extend the current refactoring function of xcode to functionality like move line, delete line, duplicate line.

Delete Line (cmd+D)

Delete the line or current selected lines.

Duplicate Line (alt+cmd+down)

Duplicate the line or current selected lines.

Move Line (alt+down | alt+up)

Move the line or current selected lines

Extract Local Variable (alt+cmd+l)

Extract the inline code into local variable within the method

NOTES: I choose to use placeholder token as solution is to avoid doing any UI implementation for now.

-(void) bar {
    **type** **variable** = NSMakeRange(10, 10);
    [self acceptARange:**variable**];
}

You will need to update the placeholder token manually.

Installation

Option 1

Option 2

Update keybinding:

If you cannot use the keystroke, please resolve conflict keybinding in System Preferences -> Keyboard -> Shortcuts -> App Shortcuts

Alternative:

You can download my keybinding file XcodeRefactoringPlus.idekeybindings and then put it at ~/Library/Developer/Xcode/UserData/KeyBindings/XcodeRefactoringPlus.idekeybindings

What to do if Xcode 6.4 doesn't load the plugin

Apple change the non-Apple plugin handling since Xcode 6.4. Now Xcode will ask you if you want to load the bundle (for once) on startup. However, there are times we accidentally click Skip Bundles, then what should we do?

Don't panic. You can reset the storage of your choice (Load bundle/skip bundles) with this command.


defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-6.4

Restart Xcode and it will should you the prompt again.


License

// Copyright (c) 2014 KinWah
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.