diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 1cf7a0dca24..f7cdbe3c99b 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -100,7 +100,7 @@
-
diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt
index ad0b2fe7671..400858db376 100644
--- a/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt
@@ -32,7 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileVisitor
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
-import org.jetbrains.kotlin.idea.core.refactoring.toPsiFile
+import org.jetbrains.kotlin.idea.refactoring.toPsiFile
import org.jetbrains.kotlin.idea.j2k.IdeaJavaToKotlinServices
import org.jetbrains.kotlin.idea.j2k.J2kPostProcessor
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateActionBase.kt b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateActionBase.kt
index 258f302d904..886ee6b0148 100644
--- a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateActionBase.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateActionBase.kt
@@ -24,7 +24,7 @@ import com.intellij.openapi.actionSystem.Presentation
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt
index e14bb317684..ef8ef1e2560 100644
--- a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.idea.core.CollectingNameValidator
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.core.overrideImplement.OverrideMemberChooserObject
import org.jetbrains.kotlin.idea.core.overrideImplement.generateMember
-import org.jetbrains.kotlin.idea.core.refactoring.quoteIfNeeded
+import org.jetbrains.kotlin.idea.refactoring.quoteIfNeeded
import org.jetbrains.kotlin.idea.quickfix.insertMembersAfter
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.util.application.runWriteAction
diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateTestSupportActionBase.kt b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateTestSupportActionBase.kt
index d952a68b1c3..77e25b5b119 100644
--- a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateTestSupportActionBase.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateTestSupportActionBase.kt
@@ -45,7 +45,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.core.overrideImplement.OverrideMemberChooserObject.BodyType
import org.jetbrains.kotlin.idea.core.overrideImplement.generateUnsupportedOrSuperCall
-import org.jetbrains.kotlin.idea.core.refactoring.j2k
+import org.jetbrains.kotlin.idea.refactoring.j2k
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.setupEditorSelection
import org.jetbrains.kotlin.idea.quickfix.insertMember
import org.jetbrains.kotlin.idea.testIntegration.findSuitableFrameworks
diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/AbstractKotlinUpDownMover.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/AbstractKotlinUpDownMover.java
index 2ba1498717a..9dcbed3f0d8 100644
--- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/AbstractKotlinUpDownMover.java
+++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/AbstractKotlinUpDownMover.java
@@ -28,7 +28,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.kotlin.idea.core.refactoring.JetRefactoringUtilKt;
+import org.jetbrains.kotlin.idea.refactoring.JetRefactoringUtilKt;
import org.jetbrains.kotlin.psi.KtBlockExpression;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.psi.KtFunctionLiteral;
diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinExpressionMover.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinExpressionMover.java
index 7828d76c4a3..e93bc4cdfac 100644
--- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinExpressionMover.java
+++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/upDownMover/KotlinExpressionMover.java
@@ -27,7 +27,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.kotlin.idea.core.refactoring.JetRefactoringUtilKt;
+import org.jetbrains.kotlin.idea.refactoring.JetRefactoringUtilKt;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt
index a3570ff90e5..4ba2ef31e1b 100644
--- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt
@@ -34,8 +34,8 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
-import org.jetbrains.kotlin.idea.core.refactoring.getLineEndOffset
-import org.jetbrains.kotlin.idea.core.refactoring.getLineStartOffset
+import org.jetbrains.kotlin.idea.refactoring.getLineEndOffset
+import org.jetbrains.kotlin.idea.refactoring.getLineStartOffset
import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt
index 96d7073c81a..5bd060385c3 100644
--- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt
@@ -53,7 +53,7 @@ import org.jetbrains.kotlin.fileClasses.internalNameWithoutInnerClasses
import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
-import org.jetbrains.kotlin.idea.core.refactoring.getLineStartOffset
+import org.jetbrains.kotlin.idea.refactoring.getLineStartOffset
import org.jetbrains.kotlin.idea.debugger.breakpoints.getLambdasAtLineIfAny
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinCodeFragmentFactory
import org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile
diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/breakpointTypeUtils.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/breakpointTypeUtils.kt
index 713fe706734..4427d4a08a0 100644
--- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/breakpointTypeUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/breakpointTypeUtils.kt
@@ -31,9 +31,9 @@ import com.intellij.xdebugger.XSourcePosition
import com.intellij.xdebugger.impl.XSourcePositionImpl
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
-import org.jetbrains.kotlin.idea.core.refactoring.getLineEndOffset
-import org.jetbrains.kotlin.idea.core.refactoring.getLineNumber
-import org.jetbrains.kotlin.idea.core.refactoring.getLineStartOffset
+import org.jetbrains.kotlin.idea.refactoring.getLineEndOffset
+import org.jetbrains.kotlin.idea.refactoring.getLineNumber
+import org.jetbrains.kotlin.idea.refactoring.getLineStartOffset
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.psi.psiUtil.startOffset
diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt
index 0736aba9d0c..2ac918fcc7a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt
@@ -40,8 +40,8 @@ import org.jetbrains.eval4j.jdi.asValue
import org.jetbrains.kotlin.asJava.KtLightClass
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
-import org.jetbrains.kotlin.idea.core.refactoring.j2kText
-import org.jetbrains.kotlin.idea.core.refactoring.quoteIfNeeded
+import org.jetbrains.kotlin.idea.refactoring.j2kText
+import org.jetbrains.kotlin.idea.refactoring.quoteIfNeeded
import org.jetbrains.kotlin.idea.debugger.KotlinEditorTextProvider
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.name.Name
diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt
index cd2ead79e3e..91a9b7fd304 100644
--- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt
@@ -56,7 +56,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheService
import org.jetbrains.kotlin.idea.caches.resolve.getJavaClassDescriptor
-import org.jetbrains.kotlin.idea.core.refactoring.quoteIfNeeded
+import org.jetbrains.kotlin.idea.refactoring.quoteIfNeeded
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinEvaluateExpressionCache.CompiledDataDescriptor
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinEvaluateExpressionCache.ParametersDescriptor
import org.jetbrains.kotlin.idea.debugger.evaluate.compilingEvaluator.loadClasses
diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaMethodFilter.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaMethodFilter.kt
index ccd166f261d..d37c3b8dda6 100644
--- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaMethodFilter.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaMethodFilter.kt
@@ -21,7 +21,7 @@ import com.intellij.debugger.engine.BreakpointStepMethodFilter
import com.intellij.debugger.engine.DebugProcessImpl
import com.intellij.util.Range
import com.sun.jdi.Location
-import org.jetbrains.kotlin.idea.core.refactoring.isMultiLine
+import org.jetbrains.kotlin.idea.refactoring.isMultiLine
import org.jetbrains.kotlin.idea.debugger.isInsideInlineArgument
import org.jetbrains.kotlin.psi.KtBlockExpression
import org.jetbrains.kotlin.psi.KtFunction
diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt
index e0b87b89ff3..d376cf930af 100644
--- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt
@@ -32,9 +32,9 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
-import org.jetbrains.kotlin.idea.core.refactoring.getLineEndOffset
-import org.jetbrains.kotlin.idea.core.refactoring.getLineNumber
-import org.jetbrains.kotlin.idea.core.refactoring.getLineStartOffset
+import org.jetbrains.kotlin.idea.refactoring.getLineEndOffset
+import org.jetbrains.kotlin.idea.refactoring.getLineNumber
+import org.jetbrains.kotlin.idea.refactoring.getLineStartOffset
import org.jetbrains.kotlin.idea.util.DebuggerUtils
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.endOffset
diff --git a/idea/src/org/jetbrains/kotlin/idea/filters/KotlinExceptionFilter.kt b/idea/src/org/jetbrains/kotlin/idea/filters/KotlinExceptionFilter.kt
index 04868eda59f..4bd2c1f7abe 100644
--- a/idea/src/org/jetbrains/kotlin/idea/filters/KotlinExceptionFilter.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/filters/KotlinExceptionFilter.kt
@@ -28,8 +28,8 @@ import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.codegen.inline.FileMapping
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil
import org.jetbrains.kotlin.codegen.inline.SMAPParser
-import org.jetbrains.kotlin.idea.core.refactoring.getLineCount
-import org.jetbrains.kotlin.idea.core.refactoring.toPsiFile
+import org.jetbrains.kotlin.idea.refactoring.getLineCount
+import org.jetbrains.kotlin.idea.refactoring.toPsiFile
import org.jetbrains.kotlin.idea.util.DebuggerUtils
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder
diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/InfixCallFix.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/InfixCallFix.kt
index eb216b9863c..47176431f8a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/inspections/InfixCallFix.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/inspections/InfixCallFix.kt
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters2
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.intentions.InfixCallToOrdinaryIntention
import org.jetbrains.kotlin.idea.quickfix.CleanupFix
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt
index c460d4f7f91..296c41fb3b2 100644
--- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt
@@ -31,8 +31,8 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively
-import org.jetbrains.kotlin.idea.core.refactoring.reportDeclarationConflict
+import org.jetbrains.kotlin.idea.refactoring.checkConflictsInteractively
+import org.jetbrains.kotlin.idea.refactoring.reportDeclarationConflict
import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring
import org.jetbrains.kotlin.idea.refactoring.getAffectedCallables
import org.jetbrains.kotlin.idea.refactoring.getContainingScope
diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt
index 95d857226cb..f6c622209aa 100644
--- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt
@@ -28,8 +28,8 @@ import org.jetbrains.kotlin.asJava.namedUnwrappedElement
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively
-import org.jetbrains.kotlin.idea.core.refactoring.reportDeclarationConflict
+import org.jetbrains.kotlin.idea.refactoring.checkConflictsInteractively
+import org.jetbrains.kotlin.idea.refactoring.reportDeclarationConflict
import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring
import org.jetbrains.kotlin.idea.refactoring.getAffectedCallables
import org.jetbrains.kotlin.idea.refactoring.getContainingScope
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt
index e3464e6b840..f1a45773714 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.lexer.KtTokens.ABSTRACT_KEYWORD
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeFunctionSignatureFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeFunctionSignatureFix.kt
index 71c03580b74..ec60860a601 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeFunctionSignatureFix.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeFunctionSignatureFix.kt
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.core.mapArgumentsToParameters
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeSignatureConfiguration
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescriptor
import org.jetbrains.kotlin.idea.refactoring.changeSignature.modify
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/InitializePropertyQuickFixFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/InitializePropertyQuickFixFactory.kt
index 5bfb8ddabc7..348032de67d 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/InitializePropertyQuickFixFactory.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/InitializePropertyQuickFixFactory.kt
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.idea.core.CollectingNameValidator
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.core.appendElement
import org.jetbrains.kotlin.idea.core.getOrCreateBody
-import org.jetbrains.kotlin.idea.core.refactoring.runRefactoringWithPostprocessing
+import org.jetbrains.kotlin.idea.refactoring.runRefactoringWithPostprocessing
import org.jetbrains.kotlin.idea.refactoring.changeSignature.*
import org.jetbrains.kotlin.idea.util.application.runWriteAction
import org.jetbrains.kotlin.psi.*
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeClassAnAnnotationClassFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeClassAnAnnotationClassFix.java
index d5443d00de8..a4bc700b7ac 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeClassAnAnnotationClassFix.java
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeClassAnAnnotationClassFix.java
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.diagnostics.Diagnostic;
import org.jetbrains.kotlin.idea.KotlinBundle;
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil;
-import org.jetbrains.kotlin.idea.core.refactoring.JetRefactoringUtilKt;
+import org.jetbrains.kotlin.idea.refactoring.JetRefactoringUtilKt;
import org.jetbrains.kotlin.idea.references.ReferenceUtilKt;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.*;
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeOverriddenMemberOpenFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeOverriddenMemberOpenFix.kt
index 84307da7d58..bd37883c19e 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeOverriddenMemberOpenFix.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeOverriddenMemberOpenFix.kt
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.*
import org.jetbrains.kotlin.descriptors.isOverridable
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.lexer.KtTokens.OPEN_KEYWORD
import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtDeclaration
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt
index 1cc0357a8c8..bd1ec1d7c2a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.core.isVisible
-import org.jetbrains.kotlin.idea.core.refactoring.createPrimaryConstructorParameterListIfAbsent
+import org.jetbrains.kotlin.idea.refactoring.createPrimaryConstructorParameterListIfAbsent
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.util.ShortenReferences
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt
index 44fe710962d..87b6bfa8bbe 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt
@@ -47,8 +47,8 @@ import org.jetbrains.kotlin.idea.caches.resolve.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
import org.jetbrains.kotlin.idea.core.CollectingNameValidator
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
-import org.jetbrains.kotlin.idea.core.refactoring.*
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.ClassKind
+import org.jetbrains.kotlin.idea.refactoring.*
import org.jetbrains.kotlin.idea.util.DialogWithEditor
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.util.ShortenReferences
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromCallActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromCallActionFactory.kt
index c032569c16b..222cec93896 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromCallActionFactory.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromCallActionFactory.kt
@@ -25,8 +25,8 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
-import org.jetbrains.kotlin.idea.core.refactoring.getExtractionContainers
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.getExtractionContainers
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.*
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt
index 2d5654e9393..aff72f161e7 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt
@@ -25,8 +25,8 @@ import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
-import org.jetbrains.kotlin.idea.core.refactoring.chooseContainerElementIfNecessary
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.chooseContainerElementIfNecessary
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.CreateFromUsageFixBase
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.*
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateConstructorFromDelegationCallActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateConstructorFromDelegationCallActionFactory.kt
index 3e31253241a..d66cb017a89 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateConstructorFromDelegationCallActionFactory.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateConstructorFromDelegationCallActionFactory.kt
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.CallableInfo
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.ParameterInfo
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.SecondaryConstructorInfo
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateConstructorFromSuperTypeCallActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateConstructorFromSuperTypeCallActionFactory.kt
index 81243bd7ac0..25648e173ab 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateConstructorFromSuperTypeCallActionFactory.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateConstructorFromSuperTypeCallActionFactory.kt
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.CallableInfo
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.ParameterInfo
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.SecondaryConstructorInfo
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateFunctionFromCallableReferenceActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateFunctionFromCallableReferenceActionFactory.kt
index 84c7780f689..eebb1ad1dbb 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateFunctionFromCallableReferenceActionFactory.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateFunctionFromCallableReferenceActionFactory.kt
@@ -20,8 +20,8 @@ import com.intellij.util.SmartList
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
-import org.jetbrains.kotlin.idea.core.refactoring.getExtractionContainers
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.*
+import org.jetbrains.kotlin.idea.refactoring.getExtractionContainers
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt
index d1290d78e07..384fdbe0c5e 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt
@@ -27,8 +27,8 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.PsiPackage
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
-import org.jetbrains.kotlin.idea.core.refactoring.getOrCreateKotlinFile
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.getOrCreateKotlinFile
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.CreateFromUsageFixBase
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.*
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.ClassKind.*
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/createClassUtils.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/createClassUtils.kt
index a8b317d566e..11d3e4380a2 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/createClassUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/createClassUtils.kt
@@ -25,7 +25,7 @@ import com.intellij.psi.PsiPackage
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.quickfix.DelegatingIntentionAction
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.containsStarProjections
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt
index 65353d18979..4b1340ec0d3 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.guessTypes
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinParameterInfo
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinTypeInfo
diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt
index 2fe79ffcb5c..2af6f222811 100644
--- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.CreateFromUsageFixBase
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.CallableBuilderConfiguration
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.CallablePlacement
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt
index e1ea4200abb..0021676b3cd 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt
@@ -27,7 +27,7 @@ import com.intellij.refactoring.RefactoringActionHandler
import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.lang.ElementsHandler
import com.intellij.refactoring.util.CommonRefactoringUtil
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
@@ -98,6 +98,6 @@ public abstract class AbstractPullPushMembersHandler(
is KtClassOrObject -> it
else -> null
} ?: return false
- }.size() == 1
+ }.size == 1
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt
index 333de673ff9..22470ea4480 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.psi.KtBlockExpression
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
@@ -50,9 +50,9 @@ public abstract class CallableRefactoring(
val project: Project,
val callableDescriptor: T,
val commandName: String) {
- private val LOG = Logger.getInstance(javaClass>())
+ private val LOG = Logger.getInstance(CallableRefactoring::class.java)
- private val kind = (callableDescriptor as? CallableMemberDescriptor)?.getKind() ?: CallableMemberDescriptor.Kind.DECLARATION
+ private val kind = (callableDescriptor as? CallableMemberDescriptor)?.kind ?: CallableMemberDescriptor.Kind.DECLARATION
protected open fun forcePerformForSelectedFunctionOnly(): Boolean {
return false
@@ -67,7 +67,7 @@ public abstract class CallableRefactoring(
OverrideResolver.getDirectlyOverriddenDeclarations(callableDescriptor as CallableMemberDescriptor)
}
else -> {
- throw IllegalStateException("Unexpected callable kind: ${kind}")
+ throw IllegalStateException("Unexpected callable kind: $kind")
}
}
}
@@ -76,11 +76,11 @@ public abstract class CallableRefactoring(
callableFromEditor: CallableDescriptor,
options: List): Int {
val superString = superCallables.map {
- it.getContainingDeclaration().getName().asString()
+ it.containingDeclaration.name.asString()
}.joinToString(prefix = "\n ", separator = ",\n ", postfix = ".\n\n")
val message = KotlinBundle.message("x.overrides.y.in.class.list",
DescriptorRenderer.COMPACT.render(callableFromEditor),
- callableFromEditor.getContainingDeclaration().getName().asString(), superString,
+ callableFromEditor.containingDeclaration.name.asString(), superString,
"refactor")
val title = IdeBundle.message("title.warning")!!
val icon = Messages.getQuestionIcon()
@@ -92,14 +92,14 @@ public abstract class CallableRefactoring(
return true
}
- val unmodifiableFile = element.getContainingFile()?.getVirtualFile()?.getPresentableUrl()
+ val unmodifiableFile = element.containingFile?.virtualFile?.presentableUrl
if (unmodifiableFile != null) {
val message = RefactoringBundle.message("refactoring.cannot.be.performed") + "\n" +
IdeBundle.message("error.message.cannot.modify.file.0", unmodifiableFile)
Messages.showErrorDialog(project, message, CommonBundle.getErrorTitle()!!)
}
else {
- LOG.error("Could not find file for Psi element: " + element.getText())
+ LOG.error("Could not find file for Psi element: " + element.text)
}
return false
@@ -144,17 +144,17 @@ public abstract class CallableRefactoring(
val deepestSuperDeclarations =
(callableDescriptor as? CallableMemberDescriptor)?.let { OverrideResolver.getDeepestSuperDeclarations(it) }
?: Collections.singletonList(callableDescriptor)
- if (ApplicationManager.getApplication()!!.isUnitTestMode()) {
+ if (ApplicationManager.getApplication()!!.isUnitTestMode) {
performRefactoring(deepestSuperDeclarations)
return true
}
- if (closestModifiableDescriptors.size() == 1 && deepestSuperDeclarations.subtract(closestModifiableDescriptors).isEmpty()) {
+ if (closestModifiableDescriptors.size == 1 && deepestSuperDeclarations.subtract(closestModifiableDescriptors).isEmpty()) {
performRefactoring(closestModifiableDescriptors)
return true
}
- val isSingleFunctionSelected = closestModifiableDescriptors.size() == 1
+ val isSingleFunctionSelected = closestModifiableDescriptors.size == 1
val selectedFunction = if (isSingleFunctionSelected) closestModifiableDescriptors.first() else callableDescriptor
val optionsForDialog = buildDialogOptions(isSingleFunctionSelected)
val code = showSuperFunctionWarningDialog(deepestSuperDeclarations, selectedFunction, optionsForDialog)
@@ -184,16 +184,16 @@ fun getAffectedCallables(project: Project, descriptorsForChange: Collection containingDescriptor.getScopeForInitializerResolution()
+ is ClassDescriptorWithResolutionScopes -> containingDescriptor.scopeForInitializerResolution
is PackageFragmentDescriptor -> LexicalScope.empty(containingDescriptor.getMemberScope().memberScopeAsImportingScope(), this)
else -> null
}
@@ -201,6 +201,6 @@ fun DeclarationDescriptor.getContainingScope(): LexicalScope? {
}
fun KtDeclarationWithBody.getBodyScope(bindingContext: BindingContext): LexicalScope? {
- val expression = getBodyExpression()?.getChildren()?.firstOrNull { it is KtExpression } ?: return null
+ val expression = bodyExpression?.children?.firstOrNull { it is KtExpression } ?: return null
return expression.getResolutionScope(bindingContext, getResolutionFacade())
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidator.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidator.kt
index 119e4022afe..32ecb871174 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidator.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidator.kt
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.lexer.KtKeywordToken
import org.jetbrains.kotlin.lexer.KtTokens
public class KotlinNamesValidator : NamesValidator {
- private val KEYWORD_SET = KtTokens.KEYWORDS.getTypes().filterIsInstance().map { it.getValue() }.toSet()
+ private val KEYWORD_SET = KtTokens.KEYWORDS.types.filterIsInstance().map { it.value }.toSet()
override fun isKeyword(name: String, project: Project?): Boolean = name in KEYWORD_SET
override fun isIdentifier(name: String, project: Project?): Boolean = KotlinNameSuggester.isIdentifier(name)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSupportProvider.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSupportProvider.kt
index 58a411d8f73..89505e7d49c 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSupportProvider.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSupportProvider.kt
@@ -52,19 +52,19 @@ public class KotlinRefactoringSupportProvider : RefactoringSupportProvider() {
override fun isInplaceRenameAvailable(element: PsiElement, context: PsiElement?): Boolean {
when (element) {
is KtProperty -> {
- if (element.isLocal()) return true
+ if (element.isLocal) return true
}
is KtDestructuringDeclarationEntry -> return true
is KtFunction -> {
- if (element.isLocal() && element.nameIdentifier != null) return true
+ if (element.isLocal && element.nameIdentifier != null) return true
}
is KtParameter -> {
- val parent = element.getParent()
+ val parent = element.parent
if (parent is KtForExpression) {
return true
}
if (parent is KtParameterList) {
- val grandparent = parent.getParent()
+ val grandparent = parent.parent
return grandparent is KtCatchClause || grandparent is KtFunctionLiteral
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt
index 4def008a391..e257e13e359 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt
@@ -25,4 +25,4 @@ public class KotlinAwareJavaParameterInfoImpl(
name: String,
type: PsiType,
val kotlinDefaultValue: KtExpression?
-): ParameterInfoImpl(oldParameterIndex, name, type, kotlinDefaultValue?.getText() ?: "")
\ No newline at end of file
+): ParameterInfoImpl(oldParameterIndex, name, type, kotlinDefaultValue?.text ?: "")
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt
index 1cf39f7d2ff..f59c4cdc07d 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor
-import org.jetbrains.kotlin.idea.core.refactoring.j2k
+import org.jetbrains.kotlin.idea.refactoring.j2k
import org.jetbrains.kotlin.idea.project.ProjectStructureUtil
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescriptor.Kind
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallableDefinitionUsage
@@ -55,10 +55,10 @@ import java.util.*
public open class KotlinChangeInfo(
val methodDescriptor: KotlinMethodDescriptor,
- private var name: String = methodDescriptor.getName(),
+ private var name: String = methodDescriptor.name,
var newReturnTypeInfo: KotlinTypeInfo = KotlinTypeInfo(true, methodDescriptor.baseDescriptor.returnType),
- var newVisibility: Visibility = methodDescriptor.getVisibility(),
- parameterInfos: List = methodDescriptor.getParameters(),
+ var newVisibility: Visibility = methodDescriptor.visibility,
+ parameterInfos: List = methodDescriptor.parameters,
receiver: KotlinParameterInfo? = methodDescriptor.receiver,
val context: PsiElement,
primaryPropagationTargets: Collection = emptyList()
@@ -93,8 +93,8 @@ public open class KotlinChangeInfo(
private val oldNameToParameterIndex: Map by lazy {
val map = HashMap()
- val parameters = methodDescriptor.baseDescriptor.getValueParameters()
- parameters.indices.forEach { i -> map[parameters.get(i).getName().asString()] = i }
+ val parameters = methodDescriptor.baseDescriptor.valueParameters
+ parameters.indices.forEach { i -> map[parameters[i].name.asString()] = i }
map
}
@@ -102,8 +102,8 @@ public open class KotlinChangeInfo(
private val isParameterSetOrOrderChangedLazy: Boolean by lazy {
val signatureParameters = getNonReceiverParameters()
methodDescriptor.receiver != receiverParameterInfo ||
- signatureParameters.size() != methodDescriptor.getParametersCount() ||
- signatureParameters.indices.any { i -> signatureParameters[i].getOldIndex() != i }
+ signatureParameters.size != methodDescriptor.parametersCount ||
+ signatureParameters.indices.any { i -> signatureParameters[i].oldIndex != i }
}
private var isPrimaryMethodUpdated: Boolean = false
@@ -119,21 +119,11 @@ public open class KotlinChangeInfo(
override fun isParameterSetOrOrderChanged(): Boolean = isParameterSetOrOrderChangedLazy
- public fun getNewParametersCount(): Int = newParameters.size()
+ public fun getNewParametersCount(): Int = newParameters.size
override fun getNewParameters(): Array = newParameters.toTypedArray()
- fun getToBeRemoved(): BooleanArray {
- return BooleanArray(originalParameters.size).apply {
- Arrays.fill(this, true)
- for (newParameter in newParameters) {
- if (newParameter.oldIndex < 0) continue
- this[newParameter.oldIndex] = false
- }
- }
- }
-
- fun getNonReceiverParametersCount(): Int = newParameters.size() - (if (receiverParameterInfo != null) 1 else 0)
+ fun getNonReceiverParametersCount(): Int = newParameters.size - (if (receiverParameterInfo != null) 1 else 0)
fun getNonReceiverParameters(): List {
methodDescriptor.baseDeclaration.let { if (it is KtProperty || it is KtParameter) return emptyList() }
@@ -141,7 +131,7 @@ public open class KotlinChangeInfo(
}
public fun setNewParameter(index: Int, parameterInfo: KotlinParameterInfo) {
- newParameters.set(index, parameterInfo)
+ newParameters[index] = parameterInfo
}
@JvmOverloads
@@ -155,7 +145,7 @@ public open class KotlinChangeInfo(
}
public fun removeParameter(index: Int) {
- val parameterInfo = newParameters.remove(index);
+ val parameterInfo = newParameters.removeAt(index);
if (parameterInfo == receiverParameterInfo) {
receiverParameterInfo = null
}
@@ -177,12 +167,12 @@ public open class KotlinChangeInfo(
name = value
}
- override fun isNameChanged(): Boolean = name != methodDescriptor.getName()
+ override fun isNameChanged(): Boolean = name != methodDescriptor.name
- public fun isVisibilityChanged(): Boolean = newVisibility != methodDescriptor.getVisibility()
+ public fun isVisibilityChanged(): Boolean = newVisibility != methodDescriptor.visibility
override fun getMethod(): PsiElement {
- return methodDescriptor.getMethod()
+ return methodDescriptor.method
}
override fun isReturnTypeChanged(): Boolean = !newReturnTypeInfo.isEquivalentTo(originalReturnTypeInfo)
@@ -281,7 +271,7 @@ public open class KotlinChangeInfo(
public fun isRefactoringTarget(inheritedCallableDescriptor: CallableDescriptor?): Boolean {
return inheritedCallableDescriptor != null
- && getMethod() == DescriptorToSourceUtils.descriptorToDeclaration(inheritedCallableDescriptor)
+ && method == DescriptorToSourceUtils.descriptorToDeclaration(inheritedCallableDescriptor)
}
public fun getNewParametersSignature(inheritedCallable: KotlinCallableDefinitionUsage<*>): String {
@@ -294,8 +284,8 @@ public open class KotlinChangeInfo(
val signatureParameters = getNonReceiverParameters()
val isLambda = inheritedCallable.declaration is KtFunctionLiteral
- if (isLambda && signatureParameters.size() == 1 && !signatureParameters.get(0).requiresExplicitType(inheritedCallable)) {
- return signatureParameters.get(0).getDeclarationSignature(0, inheritedCallable)
+ if (isLambda && signatureParameters.size == 1 && !signatureParameters[0].requiresExplicitType(inheritedCallable)) {
+ return signatureParameters[0].getDeclarationSignature(0, inheritedCallable)
}
return signatureParameters.indices
@@ -391,14 +381,14 @@ public open class KotlinChangeInfo(
newParameters: Array
): JavaChangeInfo? {
val newVisibility = if (isPrimaryMethodUpdated)
- VisibilityUtil.getVisibilityModifier(currentPsiMethod.getModifierList())
+ VisibilityUtil.getVisibilityModifier(currentPsiMethod.modifierList)
else
PsiModifier.PACKAGE_LOCAL
val propagationTargets = primaryPropagationTargets.asSequence()
.mapNotNull { it.getRepresentativeLightMethod() }
.toSet()
val javaChangeInfo = ChangeSignatureProcessor(
- getMethod().getProject(),
+ method.project,
originalPsiMethod,
false,
newVisibility,
@@ -408,7 +398,7 @@ public open class KotlinChangeInfo(
arrayOf(),
propagationTargets,
emptySet()
- ).getChangeInfo()
+ ).changeInfo
javaChangeInfo.updateMethod(currentPsiMethod)
return javaChangeInfo
@@ -449,12 +439,12 @@ public open class KotlinChangeInfo(
if (javaOldIndex >= oldParameterCount) return@map null
val type = if (isPrimaryMethodUpdated)
- currentPsiMethod.getParameterList().getParameters()[indexInCurrentPsiMethod++].getType()
+ currentPsiMethod.parameterList.parameters[indexInCurrentPsiMethod++].type
else
PsiType.VOID
val defaultValue = info.defaultValueForCall ?: info.defaultValueForParameter
- ParameterInfoImpl(javaOldIndex, info.getName(), type, defaultValue?.getText() ?: "")
+ ParameterInfoImpl(javaOldIndex, info.name, type, defaultValue?.text ?: "")
}
}
@@ -465,8 +455,8 @@ public open class KotlinChangeInfo(
): JavaChangeInfo? {
val newParameterList = receiverParameterInfo.singletonOrEmptyList() + getNonReceiverParameters()
val newJavaParameters = getJavaParameterInfos(originalPsiMethod, currentPsiMethod, newParameterList).toTypedArray()
- val newName = if (isGetter) JvmAbi.getterName(getNewName()) else getNewName()
- return createJavaChangeInfo(originalPsiMethod, currentPsiMethod, newName, currentPsiMethod.getReturnType(), newJavaParameters)
+ val newName = if (isGetter) JvmAbi.getterName(newName) else newName
+ return createJavaChangeInfo(originalPsiMethod, currentPsiMethod, newName, currentPsiMethod.returnType, newJavaParameters)
}
fun createJavaChangeInfoForSetter(originalPsiMethod: PsiMethod, currentPsiMethod: PsiMethod): JavaChangeInfo? {
@@ -474,21 +464,21 @@ public open class KotlinChangeInfo(
val oldIndex = if (methodDescriptor.receiver != null) 1 else 0
if (isPrimaryMethodUpdated) {
val newIndex = if (receiverParameterInfo != null) 1 else 0
- val setterParameter = currentPsiMethod.getParameterList().getParameters()[newIndex]
- newJavaParameters.add(ParameterInfoImpl(oldIndex, setterParameter.getName(), setterParameter.getType()))
+ val setterParameter = currentPsiMethod.parameterList.parameters[newIndex]
+ newJavaParameters.add(ParameterInfoImpl(oldIndex, setterParameter.name, setterParameter.type))
}
else {
newJavaParameters.add(ParameterInfoImpl(oldIndex, "receiver", PsiType.VOID))
}
- val newName = JvmAbi.setterName(getNewName())
+ val newName = JvmAbi.setterName(newName)
return createJavaChangeInfo(originalPsiMethod, currentPsiMethod, newName, PsiType.VOID, newJavaParameters.toTypedArray())
}
- if (ProjectStructureUtil.isJsKotlinModule(getMethod().getContainingFile() as KtFile)) return null
+ if (ProjectStructureUtil.isJsKotlinModule(method.containingFile as KtFile)) return null
if (javaChangeInfos == null) {
- val method = getMethod()
+ val method = method
originalToCurrentMethods = matchOriginalAndCurrentMethods(method.toLightMethods())
javaChangeInfos = originalToCurrentMethods.entries.mapNotNull {
val (originalPsiMethod, currentPsiMethod) = it
@@ -497,7 +487,7 @@ public open class KotlinChangeInfo(
is KtFunction, is KtClassOrObject ->
createJavaChangeInfoForFunctionOrGetter(originalPsiMethod, currentPsiMethod, false)
is KtProperty, is KtParameter -> {
- val accessorName = originalPsiMethod.getName()
+ val accessorName = originalPsiMethod.name
when {
JvmAbi.isGetterName(accessorName) ->
createJavaChangeInfoForFunctionOrGetter(originalPsiMethod, currentPsiMethod, true)
@@ -521,40 +511,40 @@ public val KotlinChangeInfo.originalBaseFunctionDescriptor: CallableDescriptor
public val KotlinChangeInfo.kind: Kind get() = methodDescriptor.kind
public val KotlinChangeInfo.oldName: String?
- get() = (methodDescriptor.getMethod() as? KtFunction)?.getName()
+ get() = (methodDescriptor.method as? KtFunction)?.name
public fun KotlinChangeInfo.getAffectedCallables(): Collection = methodDescriptor.affectedCallables + propagationTargetUsageInfos
public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: KotlinMethodDescriptor): KotlinChangeInfo {
- val method = getMethod() as PsiMethod
+ val method = method as PsiMethod
val functionDescriptor = method.getJavaMethodDescriptor()!!
- val parameterDescriptors = functionDescriptor.getValueParameters()
+ val parameterDescriptors = functionDescriptor.valueParameters
//noinspection ConstantConditions
- val originalParameterDescriptors = originalChangeSignatureDescriptor.baseDescriptor.getValueParameters()
+ val originalParameterDescriptors = originalChangeSignatureDescriptor.baseDescriptor.valueParameters
- val newParameters = getNewParameters().withIndex().map { pair ->
+ val newParameters = newParameters.withIndex().map { pair ->
val (i, info) = pair
- val oldIndex = info.getOldIndex()
- val currentType = parameterDescriptors[i].getType()
+ val oldIndex = info.oldIndex
+ val currentType = parameterDescriptors[i].type
- val defaultValueText = info.getDefaultValue()
+ val defaultValueText = info.defaultValue
val defaultValueExpr =
when {
info is KotlinAwareJavaParameterInfoImpl -> info.kotlinDefaultValue
- getLanguage().`is`(JavaLanguage.INSTANCE) && !defaultValueText.isNullOrEmpty() -> {
- PsiElementFactory.SERVICE.getInstance(method.getProject())
+ language.`is`(JavaLanguage.INSTANCE) && !defaultValueText.isNullOrEmpty() -> {
+ PsiElementFactory.SERVICE.getInstance(method.project)
.createExpressionFromText(defaultValueText!!, null)
.j2k()
}
else -> null
}
- val parameterType = if (oldIndex >= 0) originalParameterDescriptors[oldIndex].getType() else currentType
+ val parameterType = if (oldIndex >= 0) originalParameterDescriptors[oldIndex].type else currentType
KotlinParameterInfo(callableDescriptor = functionDescriptor,
originalIndex = oldIndex,
- name = info.getName(),
+ name = info.name,
originalTypeInfo = KotlinTypeInfo(false, parameterType),
defaultValueForCall = defaultValueExpr).apply {
currentTypeInfo = KotlinTypeInfo(false, currentType)
@@ -562,9 +552,9 @@ public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: KotlinM
}
return KotlinChangeInfo(originalChangeSignatureDescriptor,
- getNewName(),
+ newName,
KotlinTypeInfo(true, functionDescriptor.returnType),
- functionDescriptor.getVisibility(),
+ functionDescriptor.visibility,
newParameters,
null,
method)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt
index ecb68ff25fb..3fc319b2958 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt
@@ -38,13 +38,13 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.createJavaMethod
-import org.jetbrains.kotlin.idea.core.refactoring.toPsiFile
+import org.jetbrains.kotlin.idea.refactoring.createJavaMethod
+import org.jetbrains.kotlin.idea.refactoring.toPsiFile
import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring
+import org.jetbrains.kotlin.idea.refactoring.changeSignature.ui.KotlinChangePropertySignatureDialog
import org.jetbrains.kotlin.idea.refactoring.changeSignature.ui.KotlinChangeSignatureDialog
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
-import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.OverrideResolver
public interface KotlinChangeSignatureConfiguration {
@@ -77,7 +77,7 @@ public class KotlinChangeSignature(project: Project,
callableDescriptor,
commandName ?: ChangeSignatureHandler.REFACTORING_NAME) {
- private val LOG = Logger.getInstance(javaClass())
+ private val LOG = Logger.getInstance(KotlinChangeSignature::class.java)
override fun forcePerformForSelectedFunctionOnly() = configuration.forcePerformForSelectedFunctionOnly()
@@ -91,8 +91,8 @@ public class KotlinChangeSignature(project: Project,
KotlinChangePropertySignatureDialog.createProcessorForSilentRefactoring(project, commandName, descriptor)
}
is PsiMethod -> {
- if (baseDeclaration.getLanguage() != JavaLanguage.INSTANCE) {
- Messages.showErrorDialog("Can't change signature of ${baseDeclaration.getLanguage().getDisplayName()} method", commandName)
+ if (baseDeclaration.language != JavaLanguage.INSTANCE) {
+ Messages.showErrorDialog("Can't change signature of ${baseDeclaration.language.displayName} method", commandName)
return
}
@@ -115,8 +115,8 @@ public class KotlinChangeSignature(project: Project,
return
}
- if (baseDeclaration.getLanguage() != JavaLanguage.INSTANCE) {
- Messages.showErrorDialog("Can't change signature of ${baseDeclaration.getLanguage().getDisplayName()} method", commandName)
+ if (baseDeclaration.language != JavaLanguage.INSTANCE) {
+ Messages.showErrorDialog("Can't change signature of ${baseDeclaration.language.displayName} method", commandName)
return
}
@@ -124,7 +124,7 @@ public class KotlinChangeSignature(project: Project,
object: JavaChangeSignatureDialog(project, JavaMethodDescriptor(preview), false, null) {
override fun createRefactoringProcessor(): BaseRefactoringProcessor? {
val processor = super.createRefactoringProcessor()
- (processor as? ChangeSignatureProcessor)?.getChangeInfo()?.updateMethod(javaChangeInfo.getMethod())
+ (processor as? ChangeSignatureProcessor)?.changeInfo?.updateMethod(javaChangeInfo.method)
return processor
}
}
@@ -137,18 +137,18 @@ public class KotlinChangeSignature(project: Project,
private fun getPreviewInfoForJavaMethod(descriptor: KotlinMethodDescriptor): Pair {
val originalMethod = descriptor.baseDeclaration as PsiMethod
- val contextFile = defaultValueContext.getContainingFile() as KtFile
+ val contextFile = defaultValueContext.containingFile as KtFile
// Generate new Java method signature from the Kotlin point of view
val ktChangeInfo = KotlinChangeInfo(methodDescriptor = descriptor, context = defaultValueContext)
val ktSignature = ktChangeInfo.getNewSignature(descriptor.originalPrimaryCallable)
val dummyFileText = with(StringBuilder()) {
- contextFile.getPackageDirective()?.let { append(it.getText()).append("\n") }
+ contextFile.packageDirective?.let { append(it.text).append("\n") }
append("class Dummy {\n").append(ktSignature).append("{}\n}")
toString()
}
val dummyFile = LightVirtualFile("dummy.kt", KotlinFileType.INSTANCE, dummyFileText).toPsiFile(project) as KtFile
- val dummyDeclaration = (dummyFile.getDeclarations().first() as KtClass).getBody()!!.getDeclarations().first()
+ val dummyDeclaration = (dummyFile.declarations.first() as KtClass).getBody()!!.declarations.first()
// Convert to PsiMethod which can be used in Change Signature dialog
val containingClass = PsiElementFactory.SERVICE.getInstance(project).createClass("Dummy")
@@ -156,17 +156,17 @@ public class KotlinChangeSignature(project: Project,
// Create JavaChangeInfo based on new signature
// TODO: Support visibility change
- val visibility = VisibilityUtil.getVisibilityModifier(originalMethod.getModifierList())
- val returnType = CanonicalTypes.createTypeWrapper(preview.getReturnType() ?: PsiType.VOID)
- val params = (preview.getParameterList().getParameters().zip(ktChangeInfo.getNewParameters())).map {
+ val visibility = VisibilityUtil.getVisibilityModifier(originalMethod.modifierList)
+ val returnType = CanonicalTypes.createTypeWrapper(preview.returnType ?: PsiType.VOID)
+ val params = (preview.parameterList.parameters.zip(ktChangeInfo.newParameters)).map {
val (param, paramInfo) = it
// Keep original default value for proper update of Kotlin usages
- KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName()!!, param.getType(), paramInfo.defaultValueForCall)
+ KotlinAwareJavaParameterInfoImpl(paramInfo.oldIndex, param.name!!, param.type, paramInfo.defaultValueForCall)
}.toTypedArray()
return preview to JavaChangeInfoImpl(visibility,
originalMethod,
- preview.getName(),
+ preview.name,
returnType,
params,
arrayOf(),
@@ -178,10 +178,10 @@ public class KotlinChangeSignature(project: Project,
override fun performRefactoring(descriptorsForChange: Collection) {
val adjustedDescriptor = adjustDescriptor(descriptorsForChange) ?: return
- val affectedFunctions = adjustedDescriptor.affectedCallables.mapNotNull { it.getElement() }
+ val affectedFunctions = adjustedDescriptor.affectedCallables.mapNotNull { it.element }
if (affectedFunctions.any { !checkModifiable(it) }) return
- if (configuration.performSilently(affectedFunctions) || ApplicationManager.getApplication()!!.isUnitTestMode()) {
+ if (configuration.performSilently(affectedFunctions) || ApplicationManager.getApplication()!!.isUnitTestMode) {
runSilentRefactoring(adjustedDescriptor)
}
else {
@@ -207,8 +207,8 @@ public class KotlinChangeSignature(project: Project,
private fun preferContainedInClass(descriptorsForSignatureChange: Collection): CallableDescriptor {
for (descriptor in descriptorsForSignatureChange) {
- val containingDeclaration = descriptor.getContainingDeclaration()
- if (containingDeclaration is ClassDescriptor && containingDeclaration.getKind() != ClassKind.INTERFACE) {
+ val containingDeclaration = descriptor.containingDeclaration
+ if (containingDeclaration is ClassDescriptor && containingDeclaration.kind != ClassKind.INTERFACE) {
return descriptor
}
}
@@ -237,5 +237,5 @@ public fun createChangeInfo(
adjustedDescriptor,
defaultValueContext
) as KotlinChangeSignatureProcessor
- return processor.getChangeInfo()
+ return processor.changeInfo
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureData.kt
index 991aef38e46..9cdcda34bc5 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureData.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureData.kt
@@ -56,12 +56,12 @@ public class KotlinChangeSignatureData(
init {
receiver = createReceiverInfoIfNeeded()
- val valueParameters = when {
- baseDeclaration is KtFunction -> baseDeclaration.getValueParameters()
- baseDeclaration is KtClass -> baseDeclaration.getPrimaryConstructorParameters()
+ val valueParameters = when (baseDeclaration) {
+ is KtFunction -> baseDeclaration.valueParameters
+ is KtClass -> baseDeclaration.getPrimaryConstructorParameters()
else -> null
}
- parameters = baseDescriptor.getValueParameters()
+ parameters = baseDescriptor.valueParameters
.mapTo(receiver?.let{ arrayListOf(it) } ?: arrayListOf()) { parameterDescriptor ->
val jetParameter = valueParameters?.get(parameterDescriptor.index)
val parameterType = parameterDescriptor.type
@@ -70,11 +70,11 @@ public class KotlinChangeSignatureData(
KotlinParameterInfo(
callableDescriptor = baseDescriptor,
originalIndex = parameterDescriptor.index,
- name = parameterDescriptor.getName().asString(),
+ name = parameterDescriptor.name.asString(),
originalTypeInfo = KotlinTypeInfo(false, parameterType, parameterTypeText),
- defaultValueForParameter = jetParameter?.getDefaultValue(),
- valOrVar = jetParameter?.getValOrVarKeyword().toValVar(),
- modifierList = jetParameter?.getModifierList()
+ defaultValueForParameter = jetParameter?.defaultValue,
+ valOrVar = jetParameter?.valOrVarKeyword.toValVar(),
+ modifierList = jetParameter?.modifierList
)
}
}
@@ -88,7 +88,7 @@ public class KotlinChangeSignatureData(
bodyScope.findVariable(Name.identifier(it), NoLookupLocation.FROM_IDE) == null
}
} ?: CollectingNameValidator(paramNames)
- val receiverType = baseDescriptor.getExtensionReceiverParameter()?.getType() ?: return null
+ val receiverType = baseDescriptor.extensionReceiverParameter?.type ?: return null
val receiverName = KotlinNameSuggester.suggestNamesByType(receiverType, validator, "receiver").first()
val receiverTypeText = (baseDeclaration as? KtCallableDeclaration)?.receiverTypeReference?.text
?: IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(receiverType)
@@ -102,9 +102,9 @@ public class KotlinChangeSignatureData(
override val primaryCallables: Collection> by lazy {
descriptorsForSignatureChange.map {
- val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.getProject(), it)
+ val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.project, it)
assert(declaration != null) { "No declaration found for " + baseDescriptor }
- KotlinCallableDefinitionUsage(declaration!!, it, null, null)
+ KotlinCallableDefinitionUsage(declaration!!, it, null, null)
}
}
@@ -137,22 +137,22 @@ public class KotlinChangeSignatureData(
override fun getName(): String {
if (baseDescriptor is ConstructorDescriptor) {
- return baseDescriptor.getContainingDeclaration().getName().asString()
+ return baseDescriptor.containingDeclaration.name.asString()
}
else if (baseDescriptor is AnonymousFunctionDescriptor) {
return ""
}
else {
- return baseDescriptor.getName().asString()
+ return baseDescriptor.name.asString()
}
}
override fun getParametersCount(): Int {
- return baseDescriptor.getValueParameters().size()
+ return baseDescriptor.valueParameters.size
}
override fun getVisibility(): Visibility {
- return baseDescriptor.getVisibility()
+ return baseDescriptor.visibility
}
override fun getMethod(): PsiElement {
@@ -161,8 +161,8 @@ public class KotlinChangeSignatureData(
override fun canChangeVisibility(): Boolean {
if (DescriptorUtils.isLocal(baseDescriptor)) return false;
- val parent = baseDescriptor.getContainingDeclaration()
- return !(baseDescriptor is AnonymousFunctionDescriptor || parent is ClassDescriptor && parent.getKind() == ClassKind.INTERFACE)
+ val parent = baseDescriptor.containingDeclaration
+ return !(baseDescriptor is AnonymousFunctionDescriptor || parent is ClassDescriptor && parent.kind == ClassKind.INTERFACE)
}
override fun canChangeParameters(): Boolean {
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt
index 106704aad63..8a380e18c51 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt
@@ -48,24 +48,24 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
public class KotlinChangeSignatureHandler : ChangeSignatureHandler {
override fun findTargetMember(file: PsiFile, editor: Editor) =
- file.findElementAt(editor.getCaretModel().getOffset())?.let { findTargetMember(it) }
+ file.findElementAt(editor.caretModel.offset)?.let { findTargetMember(it) }
override fun findTargetMember(element: PsiElement) =
findTargetForRefactoring(element)
override fun invoke(project: Project, editor: Editor, file: PsiFile, dataContext: DataContext) {
- editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE)
+ editor.scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE)
val element = findTargetMember(file, editor) ?: CommonDataKeys.PSI_ELEMENT.getData(dataContext) ?: return
- val elementAtCaret = file.findElementAt(editor.getCaretModel().getOffset()) ?: return
- if (element !is KtElement) throw AssertionError("This handler must be invoked for Kotlin elements only: ${element.getText()}")
+ val elementAtCaret = file.findElementAt(editor.caretModel.offset) ?: return
+ if (element !is KtElement) throw AssertionError("This handler must be invoked for Kotlin elements only: ${element.text}")
invokeChangeSignature(element, elementAtCaret, project, editor)
}
override fun invoke(project: Project, elements: Array, dataContext: DataContext?) {
val element = elements.singleOrNull()?.unwrapped ?: return
- if (element !is KtElement) throw AssertionError("This handler must be invoked for Kotlin elements only: ${element.getText()}")
+ if (element !is KtElement) throw AssertionError("This handler must be invoked for Kotlin elements only: ${element.text}")
val editor = dataContext?.let { CommonDataKeys.EDITOR.getData(it) }
invokeChangeSignature(element, element, project, editor)
@@ -76,36 +76,36 @@ public class KotlinChangeSignatureHandler : ChangeSignatureHandler {
companion object {
public fun findTargetForRefactoring(element: PsiElement): PsiElement? {
- val elementParent = element.getParent()
+ val elementParent = element.parent
if ((elementParent is KtNamedFunction || elementParent is KtClass || elementParent is KtProperty)
- && (elementParent as KtNamedDeclaration).getNameIdentifier() === element) return elementParent
+ && (elementParent as KtNamedDeclaration).nameIdentifier === element) return elementParent
if (elementParent is KtParameter) {
- val primaryConstructor = PsiTreeUtil.getParentOfType(elementParent, javaClass())
+ val primaryConstructor = PsiTreeUtil.getParentOfType(elementParent, KtPrimaryConstructor::class.java)
if (elementParent.hasValOrVar()
- && (elementParent.getNameIdentifier() === element || elementParent.getValOrVarKeyword() === element)
+ && (elementParent.nameIdentifier === element || elementParent.valOrVarKeyword === element)
&& primaryConstructor != null
- && primaryConstructor.getValueParameterList() === elementParent.getParent()) return elementParent
+ && primaryConstructor.valueParameterList === elementParent.parent) return elementParent
}
if (elementParent is KtSecondaryConstructor && elementParent.getConstructorKeyword() === element) return elementParent
element.getStrictParentOfType()?.let { parameterList ->
- return PsiTreeUtil.getParentOfType(parameterList, javaClass(), javaClass(), javaClass())
+ return PsiTreeUtil.getParentOfType(parameterList, KtFunction::class.java, KtProperty::class.java, KtClass::class.java)
}
element.getStrictParentOfType()?.let { typeParameterList ->
- return PsiTreeUtil.getParentOfType(typeParameterList, javaClass(), javaClass(), javaClass())
+ return PsiTreeUtil.getParentOfType(typeParameterList, KtFunction::class.java, KtProperty::class.java, KtClass::class.java)
}
val call: KtCallElement? = PsiTreeUtil.getParentOfType(element,
- javaClass(),
- javaClass(),
- javaClass())
+ KtCallExpression::class.java,
+ KtSuperTypeCallEntry::class.java,
+ KtConstructorDelegationCall::class.java)
val calleeExpr = call?.let {
- val callee = it.getCalleeExpression()
- (callee as? KtConstructorCalleeExpression)?.getConstructorReferenceExpression() ?: callee
+ val callee = it.calleeExpression
+ (callee as? KtConstructorCalleeExpression)?.constructorReferenceExpression ?: callee
} ?: element.getStrictParentOfType()
if (calleeExpr is KtSimpleNameExpression || calleeExpr is KtConstructorDelegationReferenceExpression) {
@@ -157,7 +157,7 @@ public class KotlinChangeSignatureHandler : ChangeSignatureHandler {
is KtReferenceExpression -> bindingContext[BindingContext.REFERENCE_TARGET, element]
else -> bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, element]
}
- return if (descriptor is ClassDescriptor) descriptor.getUnsubstitutedPrimaryConstructor() else descriptor
+ return if (descriptor is ClassDescriptor) descriptor.unsubstitutedPrimaryConstructor else descriptor
}
public fun findDescriptor(element: PsiElement, project: Project, editor: Editor?, bindingContext: BindingContext): CallableDescriptor? {
@@ -167,14 +167,14 @@ public class KotlinChangeSignatureHandler : ChangeSignatureHandler {
return when (descriptor) {
is FunctionDescriptor -> {
- if (descriptor.getValueParameters().any { it.varargElementType != null }) {
+ if (descriptor.valueParameters.any { it.varargElementType != null }) {
val message = KotlinRefactoringBundle.message("error.cant.refactor.vararg.functions")
CommonRefactoringUtil.showErrorHint(project, editor, message, ChangeSignatureHandler.REFACTORING_NAME, HelpID.CHANGE_SIGNATURE)
return null
}
- if (descriptor.getKind() === SYNTHESIZED) {
- val message = KotlinRefactoringBundle.message("cannot.refactor.synthesized.function", descriptor.getName())
+ if (descriptor.kind === SYNTHESIZED) {
+ val message = KotlinRefactoringBundle.message("cannot.refactor.synthesized.function", descriptor.name)
CommonRefactoringUtil.showErrorHint(project, editor, message, ChangeSignatureHandler.REFACTORING_NAME, HelpID.CHANGE_SIGNATURE)
return null
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt
index e295a73e48f..dff251d4770 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt
@@ -38,18 +38,18 @@ public class KotlinChangeSignatureProcessor(project: Project,
changeInfo: KotlinChangeInfo,
private val commandName: String) : ChangeSignatureProcessorBase(project, changeInfo) {
override fun createUsageViewDescriptor(usages: Array): UsageViewDescriptor {
- val subject = if (getChangeInfo().kind.isConstructor) "constructor" else "function"
- return KotlinUsagesViewDescriptor(myChangeInfo.getMethod(), RefactoringBundle.message("0.to.change.signature", subject))
+ val subject = if (changeInfo.kind.isConstructor) "constructor" else "function"
+ return KotlinUsagesViewDescriptor(myChangeInfo.method, RefactoringBundle.message("0.to.change.signature", subject))
}
override fun getChangeInfo() = super.getChangeInfo() as KotlinChangeInfo
override fun findUsages(): Array {
val allUsages = ArrayList()
- getChangeInfo().getOrCreateJavaChangeInfos()?.let { javaChangeInfos ->
+ changeInfo.getOrCreateJavaChangeInfos()?.let { javaChangeInfos ->
val javaProcessor = JavaChangeSignatureUsageProcessor()
javaChangeInfos.mapTo(allUsages) {
- KotlinWrapperForJavaUsageInfos(it, javaProcessor.findUsages(it), getChangeInfo().getMethod())
+ KotlinWrapperForJavaUsageInfos(it, javaProcessor.findUsages(it), changeInfo.method)
}
}
super.findUsages().filterTo(allUsages) { it is KotlinUsageInfo<*> || it is UnresolvableCollisionUsageInfo }
@@ -58,7 +58,7 @@ public class KotlinChangeSignatureProcessor(project: Project,
}
override fun preprocessUsages(refUsages: Ref>): Boolean {
- val usageProcessors = ChangeSignatureUsageProcessor.EP_NAME.getExtensions()
+ val usageProcessors = ChangeSignatureUsageProcessor.EP_NAME.extensions
if (!usageProcessors.all { it.setupDefaultValues(myChangeInfo, refUsages, myProject) }) return false
@@ -72,25 +72,25 @@ public class KotlinChangeSignatureProcessor(project: Project,
RenameUtil.addConflictDescriptions(usages, conflictDescriptions)
RenameUtil.removeConflictUsages(usagesSet)
- if (!conflictDescriptions.isEmpty()) {
- if (ApplicationManager.getApplication().isUnitTestMode()) {
+ if (!conflictDescriptions.isEmpty) {
+ if (ApplicationManager.getApplication().isUnitTestMode) {
throw BaseRefactoringProcessor.ConflictsInTestsException(conflictDescriptions.values())
}
val dialog = prepareConflictsDialog(conflictDescriptions, usages)
dialog.show()
- if (!dialog.isOK()) {
- if (dialog.isShowConflicts()) prepareSuccessful()
+ if (!dialog.isOK) {
+ if (dialog.isShowConflicts) prepareSuccessful()
return false
}
}
val usageArray = usagesSet.toTypedArray()
Arrays.sort(usageArray) { u1, u2 ->
- val element1 = u1.getElement()
- val element2 = u2.getElement()
- val rank1 = if (element1 != null) element1.getTextOffset() else -1
- val rank2 = if (element2 != null) element2.getTextOffset() else -1
+ val element1 = u1.element
+ val element2 = u2.element
+ val rank1 = if (element1 != null) element1.textOffset else -1
+ val rank2 = if (element2 != null) element2.textOffset else -1
rank2 - rank1 // Reverse order
}
refUsages.set(usageArray)
@@ -100,7 +100,7 @@ public class KotlinChangeSignatureProcessor(project: Project,
return true
}
- override fun isPreviewUsages(usages: Array): Boolean = isPreviewUsages()
+ override fun isPreviewUsages(usages: Array): Boolean = isPreviewUsages
override fun getCommandName() = commandName
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt
index fc449475a6a..1bb88398437 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt
@@ -47,8 +47,8 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.codeInsight.KotlinFileReferencesResolver
import org.jetbrains.kotlin.idea.core.compareDescriptors
-import org.jetbrains.kotlin.idea.core.refactoring.createTempCopy
-import org.jetbrains.kotlin.idea.core.refactoring.isTrueJavaMethod
+import org.jetbrains.kotlin.idea.refactoring.createTempCopy
+import org.jetbrains.kotlin.idea.refactoring.isTrueJavaMethod
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.*
import org.jetbrains.kotlin.idea.refactoring.getBodyScope
import org.jetbrains.kotlin.idea.refactoring.getContainingScope
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMethodDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMethodDescriptor.kt
index 62aa78864c5..37fc8c587ab 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMethodDescriptor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMethodDescriptor.kt
@@ -37,7 +37,7 @@ public interface KotlinMethodDescriptor : MethodDescriptor Kind.FUNCTION
- descriptor.isPrimary() -> Kind.PRIMARY_CONSTRUCTOR
+ descriptor.isPrimary -> Kind.PRIMARY_CONSTRUCTOR
else -> Kind.SECONDARY_CONSTRUCTOR
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMutableMethodDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMutableMethodDescriptor.kt
index 93fb0427d1e..b3a2532e54f 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMutableMethodDescriptor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMutableMethodDescriptor.kt
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature
import org.jetbrains.kotlin.descriptors.Visibility
public class KotlinMutableMethodDescriptor(override val original: KotlinMethodDescriptor): KotlinMethodDescriptor by original {
- private val parameters: MutableList = original.getParameters()
+ private val parameters: MutableList = original.parameters
override var receiver: KotlinParameterInfo? = original.receiver
set(value: KotlinParameterInfo?) {
@@ -34,19 +34,14 @@ public class KotlinMutableMethodDescriptor(override val original: KotlinMethodDe
}
public fun removeParameter(index: Int) {
- val paramInfo = parameters.remove(index)
+ val paramInfo = parameters.removeAt(index)
if (paramInfo == receiver) {
receiver = null
}
}
public fun renameParameter(index: Int, newName: String) {
- parameters[index].setName(newName)
- }
-
- public fun clearParameters() {
- parameters.clear()
- receiver = null
+ parameters[index].name = newName
}
public fun clearNonReceiverParameters() {
@@ -55,6 +50,6 @@ public class KotlinMutableMethodDescriptor(override val original: KotlinMethodDe
}
override fun getVisibility(): Visibility? {
- return original.getVisibility()
+ return original.visibility
}
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinParameterInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinParameterInfo.kt
index d2160f34357..9b754dbe0d9 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinParameterInfo.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinParameterInfo.kt
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.compareDescriptors
-import org.jetbrains.kotlin.idea.core.refactoring.quoteIfNeeded
+import org.jetbrains.kotlin.idea.refactoring.quoteIfNeeded
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallableDefinitionUsage
import org.jetbrains.kotlin.idea.references.KtReference
import org.jetbrains.kotlin.idea.references.mainReference
@@ -49,17 +49,17 @@ public class KotlinParameterInfo @JvmOverloads constructor (
public val defaultValueParameterReferences: Map
init {
- val file = defaultValueForCall?.getContainingFile() as? KtFile
+ val file = defaultValueForCall?.containingFile as? KtFile
defaultValueParameterReferences =
- if (defaultValueForCall != null && file != null && (file.isPhysical() || file.analysisContext != null)) {
- val project = file.getProject()
+ if (defaultValueForCall != null && file != null && (file.isPhysical || file.analysisContext != null)) {
+ val project = file.project
val map = LinkedHashMap()
defaultValueForCall!!.accept(
object : KtTreeVisitorVoid() {
private fun selfParameterOrNull(parameter: DeclarationDescriptor?): ValueParameterDescriptor? {
return if (parameter is ValueParameterDescriptor &&
- compareDescriptors(project, parameter.getContainingDeclaration(), callableDescriptor)) {
+ compareDescriptors(project, parameter.containingDeclaration, callableDescriptor)) {
parameter
} else null
}
@@ -67,12 +67,12 @@ public class KotlinParameterInfo @JvmOverloads constructor (
private fun selfReceiverOrNull(receiverDescriptor: DeclarationDescriptor?): DeclarationDescriptor? {
if (compareDescriptors(project,
receiverDescriptor,
- callableDescriptor.getExtensionReceiverParameter()?.getContainingDeclaration())) {
+ callableDescriptor.extensionReceiverParameter?.containingDeclaration)) {
return receiverDescriptor
}
if (compareDescriptors(project,
receiverDescriptor,
- callableDescriptor.getDispatchReceiverParameter()?.getContainingDeclaration())) {
+ callableDescriptor.dispatchReceiverParameter?.containingDeclaration)) {
return receiverDescriptor
}
return null
@@ -97,12 +97,12 @@ public class KotlinParameterInfo @JvmOverloads constructor (
}
val resolvedCall = expression.getResolvedCall(context) ?: return null
- (resolvedCall.getResultingDescriptor() as? ReceiverParameterDescriptor)?.let {
- return if (selfReceiverOrNull(it.getContainingDeclaration()) != null) it else null
+ (resolvedCall.resultingDescriptor as? ReceiverParameterDescriptor)?.let {
+ return if (selfReceiverOrNull(it.containingDeclaration) != null) it else null
}
- selfReceiverOrNull(resolvedCall.getExtensionReceiver() as? ImplicitReceiver)?.let { return it }
- selfReceiverOrNull(resolvedCall.getDispatchReceiver() as? ImplicitReceiver)?.let { return it }
+ selfReceiverOrNull(resolvedCall.extensionReceiver as? ImplicitReceiver)?.let { return it }
+ selfReceiverOrNull(resolvedCall.dispatchReceiver as? ImplicitReceiver)?.let { return it }
return null
}
@@ -149,7 +149,7 @@ public class KotlinParameterInfo @JvmOverloads constructor (
val defaultRendering = currentTypeInfo.render()
val typeSubstitutor = inheritedCallable.typeSubstitutor ?: return defaultRendering
val currentBaseFunction = inheritedCallable.baseFunction.currentCallableDescriptor ?: return defaultRendering
- val parameterType = currentBaseFunction.getValueParameters().get(parameterIndex).getType()
+ val parameterType = currentBaseFunction.valueParameters[parameterIndex].type
if (parameterType.isError) return defaultRendering
return parameterType.renderTypeWithSubstitution(typeSubstitutor, defaultRendering, true)
}
@@ -161,13 +161,13 @@ public class KotlinParameterInfo @JvmOverloads constructor (
val baseFunctionDescriptor = baseFunction.originalCallableDescriptor
val inheritedFunctionDescriptor = inheritedCallable.originalCallableDescriptor
- val inheritedParameterDescriptors = inheritedFunctionDescriptor.getValueParameters()
+ val inheritedParameterDescriptors = inheritedFunctionDescriptor.valueParameters
if (originalIndex < 0
- || originalIndex >= baseFunctionDescriptor.getValueParameters().size()
- || originalIndex >= inheritedParameterDescriptors.size()) return name
+ || originalIndex >= baseFunctionDescriptor.valueParameters.size
+ || originalIndex >= inheritedParameterDescriptors.size) return name
- val inheritedParamName = inheritedParameterDescriptors.get(originalIndex).getName().asString()
- val oldParamName = baseFunctionDescriptor.getValueParameters().get(originalIndex).getName().asString()
+ val inheritedParamName = inheritedParameterDescriptors[originalIndex].name.asString()
+ val oldParamName = baseFunctionDescriptor.valueParameters[originalIndex].name.asString()
return when {
oldParamName == inheritedParamName && inheritedFunctionDescriptor !is AnonymousFunctionDescriptor -> name
@@ -181,16 +181,16 @@ public class KotlinParameterInfo @JvmOverloads constructor (
if (originalIndex < 0) return !inheritedCallable.hasExpectedType
- val inheritedParameterDescriptor = inheritedFunctionDescriptor.getValueParameters().get(originalIndex)
+ val inheritedParameterDescriptor = inheritedFunctionDescriptor.valueParameters[originalIndex]
val parameter = DescriptorToSourceUtils.descriptorToDeclaration(inheritedParameterDescriptor) as? KtParameter ?: return false
- return parameter.getTypeReference() != null
+ return parameter.typeReference != null
}
public fun getDeclarationSignature(parameterIndex: Int, inheritedCallable: KotlinCallableDefinitionUsage<*>): String {
val buffer = StringBuilder()
if (modifierList != null) {
- buffer.append(modifierList.getText()).append(' ')
+ buffer.append(modifierList.text).append(' ')
}
if (valOrVar != KotlinValVar.None) {
@@ -204,7 +204,7 @@ public class KotlinParameterInfo @JvmOverloads constructor (
}
if (!inheritedCallable.isInherited) {
- defaultValueForParameter?.let { buffer.append(" = ").append(it.getText()) }
+ defaultValueForParameter?.let { buffer.append(" = ").append(it.text) }
}
return buffer.toString()
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinValVar.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinValVar.kt
index 3ae82b6c553..10a1fe3d1a3 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinValVar.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinValVar.kt
@@ -39,8 +39,8 @@ public enum class KotlinValVar(val keywordName: String) {
fun PsiElement?.toValVar(): KotlinValVar {
return when {
this == null -> KotlinValVar.None
- getNode().getElementType() == KtTokens.VAL_KEYWORD -> KotlinValVar.Val
- getNode().getElementType() == KtTokens.VAR_KEYWORD -> KotlinValVar.Var
- else -> throw IllegalArgumentException("Unknown val/var token: " + getText())
+ node.elementType == KtTokens.VAL_KEYWORD -> KotlinValVar.Val
+ node.elementType == KtTokens.VAR_KEYWORD -> KotlinValVar.Var
+ else -> throw IllegalArgumentException("Unknown val/var token: " + text)
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt
index 4ee59f7a65c..9cddbe5bbb0 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt
@@ -37,7 +37,7 @@ fun KtNamedDeclaration.getDeclarationBody(): KtElement? {
this is KtClassOrObject -> getSuperTypeList()
this is KtPrimaryConstructor -> getContainingClassOrObject().getSuperTypeList()
this is KtSecondaryConstructor -> getDelegationCall()
- this is KtNamedFunction -> getBodyExpression()
+ this is KtNamedFunction -> bodyExpression
else -> null
}
}
@@ -51,9 +51,9 @@ public fun PsiElement.isCaller(allUsages: Array): Boolean {
usage is KotlinCallerUsage
|| usage is DeferredJavaMethodKotlinCallerUsage
|| usage is CallerUsageInfo
- || (usage is OverriderUsageInfo && !usage.isOriginalOverrider())
+ || (usage is OverriderUsageInfo && !usage.isOriginalOverrider)
}
- .any { it.getElement() == elementToSearch }
+ .any { it.element == elementToSearch }
}
public fun KtElement.isInsideOfCallerBody(allUsages: Array): Boolean {
@@ -61,7 +61,7 @@ public fun KtElement.isInsideOfCallerBody(allUsages: Array): Bool
it is KtNamedFunction || it is KtConstructor<*> || it is KtClassOrObject
} as? KtNamedDeclaration ?: return false
val body = container.getDeclarationBody() ?: return false
- return body.getTextRange().contains(getTextRange()) && container.isCaller(allUsages)
+ return body.textRange.contains(textRange) && container.isCaller(allUsages)
}
fun getCallableSubstitutor(
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt
index f84857fd5d3..6c9d54b9914 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt
@@ -81,27 +81,27 @@ public class KotlinMethodNode(
override fun customizeRendererText(renderer: ColoredTreeCellRenderer) {
val descriptor = when (myMethod) {
is KtFunction -> myMethod.resolveToDescriptor() as FunctionDescriptor
- is KtClass -> (myMethod.resolveToDescriptor() as ClassDescriptor).getUnsubstitutedPrimaryConstructor() ?: return
+ is KtClass -> (myMethod.resolveToDescriptor() as ClassDescriptor).unsubstitutedPrimaryConstructor ?: return
is PsiMethod -> myMethod.getJavaMethodDescriptor() ?: return
else -> throw AssertionError("Invalid declaration: ${myMethod.getElementTextWithContext()}")
}
- val containerName = sequence(descriptor) { it.getContainingDeclaration() }
+ val containerName = sequence(descriptor) { it.containingDeclaration }
.firstOrNull { it is ClassDescriptor }
- ?.getName()
+ ?.name
val renderedFunction = KotlinCallHierarchyNodeDescriptor.renderNamedFunction(descriptor)
val renderedFunctionWithContainer =
containerName?.let {
- "${if (it.isSpecial()) "[Anonymous]" else it.asString()}.$renderedFunction"
+ "${if (it.isSpecial) "[Anonymous]" else it.asString()}.$renderedFunction"
} ?: renderedFunction
- val attributes = if (isEnabled())
+ val attributes = if (isEnabled)
SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getTreeForeground())
else
SimpleTextAttributes.EXCLUDED_ATTRIBUTES
renderer.append(renderedFunctionWithContainer, attributes)
- val packageName = (myMethod.getContainingFile() as? PsiClassOwner)?.getPackageName() ?: ""
+ val packageName = (myMethod.containingFile as? PsiClassOwner)?.packageName ?: ""
renderer.append(" ($packageName)", SimpleTextAttributes(SimpleTextAttributes.STYLE_ITALIC, JBColor.GRAY))
}
@@ -117,8 +117,8 @@ public class KotlinMethodNode(
}
}
}
- val query = myMethod.getRepresentativeLightMethod()?.let { MethodReferencesSearch.search(it, it.getUseScope(), true) }
- ?: ReferencesSearch.search(myMethod, myMethod.getUseScope())
+ val query = myMethod.getRepresentativeLightMethod()?.let { MethodReferencesSearch.search(it, it.useScope, true) }
+ ?: ReferencesSearch.search(myMethod, myMethod.useScope)
query.forEach { processor.process(it) }
return callers.toList()
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt
index 9ad74ad245c..ca9513f11b4 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.idea.refactoring.changeSignature
+package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiDocumentManager
@@ -25,7 +25,8 @@ import com.intellij.util.ui.FormBuilder
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.idea.KotlinFileType
-import org.jetbrains.kotlin.idea.core.refactoring.validateElement
+import org.jetbrains.kotlin.idea.refactoring.validateElement
+import org.jetbrains.kotlin.idea.refactoring.changeSignature.*
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtPsiFactory
@@ -43,7 +44,7 @@ public class KotlinChangePropertySignatureDialog(
private val visibilityCombo = JComboBox(
arrayOf(Visibilities.INTERNAL, Visibilities.PRIVATE, Visibilities.PROTECTED, Visibilities.PUBLIC)
)
- private val nameField = EditorTextField(methodDescriptor.getName())
+ private val nameField = EditorTextField(methodDescriptor.name)
private var returnTypeField: EditorTextField by Delegates.notNull()
private var receiverTypeCheckBox: JCheckBox? = null
var receiverTypeLabel: JLabel by Delegates.notNull()
@@ -52,7 +53,7 @@ public class KotlinChangePropertySignatureDialog(
private var receiverDefaultValueField: EditorTextField? = null
init {
- setTitle("Change Signature")
+ title = "Change Signature"
init()
}
@@ -60,11 +61,11 @@ public class KotlinChangePropertySignatureDialog(
override fun createCenterPanel(): JComponent? {
fun updateReceiverUI() {
- val withReceiver = receiverTypeCheckBox!!.isSelected()
- receiverTypeLabel.setEnabled(withReceiver)
- receiverTypeField.setEnabled(withReceiver)
- receiverDefaultValueLabel?.setEnabled(withReceiver)
- receiverDefaultValueField?.setEnabled(withReceiver)
+ val withReceiver = receiverTypeCheckBox!!.isSelected
+ receiverTypeLabel.isEnabled = withReceiver
+ receiverTypeField.isEnabled = withReceiver
+ receiverDefaultValueLabel?.isEnabled = withReceiver
+ receiverDefaultValueField?.isEnabled = withReceiver
}
val documentManager = PsiDocumentManager.getInstance(myProject)
@@ -72,8 +73,8 @@ public class KotlinChangePropertySignatureDialog(
return with(FormBuilder.createFormBuilder()) {
val baseDeclaration = methodDescriptor.baseDeclaration
- if (!((baseDeclaration as? KtProperty)?.isLocal() ?: false)) {
- visibilityCombo.setSelectedItem(methodDescriptor.getVisibility())
+ if (!((baseDeclaration as? KtProperty)?.isLocal ?: false)) {
+ visibilityCombo.selectedItem = methodDescriptor.visibility
addLabeledComponent("&Visibility: ", visibilityCombo)
}
@@ -90,7 +91,7 @@ public class KotlinChangePropertySignatureDialog(
val receiverTypeCheckBox = JCheckBox("Extension property: ")
receiverTypeCheckBox.setMnemonic('x')
receiverTypeCheckBox.addActionListener { updateReceiverUI() }
- receiverTypeCheckBox.setSelected(methodDescriptor.receiver != null)
+ receiverTypeCheckBox.isSelected = methodDescriptor.receiver != null
addComponent(receiverTypeCheckBox)
this@KotlinChangePropertySignatureDialog.receiverTypeCheckBox = receiverTypeCheckBox
@@ -114,22 +115,22 @@ public class KotlinChangePropertySignatureDialog(
updateReceiverUI()
}
- getPanel()
+ panel
}
}
private fun getDefaultReceiverValue(): KtExpression? {
- val receiverDefaultValue = receiverDefaultValueField?.getText() ?: ""
+ val receiverDefaultValue = receiverDefaultValueField?.text ?: ""
return if (receiverDefaultValue.isNotEmpty()) KtPsiFactory(myProject).createExpression(receiverDefaultValue) else null
}
override fun canRun() {
val psiFactory = KtPsiFactory(myProject)
- psiFactory.createSimpleName(nameField.getText()).validateElement("Invalid name")
- psiFactory.createType(returnTypeField.getText()).validateElement("Invalid return type")
- if (receiverTypeCheckBox?.isSelected() ?: false) {
- psiFactory.createType(receiverTypeField.getText()).validateElement("Invalid receiver type")
+ psiFactory.createSimpleName(nameField.text).validateElement("Invalid name")
+ psiFactory.createType(returnTypeField.text).validateElement("Invalid return type")
+ if (receiverTypeCheckBox?.isSelected ?: false) {
+ psiFactory.createType(receiverTypeField.text).validateElement("Invalid receiver type")
}
getDefaultReceiverValue()?.validateElement("Invalid default receiver value")
}
@@ -137,21 +138,21 @@ public class KotlinChangePropertySignatureDialog(
override fun doAction() {
val originalDescriptor = methodDescriptor.original
- val receiver = if (receiverTypeCheckBox?.isSelected() ?: false) {
+ val receiver = if (receiverTypeCheckBox?.isSelected ?: false) {
originalDescriptor.receiver ?: KotlinParameterInfo(callableDescriptor = originalDescriptor.baseDescriptor,
name = "receiver",
defaultValueForCall = getDefaultReceiverValue())
} else null
- receiver?.currentTypeInfo = KotlinTypeInfo(false, null, receiverTypeField.getText())
+ receiver?.currentTypeInfo = KotlinTypeInfo(false, null, receiverTypeField.text)
val changeInfo = KotlinChangeInfo(originalDescriptor,
- nameField.getText(),
+ nameField.text,
KotlinTypeInfo(true, null, returnTypeField.text),
- visibilityCombo.getSelectedItem() as Visibility,
+ visibilityCombo.selectedItem as Visibility,
emptyList(),
receiver,
- originalDescriptor.getMethod())
+ originalDescriptor.method)
- invokeRefactoring(KotlinChangeSignatureProcessor(myProject, changeInfo, commandName ?: getTitle()))
+ invokeRefactoring(KotlinChangeSignatureProcessor(myProject, changeInfo, commandName ?: title))
}
companion object {
@@ -161,8 +162,8 @@ public class KotlinChangePropertySignatureDialog(
descriptor: KotlinMethodDescriptor
): BaseRefactoringProcessor {
val originalDescriptor = descriptor.original
- val changeInfo = KotlinChangeInfo(methodDescriptor = originalDescriptor, context = originalDescriptor.getMethod())
- changeInfo.setNewName(descriptor.getName())
+ val changeInfo = KotlinChangeInfo(methodDescriptor = originalDescriptor, context = originalDescriptor.method)
+ changeInfo.newName = descriptor.name
changeInfo.receiverParameterInfo = descriptor.receiver
return KotlinChangeSignatureProcessor(project, changeInfo, commandName)
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt
index 7af795e48b1..5532e3db288 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt
@@ -48,7 +48,6 @@ import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
-import org.jetbrains.kotlin.idea.core.refactoring.validateElementAndNotNull
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
import org.jetbrains.kotlin.idea.refactoring.changeSignature.*
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescriptor.Kind
@@ -62,7 +61,6 @@ import java.awt.BorderLayout
import java.awt.Font
import java.awt.Toolkit
import java.awt.event.ItemEvent
-import java.awt.event.ItemListener
import java.util.*
import javax.swing.*
@@ -102,30 +100,30 @@ public class KotlinChangeSignatureDialog(
}
val parameterName = getPresentationName(item)
- val typeText = item.typeCodeFragment.getText()
- val defaultValue = item.defaultValueCodeFragment.getText()
- val separator = StringUtil.repeatSymbol(' ', getParamNamesMaxLength() - parameterName.length() + 1)
+ val typeText = item.typeCodeFragment.text
+ val defaultValue = item.defaultValueCodeFragment.text
+ val separator = StringUtil.repeatSymbol(' ', getParamNamesMaxLength() - parameterName.length + 1)
var text = "$valOrVar$parameterName:$separator$typeText"
if (StringUtil.isNotEmpty(defaultValue)) {
text += " // default value = $defaultValue"
}
- val field = object : EditorTextField(" $text", getProject(), getFileType()) {
+ val field = object : EditorTextField(" $text", project, fileType) {
override fun shouldHaveBorder() = false
}
- val plainFont = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)
- field.setFont(Font(plainFont.getFontName(), plainFont.getStyle(), 12))
+ val plainFont = EditorColorsManager.getInstance().globalScheme.getFont(EditorFontType.PLAIN)
+ field.font = Font(plainFont.fontName, plainFont.style, 12)
if (selected && focused) {
- panel.setBackground(UIUtil.getTableSelectionBackground())
+ panel.background = UIUtil.getTableSelectionBackground()
field.setAsRendererWithSelection(UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground())
}
else {
- panel.setBackground(UIUtil.getTableBackground())
+ panel.background = UIUtil.getTableBackground()
if (selected && !focused) {
- panel.setBorder(DottedBorder(UIUtil.getTableForeground()))
+ panel.border = DottedBorder(UIUtil.getTableForeground())
}
}
panel.add(field, BorderLayout.WEST)
@@ -135,50 +133,50 @@ public class KotlinChangeSignatureDialog(
private fun getPresentationName(item: ParameterTableModelItemBase): String {
val parameter = item.parameter
- return if (parameter == parametersTableModel.getReceiver()) "" else parameter.getName()
+ return if (parameter == parametersTableModel.receiver) "" else parameter.name
}
private fun getColumnTextMaxLength(nameFunction: Function1, String?>) =
- parametersTableModel.getItems().map { nameFunction(it)?.length() ?: 0 }.max() ?: 0
+ parametersTableModel.items.map { nameFunction(it)?.length ?: 0 }.max() ?: 0
private fun getParamNamesMaxLength() = getColumnTextMaxLength { getPresentationName(it) }
- private fun getTypesMaxLength() = getColumnTextMaxLength { it.typeCodeFragment?.getText() }
+ private fun getTypesMaxLength() = getColumnTextMaxLength { it.typeCodeFragment?.text }
- private fun getDefaultValuesMaxLength() = getColumnTextMaxLength { it.defaultValueCodeFragment?.getText() }
+ private fun getDefaultValuesMaxLength() = getColumnTextMaxLength { it.defaultValueCodeFragment?.text }
override fun isListTableViewSupported() = true
override fun isEmptyRow(row: ParameterTableModelItemBase): Boolean {
- if (!row.parameter.getName().isNullOrEmpty()) return false
- if (!row.parameter.getTypeText().isNullOrEmpty()) return false
+ if (!row.parameter.name.isNullOrEmpty()) return false
+ if (!row.parameter.typeText.isNullOrEmpty()) return false
return true
}
override fun createCallerChooser(title: String, treeToReuse: Tree?, callback: Consumer>) =
- KotlinCallerChooser(myMethod.getMethod(), myProject, title, treeToReuse, callback)
+ KotlinCallerChooser(myMethod.method, myProject, title, treeToReuse, callback)
// Forbid receiver propagation
override fun mayPropagateParameters() =
- getParameters().any { it.isNewParameter && it != parametersTableModel.getReceiver() }
+ parameters.any { it.isNewParameter && it != parametersTableModel.receiver }
override fun getTableEditor(table: JTable, item: ParameterTableModelItemBase): JBTableRowEditor? {
return object : JBTableRowEditor() {
private val components = ArrayList()
- private val nameEditor = EditorTextField(item.parameter.getName(), getProject(), getFileType())
+ private val nameEditor = EditorTextField(item.parameter.name, getProject(), getFileType())
private fun updateNameEditor() {
- nameEditor.setEnabled(item.parameter != parametersTableModel.getReceiver())
+ nameEditor.isEnabled = item.parameter != parametersTableModel.receiver
}
private fun isDefaultColumnEnabled() =
item.parameter.isNewParameter && item.parameter != myMethod.receiver
override fun prepareEditor(table: JTable, row: Int) {
- setLayout(BoxLayout(this, BoxLayout.X_AXIS))
+ layout = BoxLayout(this, BoxLayout.X_AXIS)
var column = 0
- for (columnInfo in parametersTableModel.getColumnInfos()) {
+ for (columnInfo in parametersTableModel.columnInfos) {
val panel = JPanel(VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false))
val editor: EditorTextField?
val component: JComponent
@@ -201,22 +199,20 @@ public class KotlinChangeSignatureDialog(
}
else if (KotlinPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo)) {
val comboBox = JComboBox(KotlinValVar.values())
- comboBox.setSelectedItem(item.parameter.valOrVar)
- comboBox.addItemListener(object : ItemListener {
- override fun itemStateChanged(e: ItemEvent) {
- parametersTableModel.setValueAtWithoutUpdate(e.getItem(), row, columnFinal)
- updateSignature()
- }
- })
+ comboBox.selectedItem = item.parameter.valOrVar
+ comboBox.addItemListener {
+ parametersTableModel.setValueAtWithoutUpdate(it.item, row, columnFinal)
+ updateSignature()
+ }
component = comboBox
editor = null
}
else if (KotlinFunctionParameterTableModel.isReceiverColumn(columnInfo)) {
val checkBox = JCheckBox()
- checkBox.setSelected(parametersTableModel.getReceiver() == item.parameter)
+ checkBox.isSelected = parametersTableModel.receiver == item.parameter
checkBox.addItemListener {
- val newReceiver = if (it.getStateChange() == ItemEvent.SELECTED) item.parameter else null
- (parametersTableModel as KotlinFunctionParameterTableModel).setReceiver(newReceiver)
+ val newReceiver = if (it.stateChange == ItemEvent.SELECTED) item.parameter else null
+ (parametersTableModel as KotlinFunctionParameterTableModel).receiver = newReceiver
updateSignature()
updateNameEditor()
}
@@ -226,7 +222,7 @@ public class KotlinChangeSignatureDialog(
else
continue
- val label = JBLabel(columnInfo.getName(), UIUtil.ComponentStyle.SMALL)
+ val label = JBLabel(columnInfo.name, UIUtil.ComponentStyle.SMALL)
panel.add(label)
if (editor != null) {
@@ -237,7 +233,7 @@ public class KotlinChangeSignatureDialog(
}
}
)
- editor.setPreferredWidth(table.getWidth() / parametersTableModel.getColumnCount())
+ editor.setPreferredWidth(table.width / parametersTableModel.columnCount)
}
components.add(component)
@@ -249,27 +245,25 @@ public class KotlinChangeSignatureDialog(
}
override fun getValue(): JBTableRow {
- return object : JBTableRow {
- override fun getValueAt(column: Int): Any? {
- val columnInfo = parametersTableModel.getColumnInfos()[column]
+ return JBTableRow { column ->
+ val columnInfo = parametersTableModel.columnInfos[column]
- if (KotlinPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo))
- return (components.get(column) as @Suppress("NO_TYPE_ARGUMENTS_ON_RHS") JComboBox).getSelectedItem()
- else if (KotlinCallableParameterTableModel.isTypeColumn(columnInfo))
- return item.typeCodeFragment
- else if (KotlinCallableParameterTableModel.isNameColumn(columnInfo))
- return (components.get(column) as EditorTextField).getText()
- else if (KotlinCallableParameterTableModel.isDefaultValueColumn(columnInfo))
- return item.defaultValueCodeFragment
- else
- return null
- }
+ if (KotlinPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo))
+ (components[column] as @Suppress("NO_TYPE_ARGUMENTS_ON_RHS") JComboBox).selectedItem
+ else if (KotlinCallableParameterTableModel.isTypeColumn(columnInfo))
+ item.typeCodeFragment
+ else if (KotlinCallableParameterTableModel.isNameColumn(columnInfo))
+ (components[column] as EditorTextField).text
+ else if (KotlinCallableParameterTableModel.isDefaultValueColumn(columnInfo))
+ item.defaultValueCodeFragment
+ else
+ null
}
}
private fun getColumnWidth(letters: Int): Int {
- var font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)
- font = Font(font.getFontName(), font.getStyle(), 12)
+ var font = EditorColorsManager.getInstance().globalScheme.getFont(EditorFontType.PLAIN)
+ font = Font(font.fontName, font.style, 12)
return letters * Toolkit.getDefaultToolkit().getFontMetrics(font).stringWidth("W")
}
@@ -282,7 +276,7 @@ public class KotlinChangeSignatureDialog(
intArrayOf(4, getParamNamesMaxLength(), getTypesMaxLength())
var columnIndex = 0
- for (i in (if (myMethod.kind === Kind.PRIMARY_CONSTRUCTOR) 0 else 1)..columnLetters.size() - 1) {
+ for (i in (if (myMethod.kind === Kind.PRIMARY_CONSTRUCTOR) 0 else 1)..columnLetters.size - 1) {
val width = getColumnWidth(columnLetters[i])
if (x <= width)
@@ -296,18 +290,18 @@ public class KotlinChangeSignatureDialog(
}
override fun getPreferredFocusedComponent(): JComponent {
- val me = getMouseEvent()
+ val me = mouseEvent
val index = if (me != null)
- getEditorIndex(me.getPoint().getX().toInt())
+ getEditorIndex(me.point.getX().toInt())
else if (myMethod.kind === Kind.PRIMARY_CONSTRUCTOR) 1 else 0
- val component = components.get(index)
- return if (component is EditorTextField) component.getFocusTarget() else component
+ val component = components[index]
+ return if (component is EditorTextField) component.focusTarget else component
}
override fun getFocusableComponents(): Array {
- return Array(components.size()) {
- val component = components.get(it)
- (component as? EditorTextField)?.getFocusTarget() ?: component
+ return Array(components.size) {
+ val component = components[it]
+ (component as? EditorTextField)?.focusTarget ?: component
}
}
}
@@ -317,8 +311,8 @@ public class KotlinChangeSignatureDialog(
val changeInfo = evaluateChangeInfo(parametersTableModel,
myReturnTypeCodeFragment,
getMethodDescriptor(),
- getVisibility(),
- getMethodName(),
+ visibility,
+ methodName,
myDefaultValueContext,
true)
return changeInfo.getNewSignature(getMethodDescriptor().originalPrimaryCallable)
@@ -388,18 +382,18 @@ public class KotlinChangeSignatureDialog(
val changeInfo = evaluateChangeInfo(parametersTableModel,
myReturnTypeCodeFragment,
getMethodDescriptor(),
- getVisibility(),
- getMethodName(),
+ visibility,
+ methodName,
myDefaultValueContext,
false)
changeInfo.primaryPropagationTargets = myMethodsToPropagateParameters ?: emptyList();
- return KotlinChangeSignatureProcessor(myProject, changeInfo, commandName ?: getTitle())
+ return KotlinChangeSignatureProcessor(myProject, changeInfo, commandName ?: title)
}
public fun getMethodDescriptor(): KotlinMethodDescriptor = myMethod
override fun getSelectedIdx(): Int {
- return myMethod.getParameters().withIndex().firstOrNull { it.value.isNewParameter }?.index
+ return myMethod.parameters.withIndex().firstOrNull { it.value.isNewParameter }?.index
?: super.getSelectedIdx()
}
@@ -420,12 +414,12 @@ public class KotlinChangeSignatureDialog(
method: KotlinMethodDescriptor,
defaultValueContext: PsiElement): BaseRefactoringProcessor {
val parameterTableModel = createParametersInfoModel(method, defaultValueContext)
- parameterTableModel.setParameterInfos(method.getParameters())
+ parameterTableModel.setParameterInfos(method.parameters)
val changeInfo = evaluateChangeInfo(parameterTableModel,
createReturnTypeCodeFragment(project, method),
method,
- method.getVisibility(),
- method.getName(),
+ method.visibility,
+ method.name,
defaultValueContext,
false)
return KotlinChangeSignatureProcessor(project, changeInfo, commandName)
@@ -450,14 +444,14 @@ public class KotlinChangeSignatureDialog(
methodName: String,
defaultValueContext: PsiElement,
forPreview: Boolean): KotlinChangeInfo {
- val parameters = parametersModel.getItems().map { parameter ->
+ val parameters = parametersModel.items.map { parameter ->
val parameterInfo = parameter.parameter
parameterInfo.currentTypeInfo = parameter.typeCodeFragment.getTypeInfo(false, forPreview)
val codeFragment = parameter.defaultValueCodeFragment as KtExpressionCodeFragment
val oldDefaultValue = parameterInfo.defaultValueForCall
- if (codeFragment.getText() != (if (oldDefaultValue != null) oldDefaultValue.getText() else "")) {
+ if (codeFragment.text != (if (oldDefaultValue != null) oldDefaultValue.text else "")) {
parameterInfo.defaultValueForCall = codeFragment.getContentElement()
}
@@ -469,7 +463,7 @@ public class KotlinChangeSignatureDialog(
returnTypeCodeFragment.getTypeInfo(true, forPreview),
visibility ?: Visibilities.DEFAULT_VISIBILITY,
parameters,
- parametersModel.getReceiver(),
+ parametersModel.receiver,
defaultValueContext)
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt
index d4c506d992c..7623dd4f67a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt
@@ -20,7 +20,6 @@ import com.intellij.psi.PsiElement
import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo
-import org.jetbrains.kotlin.psi.KtConstructorDelegationCall
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.types.KotlinType
@@ -50,13 +49,3 @@ public class DeferredJavaMethodKotlinCallerUsage(
}
}
}
-
-public class JavaConstructorDeferredUsageInDelegationCall(
- val delegationCall: KtConstructorDelegationCall
-) : JavaMethodDeferredKotlinUsage(delegationCall) {
- override fun resolve(javaMethodChangeInfo: KotlinChangeInfo): JavaMethodKotlinUsageWithDelegate {
- return object : JavaMethodKotlinUsageWithDelegate(delegationCall, javaMethodChangeInfo) {
- override val delegateUsage = KotlinConstructorDelegationCallUsage(delegationCall, javaMethodChangeInfo)
- }
- }
-}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallableDefinitionUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallableDefinitionUsage.kt
index 9722af761e5..97062aed1fc 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallableDefinitionUsage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallableDefinitionUsage.kt
@@ -26,9 +26,9 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
-import org.jetbrains.kotlin.idea.core.refactoring.createPrimaryConstructorIfAbsent
-import org.jetbrains.kotlin.idea.core.refactoring.dropOverrideKeywordIfNecessary
-import org.jetbrains.kotlin.idea.core.refactoring.replaceListPsiAndKeepDelimiters
+import org.jetbrains.kotlin.idea.refactoring.createPrimaryConstructorIfAbsent
+import org.jetbrains.kotlin.idea.refactoring.dropOverrideKeywordIfNecessary
+import org.jetbrains.kotlin.idea.refactoring.replaceListPsiAndKeepDelimiters
import org.jetbrains.kotlin.idea.core.setVisibility
import org.jetbrains.kotlin.idea.core.toKeywordToken
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt
index 47c27477d1b..50c80c2690f 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages
import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
-import org.jetbrains.kotlin.idea.core.refactoring.createPrimaryConstructorParameterListIfAbsent
+import org.jetbrains.kotlin.idea.refactoring.createPrimaryConstructorParameterListIfAbsent
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo
import org.jetbrains.kotlin.idea.refactoring.changeSignature.getAffectedCallables
import org.jetbrains.kotlin.idea.refactoring.changeSignature.isInsideOfCallerBody
@@ -28,14 +28,14 @@ import org.jetbrains.kotlin.psi.*
public class KotlinCallerUsage(element: KtNamedDeclaration): KotlinUsageInfo(element) {
override fun processUsage(changeInfo: KotlinChangeInfo, element: KtNamedDeclaration, allUsages: Array): Boolean {
// Do not process function twice
- if (changeInfo.getAffectedCallables().any { it is KotlinCallableDefinitionUsage<*> && it.getElement() == element }) return true
+ if (changeInfo.getAffectedCallables().any { it is KotlinCallableDefinitionUsage<*> && it.element == element }) return true
val parameterList = when (element) {
- is KtFunction -> element.getValueParameterList()
+ is KtFunction -> element.valueParameterList
is KtClass -> element.createPrimaryConstructorParameterListIfAbsent()
else -> null
} ?: return true
- val psiFactory = KtPsiFactory(getProject())
+ val psiFactory = KtPsiFactory(project)
changeInfo.getNonReceiverParameters()
.withIndex()
.filter { it.value.isNewParameter }
@@ -52,13 +52,13 @@ public class KotlinCallerUsage(element: KtNamedDeclaration): KotlinUsageInfo(element) {
override fun processUsage(changeInfo: KotlinChangeInfo, element: KtCallElement, allUsages: Array): Boolean {
- val argumentList = element.getValueArgumentList() ?: return true
- val psiFactory = KtPsiFactory(getProject())
- val isNamedCall = argumentList.getArguments().any { it.getArgumentName() != null }
+ val argumentList = element.valueArgumentList ?: return true
+ val psiFactory = KtPsiFactory(project)
+ val isNamedCall = argumentList.arguments.any { it.getArgumentName() != null }
changeInfo.getNonReceiverParameters()
.filter { it.isNewParameter }
.forEach {
- val parameterName = it.getName()
+ val parameterName = it.name
val argumentExpression = if (element.isInsideOfCallerBody(allUsages)) {
psiFactory.createExpression(parameterName)
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinConstructorDelegationCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinConstructorDelegationCallUsage.kt
index f904912239b..64296474c34 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinConstructorDelegationCallUsage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinConstructorDelegationCallUsage.kt
@@ -29,18 +29,18 @@ public class KotlinConstructorDelegationCallUsage(
val delegate = KotlinFunctionCallUsage(call, changeInfo.methodDescriptor.originalPrimaryCallable)
override fun processUsage(changeInfo: KotlinChangeInfo, element: KtConstructorDelegationCall, allUsages: Array): Boolean {
- val isThisCall = element.isCallToThis()
+ val isThisCall = element.isCallToThis
var elementToWorkWith = element
- if (changeInfo.getNewParametersCount() > 0 && element.isImplicit()) {
- val constructor = element.getParent() as KtSecondaryConstructor
+ if (changeInfo.getNewParametersCount() > 0 && element.isImplicit) {
+ val constructor = element.parent as KtSecondaryConstructor
elementToWorkWith = constructor.replaceImplicitDelegationCallWithExplicit(isThisCall)
}
val result = delegate.processUsage(changeInfo, elementToWorkWith, allUsages)
- if (changeInfo.getNewParametersCount() == 0 && !isThisCall && !elementToWorkWith.isImplicit()) {
- (elementToWorkWith.getParent() as? KtSecondaryConstructor)?.getColon()?.delete()
+ if (changeInfo.getNewParametersCount() == 0 && !isThisCall && !elementToWorkWith.isImplicit) {
+ (elementToWorkWith.parent as? KtSecondaryConstructor)?.colon?.delete()
elementToWorkWith.replace(KtPsiFactory(element).creareDelegatedSuperTypeEntry(""))
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinEnumEntryWithoutSuperCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinEnumEntryWithoutSuperCallUsage.kt
index f3bf89f4df0..c7fbc4b687e 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinEnumEntryWithoutSuperCallUsage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinEnumEntryWithoutSuperCallUsage.kt
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.*
public class KotlinEnumEntryWithoutSuperCallUsage(enumEntry: KtEnumEntry) : KotlinUsageInfo(enumEntry) {
override fun processUsage(changeInfo: KotlinChangeInfo, element: KtEnumEntry, allUsages: Array): Boolean {
- if (changeInfo.newParameters.size() > 0) {
+ if (changeInfo.newParameters.size > 0) {
val psiFactory = KtPsiFactory(element)
val delegatorToSuperCall = (element.addAfter(
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinFunctionCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinFunctionCallUsage.kt
index 7398e32aa84..ae6adb7a49a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinFunctionCallUsage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinFunctionCallUsage.kt
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.core.moveFunctionLiteralOutsideParentheses
-import org.jetbrains.kotlin.idea.core.refactoring.replaceListPsiAndKeepDelimiters
+import org.jetbrains.kotlin.idea.refactoring.replaceListPsiAndKeepDelimiters
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinParameterInfo
import org.jetbrains.kotlin.idea.refactoring.changeSignature.isInsideOfCallerBody
@@ -461,15 +461,13 @@ class KotlinFunctionCallUsage(
}
companion object {
- private val REVERSED_TEXT_OFFSET_COMPARATOR = object : Comparator> {
- override fun compare(p1: Pair, p2: Pair): Int {
- val offset1 = p1.first.startOffset
- val offset2 = p2.first.startOffset
- return when {
- offset1 < offset2 -> 1
- offset1 > offset2 -> -1
- else -> 0
- }
+ private val REVERSED_TEXT_OFFSET_COMPARATOR = Comparator> { p1, p2 ->
+ val offset1 = p1.first.startOffset
+ val offset2 = p2.first.startOffset
+ when {
+ offset1 < offset2 -> 1
+ offset1 > offset2 -> -1
+ else -> 0
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinImplicitThisToParameterUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinImplicitThisToParameterUsage.kt
index 613010da1e4..7374a961506 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinImplicitThisToParameterUsage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinImplicitThisToParameterUsage.kt
@@ -34,8 +34,8 @@ public abstract class KotlinImplicitReceiverUsage(callElement: KtElement): Kotli
}
override fun processUsage(changeInfo: KotlinChangeInfo, element: KtElement, allUsages: Array): Boolean {
- val newQualifiedCall = KtPsiFactory(element.getProject()).createExpression(
- "${getNewReceiverText()}.${element.getText()}"
+ val newQualifiedCall = KtPsiFactory(element.project).createExpression(
+ "${getNewReceiverText()}.${element.text}"
) as KtQualifiedExpression
processReplacedElement(element.replace(newQualifiedCall) as KtElement)
return false
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinParameterUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinParameterUsage.kt
index 6cf635f521c..71d8c731886 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinParameterUsage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinParameterUsage.kt
@@ -17,17 +17,16 @@
package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages
import com.intellij.usageView.UsageInfo
-import org.jetbrains.kotlin.psi.KtSimpleNameExpression
-import org.jetbrains.kotlin.psi.KtPsiFactory
-import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo
-import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinParameterInfo
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
-import org.jetbrains.kotlin.psi.KtQualifiedExpression
-import org.jetbrains.kotlin.psi.KtElement
-import org.jetbrains.kotlin.psi.KtThisExpression
+import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo
+import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinParameterInfo
import org.jetbrains.kotlin.idea.util.ShortenReferences.Options
+import org.jetbrains.kotlin.psi.KtElement
+import org.jetbrains.kotlin.psi.KtPsiFactory
+import org.jetbrains.kotlin.psi.KtQualifiedExpression
+import org.jetbrains.kotlin.psi.KtThisExpression
// Explicit reference to function parameter or outer this
public abstract class KotlinExplicitReferenceUsage(element: T) : KotlinUsageInfo(element) {
@@ -38,8 +37,8 @@ public abstract class KotlinExplicitReferenceUsage(element: T) :
}
override fun processUsage(changeInfo: KotlinChangeInfo, element: T, allUsages: Array): Boolean {
- val newElement = KtPsiFactory(element.getProject()).createExpression(getReplacementText(changeInfo))
- val elementToReplace = (element.getParent() as? KtThisExpression) ?: element
+ val newElement = KtPsiFactory(element.project).createExpression(getReplacementText(changeInfo))
+ val elementToReplace = (element.parent as? KtThisExpression) ?: element
processReplacedElement(elementToReplace.replace(newElement) as KtElement)
return false
}
@@ -51,15 +50,15 @@ public class KotlinParameterUsage(
val containingCallable: KotlinCallableDefinitionUsage<*>
) : KotlinExplicitReferenceUsage(element) {
override fun processReplacedElement(element: KtElement) {
- val qualifiedExpression = element.getParent() as? KtQualifiedExpression
- val elementToShorten = if (qualifiedExpression?.getReceiverExpression() == element) qualifiedExpression!! else element
+ val qualifiedExpression = element.parent as? KtQualifiedExpression
+ val elementToShorten = if (qualifiedExpression?.receiverExpression == element) qualifiedExpression!! else element
elementToShorten.addToShorteningWaitSet(Options(removeThis = true, removeThisLabels = true))
}
override fun getReplacementText(changeInfo: KotlinChangeInfo): String {
if (changeInfo.receiverParameterInfo != parameterInfo) return parameterInfo.getInheritedName(containingCallable)
- val newName = changeInfo.getNewName()
+ val newName = changeInfo.newName
if (KotlinNameSuggester.isIdentifier(newName)) return "this@$newName"
return "this"
@@ -74,5 +73,5 @@ public class KotlinNonQualifiedOuterThisUsage(
element.addToShorteningWaitSet(Options(removeThisLabels = true))
}
- override fun getReplacementText(changeInfo: KotlinChangeInfo): String = "this@${targetDescriptor.getName().asString()}"
+ override fun getReplacementText(changeInfo: KotlinChangeInfo): String = "this@${targetDescriptor.name.asString()}"
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinPropertyCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinPropertyCallUsage.kt
index 3595a61ebb0..8b6c578c5da 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinPropertyCallUsage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinPropertyCallUsage.kt
@@ -38,8 +38,8 @@ public class KotlinPropertyCallUsage(element: KtSimpleNameExpression): KotlinUsa
}
private fun updateName(changeInfo: KotlinChangeInfo, element: KtSimpleNameExpression) {
- if (changeInfo.isNameChanged()) {
- element.mainReference.handleElementRename(changeInfo.getNewName())
+ if (changeInfo.isNameChanged) {
+ element.mainReference.handleElementRename(changeInfo.newName)
}
}
@@ -53,10 +53,10 @@ public class KotlinPropertyCallUsage(element: KtSimpleNameExpression): KotlinUsa
// Do not add extension receiver to calls with explicit dispatch receiver
if (newReceiver != null
&& elementToReplace is KtQualifiedExpression
- && resolvedCall?.getDispatchReceiver() is ExpressionReceiver) return
+ && resolvedCall?.dispatchReceiver is ExpressionReceiver) return
val replacingElement = newReceiver?.let {
- val psiFactory = KtPsiFactory(getProject())
+ val psiFactory = KtPsiFactory(project)
val receiver = it.defaultValueForCall ?: psiFactory.createExpression("_")
psiFactory.createExpressionByPattern("$0.$1", receiver, element)
} ?: element
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt
index a1c3559cc11..d59681833cb 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt
@@ -25,11 +25,9 @@ public class KotlinWrapperForJavaUsageInfos(
val javaUsageInfos: Array,
val primaryMethod: PsiElement
): UsageInfo(primaryMethod) {
- override fun hashCode(): Int {
- return javaChangeInfo.getMethod().hashCode();
- }
+ override fun hashCode() = javaChangeInfo.method.hashCode()
override fun equals(other: Any?): Boolean {
- return other === this || (other is KotlinWrapperForJavaUsageInfos && javaChangeInfo.getMethod() == other.javaChangeInfo.getMethod())
+ return other === this || (other is KotlinWrapperForJavaUsageInfos && javaChangeInfo.method == other.javaChangeInfo.method)
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt
index b6358bff2aa..e5f44728c9c 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt
@@ -27,7 +27,7 @@ public class CopyKotlinFileHandler : CopyHandlerDelegateBase() {
private fun adjustElements(elements: Array): Array? {
return elements
- .map { it.getContainingFile() as? KtFile ?: return null }
+ .map { it.containingFile as? KtFile ?: return null }
.toTypedArray()
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt
index d743d9db794..4337ffc5e59 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt
@@ -41,9 +41,9 @@ import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.codeInsight.shorten.performDelayedShortening
-import org.jetbrains.kotlin.idea.core.refactoring.addTypeArgumentsIfNeeded
-import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively
-import org.jetbrains.kotlin.idea.core.refactoring.getQualifiedTypeArgumentList
+import org.jetbrains.kotlin.idea.refactoring.addTypeArgumentsIfNeeded
+import org.jetbrains.kotlin.idea.refactoring.checkConflictsInteractively
+import org.jetbrains.kotlin.idea.refactoring.getQualifiedTypeArgumentList
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.refactoring.move.PackageNameInfo
import org.jetbrains.kotlin.idea.refactoring.move.lazilyProcessInternalReferencesToUpdateOnPackageNameChange
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt
index efd4be75395..072bf961d19 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt
@@ -40,11 +40,11 @@ public abstract class AbstractKotlinInplaceIntroducer(
editor: Editor
): AbstractInplaceIntroducer(project, editor, expression, localVariable, occurrences, title, KotlinFileType.INSTANCE) {
protected fun initFormComponents(init: FormBuilder.() -> Unit) {
- myWholePanel.setLayout(BorderLayout())
+ myWholePanel.layout = BorderLayout()
with(FormBuilder.createFormBuilder()) {
init()
- myWholePanel.add(getPanel(), BorderLayout.CENTER)
+ myWholePanel.add(panel, BorderLayout.CENTER)
}
}
@@ -52,7 +52,7 @@ public abstract class AbstractKotlinInplaceIntroducer(
myEditor.putUserData(InplaceRefactoring.INTRODUCE_RESTART, true)
try {
stopIntroduce(myEditor)
- myProject.executeWriteCommand(getCommandName(), getCommandName(), action)
+ myProject.executeWriteCommand(commandName, commandName, action)
// myExprMarker was invalidated by stopIntroduce()
myExprMarker = myExpr?.let { createMarker(it) }
startInplaceIntroduceTemplate()
@@ -70,7 +70,7 @@ public abstract class AbstractKotlinInplaceIntroducer(
marker: RangeMarker,
exprText: String?
): KtExpression? {
- if (exprText == null || !declaration.isValid()) return null
+ if (exprText == null || !declaration.isValid) return null
val leaf = containingFile.findElementAt(marker.startOffset) ?: return null
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceHandlerBase.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceHandlerBase.java
deleted file mode 100644
index 5dffac3ade8..00000000000
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceHandlerBase.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.RefactoringActionHandler;
-
-public abstract class KotlinIntroduceHandlerBase implements RefactoringActionHandler {
-}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt
index 84bd13fc8ac..bce93401409 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt
@@ -22,7 +22,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.refactoring.RefactoringActionHandler
-import org.jetbrains.kotlin.idea.core.refactoring.getExtractionContainers
+import org.jetbrains.kotlin.idea.refactoring.getExtractionContainers
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
import org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ui.KotlinExtractFunctionDialog
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.*
@@ -44,7 +44,7 @@ public class ExtractKotlinFunctionHandler(
onFinish: (ExtractionResult) -> Unit
) {
KotlinExtractFunctionDialog(descriptorWithConflicts.descriptor.extractionData.project, descriptorWithConflicts) {
- doRefactor(it.getCurrentConfiguration(), onFinish)
+ doRefactor(it.currentConfiguration, onFinish)
}.show()
}
}
@@ -55,10 +55,10 @@ public class ExtractKotlinFunctionHandler(
elements: List,
targetSibling: PsiElement
) {
- val adjustedElements = (elements.singleOrNull() as? KtBlockExpression)?.getStatements() ?: elements
+ val adjustedElements = (elements.singleOrNull() as? KtBlockExpression)?.statements ?: elements
val extractionData = ExtractionData(file, adjustedElements.toRange(false), targetSibling)
ExtractionEngine(helper).run(editor, extractionData) {
- processDuplicates(it.duplicateReplacers, file.getProject(), editor)
+ processDuplicates(it.duplicateReplacers, file.project, editor)
}
}
@@ -67,7 +67,7 @@ public class ExtractKotlinFunctionHandler(
EXTRACT_FUNCTION,
editor,
file,
- { elements, parent -> parent.getExtractionContainers(elements.size() == 1, allContainersEnabled) },
+ { elements, parent -> parent.getExtractionContainers(elements.size == 1, allContainersEnabled) },
continuation
)
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java
index b2c59193d85..32f40d8ef92 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java
@@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KotlinFileType;
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester;
-import org.jetbrains.kotlin.idea.core.refactoring.JetRefactoringUtilKt;
+import org.jetbrains.kotlin.idea.refactoring.JetRefactoringUtilKt;
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle;
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.*;
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
@@ -101,9 +101,9 @@ public class KotlinExtractFunctionDialog extends DialogWrapper {
}
private boolean checkNames() {
- if (!KotlinNameSuggester.INSTANCE$.isIdentifier(getFunctionName())) return false;
+ if (!KotlinNameSuggester.INSTANCE.isIdentifier(getFunctionName())) return false;
for (KotlinParameterTablePanel.ParameterInfo parameterInfo : parameterTablePanel.getParameterInfos()) {
- if (!KotlinNameSuggester.INSTANCE$.isIdentifier(parameterInfo.getName())) return false;
+ if (!KotlinNameSuggester.INSTANCE.isIdentifier(parameterInfo.getName())) return false;
}
return true;
}
@@ -227,7 +227,7 @@ public class KotlinExtractFunctionDialog extends DialogWrapper {
@Override
public Unit invoke() {
close(OK_EXIT_CODE);
- return Unit.INSTANCE$;
+ return Unit.INSTANCE;
}
},
new Function0() {
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinParameterTablePanel.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinParameterTablePanel.java
index 86f3c7b2cbc..2bb6e81afa2 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinParameterTablePanel.java
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinParameterTablePanel.java
@@ -25,7 +25,7 @@ import com.intellij.ui.table.JBTable;
import com.intellij.util.Function;
import com.intellij.util.ui.AbstractTableCellEditor;
import com.intellij.util.ui.EditableModel;
-import kotlin.CollectionsKt;
+import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -110,7 +110,9 @@ public class KotlinParameterTablePanel extends JPanel {
public void init(@Nullable Parameter receiver, @NotNull List parameters) {
parameterInfos = CollectionsKt.mapTo(
parameters,
- receiver != null ? CollectionsKt.arrayListOf(new ParameterInfo(receiver, true)) : new ArrayList(),
+ receiver != null
+ ? CollectionsKt.arrayListOf(new ParameterInfo(receiver, true))
+ : new ArrayList(),
new Function1() {
@Override
public ParameterInfo invoke(Parameter parameter) {
@@ -345,7 +347,7 @@ public class KotlinParameterTablePanel extends JPanel {
}
case PARAMETER_NAME_COLUMN: {
String name = (String) aValue;
- if (KotlinNameSuggester.INSTANCE$.isIdentifier(name)) {
+ if (KotlinNameSuggester.INSTANCE.isIdentifier(name)) {
info.setName(name);
}
updateSignature();
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt
index 8e60a27c947..24f3a3bcce7 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt
@@ -28,8 +28,6 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
-import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.ErrorMessage
-import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.Status
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputValue.*
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference.ShorteningMode
import org.jetbrains.kotlin.idea.references.mainReference
@@ -85,10 +83,10 @@ class RenameReplacement(override val parameter: Parameter): ParameterReplacement
override fun copy(parameter: Parameter) = RenameReplacement(parameter)
override fun invoke(descriptor: ExtractableCodeDescriptor, e: KtElement): KtElement {
- var expressionToReplace = (e.getParent() as? KtThisExpression ?: e).let { it.getQualifiedExpressionForSelector() ?: it }
+ var expressionToReplace = (e.parent as? KtThisExpression ?: e).let { it.getQualifiedExpressionForSelector() ?: it }
val parameterName = KtPsiUtil.unquoteIdentifier(parameter.nameForRef)
val replacingName =
- if (e.getText().startsWith('`') || !KotlinNameSuggester.isIdentifier(parameterName)) "`$parameterName`" else parameterName
+ if (e.text.startsWith('`') || !KotlinNameSuggester.isIdentifier(parameterName)) "`$parameterName`" else parameterName
val psiFactory = KtPsiFactory(e)
val replacement = when {
parameter == descriptor.receiverParameter -> psiFactory.createExpression("this")
@@ -137,13 +135,13 @@ class AddPrefixReplacement(override val parameter: Parameter): ParameterReplacem
class FqNameReplacement(val fqName: FqName): Replacement {
override fun invoke(descriptor: ExtractableCodeDescriptor, e: KtElement): KtElement {
- val thisExpr = e.getParent() as? KtThisExpression
+ val thisExpr = e.parent as? KtThisExpression
if (thisExpr != null) {
return thisExpr.replaced(KtPsiFactory(e).createExpression(fqName.asString())).getQualifiedElementSelector()!!
}
val newExpr = (e as? KtSimpleNameExpression)?.mainReference?.bindToFqName(fqName, ShorteningMode.NO_SHORTENING) as KtElement
- return if (newExpr is KtQualifiedExpression) newExpr.getSelectorExpression()!! else newExpr
+ return if (newExpr is KtQualifiedExpression) newExpr.selectorExpression!! else newExpr
}
}
@@ -201,11 +199,11 @@ abstract class OutputValueBoxer(val outputValues: List) {
protected fun extractArgumentExpressionByIndex(boxedExpression: KtExpression, index: Int): KtExpression? {
val call: KtCallExpression? = when (boxedExpression) {
is KtCallExpression -> boxedExpression
- is KtQualifiedExpression -> boxedExpression.getSelectorExpression() as? KtCallExpression
+ is KtQualifiedExpression -> boxedExpression.selectorExpression as? KtCallExpression
else -> null
}
- val arguments = call?.getValueArguments()
- if (arguments == null || arguments.size() <= index) return null
+ val arguments = call?.valueArguments
+ if (arguments == null || arguments.size <= index) return null
return arguments[index].getArgumentExpression()
}
@@ -224,7 +222,7 @@ abstract class OutputValueBoxer(val outputValues: List) {
val module: ModuleDescriptor
) : OutputValueBoxer(outputValues) {
init {
- assert(outputValues.size() <= 3) { "At most 3 output values are supported" }
+ assert(outputValues.size <= 3) { "At most 3 output values are supported" }
}
companion object {
@@ -233,7 +231,7 @@ abstract class OutputValueBoxer(val outputValues: List) {
override val returnType: KotlinType by lazy {
fun getType(): KotlinType {
- val boxingClass = when (outputValues.size()) {
+ val boxingClass = when (outputValues.size) {
1 -> return outputValues.first().valueType
2 -> module.resolveTopLevelClass(FqName("kotlin.Pair"), NoLookupLocation.FROM_IDE)!!
3 -> module.resolveTopLevelClass(FqName("kotlin.Triple"), NoLookupLocation.FROM_IDE)!!
@@ -245,7 +243,7 @@ abstract class OutputValueBoxer(val outputValues: List) {
getType()
}
- override val boxingRequired: Boolean = outputValues.size() > 1
+ override val boxingRequired: Boolean = outputValues.size > 1
override fun getBoxingExpressionPattern(arguments: List): String? {
return when (arguments.size) {
@@ -259,12 +257,12 @@ abstract class OutputValueBoxer(val outputValues: List) {
}
override fun extractExpressionByIndex(boxedExpression: KtExpression, index: Int): KtExpression? {
- if (outputValues.size() == 1) return boxedExpression
+ if (outputValues.size == 1) return boxedExpression
return extractArgumentExpressionByIndex(boxedExpression, index)
}
override fun getUnboxingExpressions(boxedText: String): Map {
- return when (outputValues.size()) {
+ return when (outputValues.size) {
0 -> Collections.emptyMap()
1 -> Collections.singletonMap(outputValues.first(), boxedText)
else -> {
@@ -285,7 +283,7 @@ abstract class OutputValueBoxer(val outputValues: List) {
)
}
- override val boxingRequired: Boolean = outputValues.size() > 0
+ override val boxingRequired: Boolean = outputValues.size > 0
override fun getBoxingExpressionPattern(arguments: List): String? {
if (arguments.isEmpty()) return null
@@ -311,15 +309,15 @@ data class ControlFlow(
val outputValueBoxer = boxerFactory(outputValues)
val defaultOutputValue: ExpressionValue? = with(outputValues.filterIsInstance()) {
- if (size() > 1) throw IllegalArgumentException("Multiple expression values: ${outputValues.joinToString()}") else firstOrNull()
+ if (size > 1) throw IllegalArgumentException("Multiple expression values: ${outputValues.joinToString()}") else firstOrNull()
}
val jumpOutputValue: Jump? = with(outputValues.filterIsInstance()) {
- val jumpCount = size()
+ val jumpCount = size
when {
isEmpty() ->
null
- outputValues.size() > jumpCount || jumpCount > 1 ->
+ outputValues.size > jumpCount || jumpCount > 1 ->
throw IllegalArgumentException("Jump values must be the only value if it's present: ${outputValues.joinToString()}")
else ->
first()
@@ -336,7 +334,7 @@ val ControlFlow.possibleReturnTypes: List
returnType.isAnnotatedNotNull() || returnType.isAnnotatedNullable() ->
listOf(approximateFlexibleTypes(returnType))
else ->
- returnType.getCapability(javaClass()).let { listOf(it!!.upperBound, it.lowerBound) }
+ returnType.getCapability(Flexibility::class.java).let { listOf(it!!.upperBound, it.lowerBound) }
}
}
@@ -457,7 +455,7 @@ enum class ExtractionTarget(val targetName: String) {
if (!descriptor.parameters.isEmpty()) return false
if (descriptor.returnType.isUnit()) return false
- val parent = descriptor.extractionData.targetSibling.getParent()
+ val parent = descriptor.extractionData.targetSibling.parent
return (parent is KtFile || parent is KtClassBody)
}
}
@@ -476,7 +474,7 @@ data class ExtractionGeneratorOptions(
val delayInitialOccurrenceReplacement: Boolean = false
) {
companion object {
- val DEFAULT = ExtractionGeneratorOptions()
+ @JvmField val DEFAULT = ExtractionGeneratorOptions()
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt
index 3fd11b3f8fd..37c93788dbc 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.codeInsight.KotlinFileReferencesResolver
import org.jetbrains.kotlin.idea.core.compareDescriptors
-import org.jetbrains.kotlin.idea.core.refactoring.getContextForContainingDeclarationBody
+import org.jetbrains.kotlin.idea.refactoring.getContextForContainingDeclarationBody
import org.jetbrains.kotlin.idea.refactoring.introduce.ExtractableSubstringInfo
import org.jetbrains.kotlin.idea.refactoring.introduce.extractableSubstringInfo
import org.jetbrains.kotlin.idea.refactoring.introduce.substringContextOrThis
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt
index 01b2de5ea14..43852e62634 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt
@@ -24,7 +24,7 @@ import com.intellij.openapi.ui.popup.Balloon
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.refactoring.BaseRefactoringProcessor
import com.intellij.ui.awt.RelativePoint
-import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively
+import org.jetbrains.kotlin.idea.refactoring.checkConflictsInteractively
import org.jetbrains.kotlin.idea.refactoring.introduce.showErrorHint
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import javax.swing.event.HyperlinkEvent
@@ -56,7 +56,7 @@ public class ExtractionEngine(
val analysisResult = helper.adjustExtractionData(extractionData).performAnalysis()
- if (ApplicationManager.getApplication()!!.isUnitTestMode() && analysisResult.status != AnalysisResult.Status.SUCCESS) {
+ if (ApplicationManager.getApplication()!!.isUnitTestMode && analysisResult.status != AnalysisResult.Status.SUCCESS) {
throw BaseRefactoringProcessor.ConflictsInTestsException(analysisResult.messages.map { it.renderMessage() })
}
@@ -83,15 +83,15 @@ public class ExtractionEngine(
AnalysisResult.Status.NON_CRITICAL_ERROR -> {
val anchorPoint = RelativePoint(
- editor.getContentComponent(),
- editor.visualPositionToXY(editor.getSelectionModel().getSelectionStartPosition()!!)
+ editor.contentComponent,
+ editor.visualPositionToXY(editor.selectionModel.selectionStartPosition!!)
)
JBPopupFactory.getInstance()!!
.createHtmlTextBalloonBuilder(
"$message
Proceed with extraction",
MessageType.WARNING,
{ event ->
- if (event?.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ if (event?.eventType == HyperlinkEvent.EventType.ACTIVATED) {
validateAndRefactor()
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt
index acc7aaea279..fbf23a4eebf 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt
@@ -40,24 +40,24 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.getPhysicalTextRange
public fun KotlinPsiRange.highlight(project: Project, editor: Editor): RangeHighlighter? {
val textRange = getPhysicalTextRange()
val highlighters = ArrayList()
- val attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)!!
+ val attributes = EditorColorsManager.getInstance().globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)!!
HighlightManager.getInstance(project).addRangeHighlight(
- editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, highlighters
+ editor, textRange.startOffset, textRange.endOffset, attributes, true, highlighters
)
return highlighters.firstOrNull()
}
public fun KotlinPsiRange.preview(project: Project, editor: Editor): RangeHighlighter? {
return highlight(project, editor)?.let {
- val startOffset = getPhysicalTextRange().getStartOffset()
+ val startOffset = getPhysicalTextRange().startOffset
val foldedRegions =
CodeFoldingManager.getInstance(project)
.getFoldRegionsAtOffset(editor, startOffset)
- .filter { !it.isExpanded() }
+ .filter { !it.isExpanded }
if (!foldedRegions.isEmpty()) {
- editor.getFoldingModel().runBatchFoldingOperation { foldedRegions.forEach { it.setExpanded(true) } }
+ editor.foldingModel.runBatchFoldingOperation { foldedRegions.forEach { it.isExpanded = true } }
}
- editor.getScrollingModel().scrollTo(editor.offsetToLogicalPosition(startOffset), ScrollType.MAKE_VISIBLE)
+ editor.scrollingModel.scrollTo(editor.offsetToLogicalPosition(startOffset), ScrollType.MAKE_VISIBLE)
it
}
@@ -68,22 +68,22 @@ public fun processDuplicates(
project: Project,
editor: Editor
) {
- val size = duplicateReplacers.size()
+ val size = duplicateReplacers.size
if (size == 0) return
if (size == 1) {
- duplicateReplacers.keySet().first().preview(project, editor)
+ duplicateReplacers.keys.first().preview(project, editor)
}
- val answer = if (ApplicationManager.getApplication()!!.isUnitTestMode())
+ val answer = if (ApplicationManager.getApplication()!!.isUnitTestMode)
Messages.YES
else
Messages.showYesNoDialog(
project,
KotlinRefactoringBundle.message(
"0.has.detected.1.code.fragments.in.this.file.that.can.be.replaced.with.a.call.to.extracted.declaration",
- ApplicationNamesInfo.getInstance().getProductName(),
- duplicateReplacers.size()
+ ApplicationNamesInfo.getInstance().productName,
+ duplicateReplacers.size
),
"Process Duplicates",
Messages.getQuestionIcon()
@@ -93,16 +93,16 @@ public fun processDuplicates(
var showAll = false
duplicateReplacersLoop@
- for ((i, entry) in duplicateReplacers.entrySet().withIndex()) {
+ for ((i, entry) in duplicateReplacers.entries.withIndex()) {
val (pattern, replacer) = entry
if (!pattern.isValid()) continue
val highlighter = pattern.preview(project, editor)
- if (!ApplicationManager.getApplication()!!.isUnitTestMode()) {
+ if (!ApplicationManager.getApplication()!!.isUnitTestMode) {
if (size > 1 && !showAll) {
val promptDialog = ReplacePromptDialog(false, RefactoringBundle.message("process.duplicates.title", i + 1, size), project)
promptDialog.show()
- when(promptDialog.getExitCode()) {
+ when(promptDialog.exitCode) {
FindManager.PromptResult.ALL -> showAll = true
FindManager.PromptResult.SKIP -> continue@duplicateReplacersLoop
FindManager.PromptResult.CANCEL -> return
@@ -117,6 +117,6 @@ public fun processDuplicates(
public fun processDuplicatesSilently(duplicateReplacers: Map Unit>, project: Project) {
project.executeWriteCommand(MethodDuplicatesHandler.REFACTORING_NAME) {
- duplicateReplacers.values().forEach { it() }
+ duplicateReplacers.values.forEach { it() }
}
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt
index c272724a0c9..ff5c2656c5a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt
@@ -45,7 +45,7 @@ import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.core.NewDeclarationNameValidator
import org.jetbrains.kotlin.idea.core.compareDescriptors
-import org.jetbrains.kotlin.idea.core.refactoring.createTempCopy
+import org.jetbrains.kotlin.idea.refactoring.createTempCopy
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.ErrorMessage
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.Status
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt
index bb2cf75b98f..d78b057935a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt
@@ -25,8 +25,8 @@ import com.intellij.refactoring.BaseRefactoringProcessor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.core.*
-import org.jetbrains.kotlin.idea.core.refactoring.isMultiLine
-import org.jetbrains.kotlin.idea.core.refactoring.removeTemplateEntryBracesIfPossible
+import org.jetbrains.kotlin.idea.refactoring.isMultiLine
+import org.jetbrains.kotlin.idea.refactoring.removeTemplateEntryBracesIfPossible
import org.jetbrains.kotlin.idea.intentions.ConvertToExpressionBodyIntention
import org.jetbrains.kotlin.idea.intentions.InfixCallToOrdinaryIntention
import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt
index 57889188221..fcdb9daaf55 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt
@@ -30,7 +30,7 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import com.intellij.ui.JBColor
import com.intellij.ui.NonFocusableCheckBox
-import org.jetbrains.kotlin.idea.core.refactoring.createPrimaryConstructorParameterListIfAbsent
+import org.jetbrains.kotlin.idea.refactoring.createPrimaryConstructorParameterListIfAbsent
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinValVar
import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractKotlinInplaceIntroducer
import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinInplaceVariableIntroducer
@@ -65,22 +65,22 @@ public class KotlinInplaceParameterIntroducer(
editor
) {
companion object {
- private val LOG = Logger.getInstance(javaClass())
+ private val LOG = Logger.getInstance(KotlinInplaceParameterIntroducer::class.java)
}
enum class PreviewDecorator {
FOR_ADD() {
override val textAttributes: TextAttributes = with(TextAttributes()) {
- setEffectType(EffectType.ROUNDED_BOX)
- setEffectColor(JBColor.RED)
+ effectType = EffectType.ROUNDED_BOX
+ effectColor = JBColor.RED
this
}
},
FOR_REMOVAL() {
override val textAttributes: TextAttributes = with(TextAttributes()) {
- setEffectType(EffectType.STRIKEOUT)
- setEffectColor(Color.BLACK)
+ effectType = EffectType.STRIKEOUT
+ effectColor = Color.BLACK
this
}
};
@@ -88,8 +88,8 @@ public class KotlinInplaceParameterIntroducer(
protected abstract val textAttributes: TextAttributes
fun applyToRange(range: TextRange, markupModel: MarkupModel) {
- markupModel.addRangeHighlighter(range.getStartOffset(),
- range.getEndOffset(),
+ markupModel.addRangeHighlighter(range.startOffset,
+ range.endOffset,
0,
textAttributes,
HighlighterTargetArea.EXACT_RANGE
@@ -110,23 +110,23 @@ public class KotlinInplaceParameterIntroducer(
init {
val templateState = TemplateManagerImpl.getTemplateState(myEditor)
- val currentType = if (templateState != null && templateState.getTemplate() != null) {
+ val currentType = if (templateState != null && templateState.template != null) {
templateState
.getVariableValue(KotlinInplaceVariableIntroducer.TYPE_REFERENCE_VARIABLE_NAME)
- ?.getText()
+ ?.text
} else null
val builder = StringBuilder()
with(descriptor) {
- (callable as? KtFunction)?.getReceiverTypeReference()?.let { receiverTypeRef ->
- builder.append(receiverTypeRef.getText()).append('.')
+ (callable as? KtFunction)?.receiverTypeReference?.let { receiverTypeRef ->
+ builder.append(receiverTypeRef.text).append('.')
if (!descriptor.withDefaultValue && receiverTypeRef in parametersToRemove) {
- _rangesToRemove.add(TextRange(0, builder.length()))
+ _rangesToRemove.add(TextRange(0, builder.length))
}
}
- builder.append(callable.getName())
+ builder.append(callable.name)
val parameters = callable.getValueParameters()
builder.append("(")
@@ -134,8 +134,8 @@ public class KotlinInplaceParameterIntroducer(
val parameter = parameters[i]
val parameterText = if (parameter == addedParameter){
- val parameterName = currentName ?: parameter.getName()
- val parameterType = currentType ?: parameter.getTypeReference()!!.getText()
+ val parameterName = currentName ?: parameter.name
+ val parameterType = currentType ?: parameter.typeReference!!.text
descriptor = descriptor.copy(newParameterName = parameterName!!, newParameterTypeText = parameterType)
val modifier = if (valVar != KotlinValVar.None) "${valVar.keywordName} " else ""
val defaultValue = if (withDefaultValue) {
@@ -144,11 +144,11 @@ public class KotlinInplaceParameterIntroducer(
"$modifier$parameterName: $parameterType$defaultValue"
}
- else parameter.getText()
+ else parameter.text
builder.append(parameterText)
- val range = TextRange(builder.length() - parameterText.length(), builder.length())
+ val range = TextRange(builder.length - parameterText.length, builder.length)
if (parameter == addedParameter) {
addedRange = range
}
@@ -176,21 +176,21 @@ public class KotlinInplaceParameterIntroducer(
init {
initFormComponents {
- addComponent(getPreviewComponent())
+ addComponent(previewComponent)
val defaultValueCheckBox = NonFocusableCheckBox("Introduce default value")
- defaultValueCheckBox.setSelected(descriptor.withDefaultValue)
+ defaultValueCheckBox.isSelected = descriptor.withDefaultValue
defaultValueCheckBox.setMnemonic('d')
defaultValueCheckBox.addActionListener {
- descriptor = descriptor.copy(withDefaultValue = defaultValueCheckBox.isSelected())
- updateTitle(getVariable())
+ descriptor = descriptor.copy(withDefaultValue = defaultValueCheckBox.isSelected)
+ updateTitle(variable)
}
addComponent(defaultValueCheckBox)
- val occurrenceCount = descriptor.occurrencesToReplace.size()
+ val occurrenceCount = descriptor.occurrencesToReplace.size
if (occurrenceCount > 1) {
val replaceAllCheckBox = NonFocusableCheckBox("Replace all occurrences ($occurrenceCount)")
- replaceAllCheckBox.setSelected(true)
+ replaceAllCheckBox.isSelected = true
replaceAllCheckBox.setMnemonic('R')
addComponent(replaceAllCheckBox)
this@KotlinInplaceParameterIntroducer.replaceAllCheckBox = replaceAllCheckBox
@@ -218,15 +218,15 @@ public class KotlinInplaceParameterIntroducer(
}
override fun deleteTemplateField(psiField: KtParameter) {
- if (psiField.isValid()) {
- (psiField.getParent() as? KtParameterList)?.removeParameter(psiField)
+ if (psiField.isValid) {
+ (psiField.parent as? KtParameterList)?.removeParameter(psiField)
}
}
- override fun isReplaceAllOccurrences() = replaceAllCheckBox?.isSelected() ?: true
+ override fun isReplaceAllOccurrences() = replaceAllCheckBox?.isSelected ?: true
override fun setReplaceAllOccurrences(allOccurrences: Boolean) {
- replaceAllCheckBox?.setSelected(allOccurrences)
+ replaceAllCheckBox?.isSelected = allOccurrences
}
override fun getComponent() = myWholePanel
@@ -234,7 +234,7 @@ public class KotlinInplaceParameterIntroducer(
override fun updateTitle(addedParameter: KtParameter?, currentName: String?) {
val preview = Preview(addedParameter, currentName)
- val document = getPreviewEditor().getDocument()
+ val document = previewEditor.document
runWriteAction { document.setText(preview.text) }
val markupModel = DocumentMarkupModel.forDocument(document, myProject, true)
@@ -255,15 +255,15 @@ public class KotlinInplaceParameterIntroducer(
}
override fun performIntroduce() {
- getDescriptorToRefactor(isReplaceAllOccurrences()).performRefactoring()
+ getDescriptorToRefactor(isReplaceAllOccurrences).performRefactoring()
}
private fun getDescriptorToRefactor(replaceAll: Boolean): IntroduceParameterDescriptor {
- val originalRange = getExpr().toRange()
+ val originalRange = expr.toRange()
return descriptor.copy(
originalRange = originalRange,
- occurrencesToReplace = if (replaceAll) getOccurrences().map { it.toRange() } else originalRange.singletonList(),
- argumentValue = getExpr()!!
+ occurrencesToReplace = if (replaceAll) occurrences.map { it.toRange() } else originalRange.singletonList(),
+ argumentValue = expr!!
)
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt
index 298ed38d12b..b61b9a248e3 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt
@@ -27,9 +27,9 @@ import com.intellij.ui.NonFocusableCheckBox
import com.intellij.usageView.BaseUsageViewDescriptor
import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.idea.KotlinFileType
-import org.jetbrains.kotlin.idea.core.refactoring.isMultiLine
-import org.jetbrains.kotlin.idea.core.refactoring.runRefactoringWithPostprocessing
-import org.jetbrains.kotlin.idea.core.refactoring.validateElement
+import org.jetbrains.kotlin.idea.refactoring.isMultiLine
+import org.jetbrains.kotlin.idea.refactoring.runRefactoringWithPostprocessing
+import org.jetbrains.kotlin.idea.refactoring.validateElement
import org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ui.KotlinExtractFunctionDialog
import org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ui.KotlinParameterTablePanel
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.*
@@ -86,25 +86,25 @@ public class KotlinIntroduceParameterDialog private constructor(
private val typeField = NameSuggestionsField(typeNameSuggestions, project, KotlinFileType.INSTANCE)
private var replaceAllCheckBox: JCheckBox? = null
private var defaultValueCheckBox: JCheckBox? = null
- private val removeParamsCheckBoxes = LinkedHashMap(descriptor.parametersToRemove.size())
+ private val removeParamsCheckBoxes = LinkedHashMap(descriptor.parametersToRemove.size)
private var parameterTablePanel: KotlinParameterTablePanel? = null
private val commandName = if (lambdaExtractionDescriptor != null) INTRODUCE_LAMBDA_PARAMETER else INTRODUCE_PARAMETER
init {
- setTitle(commandName)
+ title = commandName
init()
nameField.addDataChangedListener { validateButtons() }
typeField.addDataChangedListener { validateButtons() }
}
- override fun getPreferredFocusedComponent() = nameField.getFocusableComponent()
+ override fun getPreferredFocusedComponent() = nameField.focusableComponent
private fun updateRemoveParamCheckBoxes() {
- val enableParamRemove = (replaceAllCheckBox?.isSelected() ?: true) && (!defaultValueCheckBox!!.isSelected())
- removeParamsCheckBoxes.keySet().forEach {
- it.setEnabled(enableParamRemove)
- it.setSelected(enableParamRemove)
+ val enableParamRemove = (replaceAllCheckBox?.isSelected ?: true) && (!defaultValueCheckBox!!.isSelected)
+ removeParamsCheckBoxes.keys.forEach {
+ it.isEnabled = enableParamRemove
+ it.isSelected = enableParamRemove
}
}
@@ -124,7 +124,7 @@ public class KotlinIntroduceParameterDialog private constructor(
gbConstraints.gridy = 0
val nameLabel = JLabel("Parameter name: ")
nameLabel.setDisplayedMnemonic('n')
- nameLabel.setLabelFor(nameField)
+ nameLabel.labelFor = nameField
panel.add(nameLabel, gbConstraints)
gbConstraints.insets = Insets(4, 4, 4, 8)
@@ -141,7 +141,7 @@ public class KotlinIntroduceParameterDialog private constructor(
gbConstraints.fill = GridBagConstraints.NONE
val typeLabel = JLabel(if (lambdaExtractionDescriptor != null) "Lambda return type" else "Parameter type: ")
typeLabel.setDisplayedMnemonic('t')
- typeLabel.setLabelFor(typeField)
+ typeLabel.labelFor = typeField
panel.add(typeLabel, gbConstraints)
gbConstraints.gridx++
@@ -171,7 +171,7 @@ public class KotlinIntroduceParameterDialog private constructor(
gbConstraints.fill = GridBagConstraints.NONE
val parametersLabel = JLabel("Lambda parameters: ")
parametersLabel.setDisplayedMnemonic('p')
- parametersLabel.setLabelFor(parameterTablePanel)
+ parametersLabel.labelFor = parameterTablePanel
panel.add(parametersLabel, gbConstraints)
gbConstraints.gridx++
@@ -190,19 +190,19 @@ public class KotlinIntroduceParameterDialog private constructor(
gbConstraints.gridy++
val defaultValueCheckBox = NonFocusableCheckBox("Introduce default value")
- defaultValueCheckBox.setSelected(descriptor.withDefaultValue)
+ defaultValueCheckBox.isSelected = descriptor.withDefaultValue
defaultValueCheckBox.setMnemonic('d')
defaultValueCheckBox.addActionListener { updateRemoveParamCheckBoxes() }
panel.add(defaultValueCheckBox, gbConstraints)
this.defaultValueCheckBox = defaultValueCheckBox
- val occurrenceCount = descriptor.occurrencesToReplace.size()
+ val occurrenceCount = descriptor.occurrencesToReplace.size
if (occurrenceCount > 1) {
gbConstraints.gridy++
val replaceAllCheckBox = NonFocusableCheckBox("Replace all occurrences ($occurrenceCount)")
- replaceAllCheckBox.setSelected(true)
+ replaceAllCheckBox.isSelected = true
replaceAllCheckBox.setMnemonic('R')
replaceAllCheckBox.addActionListener { updateRemoveParamCheckBoxes() }
panel.add(replaceAllCheckBox, gbConstraints)
@@ -214,11 +214,11 @@ public class KotlinIntroduceParameterDialog private constructor(
}
for (parameter in descriptor.parametersToRemove) {
- val removeWhat = if (parameter is KtParameter) "parameter '${parameter.getName()}'" else "receiver"
+ val removeWhat = if (parameter is KtParameter) "parameter '${parameter.name}'" else "receiver"
val cb = NonFocusableCheckBox("Remove $removeWhat no longer used")
removeParamsCheckBoxes[cb] = parameter
- cb.setSelected(true)
+ cb.isSelected = true
gbConstraints.gridy++
panel.add(cb, gbConstraints)
}
@@ -230,8 +230,8 @@ public class KotlinIntroduceParameterDialog private constructor(
override fun canRun() {
val psiFactory = KtPsiFactory(myProject)
- psiFactory.createSimpleName(nameField.getEnteredName()).validateElement("Invalid parameter name")
- psiFactory.createType(typeField.getEnteredName()).validateElement("Invalid parameter type")
+ psiFactory.createSimpleName(nameField.enteredName).validateElement("Invalid parameter name")
+ psiFactory.createType(typeField.enteredName).validateElement("Invalid parameter type")
}
override fun doAction() {
@@ -245,19 +245,19 @@ public class KotlinIntroduceParameterDialog private constructor(
override fun performRefactoring(usages: Array) {
fun createLambdaForArgument(function: KtFunction): KtExpression {
- val statement = (function.getBodyExpression() as KtBlockExpression).getStatements().single()
+ val statement = (function.bodyExpression as KtBlockExpression).statements.single()
val space = if (statement.isMultiLine()) "\n" else " "
- val parameters = function.getValueParameters()
+ val parameters = function.valueParameters
val parametersText = if (parameters.isNotEmpty()) {
- " " + parameters.map { it.getName() }.joinToString() + " ->"
+ " " + parameters.map { it.name }.joinToString() + " ->"
} else ""
- val text = "{$parametersText$space${statement.getText()}$space}"
+ val text = "{$parametersText$space${statement.text}$space}"
return KtPsiFactory(myProject).createExpression(text)
}
- val chosenName = nameField.getEnteredName()
- var chosenType = typeField.getEnteredName()
+ val chosenName = nameField.enteredName
+ var chosenType = typeField.enteredName
var newArgumentValue = descriptor.newArgumentValue
var newReplacer = descriptor.occurrenceReplacer
@@ -268,8 +268,8 @@ public class KotlinIntroduceParameterDialog private constructor(
oldDescriptor,
chosenName,
"",
- parameterTablePanel?.getReceiverInfo(),
- parameterTablePanel?.getParameterInfos() ?: listOf(),
+ parameterTablePanel?.receiverInfo,
+ parameterTablePanel?.parameterInfos ?: listOf(),
null
)
val options = ExtractionGeneratorOptions.DEFAULT.copy(
@@ -278,12 +278,12 @@ public class KotlinIntroduceParameterDialog private constructor(
)
with (ExtractionGeneratorConfiguration(newDescriptor, options).generateDeclaration()) {
val function = declaration as KtFunction
- val receiverType = function.getReceiverTypeReference()?.getText()
+ val receiverType = function.receiverTypeReference?.text
val parameterTypes = function
- .getValueParameters()
- .map { it.getTypeReference()!!.getText() }
+ .valueParameters
+ .map { it.typeReference!!.text }
.joinToString()
- val returnType = function.getTypeReference()?.getText() ?: "Unit"
+ val returnType = function.typeReference?.text ?: "Unit"
chosenType = (receiverType?.let { "$it." } ?: "") + "($parameterTypes) -> $returnType"
newArgumentValue = createLambdaForArgument(function)
@@ -297,16 +297,16 @@ public class KotlinIntroduceParameterDialog private constructor(
newParameterName = chosenName,
newParameterTypeText = chosenType,
argumentValue = newArgumentValue,
- withDefaultValue = defaultValueCheckBox!!.isSelected(),
+ withDefaultValue = defaultValueCheckBox!!.isSelected,
occurrencesToReplace = with(descriptor) {
- if (replaceAllCheckBox?.isSelected() ?: true) {
+ if (replaceAllCheckBox?.isSelected ?: true) {
occurrencesToReplace
}
else {
Collections.singletonList(originalOccurrence)
}
},
- parametersToRemove = removeParamsCheckBoxes.filter { it.key.isEnabled() && it.key.isSelected() }.map { it.value },
+ parametersToRemove = removeParamsCheckBoxes.filter { it.key.isEnabled && it.key.isSelected }.map { it.value },
occurrenceReplacer = newReplacer
)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt
index 79790c250ba..6e065d5ac7d 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.psi.util.PsiTreeUtil
+import com.intellij.refactoring.RefactoringActionHandler
import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer
import com.intellij.refactoring.listeners.RefactoringEventListener
import com.intellij.util.SmartList
@@ -38,8 +39,8 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.core.NewDeclarationNameValidator
import org.jetbrains.kotlin.idea.core.moveInsideParenthesesAndReplaceWith
-import org.jetbrains.kotlin.idea.core.refactoring.removeTemplateEntryBracesIfPossible
-import org.jetbrains.kotlin.idea.core.refactoring.runRefactoringWithPostprocessing
+import org.jetbrains.kotlin.idea.refactoring.removeTemplateEntryBracesIfPossible
+import org.jetbrains.kotlin.idea.refactoring.runRefactoringWithPostprocessing
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
import org.jetbrains.kotlin.idea.refactoring.changeSignature.*
@@ -96,11 +97,11 @@ public data class IntroduceParameterDescriptor(
valVar = if (callable is KtClass) {
val modifierIsUnnecessary: (PsiElement) -> Boolean = {
when {
- it.getParent() != callable.getBody() ->
+ it.parent != callable.getBody() ->
false
it is KtAnonymousInitializer ->
true
- it is KtProperty && it.getInitializer()?.getTextRange()?.intersects(originalRange.getTextRange()) ?: false ->
+ it is KtProperty && it.initializer?.textRange?.intersects(originalRange.getTextRange()) ?: false ->
true
else ->
false
@@ -125,7 +126,7 @@ fun getParametersToRemove(
return parametersUsages.entrySet()
.filter {
it.value.all { paramUsage ->
- occurrenceRanges.any { occurrenceRange -> occurrenceRange.contains(paramUsage.getTextRange()) }
+ occurrenceRanges.any { occurrenceRange -> occurrenceRange.contains(paramUsage.textRange) }
}
}
.map { it.key }
@@ -163,14 +164,14 @@ fun IntroduceParameterDescriptor.performRefactoring() {
override fun performSilently(affectedFunctions: Collection): Boolean = true
}
- val project = callable.getProject();
+ val project = callable.project;
val changeSignature = { runChangeSignature(project, callableDescriptor, config, callable, INTRODUCE_PARAMETER) }
changeSignature.runRefactoringWithPostprocessing(project, "refactoring.changeSignature") {
try {
occurrencesToReplace.forEach { occurrenceReplacer(it) }
}
finally {
- project.getMessageBus()
+ project.messageBus
.syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC)
.refactoringDone(INTRODUCE_PARAMETER_REFACTORING_ID, null)
}
@@ -198,7 +199,7 @@ fun selectNewParameterContext(
(if (stopAt != null) parent.parents.takeWhile { it != stopAt } else parents)
.filter {
((it is KtClass && !it.isInterface() && it !is KtEnumEntry) || it is KtNamedFunction || it is KtSecondaryConstructor) &&
- ((it as KtNamedDeclaration).getValueParameterList() != null || it.getNameIdentifier() != null)
+ ((it as KtNamedDeclaration).getValueParameterList() != null || it.nameIdentifier != null)
}
.toList()
},
@@ -214,7 +215,7 @@ public interface KotlinIntroduceParameterHelper {
public open class KotlinIntroduceParameterHandler(
val helper: KotlinIntroduceParameterHelper = KotlinIntroduceParameterHelper.Default
-): KotlinIntroduceHandlerBase() {
+): RefactoringActionHandler {
open fun invoke(project: Project, editor: Editor, expression: KtExpression, targetParent: KtNamedDeclaration) {
val physicalExpression = expression.substringContextOrThis
if (physicalExpression is KtProperty && physicalExpression.isLocal && physicalExpression.nameIdentifier == null) {
@@ -250,7 +251,7 @@ public open class KotlinIntroduceParameterHandler(
val replacementType = expressionType.approximateWithResolvableType(targetParent.getResolutionScope(context, targetParent.getResolutionFacade()), false)
val body = when (targetParent) {
- is KtFunction -> targetParent.getBodyExpression()
+ is KtFunction -> targetParent.bodyExpression
is KtClass -> targetParent.getBody()
else -> null
} ?: throw AssertionError("Body element is not found: ${targetParent.getElementTextWithContext()}")
@@ -267,7 +268,7 @@ public open class KotlinIntroduceParameterHandler(
val forbiddenRanges =
if (targetParent is KtClass) {
- targetParent.getDeclarations().filter { isObjectOrNonInnerClass(it) }.map { it.getTextRange() }
+ targetParent.declarations.filter { isObjectOrNonInnerClass(it) }.map { it.textRange }
}
else {
Collections.emptyList()
@@ -298,7 +299,7 @@ public open class KotlinIntroduceParameterHandler(
INTRODUCE_PARAMETER,
null,
fun() {
- val isTestMode = ApplicationManager.getApplication().isUnitTestMode()
+ val isTestMode = ApplicationManager.getApplication().isUnitTestMode
val haveLambdaArgumentsToReplace = occurrencesToReplace.any {
it.elements.any { it is KtLambdaExpression && it.parent is KtLambdaArgument }
}
@@ -347,8 +348,8 @@ public open class KotlinIntroduceParameterHandler(
if (inplaceIsAvailable) {
with(PsiDocumentManager.getInstance(project)) {
- commitDocument(editor.getDocument())
- doPostponedOperationsAndUnblockDocument(editor.getDocument())
+ commitDocument(editor.document)
+ doPostponedOperationsAndUnblockDocument(editor.document)
}
val introducer = KotlinInplaceParameterIntroducer(introduceParameterDescriptor,
@@ -377,7 +378,7 @@ public open class KotlinIntroduceParameterHandler(
if (file !is KtFile) return
selectNewParameterContext(editor, file) { elements, targetParent ->
- val expression = ((elements.singleOrNull() as? KtBlockExpression)?.getStatements() ?: elements).singleOrNull()
+ val expression = ((elements.singleOrNull() as? KtBlockExpression)?.statements ?: elements).singleOrNull()
if (expression is KtExpression) {
invoke(project, editor, expression, targetParent as KtNamedDeclaration)
}
@@ -396,13 +397,10 @@ private fun DeclarationDescriptor?.toFunctionDescriptor(targetParent: KtNamedDec
val functionDescriptor: FunctionDescriptor? =
when (this) {
is FunctionDescriptor -> this
- is ClassDescriptor -> this.getUnsubstitutedPrimaryConstructor()
+ is ClassDescriptor -> this.unsubstitutedPrimaryConstructor
else -> null
}
- if (functionDescriptor == null) {
- throw AssertionError("Unexpected element type: ${targetParent.getElementTextWithContext()}")
- }
- return functionDescriptor
+ return functionDescriptor ?: throw AssertionError("Unexpected element type: ${targetParent.getElementTextWithContext()}")
}
private fun findInternalUsagesOfParametersAndReceiver(
@@ -413,19 +411,19 @@ private fun findInternalUsagesOfParametersAndReceiver(
targetParent.getValueParameters()
.filter { !it.hasValOrVar() }
.forEach {
- val paramUsages = ReferencesSearch.search(it).map { it.getElement() as KtElement }
+ val paramUsages = ReferencesSearch.search(it).map { it.element as KtElement }
if (paramUsages.isNotEmpty()) {
usages.put(it, paramUsages)
}
}
- val receiverTypeRef = (targetParent as? KtFunction)?.getReceiverTypeReference()
+ val receiverTypeRef = (targetParent as? KtFunction)?.receiverTypeReference
if (receiverTypeRef != null) {
targetParent.acceptChildren(
object : KtTreeVisitorVoid() {
override fun visitThisExpression(expression: KtThisExpression) {
super.visitThisExpression(expression)
- if (expression.getInstanceReference().mainReference.resolve() == targetDescriptor) {
+ if (expression.instanceReference.mainReference.resolve() == targetDescriptor) {
usages.putValue(receiverTypeRef, expression)
}
}
@@ -436,9 +434,9 @@ private fun findInternalUsagesOfParametersAndReceiver(
val bindingContext = element.analyze()
val resolvedCall = element.getResolvedCall(bindingContext) ?: return
- if ((resolvedCall.getExtensionReceiver() as? ImplicitReceiver)?.declarationDescriptor == targetDescriptor ||
- (resolvedCall.getDispatchReceiver() as? ImplicitReceiver)?.declarationDescriptor == targetDescriptor) {
- usages.putValue(receiverTypeRef, resolvedCall.getCall().getCallElement())
+ if ((resolvedCall.extensionReceiver as? ImplicitReceiver)?.declarationDescriptor == targetDescriptor ||
+ (resolvedCall.dispatchReceiver as? ImplicitReceiver)?.declarationDescriptor == targetDescriptor) {
+ usages.putValue(receiverTypeRef, resolvedCall.call.callElement)
}
}
}
@@ -495,7 +493,7 @@ public open class KotlinIntroduceLambdaParameterHandler(
}
val dialog = createDialog(project, editor, lambdaExtractionDescriptor)
- if (ApplicationManager.getApplication()!!.isUnitTestMode()) {
+ if (ApplicationManager.getApplication()!!.isUnitTestMode) {
dialog.performRefactoring()
}
else {
@@ -507,7 +505,7 @@ public open class KotlinIntroduceLambdaParameterHandler(
override fun invoke(project: Project, editor: Editor, expression: KtExpression, targetParent: KtNamedDeclaration) {
val duplicateContainer =
when (targetParent) {
- is KtFunction -> targetParent.getBodyExpression()
+ is KtFunction -> targetParent.bodyExpression
is KtClass -> targetParent.getBody()
else -> null
} ?: throw AssertionError("Body element is not found: ${targetParent.getElementTextWithContext()}")
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt
index 8efb6ef7e16..beb82524a61 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt
@@ -29,8 +29,8 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
-import org.jetbrains.kotlin.idea.core.refactoring.dropOverrideKeywordIfNecessary
-import org.jetbrains.kotlin.idea.core.refactoring.j2k
+import org.jetbrains.kotlin.idea.refactoring.dropOverrideKeywordIfNecessary
+import org.jetbrains.kotlin.idea.refactoring.j2k
import org.jetbrains.kotlin.idea.refactoring.changeSignature.*
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallableDefinitionUsage
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinConstructorDelegationCallUsage
@@ -44,8 +44,8 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import java.util.*
public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMethodUsagesProcessor {
- override fun isMethodUsage(usage: UsageInfo): Boolean = (usage.getElement() as? KtElement)?.let {
- it.getParentOfTypeAndBranch(true) { getCalleeExpression() } != null
+ override fun isMethodUsage(usage: UsageInfo): Boolean = (usage.element as? KtElement)?.let {
+ it.getParentOfTypeAndBranch(true) { calleeExpression } != null
} ?: false
override fun findConflicts(data: IntroduceParameterData, usages: Array, conflicts: MultiMap) {
@@ -61,26 +61,26 @@ public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMe
val changeSignatureData = KotlinChangeSignatureData(psiMethodDescriptor, method, Collections.singletonList(psiMethodDescriptor))
val changeInfo = KotlinChangeInfo(methodDescriptor = changeSignatureData, context = method)
- data.getParametersToRemove().toNativeArray().sortedDescending().forEach { changeInfo.removeParameter(it) }
+ data.parametersToRemove.toNativeArray().sortedDescending().forEach { changeInfo.removeParameter(it) }
// Temporarily assume that the new parameter is of Any type. Actual type is substituted during the signature update phase
- val defaultValueForCall = (data.getParameterInitializer().getExpression() as? PsiExpression)?.let { it.j2k() }
+ val defaultValueForCall = (data.parameterInitializer.expression as? PsiExpression)?.let { it.j2k() }
changeInfo.addParameter(KotlinParameterInfo(callableDescriptor = psiMethodDescriptor,
- name = data.getParameterName(),
+ name = data.parameterName,
originalTypeInfo = KotlinTypeInfo(false, psiMethodDescriptor.builtIns.anyType),
defaultValueForCall = defaultValueForCall))
return changeInfo
}
override fun processChangeMethodSignature(data: IntroduceParameterData, usage: UsageInfo, usages: Array): Boolean {
- val element = usage.getElement() as? KtFunction ?: return true
+ val element = usage.element as? KtFunction ?: return true
val changeInfo = createChangeInfo(data, element) ?: return true
// Java method is already updated at this point
- val addedParameterType = data.getMethodToReplaceIn().getJavaMethodDescriptor()!!.getValueParameters().last().getType()
- changeInfo.getNewParameters().last().currentTypeInfo = KotlinTypeInfo(false, addedParameterType)
+ val addedParameterType = data.methodToReplaceIn.getJavaMethodDescriptor()!!.valueParameters.last().type
+ changeInfo.newParameters.last().currentTypeInfo = KotlinTypeInfo(false, addedParameterType)
- val scope = element.getUseScope().let {
+ val scope = element.useScope.let {
if (it is GlobalSearchScope) GlobalSearchScope.getScopeRestrictedByFileTypes(it, KotlinFileType.INSTANCE) else it
}
val kotlinFunctions = HierarchySearchRequest(element, scope)
@@ -95,10 +95,10 @@ public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMe
}
override fun processChangeMethodUsage(data: IntroduceParameterData, usage: UsageInfo, usages: Array): Boolean {
- val psiMethod = data.getMethodToReplaceIn()
+ val psiMethod = data.methodToReplaceIn
val changeInfo = createChangeInfo(data, psiMethod) ?: return true
- val refElement = usage.getElement() as? KtReferenceExpression ?: return true
- val callElement = refElement.getParentOfTypeAndBranch(true) { getCalleeExpression() } ?: return true
+ val refElement = usage.element as? KtReferenceExpression ?: return true
+ val callElement = refElement.getParentOfTypeAndBranch(true) { calleeExpression } ?: return true
val delegateUsage = if (callElement is KtConstructorDelegationCall) {
@Suppress("CAST_NEVER_SUCCEEDS")
(KotlinConstructorDelegationCallUsage(callElement, changeInfo) as KotlinUsageInfo)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/IntroducePropertyAction.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/IntroducePropertyAction.kt
index cbf0fcfdb13..23880dbeed2 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/IntroducePropertyAction.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/IntroducePropertyAction.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable
+package org.jetbrains.kotlin.idea.refactoring.introduce.introduceProperty
import com.intellij.refactoring.RefactoringActionHandler
import com.intellij.lang.refactoring.RefactoringSupportProvider
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt
index e988df2154d..7a67d436509 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.Extracti
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.generateDeclaration
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.processDuplicatesSilently
import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinInplaceVariableIntroducer
-import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinInplaceVariableIntroducer.ControlWrapper
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFile
@@ -84,7 +83,7 @@ public class KotlinInplacePropertyIntroducer(
private fun isInitializer(): Boolean = currentTarget == ExtractionTarget.PROPERTY_WITH_INITIALIZER
override fun initPanelControls() {
- if (availableTargets.size() > 1) {
+ if (availableTargets.size > 1) {
addPanelControl(
ControlWrapper {
val propertyKindComboBox = with(JComboBox(availableTargets.map { it.targetName.capitalize() }.toTypedArray())) {
@@ -92,20 +91,20 @@ public class KotlinInplacePropertyIntroducer(
object : PopupMenuListenerAdapter() {
override fun popupMenuWillBecomeInvisible(e: PopupMenuEvent?) {
ApplicationManager.getApplication().invokeLater {
- currentTarget = availableTargets[getSelectedIndex()]
+ currentTarget = availableTargets[selectedIndex]
}
}
}
)
- setSelectedIndex(availableTargets.indexOf(currentTarget))
+ selectedIndex = availableTargets.indexOf(currentTarget)
this
}
val propertyKindLabel = JLabel("Introduce as: ")
propertyKindLabel.setDisplayedMnemonic('I')
- propertyKindLabel.setLabelFor(propertyKindComboBox)
+ propertyKindLabel.labelFor = propertyKindComboBox
val panel = JPanel()
panel.add(propertyKindLabel)
@@ -119,32 +118,32 @@ public class KotlinInplacePropertyIntroducer(
if (ExtractionTarget.PROPERTY_WITH_INITIALIZER in availableTargets) {
val condition = { isInitializer() }
- getCreateVarCheckBox()?.let {
+ createVarCheckBox?.let {
val initializer = object: Pass() {
override fun pass(t: JComponent) {
- (t as JCheckBox).setSelected(property.isVar())
+ (t as JCheckBox).isSelected = property.isVar
}
}
addPanelControl(ControlWrapper(it, condition, initializer))
}
- getCreateExplicitTypeCheckBox()?.let {
+ createExplicitTypeCheckBox?.let {
val initializer = object: Pass() {
override fun pass(t: JComponent) {
- (t as JCheckBox).setSelected(property.getTypeReference() != null)
+ (t as JCheckBox).isSelected = property.typeReference != null
}
}
addPanelControl(ControlWrapper(it, condition, initializer))
}
}
- val occurrenceCount = extractionResult.duplicateReplacers.size() + 1
+ val occurrenceCount = extractionResult.duplicateReplacers.size + 1
if (occurrenceCount > 1) {
addPanelControl(
ControlWrapper {
val replaceAllCheckBox = NonFocusableCheckBox("Replace all occurrences ($occurrenceCount)")
- replaceAllCheckBox.setSelected(replaceAll)
+ replaceAllCheckBox.isSelected = replaceAll
replaceAllCheckBox.setMnemonic('R')
- replaceAllCheckBox.addActionListener { replaceAll = replaceAllCheckBox.isSelected() }
+ replaceAllCheckBox.addActionListener { replaceAll = replaceAllCheckBox.isSelected }
replaceAllCheckBox
}
)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt
index 7d2d3c26b8a..a8080ff7315 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt
@@ -27,12 +27,13 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.*
import org.jetbrains.kotlin.idea.util.psi.patternMatching.*
import kotlin.test.*
import com.intellij.openapi.application.*
-import org.jetbrains.kotlin.idea.core.refactoring.getExtractionContainers
+import com.intellij.refactoring.RefactoringActionHandler
+import org.jetbrains.kotlin.idea.refactoring.getExtractionContainers
import java.util.*
public class KotlinIntroducePropertyHandler(
val helper: ExtractionEngineHelper = KotlinIntroducePropertyHandler.InteractiveExtractionHelper
-): KotlinIntroduceHandlerBase() {
+): RefactoringActionHandler {
object InteractiveExtractionHelper : ExtractionEngineHelper(INTRODUCE_PROPERTY) {
override fun configureAndRun(
project: Project,
@@ -65,7 +66,7 @@ public class KotlinIntroducePropertyHandler(
}
public fun doInvoke(project: Project, editor: Editor, file: KtFile, elements: List, targetSibling: PsiElement) {
- val adjustedElements = (elements.singleOrNull() as? KtBlockExpression)?.getStatements() ?: elements
+ val adjustedElements = (elements.singleOrNull() as? KtBlockExpression)?.statements ?: elements
if (adjustedElements.isNotEmpty()) {
val options = ExtractionOptions(extractAsProperty = true)
val extractionData = ExtractionData(file, adjustedElements.toRange(), targetSibling, null, options)
@@ -73,12 +74,12 @@ public class KotlinIntroducePropertyHandler(
val property = it.declaration as KtProperty
val descriptor = it.config.descriptor
- editor.getCaretModel().moveToOffset(property.getTextOffset())
- editor.getSelectionModel().removeSelection()
- if (editor.getSettings().isVariableInplaceRenameEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
+ editor.caretModel.moveToOffset(property.textOffset)
+ editor.selectionModel.removeSelection()
+ if (editor.settings.isVariableInplaceRenameEnabled && !ApplicationManager.getApplication().isUnitTestMode) {
with(PsiDocumentManager.getInstance(project)) {
- commitDocument(editor.getDocument())
- doPostponedOperationsAndUnblockDocument(editor.getDocument())
+ commitDocument(editor.document)
+ doPostponedOperationsAndUnblockDocument(editor.document)
}
val introducer = KotlinInplacePropertyIntroducer(
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceUtil.kt
index c8829b8c600..affd9e8f135 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceUtil.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceUtil.kt
@@ -25,7 +25,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
-import org.jetbrains.kotlin.idea.core.refactoring.chooseContainerElementIfNecessary
+import org.jetbrains.kotlin.idea.refactoring.chooseContainerElementIfNecessary
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringUtil
import org.jetbrains.kotlin.idea.util.psi.patternMatching.KotlinPsiRange
@@ -59,7 +59,7 @@ fun selectElementsWithTargetSibling(
val outermostParent = parent.getOutermostParentContainedIn(targetContainer)
if (outermostParent == null) {
- showErrorHintByKey(file.getProject(), editor, "cannot.refactor.no.container", operationName)
+ showErrorHintByKey(file.project, editor, "cannot.refactor.no.container", operationName)
return
}
@@ -77,7 +77,7 @@ fun selectElementsWithTargetParent(
continuation: (elements: List, targetParent: PsiElement) -> Unit
) {
fun showErrorHintByKey(key: String) {
- showErrorHintByKey(file.getProject(), editor, key, operationName)
+ showErrorHintByKey(file.project, editor, key, operationName)
}
fun selectTargetContainer(elements: List) {
@@ -102,8 +102,8 @@ fun selectElementsWithTargetParent(
}
fun selectMultipleExpressions() {
- val startOffset = editor.getSelectionModel().getSelectionStart()
- val endOffset = editor.getSelectionModel().getSelectionEnd()
+ val startOffset = editor.selectionModel.selectionStart
+ val endOffset = editor.selectionModel.selectionEnd
val elements = CodeInsightUtils.findStatements(file, startOffset, endOffset)
if (elements.isEmpty()) {
@@ -120,20 +120,20 @@ fun selectElementsWithTargetParent(
selectTargetContainer(listOf(expr))
}
else {
- if (!editor.getSelectionModel().hasSelection()) {
+ if (!editor.selectionModel.hasSelection()) {
val elementAtCaret = file.findElementAt(editor.caretModel.offset)
elementAtCaret?.getParentOfTypeAndBranch { nameIdentifier }?.let {
return@selectExpression selectTargetContainer(listOf(it))
}
- editor.getSelectionModel().selectLineAtCaret()
+ editor.selectionModel.selectLineAtCaret()
}
selectMultipleExpressions()
}
}
}
- editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE)
+ editor.scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE)
selectSingleExpression()
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java
index 4bdd6df3458..3cb0bcf1e3a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java
@@ -35,8 +35,6 @@ import com.intellij.psi.search.SearchScope;
import com.intellij.refactoring.introduce.inplace.InplaceVariableIntroducer;
import com.intellij.ui.NonFocusableCheckBox;
import com.intellij.util.ui.PositionTracker;
-import kotlin.ArraysKt;
-import kotlin.CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
@@ -391,8 +389,8 @@ public class KotlinInplaceVariableIntroducer ex
@Override
protected Collection collectRefs(SearchScope referencesSearchScope) {
- return CollectionsKt.map(
- ArraysKt.filterIsInstance(getOccurrences(), KtSimpleNameExpression.class),
+ return kotlin.collections.CollectionsKt.map(
+ kotlin.collections.ArraysKt.filterIsInstance(getOccurrences(), KtSimpleNameExpression.class),
new Function1() {
@Override
public PsiReference invoke(KtSimpleNameExpression expression) {
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt
index 905fa9082c8..b32b89336e7 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.refactoring.HelpID
+import com.intellij.refactoring.RefactoringActionHandler
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser
import com.intellij.refactoring.util.CommonRefactoringUtil
import com.intellij.ui.components.JBList
@@ -42,10 +43,8 @@ import org.jetbrains.kotlin.idea.analysis.computeTypeInfoInContext
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.*
-import org.jetbrains.kotlin.idea.core.refactoring.*
import org.jetbrains.kotlin.idea.intentions.ConvertToBlockBodyIntention
-import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
-import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringUtil
+import org.jetbrains.kotlin.idea.refactoring.*
import org.jetbrains.kotlin.idea.refactoring.introduce.*
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
@@ -74,7 +73,7 @@ import org.jetbrains.kotlin.utils.ifEmpty
import org.jetbrains.kotlin.utils.sure
import java.util.*
-object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() {
+object KotlinIntroduceVariableHandler : RefactoringActionHandler {
val INTRODUCE_VARIABLE = KotlinRefactoringBundle.message("introduce.variable")
private val EXPRESSION_KEY = Key.create("EXPRESSION_KEY")
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt
index 5dff79fac47..a109cb851a2 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt
@@ -28,15 +28,16 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.PsiReference
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil
import com.intellij.ui.NonFocusableCheckBox
-import com.intellij.util.ui.FormBuilder
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention
import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractKotlinInplaceIntroducer
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
-import org.jetbrains.kotlin.psi.*
+import org.jetbrains.kotlin.psi.KtDeclaration
+import org.jetbrains.kotlin.psi.KtExpression
+import org.jetbrains.kotlin.psi.KtProperty
+import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import org.jetbrains.kotlin.types.KotlinType
-import java.awt.BorderLayout
public class KotlinVariableInplaceIntroducer(
val addedVariable: KtProperty,
@@ -64,15 +65,15 @@ public class KotlinVariableInplaceIntroducer(
initFormComponents {
if (!doNotChangeVar) {
val varCheckBox = NonFocusableCheckBox("Declare with var")
- varCheckBox.setSelected(isVar)
+ varCheckBox.isSelected = isVar
varCheckBox.setMnemonic('v')
varCheckBox.addActionListener {
- myProject.executeWriteCommand(getCommandName(), getCommandName()) {
- PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument())
+ myProject.executeWriteCommand(commandName, commandName) {
+ PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.document)
val psiFactory = KtPsiFactory(myProject)
- val keyword = if (varCheckBox.isSelected()) psiFactory.createVarKeyword() else psiFactory.createValKeyword()
- addedVariable.getValOrVarKeyword().replace(keyword)
+ val keyword = if (varCheckBox.isSelected) psiFactory.createVarKeyword() else psiFactory.createValKeyword()
+ addedVariable.valOrVarKeyword.replace(keyword)
}
}
addComponent(varCheckBox)
@@ -80,11 +81,11 @@ public class KotlinVariableInplaceIntroducer(
if (expressionType != null && !noTypeInference) {
val expressionTypeCheckBox = NonFocusableCheckBox("Specify type explicitly")
- expressionTypeCheckBox.setSelected(false)
+ expressionTypeCheckBox.isSelected = false
expressionTypeCheckBox.setMnemonic('t')
expressionTypeCheckBox.addActionListener {
runWriteCommandAndRestart {
- if (expressionTypeCheckBox.isSelected()) {
+ if (expressionTypeCheckBox.isSelected) {
val renderedType = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(expressionType)
addedVariable.setTypeReference(KtPsiFactory(myProject).createType(renderedType))
}
@@ -105,7 +106,7 @@ public class KotlinVariableInplaceIntroducer(
override fun createFieldToStartTemplateOn(replaceAll: Boolean, names: Array) = addedVariable
override fun addAdditionalVariables(builder: TemplateBuilderImpl) {
- addedVariable.getTypeReference()?.let {
+ addedVariable.typeReference?.let {
builder.replaceElement(it,
"TypeReferenceVariable",
SpecifyTypeExplicitlyIntention.createTypeExpressionForTemplate(expressionType!!),
@@ -117,12 +118,12 @@ public class KotlinVariableInplaceIntroducer(
stringUsages: Collection>,
scope: PsiElement,
containingFile: PsiFile): Boolean {
- myEditor.getCaretModel().moveToOffset(getNameIdentifier()!!.startOffset)
+ myEditor.caretModel.moveToOffset(nameIdentifier!!.startOffset)
val result = super.buildTemplateAndStart(refs, stringUsages, scope, containingFile)
val templateState = TemplateManagerImpl.getTemplateState(InjectedLanguageUtil.getTopLevelEditor(myEditor))
- if (templateState != null && addedVariable.getTypeReference() != null) {
+ if (templateState != null && addedVariable.typeReference != null) {
templateState.addTemplateStateListener(SpecifyTypeExplicitlyIntention.createTypeReferencePostprocessor(addedVariable))
}
@@ -146,11 +147,11 @@ public class KotlinVariableInplaceIntroducer(
override fun getComponent() = myWholePanel
override fun performIntroduce() {
- val newName = getInputName() ?: return
+ val newName = inputName ?: return
addedVariable.setName(newName)
val replacement = KtPsiFactory(myProject).createExpression(newName)
- getOccurrences().forEach {
- if (it.isValid()) {
+ occurrences.forEach {
+ if (it.isValid) {
it.replace(replacement)
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/javaElementFactoryUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/javaElementFactoryUtils.kt
index 4370276ec93..d8a577e7ebc 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/javaElementFactoryUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/javaElementFactoryUtils.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.idea.core.refactoring
+package org.jetbrains.kotlin.idea.refactoring
import com.intellij.psi.PsiElementFactory
import com.intellij.psi.PsiJavaCodeReferenceElement
@@ -25,12 +25,12 @@ public fun PsiElementFactory.createReferenceListWithRole(
references: Array,
role: Role
): PsiReferenceList? {
- val refsText = references.map { it.getCanonicalText() }
+ val refsText = references.map { it.canonicalText }
val refListText = if (refsText.isNotEmpty()) refsText.joinToString() else return null
return when (role) {
- Role.THROWS_LIST -> createMethodFromText("void foo() throws $refListText {}", null).getThrowsList()
- Role.EXTENDS_LIST -> createClassFromText("class Foo extends $refListText {}", null).getInnerClasses()[0].getExtendsList()
- Role.IMPLEMENTS_LIST -> createClassFromText("class Foo implements $refListText {}", null).getInnerClasses()[0].getImplementsList()
- Role.EXTENDS_BOUNDS_LIST -> createTypeParameterFromText("T extends $refListText", null).getExtendsList()
+ Role.THROWS_LIST -> createMethodFromText("void foo() throws $refListText {}", null).throwsList
+ Role.EXTENDS_LIST -> createClassFromText("class Foo extends $refListText {}", null).innerClasses[0].extendsList
+ Role.IMPLEMENTS_LIST -> createClassFromText("class Foo implements $refListText {}", null).innerClasses[0].implementsList
+ Role.EXTENDS_BOUNDS_LIST -> createTypeParameterFromText("T extends $refListText", null).extendsList
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt
index a3208a5667b..72916a6374c 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.idea.core.refactoring
+package org.jetbrains.kotlin.idea.refactoring
import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils
import com.intellij.codeInsight.unwrap.RangeSplitter
@@ -39,7 +39,6 @@ import com.intellij.openapi.ui.popup.JBPopup
import com.intellij.openapi.ui.popup.JBPopupAdapter
import com.intellij.openapi.ui.popup.LightweightWindowEvent
import com.intellij.openapi.ui.popup.PopupChooserBuilder
-import com.intellij.openapi.util.Key
import com.intellij.openapi.util.Pass
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.text.StringUtil
@@ -94,12 +93,6 @@ import java.lang.annotation.Retention
import java.util.*
import javax.swing.Icon
-fun PsiElement.getAndRemoveCopyableUserData(key: Key): T? {
- val data = getCopyableUserData(key)
- putCopyableUserData(key, null)
- return data
-}
-
fun getOrCreateKotlinFile(fileName: String, targetDir: PsiDirectory): KtFile? =
(targetDir.findFile(fileName) ?: createKotlinFile(fileName, targetDir)) as? KtFile
@@ -107,7 +100,7 @@ fun createKotlinFile(fileName: String,
targetDir: PsiDirectory,
packageName: String? = targetDir.getPackage()?.qualifiedName): KtFile {
targetDir.checkCreateFile(fileName)
- val file = PsiFileFactory.getInstance(targetDir.getProject()).createFileFromText(
+ val file = PsiFileFactory.getInstance(targetDir.project).createFileFromText(
fileName, KotlinFileType.INSTANCE, if (!packageName.isNullOrBlank()) "package $packageName \n\n" else ""
)
@@ -128,13 +121,13 @@ public fun VirtualFile.toPsiDirectory(project: Project): PsiDirectory? = PsiMana
public fun PsiElement.getUsageContext(): PsiElement {
return when (this) {
- is KtElement -> PsiTreeUtil.getParentOfType(this, javaClass(), javaClass())!!
+ is KtElement -> PsiTreeUtil.getParentOfType(this, KtNamedDeclaration::class.java, KtFile::class.java)!!
else -> ConflictsUtil.getContainer(this)
}
}
public fun PsiElement.isInJavaSourceRoot(): Boolean =
- !JavaProjectRootsUtil.isOutsideJavaSourceRoot(getContainingFile())
+ !JavaProjectRootsUtil.isOutsideJavaSourceRoot(containingFile)
public fun KtFile.createTempCopy(text: String? = null): KtFile {
val tmpFile = KtPsiFactory(this).createAnalyzableFile(name, text ?: this.text ?: "", this)
@@ -188,7 +181,7 @@ public fun PsiElement.getExtractionContainers(strict: Boolean = true, includeAll
is KtClassBody -> getAllExtractionContainers(strict).filterIsInstance()
else -> {
val targetContainer = when (enclosingDeclaration) {
- is KtDeclarationWithBody -> enclosingDeclaration.getBodyExpression()
+ is KtDeclarationWithBody -> enclosingDeclaration.bodyExpression
is KtAnonymousInitializer -> enclosingDeclaration.body
else -> null
}
@@ -201,13 +194,13 @@ public fun Project.checkConflictsInteractively(
conflicts: MultiMap,
onShowConflicts: () -> Unit = {},
onAccept: () -> Unit) {
- if (!conflicts.isEmpty()) {
- if (ApplicationManager.getApplication()!!.isUnitTestMode()) throw ConflictsInTestsException(conflicts.values())
+ if (!conflicts.isEmpty) {
+ if (ApplicationManager.getApplication()!!.isUnitTestMode) throw ConflictsInTestsException(conflicts.values())
val dialog = ConflictsDialog(this, conflicts) { onAccept() }
dialog.show()
- if (!dialog.isOK()) {
- if (dialog.isShowConflicts()) {
+ if (!dialog.isOK) {
+ if (dialog.isShowConflicts) {
onShowConflicts()
}
return
@@ -236,12 +229,12 @@ public fun getPsiElementPopup(
val highlighter = if (highlightSelection) SelectionAwareScopeHighlighter(editor) else null
val list = JBList(elements.map(toPsi))
- list.setCellRenderer(renderer)
+ list.cellRenderer = renderer
list.addListSelectionListener { e ->
highlighter?.dropHighlight()
- val index = list.getSelectedIndex()
+ val index = list.selectedIndex
if (index >= 0) {
- highlighter?.highlight(list.getModel()!!.getElementAt(index) as PsiElement)
+ highlighter?.highlight(list.model!!.getElementAt(index) as PsiElement)
}
}
@@ -249,7 +242,7 @@ public fun getPsiElementPopup(
title?.let { setTitle(it) }
renderer.installSpeedSearch(this, true)
setItemChoosenCallback {
- val index = list.getSelectedIndex()
+ val index = list.selectedIndex
if (index >= 0) {
processor(elements[index])
}
@@ -269,9 +262,9 @@ public class SelectionAwareScopeHighlighter(val editor: Editor) {
private fun addHighlighter(r: TextRange, attr: TextAttributes) {
highlighters.add(
- editor.getMarkupModel().addRangeHighlighter(
- r.getStartOffset(),
- r.getEndOffset(),
+ editor.markupModel.addRangeHighlighter(
+ r.startOffset,
+ r.endOffset,
UnwrapHandler.HIGHLIGHTER_LEVEL,
attr,
HighlighterTargetArea.EXACT_RANGE
@@ -282,9 +275,9 @@ public class SelectionAwareScopeHighlighter(val editor: Editor) {
public fun highlight(wholeAffected: PsiElement) {
dropHighlight()
- val attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)!!
- val selectedRange = with(editor.getSelectionModel()) { TextRange(getSelectionStart(), getSelectionEnd()) }
- for (r in RangeSplitter.split(wholeAffected.getTextRange()!!, Collections.singletonList(selectedRange))) {
+ val attributes = EditorColorsManager.getInstance().globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)!!
+ val selectedRange = with(editor.selectionModel) { TextRange(selectionStart, selectionEnd) }
+ for (r in RangeSplitter.split(wholeAffected.textRange!!, Collections.singletonList(selectedRange))) {
addHighlighter(r, attributes)
}
}
@@ -316,17 +309,17 @@ fun PsiElement.getLineNumber(start: Boolean = true): Int {
}
fun PsiElement.getLineCount(): Int {
- val doc = getContainingFile()?.let { file -> PsiDocumentManager.getInstance(getProject()).getDocument(file) }
+ val doc = containingFile?.let { file -> PsiDocumentManager.getInstance(project).getDocument(file) }
if (doc != null) {
- val spaceRange = getTextRange() ?: TextRange.EMPTY_RANGE
+ val spaceRange = textRange ?: TextRange.EMPTY_RANGE
- val startLine = doc.getLineNumber(spaceRange.getStartOffset())
- val endLine = doc.getLineNumber(spaceRange.getEndOffset())
+ val startLine = doc.getLineNumber(spaceRange.startOffset)
+ val endLine = doc.getLineNumber(spaceRange.endOffset)
return endLine - startLine
}
- return (getText() ?: "").count { it == '\n' } + 1
+ return (text ?: "").count { it == '\n' } + 1
}
fun PsiElement.isMultiLine(): Boolean = getLineCount() > 1
@@ -334,10 +327,10 @@ fun PsiElement.isMultiLine(): Boolean = getLineCount() > 1
public fun KtElement.getContextForContainingDeclarationBody(): BindingContext? {
val enclosingDeclaration = getStrictParentOfType()
val bodyElement = when (enclosingDeclaration) {
- is KtDeclarationWithBody -> enclosingDeclaration.getBodyExpression()
- is KtWithExpressionInitializer -> enclosingDeclaration.getInitializer()
- is KtDestructuringDeclaration -> enclosingDeclaration.getInitializer()
- is KtParameter -> enclosingDeclaration.getDefaultValue()
+ is KtDeclarationWithBody -> enclosingDeclaration.bodyExpression
+ is KtWithExpressionInitializer -> enclosingDeclaration.initializer
+ is KtDestructuringDeclaration -> enclosingDeclaration.initializer
+ is KtParameter -> enclosingDeclaration.defaultValue
is KtAnonymousInitializer -> enclosingDeclaration.body
is KtClass -> {
val delegationSpecifierList = enclosingDeclaration.getSuperTypeList()
@@ -361,40 +354,40 @@ public fun chooseContainerElement(
object : PsiElementListCellRenderer() {
private fun PsiElement.renderName(): String {
if (this is KtPropertyAccessor) {
- return (getParent() as KtProperty).renderName() + if (isGetter()) ".get" else ".set"
+ return (parent as KtProperty).renderName() + if (isGetter) ".get" else ".set"
}
if (this is KtObjectDeclaration && this.isCompanion()) {
return "Companion object of ${getStrictParentOfType()?.renderName() ?: ""}"
}
- return (this as? PsiNamedElement)?.getName() ?: ""
+ return (this as? PsiNamedElement)?.name ?: ""
}
private fun PsiElement.renderDeclaration(): String? {
if (this is KtFunctionLiteral || isFunctionalExpression()) return renderText()
val descriptor = when {
- this is KtFile -> getName()
- this is KtElement -> analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this]
- this is PsiMember -> getJavaMemberDescriptor()
- else -> null
- } ?: return null
+ this is KtFile -> name
+ this is KtElement -> analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this]
+ this is PsiMember -> getJavaMemberDescriptor()
+ else -> null
+ } ?: return null
val name = renderName()
val params = (descriptor as? FunctionDescriptor)?.let { descriptor ->
- descriptor.getValueParameters()
- .map { DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it.getType()) }
+ descriptor.valueParameters
+ .map { DescriptorRenderer.Companion.SHORT_NAMES_IN_TYPES.renderType(it.type) }
.joinToString(", ", "(", ")")
} ?: ""
return "$name$params"
}
private fun PsiElement.renderText(): String {
- return StringUtil.shortenTextWithEllipsis(getText()!!.collapseSpaces(), 53, 0)
+ return StringUtil.shortenTextWithEllipsis(text!!.collapseSpaces(), 53, 0)
}
private fun PsiElement.getRepresentativeElement(): PsiElement {
return when (this) {
- is KtBlockExpression -> (getParent() as? KtDeclarationWithBody) ?: this
- is KtClassBody -> getParent() as KtClassOrObject
+ is KtBlockExpression -> (parent as? KtDeclarationWithBody) ?: this
+ is KtClassBody -> parent as KtClassOrObject
else -> this
}
}
@@ -431,7 +424,7 @@ public fun chooseContainerElementIfNecessary(
) {
when {
containers.isEmpty() -> return
- containers.size() == 1 || ApplicationManager.getApplication()!!.isUnitTestMode() -> onSelect(containers.first())
+ containers.size == 1 || ApplicationManager.getApplication()!!.isUnitTestMode -> onSelect(containers.first())
else -> chooseContainerElement(containers, editor, title, highlightSelection, toPsi, onSelect)
}
}
@@ -441,11 +434,11 @@ public fun PsiElement.isTrueJavaMethod(): Boolean = this is PsiMethod && this !i
public fun PsiElement.canRefactor(): Boolean {
return when {
this is PsiPackage ->
- getDirectories().any { it.canRefactor() }
+ directories.any { it.canRefactor() }
this is KtElement ||
- this is PsiMember && getLanguage() == JavaLanguage.INSTANCE ||
+ this is PsiMember && language == JavaLanguage.INSTANCE ||
this is PsiDirectory ->
- isWritable() && ProjectRootsUtil.isInProjectSource(this)
+ isWritable && ProjectRootsUtil.isInProjectSource(this)
else ->
false
}
@@ -459,10 +452,10 @@ private fun copyModifierListItems(from: PsiModifierList, to: PsiModifierList, wi
}
}
}
- for (annotation in from.getAnnotations()) {
- val annotationName = annotation.getQualifiedName()!!
+ for (annotation in from.annotations) {
+ val annotationName = annotation.qualifiedName!!
- if (javaClass().getName() != annotationName) {
+ if (Retention::class.java.name != annotationName) {
to.addAnnotation(annotationName)
}
}
@@ -473,19 +466,19 @@ private fun copyTypeParameters(
to: T,
inserter: (T, PsiTypeParameterList) -> Unit
) where T : PsiTypeParameterListOwner, T : PsiNameIdentifierOwner {
- val factory = PsiElementFactory.SERVICE.getInstance((from as PsiElement).getProject())
- val templateTypeParams = from.getTypeParameterList()?.getTypeParameters() ?: PsiTypeParameter.EMPTY_ARRAY
+ val factory = PsiElementFactory.SERVICE.getInstance((from as PsiElement).project)
+ val templateTypeParams = from.typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY
if (templateTypeParams.isNotEmpty()) {
inserter(to, factory.createTypeParameterList())
- val targetTypeParamList = to.getTypeParameterList()
+ val targetTypeParamList = to.typeParameterList
val newTypeParams = templateTypeParams.map {
- factory.createTypeParameter(it.getName(), it.getExtendsList().getReferencedTypes())
+ factory.createTypeParameter(it.name, it.extendsList.referencedTypes)
}
ChangeSignatureUtil.synchronizeList(
targetTypeParamList,
newTypeParams,
- { it!!.getTypeParameters().toList() },
- BooleanArray(newTypeParams.size())
+ { it!!.typeParameters.toList() },
+ BooleanArray(newTypeParams.size)
)
}
}
@@ -497,41 +490,41 @@ public fun createJavaMethod(function: KtFunction, targetClass: PsiClass): PsiMet
}
public fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMethod {
- val factory = PsiElementFactory.SERVICE.getInstance(template.getProject())
- val methodToAdd = if (template.isConstructor()) {
- factory.createConstructor(template.getName())
+ val factory = PsiElementFactory.SERVICE.getInstance(template.project)
+ val methodToAdd = if (template.isConstructor) {
+ factory.createConstructor(template.name)
}
else {
- factory.createMethod(template.getName(), template.getReturnType())
+ factory.createMethod(template.name, template.returnType)
}
val method = targetClass.add(methodToAdd) as PsiMethod
- copyModifierListItems(template.getModifierList(), method.getModifierList())
- if (targetClass.isInterface()) {
- method.getModifierList().setModifierProperty(PsiModifier.FINAL, false)
+ copyModifierListItems(template.modifierList, method.modifierList)
+ if (targetClass.isInterface) {
+ method.modifierList.setModifierProperty(PsiModifier.FINAL, false)
}
copyTypeParameters(template, method) { method, typeParameterList ->
- method.addAfter(typeParameterList, method.getModifierList())
+ method.addAfter(typeParameterList, method.modifierList)
}
- val targetParamList = method.getParameterList()
- val newParams = template.getParameterList().getParameters().map {
- val param = factory.createParameter(it.getName()!!, it.getType())
- copyModifierListItems(it.getModifierList()!!, param.getModifierList()!!)
+ val targetParamList = method.parameterList
+ val newParams = template.parameterList.parameters.map {
+ val param = factory.createParameter(it.name!!, it.type)
+ copyModifierListItems(it.modifierList!!, param.modifierList!!)
param
}
ChangeSignatureUtil.synchronizeList(
targetParamList,
newParams,
- { it.getParameters().toList() },
- BooleanArray(newParams.size())
+ { it.parameters.toList() },
+ BooleanArray(newParams.size)
)
- if (template.getModifierList().hasModifierProperty(PsiModifier.ABSTRACT) || targetClass.isInterface()) {
- method.getBody()!!.delete()
+ if (template.modifierList.hasModifierProperty(PsiModifier.ABSTRACT) || targetClass.isInterface) {
+ method.body!!.delete()
}
- else if (!template.isConstructor()) {
+ else if (!template.isConstructor) {
CreateFromUsageUtils.setupMethodBody(method)
}
@@ -542,13 +535,13 @@ fun createJavaField(property: KtProperty, targetClass: PsiClass): PsiField {
val template = LightClassUtil.getLightClassPropertyMethods(property).getter
?: throw AssertionError("Can't generate light method: ${property.getElementTextWithContext()}")
- val factory = PsiElementFactory.SERVICE.getInstance(template.getProject())
- val field = targetClass.add(factory.createField(property.getName()!!, template.getReturnType()!!)) as PsiField
+ val factory = PsiElementFactory.SERVICE.getInstance(template.project)
+ val field = targetClass.add(factory.createField(property.name!!, template.returnType!!)) as PsiField
- with(field.getModifierList()!!) {
- val templateModifiers = template.getModifierList()
+ with(field.modifierList!!) {
+ val templateModifiers = template.modifierList
setModifierProperty(VisibilityUtil.getVisibilityModifier(templateModifiers), true)
- if (!property.isVar() || targetClass.isInterface()) {
+ if (!property.isVar || targetClass.isInterface) {
setModifierProperty(PsiModifier.FINAL, true)
}
copyModifierListItems(templateModifiers, this, false)
@@ -558,10 +551,10 @@ fun createJavaField(property: KtProperty, targetClass: PsiClass): PsiField {
}
fun createJavaClass(klass: KtClass, targetClass: PsiClass?, forcePlainClass: Boolean = false): PsiClass {
- val kind = if (forcePlainClass) ClassKind.CLASS else (klass.resolveToDescriptor() as ClassDescriptor).getKind()
+ val kind = if (forcePlainClass) ClassKind.CLASS else (klass.resolveToDescriptor() as ClassDescriptor).kind
- val factory = PsiElementFactory.SERVICE.getInstance(klass.getProject())
- val className = klass.getName()!!
+ val factory = PsiElementFactory.SERVICE.getInstance(klass.project)
+ val className = klass.name!!
val javaClassToAdd = when (kind) {
ClassKind.CLASS -> factory.createClass(className)
ClassKind.INTERFACE -> factory.createInterface(className)
@@ -574,13 +567,13 @@ fun createJavaClass(klass: KtClass, targetClass: PsiClass?, forcePlainClass: Boo
val template = LightClassUtil.getPsiClass(klass)
?: throw AssertionError("Can't generate light class: ${klass.getElementTextWithContext()}")
- copyModifierListItems(template.getModifierList()!!, javaClass.getModifierList()!!)
- if (template.isInterface()) {
- javaClass.getModifierList()!!.setModifierProperty(PsiModifier.ABSTRACT, false)
+ copyModifierListItems(template.modifierList!!, javaClass.modifierList!!)
+ if (template.isInterface) {
+ javaClass.modifierList!!.setModifierProperty(PsiModifier.ABSTRACT, false)
}
copyTypeParameters(template, javaClass) { klass, typeParameterList ->
- klass.addAfter(typeParameterList, klass.getNameIdentifier())
+ klass.addAfter(typeParameterList, klass.nameIdentifier)
}
// Turning interface to class
@@ -605,16 +598,16 @@ fun createJavaClass(klass: KtClass, targetClass: PsiClass?, forcePlainClass: Boo
implementsList?.let { javaClass.implementsList?.replace(it) }
}
- for (method in template.getMethods()) {
- val hasParams = method.getParameterList().getParametersCount() > 0
- val needSuperCall = !template.isEnum() &&
- (template.getSuperClass()?.getConstructors() ?: PsiMethod.EMPTY_ARRAY).all {
- it.getParameterList().getParametersCount() > 0
+ for (method in template.methods) {
+ val hasParams = method.parameterList.parametersCount > 0
+ val needSuperCall = !template.isEnum &&
+ (template.superClass?.constructors ?: PsiMethod.EMPTY_ARRAY).all {
+ it.parameterList.parametersCount > 0
}
- if (method.isConstructor() && !(hasParams || needSuperCall)) continue
+ if (method.isConstructor && !(hasParams || needSuperCall)) continue
with(createJavaMethod(method, javaClass)) {
- if (isConstructor() && needSuperCall) {
- getBody()!!.add(factory.createStatementFromText("super();", this))
+ if (isConstructor && needSuperCall) {
+ body!!.add(factory.createStatementFromText("super();", this))
}
}
}
@@ -626,7 +619,7 @@ fun PsiElement.j2kText(): String? {
if (language != JavaLanguage.INSTANCE) return null
val j2kConverter = JavaToKotlinConverter(project,
- ConverterSettings.defaultSettings,
+ ConverterSettings.Companion.defaultSettings,
IdeaJavaToKotlinServices)
return j2kConverter.elementsToKotlin(listOf(this)).results.single()?.text ?: return null //TODO: insert imports
}
@@ -646,7 +639,7 @@ public fun (() -> Any).runRefactoringWithPostprocessing(
targetRefactoringId: String,
finishAction: () -> Unit
) {
- val connection = project.getMessageBus().connect()
+ val connection = project.messageBus.connect()
connection.subscribe(RefactoringEventListener.REFACTORING_EVENT_TOPIC,
object: RefactoringEventListener {
override fun undoRefactoring(refactoringId: String) {
@@ -689,7 +682,7 @@ public fun KtElement?.validateElement(errorMessage: String) {
public fun Project.runSynchronouslyWithProgress(progressTitle: String, canBeCanceled: Boolean, action: () -> T): T? {
var result: T? = null
- ProgressManager.getInstance().runProcessWithProgressSynchronously( { result = action() }, progressTitle, canBeCanceled, this)
+ ProgressManager.getInstance().runProcessWithProgressSynchronously({ result = action() }, progressTitle, canBeCanceled, this)
return result
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfo.kt
index 88d26d36093..5d47d1a0aee 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfo.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfo.kt
@@ -73,9 +73,7 @@ public fun KotlinMemberInfo.toJavaMemberInfo(): MemberInfo? {
is KtClassOrObject -> declaration.toLightClass()
else -> null
}
- if (psiMember == null) return null
-
- val info = MemberInfo(psiMember, isSuperClass, null)
+ val info = MemberInfo(psiMember ?: return null, isSuperClass, null)
info.isToAbstract = isToAbstract
return info
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionTable.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionTable.kt
index cd32bf29e05..da5117f707c 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionTable.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionTable.kt
@@ -46,7 +46,7 @@ public class KotlinMemberSelectionTable(
}
override fun isAbstractColumnEditable(rowIndex: Int): Boolean {
- val memberInfo = myMemberInfos.get(rowIndex)
+ val memberInfo = myMemberInfos[rowIndex]
if (memberInfo.isStatic()) return false
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/memberInfoUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/memberInfoUtils.kt
index 5d2f20010d5..000525210ee 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/memberInfoUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/memberInfoUtils.kt
@@ -17,17 +17,13 @@
package org.jetbrains.kotlin.idea.refactoring.memberInfo
import com.intellij.psi.PsiClass
-import com.intellij.psi.PsiMember
-import com.intellij.psi.PsiModifier
import com.intellij.psi.PsiNamedElement
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
-import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtClassOrObject
-import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
fun PsiNamedElement.getClassDescriptorIfAny(resolutionFacade: ResolutionFacade? = null): ClassDescriptor? {
@@ -38,14 +34,6 @@ fun PsiNamedElement.getClassDescriptorIfAny(resolutionFacade: ResolutionFacade?
}
}
-fun PsiNamedElement.isAbstractMember(): Boolean {
- return when(this) {
- is KtNamedDeclaration -> hasModifier(KtTokens.ABSTRACT_KEYWORD)
- is PsiMember -> hasModifierProperty(PsiModifier.ABSTRACT)
- else -> false
- }
-}
-
// Applies to JetClassOrObject and PsiClass
public fun PsiNamedElement.qualifiedClassNameForRendering(): String {
val fqName = when (this) {
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt
index ee8f461647e..0a79b1fb934 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt
@@ -31,31 +31,31 @@ import org.jetbrains.kotlin.idea.references.mainReference
public class MoveJavaInnerClassKotlinUsagesHandler: MoveInnerClassUsagesHandler {
override fun correctInnerClassUsage(usage: UsageInfo, outerClass: PsiClass) {
- val innerCall = usage.getElement()?.getParent() as? KtCallExpression ?: return
+ val innerCall = usage.element?.parent as? KtCallExpression ?: return
- val receiver = (innerCall.getParent() as? KtQualifiedExpression)?.getReceiverExpression()
+ val receiver = (innerCall.parent as? KtQualifiedExpression)?.receiverExpression
val outerClassRef = when (receiver) {
- is KtCallExpression -> receiver.getCalleeExpression()
+ is KtCallExpression -> receiver.calleeExpression
is KtQualifiedExpression -> receiver.getQualifiedElementSelector()
else -> null
} as? KtSimpleNameExpression
if (outerClassRef?.mainReference?.resolve() != outerClass) return
- val outerCall = outerClassRef!!.getParent() as? KtCallExpression ?: return
+ val outerCall = outerClassRef!!.parent as? KtCallExpression ?: return
- val psiFactory = KtPsiFactory(usage.getProject())
+ val psiFactory = KtPsiFactory(usage.project)
- val argumentList = innerCall.getValueArgumentList()
+ val argumentList = innerCall.valueArgumentList
if (argumentList != null) {
val newArguments = ArrayList()
- newArguments.add(outerCall.getText()!!)
- argumentList.getArguments().mapTo(newArguments) { it.getText()!! }
+ newArguments.add(outerCall.text!!)
+ argumentList.arguments.mapTo(newArguments) { it.text!! }
argumentList.replace(psiFactory.createCallArguments(newArguments.joinToString(prefix = "(", postfix = ")")))
}
else {
- innerCall.getLambdaArguments().firstOrNull()?.let { lambdaArg ->
- val anchor = PsiTreeUtil.skipSiblingsBackward(lambdaArg, javaClass())
- innerCall.addAfter(psiFactory.createCallArguments("(${outerCall.getText()})"), anchor)
+ innerCall.lambdaArguments.firstOrNull()?.let { lambdaArg ->
+ val anchor = PsiTreeUtil.skipSiblingsBackward(lambdaArg, PsiWhiteSpace::class.java)
+ innerCall.addAfter(psiFactory.createCallArguments("(${outerCall.text})"), anchor)
}
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageIntention.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageIntention.kt
index b6b92d08c05..490a4fe7965 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageIntention.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageIntention.kt
@@ -24,30 +24,30 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiDocumentManager
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
-import org.jetbrains.kotlin.idea.core.refactoring.hasIdentifiersOnly
+import org.jetbrains.kotlin.idea.refactoring.hasIdentifiersOnly
import org.jetbrains.kotlin.idea.intentions.SelfTargetingOffsetIndependentIntention
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.psi.KtPackageDirective
-public class ChangePackageIntention: SelfTargetingOffsetIndependentIntention(javaClass(), "Change package") {
+public class ChangePackageIntention: SelfTargetingOffsetIndependentIntention(KtPackageDirective::class.java, "Change package") {
companion object {
private val PACKAGE_NAME_VAR = "PACKAGE_NAME"
}
- override fun isApplicableTo(element: KtPackageDirective) = element.getPackageNameExpression() != null
+ override fun isApplicableTo(element: KtPackageDirective) = element.packageNameExpression != null
override fun applyTo(element: KtPackageDirective, editor: Editor) {
- if (ApplicationManager.getApplication().isUnitTestMode()) {
+ if (ApplicationManager.getApplication().isUnitTestMode) {
throw UnsupportedOperationException("Do not call applyTo() in the test mode")
}
val file = element.getContainingKtFile()
- val project = file.getProject()
+ val project = file.project
- val nameExpression = element.getPackageNameExpression()!!
- val currentName = element.getQualifiedName()
+ val nameExpression = element.packageNameExpression!!
+ val currentName = element.qualifiedName
val builder = TemplateBuilderImpl(file)
builder.replaceElement(
@@ -64,7 +64,7 @@ public class ChangePackageIntention: SelfTargetingOffsetIndependentIntention(),
+ elementsToMove = file.declarations.filterIsInstance(),
moveTarget = object: KotlinMoveTarget {
- override val packageWrapper = PackageWrapper(file.getManager(), newFqName.asString())
+ override val packageWrapper = PackageWrapper(file.manager, newFqName.asString())
- override fun getOrCreateTargetPsi(originalPsi: PsiElement) = originalPsi.getContainingFile()
+ override fun getOrCreateTargetPsi(originalPsi: PsiElement) = originalPsi.containingFile
override fun getTargetPsiIfExists(originalPsi: PsiElement) = null
@@ -61,7 +61,7 @@ public class KotlinChangePackageRefactoring(val file: KtFile) {
val internalUsages = file.getInternalReferencesToUpdateOnPackageNameChange(PackageNameInfo(currentFqName, newFqName.toUnsafe()))
project.executeWriteCommand("Change file's package to '${newFqName.asString()}'") {
- packageDirective.setFqName(newFqName)
+ packageDirective.fqName = newFqName
postProcessMoveUsages(internalUsages)
project.runWithElementsToShortenIsEmptyIgnored { declarationProcessor.execute(declarationUsages) }
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/MoveFileToPackageMatchingDirectoryIntention.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/MoveFileToPackageMatchingDirectoryIntention.kt
index 6e93fdffaee..68ffb03988c 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/MoveFileToPackageMatchingDirectoryIntention.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/MoveFileToPackageMatchingDirectoryIntention.kt
@@ -19,38 +19,35 @@ package org.jetbrains.kotlin.idea.refactoring.move.changePackage
import com.intellij.CommonBundle
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.ui.Messages
-import com.intellij.psi.JavaPsiFacade
-import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesUtil
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesUtil
import com.intellij.refactoring.util.RefactoringMessageUtil
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.core.packageMatchesDirectory
import org.jetbrains.kotlin.idea.intentions.SelfTargetingOffsetIndependentIntention
import org.jetbrains.kotlin.psi.KtPackageDirective
-import org.jetbrains.kotlin.idea.core.packageMatchesDirectory
public class MoveFileToPackageMatchingDirectoryIntention : SelfTargetingOffsetIndependentIntention(
- javaClass(), "", "Move file to package-matching directory"
+ KtPackageDirective::class.java, "", "Move file to package-matching directory"
) {
override fun isApplicableTo(element: KtPackageDirective): Boolean {
if (element.getContainingKtFile().packageMatchesDirectory()) return false
- val qualifiedName = element.getQualifiedName()
+ val qualifiedName = element.qualifiedName
val dirName = if (qualifiedName.isEmpty()) "source root" else "'${qualifiedName.replace('.', '/')}'"
- setText("Move file to $dirName")
+ text = "Move file to $dirName"
return true
}
override fun applyTo(element: KtPackageDirective, editor: Editor) {
val file = element.getContainingKtFile()
- val project = file.getProject()
+ val project = file.project
val targetDirectory = MoveClassesOrPackagesUtil.chooseDestinationPackage(
project,
- element.getQualifiedName(),
- file.getContainingDirectory()
+ element.qualifiedName,
+ file.containingDirectory
) ?: return
- RefactoringMessageUtil.checkCanCreateFile(targetDirectory, file.getName())?.let {
+ RefactoringMessageUtil.checkCanCreateFile(targetDirectory, file.name)?.let {
Messages.showMessageDialog(project, it, CommonBundle.getErrorTitle(), Messages.getErrorIcon())
return
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt
index 866e4103322..db9c4cb18fc 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt
@@ -22,5 +22,5 @@ import org.jetbrains.kotlin.psi.KtPackageDirective
public class PackageDirectoryMismatchInspection: IntentionBasedInspection(
listOf(IntentionBasedInspection.IntentionData(MoveFileToPackageMatchingDirectoryIntention()), IntentionBasedInspection.IntentionData(ChangePackageToMatchDirectoryIntention())),
"Package directive doesn't match file location",
- javaClass()
+ KtPackageDirective::class.java
)
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt
index 2c42aec542e..84b05aa54a8 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt
@@ -26,7 +26,7 @@ import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectori
import com.intellij.usageView.UsageInfo
import com.intellij.util.Function
import org.jetbrains.kotlin.idea.core.getPackage
-import org.jetbrains.kotlin.idea.core.refactoring.invokeOnceOnCommandFinish
+import org.jetbrains.kotlin.idea.refactoring.invokeOnceOnCommandFinish
import org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.MoveKotlinTopLevelDeclarationsProcessor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtFile
@@ -54,7 +54,7 @@ public class KotlinMoveDirectoryWithClassesHelper : MoveDirectoryWithClassesHelp
return fileToMoveContext
?: HashMap().apply {
fileToMoveContext = this
- invokeOnceOnCommandFinish { fileToMoveContext = null }
+ invokeOnceOnCommandFinish { fileToMoveContext = null }
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveFilesOrDirectoriesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveFilesOrDirectoriesHandler.kt
index 6cc8aac20be..03ce1a1169d 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveFilesOrDirectoriesHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveFilesOrDirectoriesHandler.kt
@@ -29,8 +29,8 @@ public class KotlinMoveFilesOrDirectoriesHandler : MoveFilesOrDirectoriesHandler
return elements.map {
when {
it is PsiFile || it is PsiDirectory -> it
- it is PsiClass && it.getContainingClass() == null -> it.getContainingFile()
- it is KtClassOrObject && it.getParent() is KtFile -> it.getParent()
+ it is PsiClass && it.containingClass == null -> it.containingFile
+ it is KtClassOrObject && it.parent is KtFile -> it.parent
else -> return null
}
}.toTypedArray()
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt
index d3c72e72d0e..f5ccd967707 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt
@@ -24,10 +24,9 @@ import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectori
import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.codeInsight.shorten.runWithElementsToShortenIsEmptyIgnored
-import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.core.getPackage
import org.jetbrains.kotlin.idea.core.packageMatchesDirectory
-import org.jetbrains.kotlin.idea.core.refactoring.hasIdentifiersOnly
+import org.jetbrains.kotlin.idea.refactoring.hasIdentifiersOnly
import org.jetbrains.kotlin.idea.refactoring.move.*
import org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.*
import org.jetbrains.kotlin.name.FqNameUnsafe
@@ -133,7 +132,7 @@ public class MoveKotlinFileHandler : MoveFileHandler() {
}
override fun retargetUsages(usageInfos: List?, oldToNewMap: Map) {
- val moveContext = oldToNewMap.keySet().firstIsInstanceOrNull() ?: return
+ val moveContext = oldToNewMap.keys.firstIsInstanceOrNull() ?: return
retargetUsages(usageInfos, moveContext.declarationMoveProcessor)
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/KotlinMoveTarget.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/KotlinMoveTarget.kt
index efbbd478e89..35e7e048ea8 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/KotlinMoveTarget.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/KotlinMoveTarget.kt
@@ -42,8 +42,8 @@ public object EmptyKotlinMoveTarget: KotlinMoveTarget {
}
public class KotlinMoveTargetForExistingFile(val targetFile: KtFile): KotlinMoveTarget {
- override val packageWrapper: PackageWrapper? = targetFile.getPackageFqName().asString().let { packageName ->
- PackageWrapper(PsiManager.getInstance(targetFile.getProject()), packageName)
+ override val packageWrapper: PackageWrapper? = targetFile.packageFqName.asString().let { packageName ->
+ PackageWrapper(PsiManager.getInstance(targetFile.project), packageName)
}
override fun getOrCreateTargetPsi(originalPsi: PsiElement) = targetFile
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveDeclarationToSeparateFileIntention.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveDeclarationToSeparateFileIntention.kt
index 7452bde031a..03ea0745af0 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveDeclarationToSeparateFileIntention.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveDeclarationToSeparateFileIntention.kt
@@ -24,7 +24,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.util.TextRange
import com.intellij.refactoring.move.MoveCallback
import com.intellij.refactoring.util.CommonRefactoringUtil
-import org.jetbrains.kotlin.idea.core.refactoring.createKotlinFile
+import org.jetbrains.kotlin.idea.refactoring.createKotlinFile
import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention
import org.jetbrains.kotlin.idea.quickfix.moveCaret
import org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog
@@ -43,7 +43,7 @@ public class MoveDeclarationToSeparateFileIntention :
if (element.name == null) return null
if (element.parent !is KtFile) return null
if (element.hasModifier(KtTokens.PRIVATE_KEYWORD)) return null
- if (element.getContainingKtFile().declarations.size() == 1) return null
+ if (element.getContainingKtFile().declarations.size == 1) return null
val keyword = when (element) {
is KtClass -> element.getClassOrInterfaceKeyword()
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsHandler.kt
index 26e11560817..9e532464bca 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsHandler.kt
@@ -31,8 +31,7 @@ import com.intellij.refactoring.move.MoveHandlerDelegate
import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesImpl
import com.intellij.refactoring.util.CommonRefactoringUtil
import org.jetbrains.kotlin.idea.core.getPackage
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
-import org.jetbrains.kotlin.idea.core.refactoring.isInJavaSourceRoot
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog
import org.jetbrains.kotlin.psi.*
import java.util.*
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt
index ae2be9dd510..59068fdb750 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt
@@ -47,7 +47,7 @@ import org.jetbrains.kotlin.idea.codeInsight.KotlinFileReferencesResolver
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.core.deleteSingle
import org.jetbrains.kotlin.idea.core.getPackage
-import org.jetbrains.kotlin.idea.core.refactoring.getUsageContext
+import org.jetbrains.kotlin.idea.refactoring.getUsageContext
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName
import org.jetbrains.kotlin.idea.refactoring.move.*
@@ -96,7 +96,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
}
private var nonCodeUsages: Array? = null
- private val elementsToMove = options.elementsToMove.filter { e -> e.getContainingFile() != options.moveTarget.getTargetPsiIfExists(e) }
+ private val elementsToMove = options.elementsToMove.filter { e -> e.containingFile != options.moveTarget.getTargetPsiIfExists(e) }
private val kotlinToLightElementsBySourceFile = elementsToMove
.groupBy { it.getContainingKtFile() }
.mapValues { it.value.keysToMap { it.toLightElements() } }
@@ -110,18 +110,18 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
}
public override fun findUsages(): Array {
- val newPackageName = options.moveTarget.packageWrapper?.getQualifiedName() ?: ""
+ val newPackageName = options.moveTarget.packageWrapper?.qualifiedName ?: ""
fun collectUsages(kotlinToLightElements: Map>, result: MutableList) {
- kotlinToLightElements.values().flatMap { it }.flatMapTo(result) { lightElement ->
- val newFqName = StringUtil.getQualifiedName(newPackageName, lightElement.getName())
+ kotlinToLightElements.values.flatMap { it }.flatMapTo(result) { lightElement ->
+ val newFqName = StringUtil.getQualifiedName(newPackageName, lightElement.name)
val foundReferences = HashSet()
- val projectScope = lightElement.getProject().projectScope()
+ val projectScope = lightElement.project.projectScope()
val results = ReferencesSearch
.search(lightElement, projectScope, false)
.mapNotNullTo(ArrayList()) { ref ->
- if (foundReferences.add(ref) && elementsToMove.all { !it.isAncestor(ref.getElement())}) {
+ if (foundReferences.add(ref) && elementsToMove.all { !it.isAncestor(ref.element)}) {
createMoveUsageInfoIfPossible(ref, lightElement, true)
}
else null
@@ -139,7 +139,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
)
}
- MoveClassHandler.EP_NAME.getExtensions().forEach { handler -> handler.preprocessUsages(results) }
+ MoveClassHandler.EP_NAME.extensions.forEach { handler -> handler.preprocessUsages(results) }
results
}
@@ -155,10 +155,10 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
fun collectConflictsInUsages(usages: List) {
val declarationToContainers = HashMap>()
for (usage in usages) {
- val element = usage.getElement()
+ val element = usage.element
if (element == null || usage !is MoveRenameUsageInfo || usage is NonCodeUsageInfo) continue
- val declaration = usage.getReferencedElement()?.namedUnwrappedElement as? KtNamedDeclaration
+ val declaration = usage.referencedElement?.namedUnwrappedElement as? KtNamedDeclaration
if (declaration == null || !declaration.isPrivate()) continue
if (element.isInsideOf(elementsToMove)) continue
@@ -166,8 +166,8 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
val container = element.getUsageContext()
if (!declarationToContainers.getOrPut(declaration) { HashSet() }.add(container)) continue
- val currentPackage = element.getContainingFile()?.getContainingDirectory()?.getPackage()
- if (currentPackage?.getQualifiedName() == newPackageName) continue
+ val currentPackage = element.containingFile?.containingDirectory?.getPackage()
+ if (currentPackage?.qualifiedName == newPackageName) continue
conflicts.putValue(
declaration,
@@ -188,7 +188,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
val referenceToContext = KotlinFileReferencesResolver.resolve(element = declaration, resolveQualifiers = false)
for ((refExpr, bindingContext) in referenceToContext) {
val refTarget = bindingContext[BindingContext.REFERENCE_TARGET, refExpr]?.let { descriptor ->
- DescriptorToSourceUtilsIde.getAnyDeclaration(declaration.getProject(), descriptor)
+ DescriptorToSourceUtilsIde.getAnyDeclaration(declaration.project, descriptor)
}
if (refTarget == null || refTarget.isInsideOf(elementsToMove)) continue
@@ -196,7 +196,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
is KtModifierListOwner ->
refTarget.isPrivate()
is PsiModifierListOwner ->
- VisibilityUtil.getVisibilityModifier(refTarget.getModifierList()) == PsiModifier.PACKAGE_LOCAL
+ VisibilityUtil.getVisibilityModifier(refTarget.modifierList) == PsiModifier.PACKAGE_LOCAL
else -> false
}
@@ -204,8 +204,8 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
if (!declarationToReferenceTargets.getOrPut(declaration) { HashSet() }.add(refTarget)) continue
- val currentPackage = declaration.getContainingFile()?.getContainingDirectory()?.getPackage()
- if (currentPackage?.getQualifiedName() == newPackageName) continue
+ val currentPackage = declaration.containingFile?.containingDirectory?.getPackage()
+ if (currentPackage?.qualifiedName == newPackageName) continue
conflicts.putValue(
declaration,
@@ -222,7 +222,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
val usages = ArrayList()
for ((sourceFile, kotlinToLightElements) in kotlinToLightElementsBySourceFile) {
// No need to find and process usages if package is not changed
- if (sourceFile.getPackageFqName().asString() == newPackageName) return UsageInfo.EMPTY_ARRAY
+ if (sourceFile.packageFqName.asString() == newPackageName) return UsageInfo.EMPTY_ARRAY
collectUsages(kotlinToLightElements, usages)
collectConflictsInUsages(usages)
@@ -243,14 +243,14 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
moveTarget: KotlinMoveTarget,
usagesToProcessAfterMove: MutableList
): KtNamedDeclaration? {
- val file = declaration.getContainingFile() as? KtFile
- assert(file != null) { "${declaration.javaClass}: ${declaration.getText()}" }
+ val file = declaration.containingFile as? KtFile
+ assert(file != null) { "${declaration.javaClass}: ${declaration.text}" }
val targetFile = moveTarget.getOrCreateTargetPsi(declaration) as? KtFile
- ?: throw AssertionError("Couldn't create Kotlin file for: ${declaration.javaClass}: ${declaration.getText()}")
+ ?: throw AssertionError("Couldn't create Kotlin file for: ${declaration.javaClass}: ${declaration.text}")
if (options.updateInternalReferences) {
- val packageNameInfo = PackageNameInfo(file!!.getPackageFqName(), targetFile.getPackageFqName().toUnsafe())
+ val packageNameInfo = PackageNameInfo(file!!.packageFqName, targetFile.packageFqName.toUnsafe())
val (usagesToProcessLater, usagesToProcessNow) = declaration
.getInternalReferencesToUpdateOnPackageNameChange(packageNameInfo)
.partition { it is MoveRenameUsageInfoForExtension }
@@ -300,7 +300,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
oldToNewElementsMapping[sourceFile] = newDeclaration.getContainingKtFile()
- getTransaction()!!.getElementListener(oldDeclaration).elementMoved(newDeclaration)
+ transaction!!.getElementListener(oldDeclaration).elementMoved(newDeclaration)
for ((oldElement, newElement) in oldLightElements.asSequence().zip(newDeclaration.toLightElements().asSequence())) {
oldToNewElementsMapping[oldElement] = newElement
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt
index 54efa052237..7d5bc39175f 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt
@@ -45,7 +45,7 @@ import com.intellij.util.IncorrectOperationException
import com.intellij.util.ui.FormBuilder
import com.intellij.util.ui.UIUtil
import org.jetbrains.kotlin.idea.core.packageMatchesDirectory
-import org.jetbrains.kotlin.idea.core.refactoring.isInJavaSourceRoot
+import org.jetbrains.kotlin.idea.refactoring.isInJavaSourceRoot
import org.jetbrains.kotlin.idea.util.application.executeCommand
import org.jetbrains.kotlin.idea.util.application.runWriteAction
import org.jetbrains.kotlin.psi.KtFile
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java
index 8f2837e3235..14c3a7e2259 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java
@@ -55,15 +55,15 @@ import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.text.UniqueNameGenerator;
import com.intellij.util.ui.UIUtil;
-import kotlin.ArraysKt;
-import kotlin.CollectionsKt;
+import kotlin.collections.ArraysKt;
+import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KotlinFileType;
import org.jetbrains.kotlin.idea.core.PackageUtilsKt;
-import org.jetbrains.kotlin.idea.core.refactoring.JetRefactoringUtilKt;
+import org.jetbrains.kotlin.idea.refactoring.JetRefactoringUtilKt;
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle;
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo;
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionPanel;
@@ -760,7 +760,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
MoveKotlinTopLevelDeclarationsOptions options = new MoveKotlinTopLevelDeclarationsOptions(
elementsToMove, target, isSearchInComments(), isSearchInNonJavaFiles(), true, deleteSourceFile, moveCallback
);
- invokeRefactoring(new MoveKotlinTopLevelDeclarationsProcessor(myProject, options, Mover.Default.INSTANCE$));
+ invokeRefactoring(new MoveKotlinTopLevelDeclarationsProcessor(myProject, options, Mover.Default.INSTANCE));
}
catch (IncorrectOperationException e) {
CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"), e.getMessage(), null, myProject);
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt
index 70dd6e71090..70d81b994c5 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt
@@ -21,7 +21,6 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.util.Comparing
import com.intellij.openapi.util.Key
-import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.*
import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.RefactoringSettings
@@ -44,9 +43,9 @@ import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.codeInsight.KotlinFileReferencesResolver
-import org.jetbrains.kotlin.idea.core.refactoring.isInJavaSourceRoot
import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.refactoring.fqName.isImported
+import org.jetbrains.kotlin.idea.refactoring.isInJavaSourceRoot
import org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.ui.KotlinAwareMoveFilesOrDirectoriesDialog
import org.jetbrains.kotlin.idea.references.KtReference
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
@@ -79,15 +78,15 @@ fun KtElement.lazilyProcessInternalReferencesToUpdateOnPackageNameChange(
packageNameInfo: PackageNameInfo,
body: (originalRefExpr: KtSimpleNameExpression, usageFactory: (KtSimpleNameExpression) -> UsageInfo?) -> Unit
) {
- val file = getContainingFile() as? KtFile ?: return
+ val file = containingFile as? KtFile ?: return
- val importPaths = file.getImportDirectives().mapNotNull { it.getImportPath() }
+ val importPaths = file.importDirectives.mapNotNull { it.importPath }
tailrec fun isImported(descriptor: DeclarationDescriptor): Boolean {
- val fqName = DescriptorUtils.getFqName(descriptor).let { if (it.isSafe()) it.toSafe() else return@isImported false }
+ val fqName = DescriptorUtils.getFqName(descriptor).let { if (it.isSafe) it.toSafe() else return@isImported false }
if (importPaths.any { fqName.isImported(it, false) }) return true
- val containingDescriptor = descriptor.getContainingDeclaration()
+ val containingDescriptor = descriptor.containingDeclaration
return when (containingDescriptor) {
is ClassDescriptor, is PackageViewDescriptor -> isImported(containingDescriptor)
else -> false
@@ -97,13 +96,13 @@ fun KtElement.lazilyProcessInternalReferencesToUpdateOnPackageNameChange(
fun processReference(refExpr: KtSimpleNameExpression, bindingContext: BindingContext): ((KtSimpleNameExpression) -> UsageInfo?)? {
val descriptor = bindingContext[BindingContext.REFERENCE_TARGET, refExpr]?.getImportableDescriptor() ?: return null
- val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(getProject(), descriptor) ?: return null
+ val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor) ?: return null
val isCallable = descriptor is CallableDescriptor
val isExtension = isCallable && declaration.isExtensionDeclaration()
if (isCallable && !isExtension) {
- val containingDescriptor = descriptor.getContainingDeclaration()
+ val containingDescriptor = descriptor.containingDeclaration
if (refExpr.getReceiverExpression() != null) {
return fun(refExpr: KtSimpleNameExpression): UsageInfo? {
val receiver = refExpr.getReceiverExpression() ?: return null
@@ -116,9 +115,9 @@ fun KtElement.lazilyProcessInternalReferencesToUpdateOnPackageNameChange(
}
val fqName = DescriptorUtils.getFqName(descriptor)
- if (!fqName.isSafe()) return null
+ if (!fqName.isSafe) return null
- val packageName = DescriptorUtils.getParentOfType(descriptor, javaClass(), false)?.let {
+ val packageName = DescriptorUtils.getParentOfType(descriptor, PackageFragmentDescriptor::class.java, false)?.let {
DescriptorUtils.getFqName(it).toSafe()
}
@@ -133,7 +132,7 @@ fun KtElement.lazilyProcessInternalReferencesToUpdateOnPackageNameChange(
return fqName.asString().let {
val prefix = packageName.asString()
val prefixOffset = it.indexOf(prefix)
- val newFqName = FqName(it.replaceRange(prefixOffset..prefixOffset + prefix.length() - 1, newPackageName.asString()))
+ val newFqName = FqName(it.replaceRange(prefixOffset..prefixOffset + prefix.length - 1, newPackageName.asString()))
MoveRenameSelfUsageInfo(refExpr.mainReference, declaration, newFqName)
}
}
@@ -151,7 +150,7 @@ fun KtElement.lazilyProcessInternalReferencesToUpdateOnPackageNameChange(
val referenceToContext = KotlinFileReferencesResolver.resolve(file = file, elements = listOf(this))
for ((refExpr, bindingContext) in referenceToContext) {
- if (refExpr !is KtSimpleNameExpression || refExpr.getParent() is KtThisExpression) continue
+ if (refExpr !is KtSimpleNameExpression || refExpr.parent is KtThisExpression) continue
if (bindingContext[BindingContext.QUALIFIER, refExpr] != null) continue
processReference(refExpr, bindingContext)?.let { body(refExpr, it) }
@@ -178,16 +177,16 @@ fun createMoveUsageInfoIfPossible(
referencedElement: PsiElement,
addImportToOriginalFile: Boolean
): UsageInfo? {
- val element = reference.getElement()
+ val element = reference.element
if (element.getStrictParentOfType() != null) return null
- val range = reference.getRangeInElement()!!
- val startOffset = range.getStartOffset()
- val endOffset = range.getEndOffset()
+ val range = reference.rangeInElement!!
+ val startOffset = range.startOffset
+ val endOffset = range.endOffset
if (isUnqualifiedExtensionReference(reference, referencedElement)) {
return MoveRenameUsageInfoForExtension(
- element, reference, startOffset, endOffset, referencedElement, element.getContainingFile()!!, addImportToOriginalFile
+ element, reference, startOffset, endOffset, referencedElement, element.containingFile!!, addImportToOriginalFile
)
}
return MoveRenameUsageInfo(element, reference, startOffset, endOffset, referencedElement, false)
@@ -213,7 +212,7 @@ public fun guessNewFileName(declarationsToMove: Collection):
private fun updateJavaReference(reference: PsiReferenceExpression, oldElement: PsiElement, newElement: PsiElement): Boolean {
if (oldElement is PsiMember && newElement is PsiMember) {
// Remove import of old package facade, if any
- val oldClassName = oldElement.getContainingClass()?.getQualifiedName()
+ val oldClassName = oldElement.containingClass?.qualifiedName
if (oldClassName != null) {
val importOfOldClass = (reference.containingFile as? PsiJavaFile)?.importList?.allImportStatements?.firstOrNull {
when (it) {
@@ -227,12 +226,12 @@ private fun updateJavaReference(reference: PsiReferenceExpression, oldElement: P
}
}
- val newClass = newElement.getContainingClass()
- if (newClass != null && reference.getQualifierExpression() != null) {
- val mockMoveMembersOptions = MockMoveMembersOptions(newClass.getQualifiedName(), arrayOf(newElement))
+ val newClass = newElement.containingClass
+ if (newClass != null && reference.qualifierExpression != null) {
+ val mockMoveMembersOptions = MockMoveMembersOptions(newClass.qualifiedName, arrayOf(newElement))
val moveMembersUsageInfo = MoveMembersProcessor.MoveMembersUsageInfo(
- newElement, reference.getElement(), newClass, reference.getQualifierExpression(), reference)
- val moveMemberHandler = MoveMemberHandler.EP_NAME.forLanguage(reference.getElement().getLanguage())
+ newElement, reference.element, newClass, reference.qualifierExpression, reference)
+ val moveMemberHandler = MoveMemberHandler.EP_NAME.forLanguage(reference.element.language)
if (moveMemberHandler != null) {
moveMemberHandler.changeExternalUsage(mockMoveMembersOptions, moveMembersUsageInfo)
return true
@@ -252,22 +251,20 @@ fun postProcessMoveUsages(usages: List,
fun counterpart(e: PsiElement) = oldToNewElementsMapping[e] ?: e
val sortedUsages = usages.sortedWith(
- object : Comparator {
- override fun compare(o1: UsageInfo, o2: UsageInfo): Int {
- val file1 = o1.getVirtualFile()
- val file2 = o2.getVirtualFile()
- if (Comparing.equal(file1, file2)) {
- val rangeInElement1 = o1.getRangeInElement()
- val rangeInElement2 = o2.getRangeInElement()
- if (rangeInElement1 != null && rangeInElement2 != null) {
- return rangeInElement2.getStartOffset() - rangeInElement1.getStartOffset()
- }
- return 0
+ Comparator { o1, o2 ->
+ val file1 = o1.virtualFile
+ val file2 = o2.virtualFile
+ if (Comparing.equal(file1, file2)) {
+ val rangeInElement1 = o1.rangeInElement
+ val rangeInElement2 = o2.rangeInElement
+ if (rangeInElement1 != null && rangeInElement2 != null) {
+ return@Comparator rangeInElement2.startOffset - rangeInElement1.startOffset
}
- if (file1 == null) return -1
- if (file2 == null) return 1
- return Comparing.compare(file1.getPath(), file2.getPath())
+ return@Comparator 0
}
+ if (file1 == null) return@Comparator -1
+ if (file2 == null) return@Comparator 1
+ Comparing.compare(file1.path, file2.path)
}
)
@@ -285,14 +282,14 @@ fun postProcessMoveUsages(usages: List,
is MoveRenameUsageInfoForExtension -> {
val file = with(usage) { if (addImportToOriginalFile) originalFile else counterpart(originalFile) } as KtFile
- val declaration = counterpart(usage.getReferencedElement()!!).unwrapped as KtDeclaration
- ImportInsertHelper.getInstance(usage.getProject()).importDescriptor(file, declaration.resolveToDescriptor())
+ val declaration = counterpart(usage.referencedElement!!).unwrapped as KtDeclaration
+ ImportInsertHelper.getInstance(usage.project).importDescriptor(file, declaration.resolveToDescriptor())
}
is MoveRenameUsageInfo -> {
- val oldElement = usage.getReferencedElement()!!
+ val oldElement = usage.referencedElement!!
val newElement = counterpart(oldElement)
- usage.getReference()?.let {
+ usage.reference?.let {
try {
if (it is KtSimpleNameReference) {
it.bindToElement(newElement, shorteningMode)
@@ -340,10 +337,10 @@ public fun moveFilesOrDirectories(
val updatePackageDirective = (moveDialog as? KotlinAwareMoveFilesOrDirectoriesDialog)?.updatePackageDirective
try {
- val choice = if (elements.size() > 1 || elements[0] is PsiDirectory) intArrayOf(-1) else null
+ val choice = if (elements.size > 1 || elements[0] is PsiDirectory) intArrayOf(-1) else null
val elementsToMove = elements.filterNot {
it is PsiFile
- && runWriteAction { CopyFilesOrDirectoriesHandler.checkFileExist(selectedDir, choice, it, it.getName(), "Move") }
+ && runWriteAction { CopyFilesOrDirectoriesHandler.checkFileExist(selectedDir, choice, it, it.name, "Move") }
}
elementsToMove.forEach {
@@ -370,12 +367,12 @@ public fun moveFilesOrDirectories(
}
}
catch (e: IncorrectOperationException) {
- CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"), e.getMessage(), "refactoring.moveFile", project)
+ CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"), e.message, "refactoring.moveFile", project)
}
}
}
- if (ApplicationManager.getApplication().isUnitTestMode()) {
+ if (ApplicationManager.getApplication().isUnitTestMode) {
doRun(null)
return
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPreconversionPullUpHelper.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPreconversionPullUpHelper.kt
index cce472bd3d2..1367b68bc20 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPreconversionPullUpHelper.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPreconversionPullUpHelper.kt
@@ -30,8 +30,8 @@ import com.intellij.util.VisibilityUtil
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.core.getOrCreateCompanionObject
-import org.jetbrains.kotlin.idea.core.refactoring.j2k
-import org.jetbrains.kotlin.idea.core.refactoring.j2kText
+import org.jetbrains.kotlin.idea.refactoring.j2k
+import org.jetbrains.kotlin.idea.refactoring.j2kText
import org.jetbrains.kotlin.idea.core.setVisibility
import org.jetbrains.kotlin.idea.refactoring.safeDelete.removeOverrideModifier
import org.jetbrains.kotlin.lexer.KtTokens
@@ -133,7 +133,7 @@ public class JavaToKotlinPreconversionPullUpHelper(
membersToDummyDeclarations[member] = addMemberToTarget(dummyDeclaration, memberOwner)
}
- private fun getCurrentSuperInterfaceCount() = dummyTargetClass.implementsList?.referenceElements?.size() ?: 0
+ private fun getCurrentSuperInterfaceCount() = dummyTargetClass.implementsList?.referenceElements?.size ?: 0
override fun postProcessMember(member: PsiMember) {
javaHelper.postProcessMember(member)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpDialog.kt
index 91c52a0ae65..ff398f9c15b 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpDialog.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpDialog.kt
@@ -28,7 +28,7 @@ import com.intellij.refactoring.classMembers.MemberInfoModel
import com.intellij.refactoring.memberPullUp.PullUpProcessor
import com.intellij.refactoring.util.DocCommentPolicy
import org.jetbrains.kotlin.asJava.toLightClass
-import org.jetbrains.kotlin.idea.core.refactoring.isInterfaceClass
+import org.jetbrains.kotlin.idea.refactoring.isInterfaceClass
import org.jetbrains.kotlin.idea.refactoring.memberInfo.*
import org.jetbrains.kotlin.psi.*
@@ -109,12 +109,12 @@ public class KotlinPullUpDialog(
override fun createMemberSelectionTable(infos: MutableList) =
KotlinMemberSelectionTable(infos, null, "Make abstract")
- override fun isOKActionEnabled() = selectedMemberInfos.size() > 0
+ override fun isOKActionEnabled() = selectedMemberInfos.size > 0
override fun doAction() {
val selectedMembers = selectedMemberInfos
val targetClass = superClass!!
- checkConflicts(getProject(), sourceClass, targetClass, selectedMembers, { close(DialogWrapper.OK_EXIT_CODE) }) {
+ checkConflicts(project, sourceClass, targetClass, selectedMembers, { close(DialogWrapper.OK_EXIT_CODE) }) {
invokeRefactoring(createProcessor(sourceClass, targetClass, selectedMembers))
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHandler.kt
index 472ea4b4254..eb48ac11869 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHandler.kt
@@ -28,7 +28,7 @@ import com.intellij.refactoring.util.CommonRefactoringUtil
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
-import org.jetbrains.kotlin.idea.core.refactoring.canRefactor
+import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.refactoring.AbstractPullPushMembersHandler
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfoStorage
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelper.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelper.kt
index 14f739903d9..14bbf865ca5 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelper.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelper.kt
@@ -34,10 +34,9 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.core.dropDefaultValue
-import org.jetbrains.kotlin.idea.core.refactoring.createJavaField
-import org.jetbrains.kotlin.idea.core.refactoring.createJavaMethod
-import org.jetbrains.kotlin.idea.core.refactoring.createPrimaryConstructorIfAbsent
import org.jetbrains.kotlin.idea.intentions.setType
+import org.jetbrains.kotlin.idea.refactoring.createJavaField
+import org.jetbrains.kotlin.idea.refactoring.createPrimaryConstructorIfAbsent
import org.jetbrains.kotlin.idea.refactoring.safeDelete.removeOverrideModifier
import org.jetbrains.kotlin.idea.util.anonymousObjectSuperTypeOrNull
import org.jetbrains.kotlin.idea.util.psi.patternMatching.KotlinPsiUnifier
@@ -216,7 +215,7 @@ class KotlinPullUpHelper(
}
private val targetConstructorToPropertyInitializerInfoMap = LinkedHashMap>().let { result ->
- for (targetConstructor in targetToSourceConstructors.keySet()) {
+ for (targetConstructor in targetToSourceConstructors.keys) {
val propertyToInitializerInfo = LinkedHashMap()
for (property in propertiesToMoveInitializers) {
val propertyDescriptor = data.memberDescriptors[property] as? PropertyDescriptor ?: continue
@@ -224,14 +223,14 @@ class KotlinPullUpHelper(
}
val unmovableProperties = RefactoringUtil.transitiveClosure(
object : RefactoringUtil.Graph {
- override fun getVertices() = propertyToInitializerInfo.keySet()
+ override fun getVertices() = propertyToInitializerInfo.keys
override fun getTargets(source: KtProperty) = propertyToInitializerInfo[source]?.usedProperties
},
{ !propertyToInitializerInfo.containsKey(it) }
)
- propertyToInitializerInfo.keySet().removeAll(unmovableProperties)
+ propertyToInitializerInfo.keys.removeAll(unmovableProperties)
result[targetConstructor] = propertyToInitializerInfo
}
result
@@ -393,7 +392,7 @@ class KotlinPullUpHelper(
val newTypeParameterBounds = lightMethod.typeParameters.map {
it.superTypes.map { substitutor.substitute(it) as? PsiClassType ?: objectType }
}
- val newMethod = createJavaMethod(member, data.targetClass)
+ val newMethod = org.jetbrains.kotlin.idea.refactoring.createJavaMethod(member, data.targetClass)
RefactoringUtil.makeMethodAbstract(data.targetClass, newMethod)
newMethod.returnTypeElement?.replace(elementFactory.createTypeElement(newReturnType))
newMethod.parameterList.parameters.forEachIndexed { i, parameter ->
@@ -565,17 +564,15 @@ class KotlinPullUpHelper(
}
}
- for ((constructorElement, propertyToInitializerInfo) in targetConstructorToPropertyInitializerInfoMap.entrySet()) {
- val properties = propertyToInitializerInfo.keySet().sortedWith(
- object : Comparator {
- override fun compare(property1: KtProperty, property2: KtProperty): Int {
- val info1 = propertyToInitializerInfo[property1]!!
- val info2 = propertyToInitializerInfo[property2]!!
- return when {
- property2 in info1.usedProperties -> -1
- property1 in info2.usedProperties -> 1
- else -> 0
- }
+ for ((constructorElement, propertyToInitializerInfo) in targetConstructorToPropertyInitializerInfoMap.entries) {
+ val properties = propertyToInitializerInfo.keys.sortedWith(
+ Comparator { property1, property2 ->
+ val info1 = propertyToInitializerInfo[property1]!!
+ val info2 = propertyToInitializerInfo[property2]!!
+ when {
+ property2 in info1.usedProperties -> -1
+ property1 in info2.usedProperties -> 1
+ else -> 0
}
}
)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelperFactory.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelperFactory.kt
index b91de8661aa..35cbf166723 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelperFactory.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelperFactory.kt
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.idea.refactoring.pullUp
import com.intellij.ide.highlighter.JavaFileType
-import com.intellij.lang.StdLanguages
+import com.intellij.lang.java.JavaLanguage
import com.intellij.psi.*
import com.intellij.refactoring.memberPullUp.JavaPullUpHelper
import com.intellij.refactoring.memberPullUp.PullUpData
@@ -26,7 +26,7 @@ import com.intellij.refactoring.memberPullUp.PullUpHelperFactory
import org.jetbrains.kotlin.asJava.namedUnwrappedElement
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.KotlinLanguage
-import org.jetbrains.kotlin.idea.core.refactoring.createJavaClass
+import org.jetbrains.kotlin.idea.refactoring.createJavaClass
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtNamedDeclaration
@@ -47,7 +47,7 @@ public class KotlinPullUpHelperFactory : PullUpHelperFactory {
if (!data.sourceClass.isInheritor(data.targetClass, true)) return EmptyPullUpHelper
data.toKotlinPullUpData()?.let { return KotlinPullUpHelper(data, it) }
- if (data.targetClass.language.`is`(KotlinLanguage.INSTANCE) && data.sourceClass.language.`is`(StdLanguages.JAVA)) {
+ if (data.targetClass.language == KotlinLanguage.INSTANCE && data.sourceClass.language == JavaLanguage.INSTANCE) {
return JavaToKotlinPostconversionPullUpHelper(data)
}
@@ -99,7 +99,7 @@ public class JavaToKotlinPullUpHelperFactory : PullUpHelperFactory {
createJavaToKotlinPullUpHelper(data)?.let { return it }
return PullUpHelper.INSTANCE
- .allForLanguage(StdLanguages.JAVA)
+ .allForLanguage(JavaLanguage.INSTANCE)
.firstOrNull { it !is JavaToKotlinPullUpHelperFactory }
?.createPullUpHelper(data)
?: EmptyPullUpHelper
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/pullUpConflictsUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/pullUpConflictsUtils.kt
index 522a36e22b3..94cdc43df72 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/pullUpConflictsUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/pullUpConflictsUtils.kt
@@ -23,7 +23,7 @@ import com.intellij.refactoring.RefactoringBundle
import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.descriptors.*
-import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively
+import org.jetbrains.kotlin.idea.refactoring.checkConflictsInteractively
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.references.KtReference
import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownDialog.kt
index 8e3318bf873..b091d061e82 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownDialog.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownDialog.kt
@@ -95,10 +95,10 @@ public class KotlinPushDownDialog(
}
override fun doAction() {
- if (!isOKActionEnabled()) return
+ if (!isOKActionEnabled) return
JavaRefactoringSettings.getInstance().PUSH_DOWN_PREVIEW_USAGES = isPreviewUsages
- invokeRefactoring(KotlinPushDownProcessor(getProject(), sourceClass, selectedMemberInfos))
+ invokeRefactoring(KotlinPushDownProcessor(project, sourceClass, selectedMemberInfos))
}
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownHandler.kt
index 85ea55f07b4..7b562d31fa4 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownHandler.kt
@@ -28,13 +28,10 @@ import com.intellij.refactoring.util.RefactoringUIUtil
import org.jetbrains.kotlin.idea.refactoring.AbstractPullPushMembersHandler
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfoStorage
-import org.jetbrains.kotlin.idea.refactoring.memberInfo.qualifiedClassNameForRendering
import org.jetbrains.kotlin.idea.refactoring.pullUp.PULL_MEMBERS_UP
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtNamedDeclaration
-import org.jetbrains.kotlin.psi.KtObjectDeclaration
-import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
import org.jetbrains.kotlin.psi.psiUtil.isInheritable
val PUSH_MEMBERS_DOWN = "Push Members Down"
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownProcessor.kt
index e7f989d15ad..5adaab63bd9 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownProcessor.kt
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
-import org.jetbrains.kotlin.idea.core.refactoring.runSynchronouslyWithProgress
+import org.jetbrains.kotlin.idea.refactoring.runSynchronouslyWithProgress
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.refactoring.pullUp.*
import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticInheritorRenamer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticInheritorRenamer.kt
index e5684b4345b..909342b43fe 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticInheritorRenamer.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticInheritorRenamer.kt
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.idea.refactoring.rename
-import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiNamedElement
import com.intellij.psi.search.searches.ClassInheritorsSearch
@@ -24,7 +23,6 @@ import com.intellij.refactoring.JavaRefactoringSettings
import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.rename.naming.AutomaticRenamer
import com.intellij.refactoring.rename.naming.AutomaticRenamerFactory
-import com.intellij.refactoring.rename.naming.InheritorRenamer
import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.asJava.LightClassUtil
import org.jetbrains.kotlin.asJava.unwrapped
@@ -35,13 +33,13 @@ public class AutomaticInheritorRenamer(klass: KtClass, newName: String): Automat
val lightClass = LightClassUtil.getPsiClass(klass)
if (lightClass != null) {
for (inheritorLightClass in ClassInheritorsSearch.search(lightClass, true).findAll()) {
- if ((inheritorLightClass.unwrapped as? PsiNamedElement)?.getName() != null) {
+ if ((inheritorLightClass.unwrapped as? PsiNamedElement)?.name != null) {
myElements.add(inheritorLightClass.unwrapped as PsiNamedElement)
}
}
}
- suggestAllNames(klass.getName(), newName)
+ suggestAllNames(klass.name, newName)
}
override fun getDialogTitle() = RefactoringBundle.message("rename.inheritors.title")
@@ -52,7 +50,7 @@ public class AutomaticInheritorRenamer(klass: KtClass, newName: String): Automat
public class AutomaticInheritorRenamerFactory : AutomaticRenamerFactory {
override fun isApplicable(element: PsiElement) = element is KtClass
override fun getOptionName() = RefactoringBundle.message("rename.inheritors")
- override fun isEnabled() = JavaRefactoringSettings.getInstance().isToRenameInheritors()
+ override fun isEnabled() = JavaRefactoringSettings.getInstance().isToRenameInheritors
override fun setEnabled(enabled: Boolean) = JavaRefactoringSettings.getInstance().setRenameInheritors(enabled)
override fun createRenamer(element: PsiElement, newName: String, usages: Collection): AutomaticRenamer {
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticOverloadsRenamer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticOverloadsRenamer.kt
index e8b195ad455..7ad9cf0eccc 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticOverloadsRenamer.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticOverloadsRenamer.kt
@@ -17,26 +17,22 @@
package org.jetbrains.kotlin.idea.refactoring.rename
import com.intellij.openapi.module.ModuleUtilCore
-import com.intellij.openapi.roots.ProjectFileIndex
import com.intellij.psi.PsiElement
-import com.intellij.psi.PsiMethod
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.refactoring.JavaRefactoringSettings
import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.rename.naming.AutomaticRenamer
import com.intellij.refactoring.rename.naming.AutomaticRenamerFactory
import com.intellij.usageView.UsageInfo
-import org.jetbrains.kotlin.idea.stubindex.KotlinTopLevelFunctionByPackageIndex
import org.jetbrains.kotlin.idea.stubindex.KotlinTopLevelFunctionFqnNameIndex
import org.jetbrains.kotlin.psi.KtClassBody
-import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNamedFunction
public class AutomaticOverloadsRenamer(function: KtNamedFunction, newName: String) : AutomaticRenamer() {
init {
myElements.addAll(function.getOverloads().filter { it != function })
- suggestAllNames(function.getName(), newName)
+ suggestAllNames(function.name, newName)
}
override fun getDialogTitle() = "Rename Overloads"
@@ -46,20 +42,20 @@ public class AutomaticOverloadsRenamer(function: KtNamedFunction, newName: Strin
}
private fun KtNamedFunction.getOverloads(): Collection {
- val parent = getParent()
+ val parent = parent
when (parent) {
is KtFile -> {
val module = ModuleUtilCore.findModuleForPsiElement(this)
if (module != null) {
val searchScope = GlobalSearchScope.moduleScope(module)
- val fqName = getFqName()
+ val fqName = fqName
if (fqName != null) {
- return KotlinTopLevelFunctionFqnNameIndex.getInstance().get(fqName.asString(), getProject(), searchScope)
+ return KotlinTopLevelFunctionFqnNameIndex.getInstance().get(fqName.asString(), project, searchScope)
}
}
}
is KtClassBody -> {
- return parent.getDeclarations().filterIsInstance().filter { it.getName() == this.getName() }
+ return parent.declarations.filterIsInstance().filter { it.name == this.name }
}
}
return emptyList()
@@ -67,13 +63,18 @@ private fun KtNamedFunction.getOverloads(): Collection {
public class AutomaticOverloadsRenamerFactory : AutomaticRenamerFactory {
override fun isApplicable(element: PsiElement): Boolean {
- return element is KtNamedFunction && element.getName() != null
- && (element.getParent() is KtFile || element.getParent() is KtClassBody)
+ return element is KtNamedFunction && element.name != null
+ && (element.parent is KtFile || element.parent is KtClassBody)
}
override fun getOptionName() = RefactoringBundle.message("rename.overloads")
- override fun isEnabled() = JavaRefactoringSettings.getInstance().isRenameOverloads()
- override fun setEnabled(enabled: Boolean) = JavaRefactoringSettings.getInstance().setRenameOverloads(enabled)
+
+ override fun isEnabled() = JavaRefactoringSettings.getInstance().isRenameOverloads
+
+ override fun setEnabled(enabled: Boolean) {
+ JavaRefactoringSettings.getInstance().isRenameOverloads = enabled
+ }
+
override fun createRenamer(element: PsiElement, newName: String, usages: Collection)
= AutomaticOverloadsRenamer(element as KtNamedFunction, newName)
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt
index 5e16ea75d7d..3cb143aa798 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt
@@ -50,15 +50,15 @@ public class AutomaticVariableRenamer(
init {
for (usage in usages) {
- val usageElement = usage.getElement() ?: continue
+ val usageElement = usage.element ?: continue
val parameterOrVariable = PsiTreeUtil.getParentOfType(
usageElement,
- javaClass(),
- javaClass()
+ KtVariableDeclaration::class.java,
+ KtParameter::class.java
) as KtCallableDeclaration? ?: continue
- if (parameterOrVariable.getTypeReference()?.isAncestor(usageElement) != true) continue
+ if (parameterOrVariable.typeReference?.isAncestor(usageElement) != true) continue
val descriptor = try {
parameterOrVariable.resolveToDescriptor()
@@ -67,7 +67,7 @@ public class AutomaticVariableRenamer(
continue
}
- val type = (descriptor as VariableDescriptor).getType()
+ val type = (descriptor as VariableDescriptor).type
if (type.isCollectionLikeOf(klass)) {
toUnpluralize.add(parameterOrVariable)
}
@@ -75,7 +75,7 @@ public class AutomaticVariableRenamer(
myElements.add(parameterOrVariable)
}
- suggestAllNames(klass.getName(), newClassName)
+ suggestAllNames(klass.name, newClassName)
}
override fun getDialogTitle() = RefactoringBundle.message("rename.variables.title")
@@ -106,10 +106,10 @@ public class AutomaticVariableRenamer(
}
private fun KotlinType.isCollectionLikeOf(classPsiElement: PsiNamedElement): Boolean {
- val klass = this.getConstructor().getDeclarationDescriptor() as? ClassDescriptor ?: return false
- if (KotlinBuiltIns.isArray(this) || DescriptorUtils.isSubclass(klass, klass.builtIns.getCollection())) {
- val typeArgument = this.getArguments().singleOrNull()?.getType() ?: return false
- val typePsiElement = ((typeArgument.getConstructor().getDeclarationDescriptor() as? ClassDescriptor)?.getSource() as? PsiSourceElement)?.psi
+ val klass = this.constructor.declarationDescriptor as? ClassDescriptor ?: return false
+ if (KotlinBuiltIns.isArray(this) || DescriptorUtils.isSubclass(klass, klass.builtIns.collection)) {
+ val typeArgument = this.arguments.singleOrNull()?.type ?: return false
+ val typePsiElement = ((typeArgument.constructor.declarationDescriptor as? ClassDescriptor)?.source as? PsiSourceElement)?.psi
return classPsiElement == typePsiElement || typeArgument.isCollectionLikeOf(classPsiElement)
}
return false
@@ -122,7 +122,7 @@ public class AutomaticVariableRenamerFactory: AutomaticRenamerFactory {
override fun createRenamer(element: PsiElement, newName: String, usages: Collection) =
AutomaticVariableRenamer(element as PsiNamedElement, newName, usages)
- override fun isEnabled() = JavaRefactoringSettings.getInstance().isToRenameVariables()
+ override fun isEnabled() = JavaRefactoringSettings.getInstance().isToRenameVariables
override fun setEnabled(enabled: Boolean) = JavaRefactoringSettings.getInstance().setRenameVariables(enabled)
override fun getOptionName() = RefactoringBundle.message("rename.variables")
@@ -135,7 +135,7 @@ public class AutomaticVariableInJavaRenamerFactory: AutomaticRenamerFactory {
// Using java variable renamer for java usages
com.intellij.refactoring.rename.naming.AutomaticVariableRenamer((element as KtClass).toLightClass()!!, newName, usages)
- override fun isEnabled() = JavaRefactoringSettings.getInstance().isToRenameVariables()
+ override fun isEnabled() = JavaRefactoringSettings.getInstance().isToRenameVariables
override fun setEnabled(enabled: Boolean) = JavaRefactoringSettings.getInstance().setRenameVariables(enabled)
override fun getOptionName() = RefactoringBundle.message("rename.variables")
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameDynamicMemberHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameDynamicMemberHandler.kt
index f6cc6889233..52721b7f74e 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameDynamicMemberHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameDynamicMemberHandler.kt
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
public class RenameDynamicMemberHandler: VariableInplaceRenameHandler() {
override fun isAvailable(element: PsiElement?, editor: Editor, file: PsiFile): Boolean {
val callee = PsiTreeUtil.findElementOfClassAtOffset(
- file, editor.getCaretModel().getOffset(), javaClass(), false
+ file, editor.caretModel.offset, KtSimpleNameExpression::class.java, false
) ?: return false
val calleeDescriptor = callee.analyze()[BindingContext.REFERENCE_TARGET, callee] ?: return false
return calleeDescriptor.isDynamic()
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinFunctionProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinFunctionProcessor.kt
index ec32123a38c..a06b5136449 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinFunctionProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinFunctionProcessor.kt
@@ -26,7 +26,7 @@ import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.asJava.KtLightMethod
import org.jetbrains.kotlin.asJava.LightClassUtil
import org.jetbrains.kotlin.asJava.unwrapped
-import org.jetbrains.kotlin.idea.core.refactoring.dropOverrideKeywordIfNecessary
+import org.jetbrains.kotlin.idea.refactoring.dropOverrideKeywordIfNecessary
import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtNamedDeclaration
@@ -41,10 +41,7 @@ public class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() {
}
override fun substituteElementToRename(element: PsiElement?, editor: Editor?): PsiElement? {
- val wrappedMethod = wrapPsiMethod(element)
- if (wrappedMethod == null) {
- return element
- }
+ val wrappedMethod = wrapPsiMethod(element) ?: return element
// Use java dialog to ask we should rename function with the base element
val substitutedJavaElement = javaMethodProcessorInstance.substituteElementToRename(wrappedMethod, editor)
@@ -57,7 +54,7 @@ public class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() {
override fun prepareRenaming(element: PsiElement?, newName: String?, allRenames: MutableMap, scope: SearchScope) {
val psiMethod = wrapPsiMethod(element)
- if (psiMethod?.getContainingClass() != null) {
+ if (psiMethod?.containingClass != null) {
javaMethodProcessorInstance.prepareRenaming(psiMethod, newName, allRenames, scope)
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinImplicitLambdaParameter.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinImplicitLambdaParameter.kt
index d1e87876fc9..a1f76c9b1e8 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinImplicitLambdaParameter.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinImplicitLambdaParameter.kt
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.KtNameReferenceExpression
public class RenameKotlinImplicitLambdaParameter: VariableInplaceRenameHandler() {
override fun isAvailable(element: PsiElement?, editor: Editor, file: PsiFile): Boolean {
val nameExpression = PsiTreeUtil.findElementOfClassAtOffset(
- file, editor.getCaretModel().getOffset(), javaClass(), false)
+ file, editor.caretModel.offset, KtNameReferenceExpression::class.java, false)
return nameExpression != null && isAutoCreatedItUsage(nameExpression)
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinParameterProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinParameterProcessor.kt
index 6ffb35e2fcc..0811e77ee8e 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinParameterProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinParameterProcessor.kt
@@ -20,7 +20,6 @@ import com.intellij.psi.PsiElement
import com.intellij.refactoring.listeners.RefactoringElementListener
import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
-import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeSignatureConfiguration
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescriptor
@@ -29,29 +28,28 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.runChangeSignature
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
-import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.OverrideResolver
public class RenameKotlinParameterProcessor : RenameKotlinPsiProcessor() {
override fun canProcessElement(element: PsiElement): Boolean {
- return element is KtParameter && element.getParent().getParent() is KtNamedFunction
+ return element is KtParameter && element.parent.parent is KtNamedFunction
}
override fun renameElement(element: PsiElement, newName: String, usages: Array, listener: RefactoringElementListener?) {
- val function = (element as KtParameter).getParent().getParent() as KtNamedFunction
- val paramIndex = function.getValueParameters().indexOf(element)
+ val function = (element as KtParameter).parent.parent as KtNamedFunction
+ val paramIndex = function.valueParameters.indexOf(element)
assert(paramIndex != -1, { "couldn't find parameter in parent ${element.getElementTextWithContext()}" })
val functionDescriptor = function.resolveToDescriptor() as? FunctionDescriptor ?: return
- val parameterDescriptor = functionDescriptor.getValueParameters()[paramIndex]
+ val parameterDescriptor = functionDescriptor.valueParameters[paramIndex]
- val parameterNameChangedOnOverride = parameterDescriptor.getOverriddenDescriptors().any {
+ val parameterNameChangedOnOverride = parameterDescriptor.overriddenDescriptors.any {
overriddenParameter -> OverrideResolver.shouldReportParameterNameOverrideWarning(parameterDescriptor, overriddenParameter)
}
val changeSignatureConfiguration = object : KotlinChangeSignatureConfiguration {
override fun configure(originalDescriptor: KotlinMethodDescriptor): KotlinMethodDescriptor {
- val paramInfoIndex = if (functionDescriptor.getExtensionReceiverParameter() != null) paramIndex + 1 else paramIndex
+ val paramInfoIndex = if (functionDescriptor.extensionReceiverParameter != null) paramIndex + 1 else paramIndex
return originalDescriptor.modify { it.renameParameter(paramInfoIndex, newName) }
}
@@ -60,6 +58,6 @@ public class RenameKotlinParameterProcessor : RenameKotlinPsiProcessor() {
override fun forcePerformForSelectedFunctionOnly() = parameterNameChangedOnOverride
}
- runChangeSignature(element.getProject(), functionDescriptor, changeSignatureConfiguration, element, "Rename parameter")
+ runChangeSignature(element.project, functionDescriptor, changeSignatureConfiguration, element, "Rename parameter")
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt
index 56b64b3a3a3..a0205b7aa30 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt
@@ -32,12 +32,10 @@ import com.intellij.refactoring.util.RefactoringUtil
import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.asJava.LightClassUtil
import org.jetbrains.kotlin.asJava.namedUnwrappedElement
-import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
-import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
-import org.jetbrains.kotlin.idea.core.refactoring.dropOverrideKeywordIfNecessary
+import org.jetbrains.kotlin.idea.refactoring.dropOverrideKeywordIfNecessary
import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.load.java.JvmAbi
@@ -60,23 +58,21 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
val namedUnwrappedElement = element?.namedUnwrappedElement
val callableDeclaration = namedUnwrappedElement as? KtCallableDeclaration
- if (callableDeclaration == null) throw IllegalStateException("Can't be for element $element there because of canProcessElement()")
+ ?: throw IllegalStateException("Can't be for element $element there because of canProcessElement()")
val deepestSuperDeclaration = findDeepestOverriddenDeclaration(callableDeclaration)
if (deepestSuperDeclaration == null || deepestSuperDeclaration == callableDeclaration) {
return callableDeclaration
}
- if (ApplicationManager.getApplication()!!.isUnitTestMode()) {
- return deepestSuperDeclaration
- }
+ if (ApplicationManager.getApplication()!!.isUnitTestMode) return deepestSuperDeclaration
val containsText: String? =
- deepestSuperDeclaration.getFqName()?.parent()?.asString() ?:
- (deepestSuperDeclaration.getParent() as? KtClassOrObject)?.getName()
+ deepestSuperDeclaration.fqName?.parent()?.asString() ?:
+ (deepestSuperDeclaration.parent as? KtClassOrObject)?.name
val result = Messages.showYesNoCancelDialog(
- deepestSuperDeclaration.getProject(),
+ deepestSuperDeclaration.project,
if (containsText != null) "Do you want to rename base property from \n$containsText" else "Do you want to rename base property",
"Rename warning",
Messages.getQuestionIcon())
@@ -113,14 +109,14 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
return
}
- val name = (element as KtNamedDeclaration).getName()!!
+ val name = (element as KtNamedDeclaration).name!!
val oldGetterName = JvmAbi.getterName(name)
val oldSetterName = JvmAbi.setterName(name)
val refKindUsages = usages.toList().groupBy { usage: UsageInfo ->
- val refElement = usage.getReference()?.resolve()
+ val refElement = usage.reference?.resolve()
if (refElement is PsiMethod) {
- when (refElement.getName()) {
+ when (refElement.name) {
oldGetterName -> UsageKind.GETTER_USAGE
oldSetterName -> UsageKind.SETTER_USAGE
else -> UsageKind.SIMPLE_PROPERTY_USAGE
@@ -160,11 +156,11 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
if (overriderElement != null && overriderElement !is SyntheticElement) {
RenameProcessor.assertNonCompileElement(overriderElement)
- val overriderName = overriderElement.getName()
+ val overriderName = overriderElement.name
if (overriderElement is PsiMethod) {
if (newName != null && Name.isValidIdentifier(newName)) {
- val isGetter = overriderElement.getParameterList().getParametersCount() == 0
+ val isGetter = overriderElement.parameterList.parametersCount == 0
allRenames[overriderElement] = if (isGetter) JvmAbi.getterName(newName) else JvmAbi.setterName(newName)
}
}
@@ -179,7 +175,7 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
}
private fun findDeepestOverriddenDeclaration(declaration: KtCallableDeclaration): KtCallableDeclaration? {
- if (declaration.getModifierList()?.hasModifier(KtTokens.OVERRIDE_KEYWORD) == true) {
+ if (declaration.modifierList?.hasModifier(KtTokens.OVERRIDE_KEYWORD) == true) {
val bindingContext = declaration.analyze()
var descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]
if (descriptor is ValueParameterDescriptor) {
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameOnSecondaryConstructorHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameOnSecondaryConstructorHandler.kt
index 48dd71a884d..0c1affa7880 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameOnSecondaryConstructorHandler.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameOnSecondaryConstructorHandler.kt
@@ -39,8 +39,8 @@ public class RenameOnSecondaryConstructorHandler : RenameHandler {
val file = CommonDataKeys.PSI_FILE.getData(dataContext) ?: return false
val element = PsiTreeUtil.findElementOfClassAtOffsetWithStopSet(
- file, editor.getCaretModel().getOffset(), javaClass(), false,
- javaClass(), javaClass(), javaClass()
+ file, editor.caretModel.offset, KtSecondaryConstructor::class.java, false,
+ KtBlockExpression::class.java, KtValueArgumentList::class.java, KtParameterList::class.java
)
return element != null;
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/renameUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/renameUtil.kt
index 5aab7fab480..5ace4951f0b 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/renameUtil.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/renameUtil.kt
@@ -29,11 +29,11 @@ fun checkConflictsAndReplaceUsageInfos(result: MutableList) {
val usagesToRemove = ArrayList()
for (usageInfo in result) {
- val ref = usageInfo.getReference()
+ val ref = usageInfo.reference
if (usageInfo !is MoveRenameUsageInfo || ref !is AbstractKtReference<*> || ref.canRename()) continue
- val refElement = usageInfo.getElement()
- val referencedElement = usageInfo.getReferencedElement()
+ val refElement = usageInfo.element
+ val referencedElement = usageInfo.referencedElement
if (refElement != null && referencedElement != null) {
usagesToAdd.add(UnresolvableConventionViolationUsageInfo(refElement, referencedElement))
usagesToRemove.add(usageInfo)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinJavaSafeDeleteDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinJavaSafeDeleteDelegate.kt
index 7d89e6c29af..b50e8baf1ca 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinJavaSafeDeleteDelegate.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinJavaSafeDeleteDelegate.kt
@@ -38,46 +38,43 @@ public class KotlinJavaSafeDeleteDelegate : JavaSafeDeleteDelegate {
) {
if (reference !is KtReference) return
- val element = reference.getElement()
+ val element = reference.element
- val callExpression = element.getNonStrictParentOfType()
- if (callExpression == null) return
+ val callExpression = element.getNonStrictParentOfType() ?: return
- val calleeExpression = callExpression.getCalleeExpression()
+ val calleeExpression = callExpression.calleeExpression
if (!(calleeExpression is KtReferenceExpression && calleeExpression.isAncestor(element))) return
val bindingContext = element.analyze()
- val descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, calleeExpression)
- if (descriptor == null) return
+ val descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, calleeExpression) ?: return
val originalDeclaration = method.unwrapped
if (originalDeclaration !is PsiMethod && originalDeclaration !is KtDeclaration) return
if (originalDeclaration != DescriptorToSourceUtils.descriptorToDeclaration(descriptor)) return
- val args = callExpression.getValueArguments()
+ val args = callExpression.valueArguments
- val namedArguments = args.filter { arg -> arg is KtValueArgument && arg.getArgumentName()?.getText() == parameter.getName() }
+ val namedArguments = args.filter { arg -> arg is KtValueArgument && arg.getArgumentName()?.text == parameter.name }
if (!namedArguments.isEmpty()) {
usages.add(SafeDeleteValueArgumentListUsageInfo(namedArguments.first(), parameter))
return
}
- val originalParameter = parameter.unwrapped
- if (originalParameter == null) return
+ val originalParameter = parameter.unwrapped ?: return
val parameterIndex = originalParameter.parameterIndex()
if (parameterIndex < 0) return
- val argCount = args.size()
+ val argCount = args.size
if (parameterIndex < argCount) {
- usages.add(SafeDeleteValueArgumentListUsageInfo((args.get(parameterIndex) as KtValueArgument), parameter))
+ usages.add(SafeDeleteValueArgumentListUsageInfo((args[parameterIndex] as KtValueArgument), parameter))
} else {
- val lambdaArgs = callExpression.getLambdaArguments()
+ val lambdaArgs = callExpression.lambdaArguments
val lambdaIndex = parameterIndex - argCount
- if (lambdaIndex < lambdaArgs.size()) {
- usages.add(SafeDeleteReferenceSimpleDeleteUsageInfo(lambdaArgs.get(lambdaIndex), parameter, true))
+ if (lambdaIndex < lambdaArgs.size) {
+ usages.add(SafeDeleteReferenceSimpleDeleteUsageInfo(lambdaArgs[lambdaIndex], parameter, true))
}
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverrideAnnotation.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverrideAnnotation.kt
index 4fbd44d50ce..7ff10efc0d4 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverrideAnnotation.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverrideAnnotation.kt
@@ -24,6 +24,6 @@ public class KotlinSafeDeleteOverrideAnnotation(
element: PsiElement, referencedElement: PsiElement
) : SafeDeleteUsageInfo(element, referencedElement), SafeDeleteCustomUsageInfo {
public override fun performRefactoring() {
- getElement()?.removeOverrideModifier()
+ element?.removeOverrideModifier()
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverridingUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverridingUsageInfo.kt
index 5da820b9be3..880a7322a28 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverridingUsageInfo.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverridingUsageInfo.kt
@@ -24,9 +24,9 @@ import org.jetbrains.kotlin.psi.KtPsiUtil
public class KotlinSafeDeleteOverridingUsageInfo(
overridingElement: PsiElement, superElement: PsiElement
) : SafeDeleteUsageInfo(overridingElement, superElement), SafeDeleteCustomUsageInfo {
- public val overridingElement: PsiElement get() = getElement()!!
+ public val overridingElement: PsiElement get() = element!!
public override fun performRefactoring(): Unit {
- KtPsiUtil.ascendIfPropertyAccessor(getElement())?.delete()
+ KtPsiUtil.ascendIfPropertyAccessor(element)?.delete()
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt
index e5e6c79bba5..ec07cfa463a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt
@@ -57,13 +57,9 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
): NonCodeUsageSearchInfo {
val deleteList = allElementsToDelete.toList()
- fun getIgnoranceCondition(): Condition {
- return object : Condition {
- override fun value(t: PsiElement?): Boolean {
- if (t is KtFile) return false
- return deleteList.any { element -> JavaSafeDeleteProcessor.isInside(t, element.unwrapped) }
- }
- }
+ fun getIgnoranceCondition() = Condition {
+ if (it is KtFile) return@Condition false
+ deleteList.any { element -> JavaSafeDeleteProcessor.isInside(it, element.unwrapped) }
}
fun getSearchInfo(element: PsiElement): NonCodeUsageSearchInfo {
@@ -77,26 +73,26 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
javaUsages.mapNotNullTo(usages) { usageInfo ->
when (usageInfo) {
is SafeDeleteOverridingMethodUsageInfo ->
- usageInfo.getSmartPointer().getElement()?.let { usageElement ->
- KotlinSafeDeleteOverridingUsageInfo(usageElement, usageInfo.getReferencedElement())
+ usageInfo.smartPointer.element?.let { usageElement ->
+ KotlinSafeDeleteOverridingUsageInfo(usageElement, usageInfo.referencedElement)
}
is SafeDeleteOverrideAnnotation ->
- usageInfo.getSmartPointer().getElement()?.let { usageElement ->
- if (usageElement.toLightMethods().all { method -> method.findSuperMethods().size() == 0 }) {
- KotlinSafeDeleteOverrideAnnotation(usageElement, usageInfo.getReferencedElement())
+ usageInfo.smartPointer.element?.let { usageElement ->
+ if (usageElement.toLightMethods().all { method -> method.findSuperMethods().size == 0 }) {
+ KotlinSafeDeleteOverrideAnnotation(usageElement, usageInfo.referencedElement)
}
else null
}
is SafeDeleteReferenceJavaDeleteUsageInfo ->
- usageInfo.getElement()?.let { usageElement ->
+ usageInfo.element?.let { usageElement ->
if (usageElement.getNonStrictParentOfType() != null) null
else {
usageElement.getNonStrictParentOfType()?.let { importDirective ->
SafeDeleteImportDirectiveUsageInfo(importDirective, element.unwrapped as KtDeclaration)
} ?: if (forceReferencedElementUnwrapping) {
- SafeDeleteReferenceJavaDeleteUsageInfo(usageElement, element.unwrapped, usageInfo.isSafeDelete())
+ SafeDeleteReferenceJavaDeleteUsageInfo(usageElement, element.unwrapped, usageInfo.isSafeDelete)
} else usageInfo
}
}
@@ -110,7 +106,7 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
fun findUsagesByJavaProcessor(elements: Sequence, insideDeleted: Condition): Condition =
elements
- .mapNotNull { element -> findUsagesByJavaProcessor(element, true)?.getInsideDeletedCondition() }
+ .mapNotNull { element -> findUsagesByJavaProcessor(element, true)?.insideDeletedCondition }
.fold(insideDeleted) { condition1, condition2 -> Conditions.or(condition1, condition2) }
fun findUsagesByJavaProcessor(ktDeclaration: KtDeclaration): NonCodeUsageSearchInfo {
@@ -124,11 +120,11 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
}
fun findKotlinDeclarationUsages(declaration: KtDeclaration): NonCodeUsageSearchInfo {
- ReferencesSearch.search(declaration, declaration.getUseScope())
+ ReferencesSearch.search(declaration, declaration.useScope)
.asSequence()
- .filterNot { reference -> getIgnoranceCondition().value(reference.getElement()) }
+ .filterNot { reference -> getIgnoranceCondition().value(reference.element) }
.mapTo(usages) { reference ->
- reference.getElement().getNonStrictParentOfType()?.let { importDirective ->
+ reference.element.getNonStrictParentOfType()?.let { importDirective ->
SafeDeleteImportDirectiveUsageInfo(importDirective, element.unwrapped as KtDeclaration)
} ?: SafeDeleteReferenceSimpleDeleteUsageInfo(element, declaration, false)
}
@@ -137,27 +133,26 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
}
fun findTypeParameterUsages(parameter: KtTypeParameter) {
- val owner = parameter.getNonStrictParentOfType()
- if (owner == null) return
+ val owner = parameter.getNonStrictParentOfType() ?: return
- val parameterList = owner.getTypeParameters()
+ val parameterList = owner.typeParameters
val parameterIndex = parameterList.indexOf(parameter)
for (reference in ReferencesSearch.search(owner)) {
if (reference !is KtReference) continue
- val referencedElement = reference.getElement()
+ val referencedElement = reference.element
val argList = referencedElement.getNonStrictParentOfType()?.let { jetType ->
- jetType.getTypeArgumentList()
+ jetType.typeArgumentList
} ?: referencedElement.getNonStrictParentOfType()?.let { callExpression ->
- callExpression.getTypeArgumentList()
+ callExpression.typeArgumentList
} ?: null
if (argList != null) {
- val projections = argList.getArguments()
- if (parameterIndex < projections.size()) {
- usages.add(SafeDeleteTypeArgumentListUsageInfo(projections.get(parameterIndex), parameter))
+ val projections = argList.arguments
+ if (parameterIndex < projections.size) {
+ usages.add(SafeDeleteTypeArgumentListUsageInfo(projections[parameterIndex], parameter))
}
}
}
@@ -230,9 +225,9 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
override fun findConflicts(element: PsiElement, allElementsToDelete: Array): MutableCollection? {
if (element is KtNamedFunction || element is KtProperty) {
val jetClass = element.getNonStrictParentOfType()
- if (jetClass == null || jetClass.getBody() != element.getParent()) return null
+ if (jetClass == null || jetClass.getBody() != element.parent) return null
- val modifierList = jetClass.getModifierList()
+ val modifierList = jetClass.modifierList
if (modifierList != null && modifierList.hasModifier(KtTokens.ABSTRACT_KEYWORD)) return null
val bindingContext = (element as KtElement).analyze()
@@ -240,16 +235,16 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
if (declarationDescriptor !is CallableMemberDescriptor) return null
- return declarationDescriptor.getOverriddenDescriptors()
+ return declarationDescriptor.overriddenDescriptors
.asSequence()
- .filter { overridenDescriptor -> overridenDescriptor.getModality() == Modality.ABSTRACT }
+ .filter { overridenDescriptor -> overridenDescriptor.modality == Modality.ABSTRACT }
.mapTo(ArrayList()) { overridenDescriptor ->
KotlinBundle.message(
"x.implements.y",
KotlinRefactoringUtil.formatFunction(declarationDescriptor, true),
- KotlinRefactoringUtil.formatClass(declarationDescriptor.getContainingDeclaration(), true),
+ KotlinRefactoringUtil.formatClass(declarationDescriptor.containingDeclaration, true),
KotlinRefactoringUtil.formatFunction(overridenDescriptor, true),
- KotlinRefactoringUtil.formatClass(overridenDescriptor.getContainingDeclaration(), true)
+ KotlinRefactoringUtil.formatClass(overridenDescriptor.containingDeclaration, true)
)
}
}
@@ -275,15 +270,15 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
}
if (!overridingMethodUsages.isEmpty()) {
- if (ApplicationManager.getApplication()!!.isUnitTestMode()) {
+ if (ApplicationManager.getApplication()!!.isUnitTestMode) {
result.addAll(overridingMethodUsages)
} else {
val dialog = KotlinOverridingDialog(project, overridingMethodUsages)
dialog.show()
- if (!dialog.isOK()) return null
+ if (!dialog.isOK) return null
- result.addAll(dialog.getSelected())
+ result.addAll(dialog.selected)
}
}
@@ -295,12 +290,12 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
is PsiMethod -> element.cleanUpOverrides()
is KtNamedFunction ->
- if (!element.isLocal()) {
+ if (!element.isLocal) {
element.getRepresentativeLightMethod()?.cleanUpOverrides()
}
is KtProperty ->
- if (!element.isLocal()) {
+ if (!element.isLocal) {
element.toLightMethods().forEach { method -> method.cleanUpOverrides() }
}
@@ -308,7 +303,7 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
element.deleteElementAndCleanParent()
is KtParameter ->
- (element.getParent() as KtParameterList).removeParameter(element)
+ (element.parent as KtParameterList).removeParameter(element)
}
}
@@ -325,7 +320,7 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
return KotlinRefactoringUtil.checkParametersInMethodHierarchy(element)
}
- if (ApplicationManager.getApplication()!!.isUnitTestMode()) return Collections.singletonList(element)
+ if (ApplicationManager.getApplication()!!.isUnitTestMode) return Collections.singletonList(element)
return when (element) {
is KtNamedFunction, is KtProperty ->
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteTypeArgumentListUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteTypeArgumentListUsageInfo.kt
index 375e914eddd..e127fa01548 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteTypeArgumentListUsageInfo.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteTypeArgumentListUsageInfo.kt
@@ -24,6 +24,6 @@ public class SafeDeleteTypeArgumentListUsageInfo(
typeProjection: KtTypeProjection, parameter: KtTypeParameter
) : SafeDeleteReferenceSimpleDeleteUsageInfo(typeProjection, parameter, true) {
public override fun deleteElement() {
- getElement()?.deleteElementAndCleanParent()
+ element?.deleteElementAndCleanParent()
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteValueArgumentListUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteValueArgumentListUsageInfo.kt
index 0b249c52af1..3b93b603052 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteValueArgumentListUsageInfo.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteValueArgumentListUsageInfo.kt
@@ -25,8 +25,8 @@ public class SafeDeleteValueArgumentListUsageInfo(
valueArgument: KtValueArgument, parameter: PsiElement
) : SafeDeleteReferenceSimpleDeleteUsageInfo(valueArgument, parameter, true) {
public override fun deleteElement() {
- val element = getElement() as? KtValueArgument ?: return
- val parent = element.getParent()
+ val element = element as? KtValueArgument ?: return
+ val parent = element.parent
if (parent is KtValueArgumentList) {
parent.removeArgument(element)
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt
index 6566109ac90..4e56dba29be 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt
@@ -27,8 +27,8 @@ public fun PsiElement.canDeleteElement(): Boolean {
if (this is KtObjectDeclaration && isObjectLiteral()) return false
if (this is KtParameter) {
- val parameterList = getParent() as? KtParameterList ?: return false
- val declaration = parameterList.getParent() as? KtDeclaration ?: return false
+ val parameterList = parent as? KtParameterList ?: return false
+ val declaration = parameterList.parent as? KtDeclaration ?: return false
return declaration !is KtPropertyAccessor
}
@@ -43,11 +43,11 @@ public fun PsiElement.canDeleteElement(): Boolean {
fun PsiElement.removeOverrideModifier() {
when (this) {
is KtNamedFunction, is KtProperty -> {
- (this as KtModifierListOwner).getModifierList()?.getModifier(KtTokens.OVERRIDE_KEYWORD)?.delete()
+ (this as KtModifierListOwner).modifierList?.getModifier(KtTokens.OVERRIDE_KEYWORD)?.delete()
}
is PsiMethod -> {
- getModifierList().getAnnotations().firstOrNull {
- annotation -> annotation.getQualifiedName() == "java.lang.Override"
+ modifierList.annotations.firstOrNull {
+ annotation -> annotation.qualifiedName == "java.lang.Override"
}?.delete()
}
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt b/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt
index ce67a87d3f9..e560077164a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt
@@ -38,8 +38,8 @@ import org.jetbrains.kotlin.asJava.toLightClass
import org.jetbrains.kotlin.idea.actions.JavaToKotlinAction
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.getPackage
-import org.jetbrains.kotlin.idea.core.refactoring.j2k
-import org.jetbrains.kotlin.idea.core.refactoring.toPsiDirectory
+import org.jetbrains.kotlin.idea.refactoring.j2k
+import org.jetbrains.kotlin.idea.refactoring.toPsiDirectory
import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention
import org.jetbrains.kotlin.idea.util.application.executeCommand
import org.jetbrains.kotlin.idea.util.runWithAlternativeResolveEnabled
diff --git a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt
index 4c9256d9bc5..35039339e47 100644
--- a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt
@@ -22,7 +22,7 @@ import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.util.containers.ContainerUtil
import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.descriptors.*
-import org.jetbrains.kotlin.idea.core.refactoring.getContextForContainingDeclarationBody
+import org.jetbrains.kotlin.idea.refactoring.getContextForContainingDeclarationBody
import org.jetbrains.kotlin.idea.refactoring.introduce.ExtractableSubstringInfo
import org.jetbrains.kotlin.idea.refactoring.introduce.extractableSubstringInfo
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractBeforeExtractFunctionInsertionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractBeforeExtractFunctionInsertionTest.kt
index 1ada230aa3f..e0d5392d1da 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractBeforeExtractFunctionInsertionTest.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractBeforeExtractFunctionInsertionTest.kt
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.debugger
import com.intellij.openapi.util.io.FileUtil
import com.intellij.testFramework.LightCodeInsightTestCase
import com.intellij.testFramework.LightPlatformCodeInsightTestCase
-import org.jetbrains.kotlin.idea.core.refactoring.getLineNumber
+import org.jetbrains.kotlin.idea.refactoring.getLineNumber
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinCodeFragmentFactory
import org.jetbrains.kotlin.idea.debugger.evaluate.addDebugExpressionIntoTmpFileForExtractFunction
import org.jetbrains.kotlin.psi.KtExpressionCodeFragment
diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt
index 8f6789cba72..4ca35d8d229 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt
@@ -45,7 +45,7 @@ import com.intellij.xdebugger.XDebuggerUtil
import com.intellij.xdebugger.breakpoints.*
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties
import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties
-import org.jetbrains.kotlin.idea.core.refactoring.getLineNumber
+import org.jetbrains.kotlin.idea.refactoring.getLineNumber
import org.jetbrains.kotlin.idea.debugger.breakpoints.KotlinFieldBreakpoint
import org.jetbrains.kotlin.idea.debugger.breakpoints.KotlinFieldBreakpointType
import org.jetbrains.kotlin.idea.debugger.breakpoints.KotlinLineBreakpointType
diff --git a/idea/tests/org/jetbrains/kotlin/idea/filters/AbstractKotlinExceptionFilterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/filters/AbstractKotlinExceptionFilterTest.kt
index 678a0659d64..87ac0bb6f60 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/filters/AbstractKotlinExceptionFilterTest.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/filters/AbstractKotlinExceptionFilterTest.kt
@@ -27,7 +27,7 @@ import com.intellij.testFramework.PsiTestUtil
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider
import org.jetbrains.kotlin.fileClasses.getFileClassFqName
-import org.jetbrains.kotlin.idea.core.refactoring.toVirtualFile
+import org.jetbrains.kotlin.idea.refactoring.toVirtualFile
import org.jetbrains.kotlin.idea.test.KotlinCodeInsightTestCase
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.kotlin.psi.KtFile
diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMoveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMoveTest.kt
index 762952408a8..16474418aed 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMoveTest.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMoveTest.kt
@@ -37,8 +37,8 @@ import com.intellij.refactoring.move.moveInner.MoveInnerProcessor
import com.intellij.refactoring.move.moveMembers.MockMoveMembersOptions
import com.intellij.refactoring.move.moveMembers.MoveMembersProcessor
import com.intellij.util.ActionRunner
-import org.jetbrains.kotlin.idea.core.refactoring.createKotlinFile
-import org.jetbrains.kotlin.idea.core.refactoring.toPsiDirectory
+import org.jetbrains.kotlin.idea.refactoring.createKotlinFile
+import org.jetbrains.kotlin.idea.refactoring.toPsiDirectory
import org.jetbrains.kotlin.idea.jsonUtils.getNullableString
import org.jetbrains.kotlin.idea.jsonUtils.getString
import org.jetbrains.kotlin.idea.refactoring.move.changePackage.KotlinChangePackageRefactoring