Creating Custom extract action

I am trying to create a custom extract action using the following class

 
public class RefactoringSupportProvider extends com.intellij.lang.refactoring.RefactoringSupportProvider {
    @Nullable
    @Override
    public
RefactoringActionHandler getIntroduceConstantHandler() {
        return new ExtractHandler();
    
}
}


The flow in Intellij is :  Refactor -----> extract -----> constant (refer to attachment)

I want to change 'constant' to  'custom extract' so that flow becomes like : Refactor -----> extract -----> custom extract

Any suggestions how to do that?



Attachment(s):
Screen Shot 2015-03-31 at 10.54.43 AM.png
2 comments
Comment actions Permalink

If you want to create a custom refactoring, you don't need to touch RefactoringSupportProvider at all. Simply implement your own AnAction and add it to the correct action group (the ID is IntroduceActionGroup).

0
Comment actions Permalink

Thanks for the suggestion.
I tried creating an action in plugin.xml, it works as expected.

  
<actions>
    <action id="Custom Extract"
            class="CustomExtractAction"
            text="Custom Extract">
        <add-to-group group-id="RefactoringMenu" anchor="last"/>
        <keyboard-shortcut first-keystroke="ctrl alt c" keymap="$default"/>
    </action>
</actions>
 

But Is there any way to disable that action for specific files ?

0

Please sign in to leave a comment.