From b99c191bb22f7c584dbecd73871d82085cd5c297 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Tue, 24 Feb 2015 17:44:38 +0300 Subject: [PATCH] Refactoring: Rename AbstractExtractFunctionAction ->AbstractIntroduceAction and move to 'introduce' package --- .../introduce/AbstractIntroduceAction.kt | 32 +++++++++++++++++++ .../extractFunction/ExtractFunctionAction.kt | 19 ++--------- 2 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractIntroduceAction.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractIntroduceAction.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractIntroduceAction.kt new file mode 100644 index 00000000000..a7887b0dfd7 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractIntroduceAction.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring.introduce + +import com.intellij.refactoring.actions.* +import com.intellij.psi.* +import org.jetbrains.kotlin.psi.* + +public abstract class AbstractIntroduceAction : BasePlatformRefactoringAction() { + { + setInjectedContext(true) + } + + override fun isAvailableInEditorOnly(): Boolean = true + + protected override fun isEnabledOnElements(elements: Array): Boolean = + elements.all { it is JetElement } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractFunctionAction.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractFunctionAction.kt index 29d8265ebbd..b83cbbd8aeb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractFunctionAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractFunctionAction.kt @@ -16,30 +16,17 @@ package org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction -import com.intellij.refactoring.actions.BasePlatformRefactoringAction -import com.intellij.psi.PsiElement import com.intellij.refactoring.RefactoringActionHandler import com.intellij.lang.refactoring.RefactoringSupportProvider -import org.jetbrains.kotlin.psi.JetElement import org.jetbrains.kotlin.idea.refactoring.JetRefactoringSupportProvider +import org.jetbrains.kotlin.idea.refactoring.introduce.* -public abstract class AbstractExtractFunctionAction: BasePlatformRefactoringAction() { - { - setInjectedContext(true) - } - - override fun isAvailableInEditorOnly(): Boolean = true - - protected override fun isEnabledOnElements(elements: Array): Boolean = - elements.all { it is JetElement } -} - -public class ExtractFunctionAction: AbstractExtractFunctionAction() { +public class ExtractFunctionAction: AbstractIntroduceAction() { override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? = (provider as? JetRefactoringSupportProvider)?.getExtractFunctionHandler() } -public class ExtractFunctionToScopeAction: AbstractExtractFunctionAction() { +public class ExtractFunctionToScopeAction: AbstractIntroduceAction() { override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? = (provider as? JetRefactoringSupportProvider)?.getExtractFunctionToScopeHandler() }