diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index fd8e323f5ff..1a71ec6edb0 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -96,6 +96,12 @@ text="Configure Kotlin (JavaScript) in Project"> + + + + + diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringSupportProvider.java b/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringSupportProvider.java index e800a1f7578..ae2fa5543e8 100644 --- a/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringSupportProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringSupportProvider.java @@ -44,6 +44,11 @@ public class JetRefactoringSupportProvider extends RefactoringSupportProvider { return new ExtractKotlinFunctionHandler(); } + @NotNull + public RefactoringActionHandler getExtractFunctionToScopeHandler() { + return new ExtractKotlinFunctionHandler(true); + } + @Override public boolean isInplaceRenameAvailable(@NotNull PsiElement element, PsiElement context) { if (element instanceof JetProperty) { diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/ExtractFunctionToScopeAction.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/ExtractFunctionToScopeAction.kt new file mode 100644 index 00000000000..0af10c1561e --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/ExtractFunctionToScopeAction.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2014 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.jet.plugin.refactoring.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.jet.lang.psi.JetElement +import org.jetbrains.jet.plugin.refactoring.JetRefactoringSupportProvider + +public class ExtractFunctionToScopeAction: BasePlatformRefactoringAction() { + { + setInjectedContext(true) + } + + override fun isAvailableInEditorOnly(): Boolean { + return true + } + + protected override fun isEnabledOnElements(elements: Array): Boolean { + return elements.all { it is JetElement } + } + + override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? { + return (provider as? JetRefactoringSupportProvider)?.getExtractFunctionToScopeHandler() + } +}