KotlinChangePackageRefactoring: fix formatting for long qualifier names

#KT-38627 Fixed
This commit is contained in:
Dmitry Gridin
2020-04-28 12:20:15 +07:00
parent db5751616a
commit a11e6b2eed
5 changed files with 35 additions and 15 deletions
@@ -1,24 +1,13 @@
/*
* 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.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.refactoring.move.changePackage
import com.intellij.refactoring.RefactoringBundle
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.codeInsight.shorten.runRefactoringAndKeepDelayedRequests
import org.jetbrains.kotlin.idea.codeInsight.shorten.performDelayedRefactoringRequests
import org.jetbrains.kotlin.idea.core.quoteIfNeeded
import org.jetbrains.kotlin.idea.core.util.runSynchronouslyWithProgress
import org.jetbrains.kotlin.idea.refactoring.move.ContainerChangeInfo
@@ -58,7 +47,8 @@ class KotlinChangePackageRefactoring(val file: KtFile) {
project.executeWriteCommand(KotlinBundle.message("text.change.file.package.to.0", newFqName)) {
packageDirective.fqName = newFqName.quoteIfNeeded()
postProcessMoveUsages(internalUsages)
project.runRefactoringAndKeepDelayedRequests { declarationProcessor.execute(declarationUsages) }
performDelayedRefactoringRequests(project)
declarationProcessor.execute(declarationUsages)
}
}
}
@@ -0,0 +1,9 @@
package cccc.zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
class SomeVeryImportantClass {
fun getSomeData(): Any? = null
companion object {
fun getInstance(o: Any): SomeVeryImportantClass = SomeVeryImportantClass()
}
}
@@ -0,0 +1,9 @@
package cccc.ssss
class SomeVeryImportantClass {
fun getSomeData(): Any? = null
companion object {
fun getInstance(o: Any): SomeVeryImportantClass = SomeVeryImportantClass()
}
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_PACKAGE",
"fqn": "cccc.ssss",
"newName": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",
"comment": "KT-35338",
"mainFile": "Y.kt"
}
@@ -888,6 +888,11 @@ public class RenameTestGenerated extends AbstractRenameTest {
runTest("idea/testData/refactoring/rename/renameKotlinPackageFunctionFromJavaNewFacade/renameKotlinPackageFunctionFromJava.test");
}
@TestMetadata("renameKotlinPackageWithLongType/renameKotlinPackageWithLongType.test")
public void testRenameKotlinPackageWithLongType_RenameKotlinPackageWithLongType() throws Exception {
runTest("idea/testData/refactoring/rename/renameKotlinPackageWithLongType/renameKotlinPackageWithLongType.test");
}
@TestMetadata("renameKotlinParameterWithGetterJvmName/renameKotlinParameterWithGetterJvmName.test")
public void testRenameKotlinParameterWithGetterJvmName_RenameKotlinParameterWithGetterJvmName() throws Exception {
runTest("idea/testData/refactoring/rename/renameKotlinParameterWithGetterJvmName/renameKotlinParameterWithGetterJvmName.test");