Extract Function: Replace IDEA "Extract Method..." action with "Extract Function..."
This commit is contained in:
@@ -97,10 +97,15 @@
|
||||
<add-to-group group-id="KotlinToolsGroup"/>
|
||||
</action>
|
||||
|
||||
<action id="ExtractFunction" class="org.jetbrains.jet.plugin.refactoring.extractFunction.ExtractFunctionAction"
|
||||
text="Extract _Function..." use-shortcut-of="ExtractMethod">
|
||||
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="ExtractMethod"/>
|
||||
</action>
|
||||
|
||||
<action id="ExtractFunctionToScope" class="org.jetbrains.jet.plugin.refactoring.extractFunction.ExtractFunctionToScopeAction"
|
||||
text="Extract Function to _Scope...">
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="control alt shift M"/>
|
||||
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="ExtractMethod"/>
|
||||
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="ExtractFunction"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ public class JetRefactoringSupportProvider extends RefactoringSupportProvider {
|
||||
return new KotlinIntroduceVariableHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefactoringActionHandler getExtractMethodHandler() {
|
||||
@NotNull
|
||||
public RefactoringActionHandler getExtractFunctionHandler() {
|
||||
return new ExtractKotlinFunctionHandler();
|
||||
}
|
||||
|
||||
|
||||
+14
-11
@@ -23,20 +23,23 @@ import com.intellij.lang.refactoring.RefactoringSupportProvider
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.plugin.refactoring.JetRefactoringSupportProvider
|
||||
|
||||
public class ExtractFunctionToScopeAction: BasePlatformRefactoringAction() {
|
||||
public abstract class AbstractExtractFunctionAction: BasePlatformRefactoringAction() {
|
||||
{
|
||||
setInjectedContext(true)
|
||||
}
|
||||
|
||||
override fun isAvailableInEditorOnly(): Boolean {
|
||||
return true
|
||||
}
|
||||
override fun isAvailableInEditorOnly(): Boolean = true
|
||||
|
||||
protected override fun isEnabledOnElements(elements: Array<out PsiElement>): Boolean {
|
||||
return elements.all { it is JetElement }
|
||||
}
|
||||
|
||||
override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? {
|
||||
return (provider as? JetRefactoringSupportProvider)?.getExtractFunctionToScopeHandler()
|
||||
}
|
||||
protected override fun isEnabledOnElements(elements: Array<out PsiElement>): Boolean =
|
||||
elements.all { it is JetElement }
|
||||
}
|
||||
|
||||
public class ExtractFunctionAction: AbstractExtractFunctionAction() {
|
||||
override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? =
|
||||
(provider as? JetRefactoringSupportProvider)?.getExtractFunctionHandler()
|
||||
}
|
||||
|
||||
public class ExtractFunctionToScopeAction: AbstractExtractFunctionAction() {
|
||||
override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? =
|
||||
(provider as? JetRefactoringSupportProvider)?.getExtractFunctionToScopeHandler()
|
||||
}
|
||||
Reference in New Issue
Block a user