diff --git a/ChangeLog.md b/ChangeLog.md index 3e35172282e..d428031a314 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -162,6 +162,8 @@ Issues fixed: - Fixed NoSuchFieldException in Kotlin module settings on IDEA Ultimate - [KT-11702](https://youtrack.jetbrains.com/issue/KT-11702) Fixed resolution of Kotlin beans with custom name - [KT-11689](https://youtrack.jetbrains.com/issue/KT-11689) Fixed exception on attempt to navigate to Kotlin file from Spring notification balloon +- [KT-11725](https://youtrack.jetbrains.com/issue/KT-11725) Fixed renaming of injected SpEL references +- [KT-11720](https://youtrack.jetbrains.com/issue/KT-11720) Fixed renaming of Kotlin beans through SpEL references #### Debugger diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtStringTemplateExpression.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtStringTemplateExpression.java index 11f463bc8c7..a2a886dadae 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtStringTemplateExpression.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtStringTemplateExpression.java @@ -56,6 +56,8 @@ public class KtStringTemplateExpression extends KtExpressionImpl implements PsiL @Override public PsiLanguageInjectionHost updateText(@NotNull String text) { + KtExpression newExpression = new KtPsiFactory(getProject()).createExpressionIfPossible(text); + if (newExpression instanceof KtStringTemplateExpression) return (KtStringTemplateExpression) replace(newExpression); return ElementManipulators.handleContentChange(this, text); } diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/FakeFileForLightClass.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/FakeFileForLightClass.kt index 969f40a7d7a..69c0650d430 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/FakeFileForLightClass.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/FakeFileForLightClass.kt @@ -33,6 +33,7 @@ package org.jetbrains.kotlin.asJava import com.intellij.psi.ClassFileViewProvider +import com.intellij.psi.PsiElementVisitor import com.intellij.psi.impl.compiled.ClsFileImpl import com.intellij.psi.stubs.PsiClassHolderFileStub import org.jetbrains.kotlin.name.FqName @@ -51,4 +52,9 @@ open class FakeFileForLightClass( override fun getClasses() = arrayOf(lightClass()) override fun getNavigationElement() = ktFile + + override fun accept(visitor: PsiElementVisitor) { + // Prevent access to compiled PSI + // TODO: More complex traversal logic may be implemented when necessary + } } \ No newline at end of file diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KtLightAnnotation.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KtLightAnnotation.kt index 7968a795a65..95daca23580 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KtLightAnnotation.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KtLightAnnotation.kt @@ -74,6 +74,7 @@ class KtLightAnnotation( override fun getReference() = references.singleOrNull() override fun getReferences() = ReferenceProvidersRegistry.getReferencesFromProviders(delegate, PsiReferenceService.Hints.NO_HINTS) override fun getLanguage() = KotlinLanguage.INSTANCE + override fun getNavigationElement() = originalExpression } inner class LightArrayInitializerValue(private val delegate: PsiArrayInitializerMemberValue) : PsiArrayInitializerMemberValue by delegate { diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt index e007ba91866..8283868bdf9 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt @@ -18,9 +18,10 @@ package org.jetbrains.kotlin.idea.refactoring.rename import com.google.gson.JsonObject import com.google.gson.JsonParser -import com.intellij.codeInsight.TargetElementUtilBase +import com.intellij.codeInsight.TargetElementUtil import com.intellij.lang.properties.psi.PropertiesFile import com.intellij.lang.properties.psi.Property +import com.intellij.openapi.editor.Editor import com.intellij.openapi.extensions.Extensions import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.module.Module @@ -32,6 +33,7 @@ import com.intellij.openapi.vfs.VfsUtilCore import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFileVisitor import com.intellij.psi.* +import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil import com.intellij.psi.search.GlobalSearchScope import com.intellij.refactoring.BaseRefactoringProcessor.ConflictsInTestsException import com.intellij.refactoring.MultiFileTestCase @@ -46,10 +48,7 @@ import org.jetbrains.kotlin.idea.jsonUtils.getNullableString import org.jetbrains.kotlin.idea.jsonUtils.getString import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.search.allScope -import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil -import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils -import org.jetbrains.kotlin.idea.test.KotlinMultiFileTestCase -import org.jetbrains.kotlin.idea.test.PluginTestCaseBase +import org.jetbrains.kotlin.idea.test.* import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.* import org.jetbrains.kotlin.psi.KtFile @@ -93,7 +92,11 @@ abstract class AbstractRenameTest : KotlinMultiFileTestCase() { ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk()) } + val fixtureClasses = renameObject.getAsJsonArray("fixtureClasses")?.map { it.asString } ?: emptyList() + try { + fixtureClasses.forEach { TestFixtureExtension.loadFixture(it, module) } + val context = TestContext() when (RenameType.valueOf(renameTypeStr)) { @@ -137,6 +140,13 @@ abstract class AbstractRenameTest : KotlinMultiFileTestCase() { Assert.fail("""Unexpected "hint: $hintExceptionUnquoted" """) } } + finally { + fixtureClasses.forEach { TestFixtureExtension.unloadFixture(it) } + } + } + + protected open fun configExtra(rootDir: VirtualFile, renameParamsObject: JsonObject) { + } private fun renameMarkedElement(renameParamsObject: JsonObject, context: TestContext) { @@ -144,21 +154,34 @@ abstract class AbstractRenameTest : KotlinMultiFileTestCase() { val newName = renameParamsObject.getString("newName") doTestCommittingDocuments { rootDir, rootAfter -> - val mainFile = rootDir.findChild(mainFilePath)!! + configExtra(rootDir, renameParamsObject) + + val mainFile = rootDir.findFileByRelativePath(mainFilePath)!! val psiFile = PsiManager.getInstance(context.project).findFile(mainFile)!! val doc = PsiDocumentManager.getInstance(project).getDocument(psiFile)!! val marker = doc.extractMarkerOffset(project, "/*rename*/") assert(marker != -1) - val toRename = if (renameParamsObject["byRef"]?.asBoolean ?: false) { - val editor = createEditor(mainFile) - editor.caretModel.moveToOffset(marker) - TargetElementUtilBase.findTargetElement(editor, TargetElementUtilBase.getInstance().allAccepted)!! + val isByRef = renameParamsObject["byRef"]?.asBoolean ?: false + val isInjected = renameParamsObject["injected"]?.asBoolean ?: false + var currentEditor: Editor? = null + var currentFile: PsiFile = psiFile + if (isByRef || isInjected) { + currentEditor = createEditor(mainFile) + currentEditor.caretModel.moveToOffset(marker) + if (isInjected) { + currentFile = InjectedLanguageUtil.findInjectedPsiNoCommit(psiFile, marker)!! + currentEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(currentEditor, currentFile) + } + } + val toRename = if (isByRef) { + TargetElementUtil.findTargetElement(currentEditor, TargetElementUtil.getInstance().allAccepted)!! } else { - psiFile.findElementAt(marker)!!.getNonStrictParentOfType()!! + currentFile.findElementAt(marker)!!.getNonStrictParentOfType()!! } + val substitution = RenamePsiElementProcessor.forElement(toRename).substituteElementToRename(toRename, null) runRenameProcessor(context, newName, substitution, true, true) diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/JavaAnnotated.java new file mode 100644 index 00000000000..ba58556ac00 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/JavaAnnotated.java @@ -0,0 +1,11 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Bean public JavaSpringBean buildBeanJNew() { return new JavaSpringBean(3); } + @Value("#{buildBeanJNew.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..20e4cc98699 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJava/after/test/KotlinAnnotated.kt @@ -0,0 +1,9 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration + +@Configuration +open class KotlinAnnotated { + @Value("#{buildBeanJNew.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/JavaAnnotated.java new file mode 100644 index 00000000000..9347cf5e728 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/JavaAnnotated.java @@ -0,0 +1,11 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Bean public JavaSpringBean buildBeanJ() { return new JavaSpringBean(3); } + @Value("#{/*rename*/buildBeanJ.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..18e97c80d6c --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJava/before/test/KotlinAnnotated.kt @@ -0,0 +1,9 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration + +@Configuration +open class KotlinAnnotated { + @Value("#{buildBeanJ.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJava/javaSpelRefToJava.test b/ultimate/testData/spring/core/rename/javaSpelRefToJava/javaSpelRefToJava.test new file mode 100644 index 00000000000..7ec3775f4a5 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJava/javaSpelRefToJava.test @@ -0,0 +1,10 @@ +{ + "fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"], + "type": "MARKED_ELEMENT", + "mainFile": "test/JavaAnnotated.java", + "springFileSet": ["test/JavaAnnotated.java", "test/KotlinAnnotated.kt"], + "injected": "true", + "byRef": "true", + "newName": "buildBeanJNew", + "withRuntime": "true" +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/JavaAnnotated.java new file mode 100644 index 00000000000..04df29ab7c0 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/JavaAnnotated.java @@ -0,0 +1,11 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Bean(name = {"annJavaBean2"}) public JavaSpringBean buildBeanJ() { return new JavaSpringBean(3); } + @Value("#{annJavaBean2.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..c712b5fbaab --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/after/test/KotlinAnnotated.kt @@ -0,0 +1,9 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration + +@Configuration +open class KotlinAnnotated { + @Value("#{annJavaBean2.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/JavaAnnotated.java new file mode 100644 index 00000000000..810d24e4caa --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/JavaAnnotated.java @@ -0,0 +1,11 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Bean(name = { "annJavaBean" }) public JavaSpringBean buildBeanJ() { return new JavaSpringBean(3); } + @Value("#{/*rename*/annJavaBean.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..f5d321ece96 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/before/test/KotlinAnnotated.kt @@ -0,0 +1,9 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration + +@Configuration +open class KotlinAnnotated { + @Value("#{annJavaBean.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/javaSpelRefToJavaAnnotated.test b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/javaSpelRefToJavaAnnotated.test new file mode 100644 index 00000000000..b33e52a6de6 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/javaSpelRefToJavaAnnotated.test @@ -0,0 +1,10 @@ +{ + "fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"], + "type": "MARKED_ELEMENT", + "mainFile": "test/JavaAnnotated.java", + "springFileSet": ["test/JavaAnnotated.java", "test/KotlinAnnotated.kt"], + "injected": "true", + "byRef": "true", + "newName": "annJavaBean2", + "withRuntime": "true" +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/JavaAnnotated.java new file mode 100644 index 00000000000..0abec8e23cb --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/JavaAnnotated.java @@ -0,0 +1,10 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Value("#{buildBeanJNew.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..11625ea8be7 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKt/after/test/KotlinAnnotated.kt @@ -0,0 +1,13 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Bean + +@Configuration +open class KotlinAnnotated { + @Bean + fun buildBeanJNew() = JavaSpringBean(3) + + @Value("#{buildBeanJNew.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/JavaAnnotated.java new file mode 100644 index 00000000000..88196affd1f --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/JavaAnnotated.java @@ -0,0 +1,10 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Value("#{/*rename*/buildBeanJ.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..c89235ec91c --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKt/before/test/KotlinAnnotated.kt @@ -0,0 +1,13 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Bean + +@Configuration +open class KotlinAnnotated { + @Bean + fun buildBeanJ() = JavaSpringBean(3) + + @Value("#{buildBeanJ.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKt/javaSpelRefToKt.test b/ultimate/testData/spring/core/rename/javaSpelRefToKt/javaSpelRefToKt.test new file mode 100644 index 00000000000..7ec3775f4a5 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKt/javaSpelRefToKt.test @@ -0,0 +1,10 @@ +{ + "fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"], + "type": "MARKED_ELEMENT", + "mainFile": "test/JavaAnnotated.java", + "springFileSet": ["test/JavaAnnotated.java", "test/KotlinAnnotated.kt"], + "injected": "true", + "byRef": "true", + "newName": "buildBeanJNew", + "withRuntime": "true" +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/JavaAnnotated.java new file mode 100644 index 00000000000..22e19e3de6c --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/JavaAnnotated.java @@ -0,0 +1,10 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Value("#{annJavaBean2.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..8c94a9f5cfe --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/after/test/KotlinAnnotated.kt @@ -0,0 +1,13 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Bean + +@Configuration +open class KotlinAnnotated { + @Bean(name = arrayOf("annJavaBean2")) + fun buildBeanJ() = JavaSpringBean(3) + + @Value("#{annJavaBean2.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/JavaAnnotated.java new file mode 100644 index 00000000000..b471305f077 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/JavaAnnotated.java @@ -0,0 +1,10 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Value("#{/*rename*/annJavaBean.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..172f1583e3c --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/before/test/KotlinAnnotated.kt @@ -0,0 +1,13 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Bean + +@Configuration +open class KotlinAnnotated { + @Bean(name = arrayOf("annJavaBean")) + fun buildBeanJ() = JavaSpringBean(3) + + @Value("#{annJavaBean.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/javaSpelRefToKtAnnotated.test b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/javaSpelRefToKtAnnotated.test new file mode 100644 index 00000000000..b33e52a6de6 --- /dev/null +++ b/ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/javaSpelRefToKtAnnotated.test @@ -0,0 +1,10 @@ +{ + "fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"], + "type": "MARKED_ELEMENT", + "mainFile": "test/JavaAnnotated.java", + "springFileSet": ["test/JavaAnnotated.java", "test/KotlinAnnotated.kt"], + "injected": "true", + "byRef": "true", + "newName": "annJavaBean2", + "withRuntime": "true" +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/JavaAnnotated.java new file mode 100644 index 00000000000..ba58556ac00 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/JavaAnnotated.java @@ -0,0 +1,11 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Bean public JavaSpringBean buildBeanJNew() { return new JavaSpringBean(3); } + @Value("#{buildBeanJNew.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..20e4cc98699 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJava/after/test/KotlinAnnotated.kt @@ -0,0 +1,9 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration + +@Configuration +open class KotlinAnnotated { + @Value("#{buildBeanJNew.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/JavaAnnotated.java new file mode 100644 index 00000000000..6e19c7f69d7 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/JavaAnnotated.java @@ -0,0 +1,11 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Bean public JavaSpringBean buildBeanJ() { return new JavaSpringBean(3); } + @Value("#{buildBeanJ.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..0d9d3129624 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJava/before/test/KotlinAnnotated.kt @@ -0,0 +1,9 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration + +@Configuration +open class KotlinAnnotated { + @Value("#{/*rename*/buildBeanJ.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJava/ktSpelRefToJava.test b/ultimate/testData/spring/core/rename/ktSpelRefToJava/ktSpelRefToJava.test new file mode 100644 index 00000000000..0caf957cd11 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJava/ktSpelRefToJava.test @@ -0,0 +1,10 @@ +{ + "fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"], + "type": "MARKED_ELEMENT", + "mainFile": "test/KotlinAnnotated.kt", + "springFileSet": ["test/JavaAnnotated.java", "test/KotlinAnnotated.kt"], + "injected": "true", + "byRef": "true", + "newName": "buildBeanJNew", + "withRuntime": "true" +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/JavaAnnotated.java new file mode 100644 index 00000000000..04df29ab7c0 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/JavaAnnotated.java @@ -0,0 +1,11 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Bean(name = {"annJavaBean2"}) public JavaSpringBean buildBeanJ() { return new JavaSpringBean(3); } + @Value("#{annJavaBean2.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..c712b5fbaab --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/after/test/KotlinAnnotated.kt @@ -0,0 +1,9 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration + +@Configuration +open class KotlinAnnotated { + @Value("#{annJavaBean2.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/JavaAnnotated.java new file mode 100644 index 00000000000..4884ffb3e22 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/JavaAnnotated.java @@ -0,0 +1,11 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Bean(name = { "annJavaBean" }) public JavaSpringBean buildBeanJ() { return new JavaSpringBean(3); } + @Value("#{annJavaBean.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..1ad1cd254f4 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/before/test/KotlinAnnotated.kt @@ -0,0 +1,9 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration + +@Configuration +open class KotlinAnnotated { + @Value("#{/*rename*/annJavaBean.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/ktSpelRefToJavaAnnotated.test b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/ktSpelRefToJavaAnnotated.test new file mode 100644 index 00000000000..e43966245d8 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/ktSpelRefToJavaAnnotated.test @@ -0,0 +1,10 @@ +{ + "fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"], + "type": "MARKED_ELEMENT", + "mainFile": "test/KotlinAnnotated.kt", + "springFileSet": ["test/JavaAnnotated.java", "test/KotlinAnnotated.kt"], + "injected": "true", + "byRef": "true", + "newName": "annJavaBean2", + "withRuntime": "true" +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/JavaAnnotated.java new file mode 100644 index 00000000000..0abec8e23cb --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/JavaAnnotated.java @@ -0,0 +1,10 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Value("#{buildBeanJNew.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..11625ea8be7 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKt/after/test/KotlinAnnotated.kt @@ -0,0 +1,13 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Bean + +@Configuration +open class KotlinAnnotated { + @Bean + fun buildBeanJNew() = JavaSpringBean(3) + + @Value("#{buildBeanJNew.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/JavaAnnotated.java new file mode 100644 index 00000000000..c3ae9949f0b --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/JavaAnnotated.java @@ -0,0 +1,10 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Value("#{buildBeanJ.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..db769e39f2b --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKt/before/test/KotlinAnnotated.kt @@ -0,0 +1,13 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Bean + +@Configuration +open class KotlinAnnotated { + @Bean + fun buildBeanJ() = JavaSpringBean(3) + + @Value("#{/*rename*/buildBeanJ.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKt/ktSpelRefToKt.test b/ultimate/testData/spring/core/rename/ktSpelRefToKt/ktSpelRefToKt.test new file mode 100644 index 00000000000..0caf957cd11 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKt/ktSpelRefToKt.test @@ -0,0 +1,10 @@ +{ + "fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"], + "type": "MARKED_ELEMENT", + "mainFile": "test/KotlinAnnotated.kt", + "springFileSet": ["test/JavaAnnotated.java", "test/KotlinAnnotated.kt"], + "injected": "true", + "byRef": "true", + "newName": "buildBeanJNew", + "withRuntime": "true" +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/JavaAnnotated.java new file mode 100644 index 00000000000..22e19e3de6c --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/JavaAnnotated.java @@ -0,0 +1,10 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Value("#{annJavaBean2.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..8c94a9f5cfe --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/after/test/KotlinAnnotated.kt @@ -0,0 +1,13 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Bean + +@Configuration +open class KotlinAnnotated { + @Bean(name = arrayOf("annJavaBean2")) + fun buildBeanJ() = JavaSpringBean(3) + + @Value("#{annJavaBean2.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/JavaAnnotated.java b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/JavaAnnotated.java new file mode 100644 index 00000000000..6496db107f3 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/JavaAnnotated.java @@ -0,0 +1,10 @@ +package test; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JavaAnnotated { + @Value("#{annJavaBean.value + 1}") private int newValue; +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/JavaSpringBean.java b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/JavaSpringBean.java new file mode 100644 index 00000000000..400c40b6d1d --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/JavaSpringBean.java @@ -0,0 +1,6 @@ +package test; + +public class JavaSpringBean { + public final int value; + public JavaSpringBean(int p) { value = p; } +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/KotlinAnnotated.kt b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/KotlinAnnotated.kt new file mode 100644 index 00000000000..5ac8566c963 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/before/test/KotlinAnnotated.kt @@ -0,0 +1,13 @@ +package test + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Bean + +@Configuration +open class KotlinAnnotated { + @Bean(name = arrayOf("annJavaBean")) + fun buildBeanJ() = JavaSpringBean(3) + + @Value("#{/*rename*/annJavaBean.value + 1}") private var newValue: Int = 0 +} \ No newline at end of file diff --git a/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/ktSpelRefToKtAnnotated.test b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/ktSpelRefToKtAnnotated.test new file mode 100644 index 00000000000..e43966245d8 --- /dev/null +++ b/ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/ktSpelRefToKtAnnotated.test @@ -0,0 +1,10 @@ +{ + "fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"], + "type": "MARKED_ELEMENT", + "mainFile": "test/KotlinAnnotated.kt", + "springFileSet": ["test/JavaAnnotated.java", "test/KotlinAnnotated.kt"], + "injected": "true", + "byRef": "true", + "newName": "annJavaBean2", + "withRuntime": "true" +} \ No newline at end of file diff --git a/ultimate/tests/org/jetbrains/kotlin/idea/rename/AbstractUltimateRenameTest.kt b/ultimate/tests/org/jetbrains/kotlin/idea/rename/AbstractUltimateRenameTest.kt new file mode 100644 index 00000000000..46bdab465de --- /dev/null +++ b/ultimate/tests/org/jetbrains/kotlin/idea/rename/AbstractUltimateRenameTest.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2016 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.rename + +import org.jetbrains.kotlin.idea.refactoring.rename.AbstractRenameTest +import org.jetbrains.kotlin.tests.ULTIMATE_TEST_DATA_DIR + +abstract class AbstractUltimateRenameTest : AbstractRenameTest() { + override fun getTestDataPath() = ULTIMATE_TEST_DATA_DIR +} \ No newline at end of file diff --git a/ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/rename/AbstractSpringRenameTest.kt b/ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/rename/AbstractSpringRenameTest.kt new file mode 100644 index 00000000000..d1d659d4b82 --- /dev/null +++ b/ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/rename/AbstractSpringRenameTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2016 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.spring.tests.rename + +import com.google.gson.JsonObject +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.spring.facet.SpringFacet +import org.jetbrains.kotlin.idea.rename.AbstractUltimateRenameTest + +abstract class AbstractSpringRenameTest : AbstractUltimateRenameTest() { + override fun getTestRoot() = "/spring/core/rename/" + + override fun configExtra(rootDir: VirtualFile, renameParamsObject: JsonObject) { + val fileSet = SpringFacet.getInstance(module)!!.addFileSet("default", "default")!! + for (filePath in renameParamsObject.getAsJsonArray("springFileSet")) { + fileSet.addFile(rootDir.findFileByRelativePath(filePath.asString)!!) + } + } +} \ No newline at end of file diff --git a/ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/rename/SpringRenameTestGenerated.java b/ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/rename/SpringRenameTestGenerated.java new file mode 100644 index 00000000000..fd06796cff2 --- /dev/null +++ b/ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/rename/SpringRenameTestGenerated.java @@ -0,0 +1,85 @@ +/* + * Copyright 2010-2016 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.spring.tests.rename; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("ultimate/testData/spring/core/rename") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class SpringRenameTestGenerated extends AbstractSpringRenameTest { + public void testAllFilesPresentInRename() throws Exception { + KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("ultimate/testData/spring/core/rename"), Pattern.compile("^(.+)\\.test$")); + } + + @TestMetadata("javaSpelRefToJava/javaSpelRefToJava.test") + public void testJavaSpelRefToJava_JavaSpelRefToJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/javaSpelRefToJava/javaSpelRefToJava.test"); + doTest(fileName); + } + + @TestMetadata("javaSpelRefToJavaAnnotated/javaSpelRefToJavaAnnotated.test") + public void testJavaSpelRefToJavaAnnotated_JavaSpelRefToJavaAnnotated() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/javaSpelRefToJavaAnnotated/javaSpelRefToJavaAnnotated.test"); + doTest(fileName); + } + + @TestMetadata("javaSpelRefToKt/javaSpelRefToKt.test") + public void testJavaSpelRefToKt_JavaSpelRefToKt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/javaSpelRefToKt/javaSpelRefToKt.test"); + doTest(fileName); + } + + @TestMetadata("javaSpelRefToKtAnnotated/javaSpelRefToKtAnnotated.test") + public void testJavaSpelRefToKtAnnotated_JavaSpelRefToKtAnnotated() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/javaSpelRefToKtAnnotated/javaSpelRefToKtAnnotated.test"); + doTest(fileName); + } + + @TestMetadata("ktSpelRefToJava/ktSpelRefToJava.test") + public void testKtSpelRefToJava_KtSpelRefToJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/ktSpelRefToJava/ktSpelRefToJava.test"); + doTest(fileName); + } + + @TestMetadata("ktSpelRefToJavaAnnotated/ktSpelRefToJavaAnnotated.test") + public void testKtSpelRefToJavaAnnotated_KtSpelRefToJavaAnnotated() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/ktSpelRefToJavaAnnotated/ktSpelRefToJavaAnnotated.test"); + doTest(fileName); + } + + @TestMetadata("ktSpelRefToKt/ktSpelRefToKt.test") + public void testKtSpelRefToKt_KtSpelRefToKt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/ktSpelRefToKt/ktSpelRefToKt.test"); + doTest(fileName); + } + + @TestMetadata("ktSpelRefToKtAnnotated/ktSpelRefToKtAnnotated.test") + public void testKtSpelRefToKtAnnotated_KtSpelRefToKtAnnotated() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/ktSpelRefToKtAnnotated.test"); + doTest(fileName); + } +} diff --git a/ultimate/tests/org/jetbrains/kotlin/tests/GenerateTests.kt b/ultimate/tests/org/jetbrains/kotlin/tests/GenerateTests.kt index f6939eab41d..dc4c989937e 100644 --- a/ultimate/tests/org/jetbrains/kotlin/tests/GenerateTests.kt +++ b/ultimate/tests/org/jetbrains/kotlin/tests/GenerateTests.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.idea.spring.tests.gutter.AbstractSpringClassAnnotato import org.jetbrains.kotlin.idea.spring.tests.references.AbstractSpringReferenceCompletionHandlerTest import org.jetbrains.kotlin.idea.spring.tests.references.AbstractSpringReferenceCompletionTest import org.jetbrains.kotlin.idea.spring.tests.references.AbstractSpringReferenceNavigationTest +import org.jetbrains.kotlin.idea.spring.tests.rename.AbstractSpringRenameTest fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -56,5 +57,9 @@ fun main(args: Array) { testClass() { model("spring/core/generate", pattern = "^([\\w]+)\\.kt$", singleClass = true) } + + testClass() { + model("spring/core/rename", extension = "test", singleClass = true) + } } } diff --git a/ultimate/tests/org/jetbrains/kotlin/tests/testUtils.kt b/ultimate/tests/org/jetbrains/kotlin/tests/testUtils.kt index 5575f26c26c..1b97b244bd4 100644 --- a/ultimate/tests/org/jetbrains/kotlin/tests/testUtils.kt +++ b/ultimate/tests/org/jetbrains/kotlin/tests/testUtils.kt @@ -20,3 +20,6 @@ import org.jetbrains.kotlin.test.KotlinTestUtils val ULTIMATE_TEST_ROOT: String get() = "${KotlinTestUtils.getHomeDirectory()}/ultimate" + +val ULTIMATE_TEST_DATA_DIR: String + get() = "$ULTIMATE_TEST_ROOT/testData" \ No newline at end of file