Spring Support: Support Find Usages/Rename (on both declarations and

references) of Kotlin declarations referenced in the XML config
 #KT-11719 Fixed
 #KT-11652 Fixed
This commit is contained in:
Alexey Sedunov
2016-04-06 14:08:33 +03:00
parent a553f67744
commit 119cf0f0cd
68 changed files with 615 additions and 58 deletions
+2
View File
@@ -131,6 +131,7 @@ New features:
- [KT-11604](https://youtrack.jetbrains.com/issue/KT-11604) Support "Configure Spring facet" inspection on Kotlin classes
- [KT-11407](https://youtrack.jetbrains.com/issue/KT-11407) Implemented "Generate Spring Dependency..." actions
- [KT-11408](https://youtrack.jetbrains.com/issue/KT-11408) Implemented "Generate @Autowired Dependency..." action
- [KT-11652](https://youtrack.jetbrains.com/issue/KT-11652) Rename bean attributes mentioned in Spring XML config together with corresponding Kotlin declarations
Issues fixed:
@@ -164,6 +165,7 @@ Issues fixed:
- [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
- [KT-11719](https://youtrack.jetbrains.com/issue/KT-11719) Fixed renaming of Kotlin parameters references in XML files
#### Debugger
@@ -170,4 +170,14 @@ public class KtLightParameter extends LightParameter implements KtLightDeclarati
public PsiElement getParent() {
return getMethod().getParameterList();
}
@Override
public boolean isEquivalentTo(PsiElement another) {
KtParameter kotlinOrigin = getKotlinOrigin();
if (another instanceof KtLightParameter && kotlinOrigin != null) {
KtLightParameter anotherParam = (KtLightParameter) another;
return kotlinOrigin.equals(anotherParam.getKotlinOrigin()) && getClsDelegate().equals(anotherParam.getClsDelegate());
}
return super.isEquivalentTo(another);
}
}
@@ -224,8 +224,8 @@ class KotlinReferencesSearcher : QueryExecutorBase<PsiReference, ReferencesSearc
}
private fun searchPropertyMethods(queryParameters: ReferencesSearch.SearchParameters, parameter: KtParameter) {
val propertyMethods = runReadAction { LightClassUtil.getLightClassPropertyMethods(parameter) }
propertyMethods.allDeclarations.forEach { searchNamedElement(queryParameters, it) }
val lightElements = runReadAction { parameter.toLightElements() }
lightElements.forEach { searchNamedElement(queryParameters, it) }
}
private fun searchDataClassComponentUsages(queryParameters: ReferencesSearch.SearchParameters,
@@ -40,6 +40,15 @@ class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() {
return element is KtNamedFunction || (element is KtLightMethod && element.kotlinOrigin is KtNamedFunction)
}
override fun findCollisions(
element: PsiElement?,
newName: String?,
allRenames: Map<out PsiElement?, String>,
result: MutableList<UsageInfo>
) {
checkConflictsAndReplaceUsageInfos(result)
}
override fun substituteElementToRename(element: PsiElement?, editor: Editor?): PsiElement? {
val wrappedMethod = wrapPsiMethod(element) ?: return element
@@ -27,7 +27,6 @@ import com.intellij.psi.search.SearchScope
import com.intellij.psi.search.searches.OverridingMethodsSearch
import com.intellij.refactoring.listeners.RefactoringElementListener
import com.intellij.refactoring.rename.RenameProcessor
import com.intellij.refactoring.rename.RenamePsiElementProcessor
import com.intellij.refactoring.util.RefactoringUtil
import com.intellij.usageView.UsageInfo
import org.jetbrains.kotlin.asJava.LightClassUtil
@@ -45,7 +44,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.OverrideResolver
class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
class RenameKotlinPropertyProcessor : RenameKotlinPsiProcessor() {
override fun canProcessElement(element: PsiElement): Boolean {
val namedUnwrappedElement = element.namedUnwrappedElement
return namedUnwrappedElement is KtProperty || (namedUnwrappedElement is KtParameter && namedUnwrappedElement.hasValOrVar())
@@ -16,20 +16,27 @@
package org.jetbrains.kotlin.idea.refactoring.rename
import com.intellij.refactoring.rename.RenamePsiElementProcessor
import com.intellij.psi.PsiElement
import com.intellij.usageView.UsageInfo
import com.intellij.psi.PsiReference
import com.intellij.psi.search.searches.MethodReferencesSearch
import com.intellij.refactoring.rename.RenamePsiElementProcessor
import org.jetbrains.kotlin.asJava.toLightMethods
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.utils.SmartList
abstract class RenameKotlinPsiProcessor : RenamePsiElementProcessor() {
override fun canProcessElement(element: PsiElement): Boolean = element is KtNamedDeclaration
override fun findCollisions(
element: PsiElement?,
newName: String?,
allRenames: Map<out PsiElement?, String>,
result: MutableList<UsageInfo>
) {
checkConflictsAndReplaceUsageInfos(result)
override fun findReferences(element: PsiElement): Collection<PsiReference> {
val references = SmartList<PsiReference>(super.findReferences(element))
if (element is KtNamedFunction
|| (element is KtProperty && !element.isLocal)
|| (element is KtParameter && element.hasValOrVar())) {
element.toLightMethods().flatMapTo(references) { MethodReferencesSearch.search(it) }
}
return references
}
}
@@ -61,6 +61,7 @@ import org.jetbrains.kotlin.idea.findUsages.KotlinPropertyFindUsagesOptions;
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase;
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor;
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
import org.jetbrains.kotlin.idea.test.TestFixtureExtension;
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
@@ -293,6 +294,10 @@ public abstract class AbstractFindUsagesTest extends KotlinLightCodeInsightFixtu
myFixture.setTestDataPath(PluginTestCaseBase.getTestDataPathBase() + "/findUsages");
}
protected void extraConfig(@SuppressWarnings("UnusedParameters") @NotNull String path) {
}
protected <T extends PsiElement> void doTest(@NotNull String path) throws Exception {
File mainFile = new File(path);
final String mainFileName = mainFile.getName();
@@ -315,59 +320,73 @@ public abstract class AbstractFindUsagesTest extends KotlinLightCodeInsightFixtu
: Property.class);
}
OptionsParser parser = OptionsParser.getParserByPsiElementClass(caretElementClass);
String rootPath = path.substring(0, path.lastIndexOf("/") + 1);
File rootDir = new File(rootPath);
File[] extraFiles = rootDir.listFiles(
new FilenameFilter() {
@Override
public boolean accept(@NotNull File dir, @NotNull String name) {
if (!name.startsWith(prefix) || name.equals(mainFileName)) return false;
String ext = FileUtilRt.getExtension(name);
return ext.equals("kt")
|| ext.equals("java")
|| ext.equals("xml")
|| ext.equals("properties")
|| (ext.equals("txt") && !name.endsWith(".results.txt"));
}
}
);
assert extraFiles != null;
for (File file : extraFiles) {
myFixture.configureByFile(rootPath + file.getName());
List<String> fixtureClasses = InTextDirectivesUtils.findListWithPrefixes(mainFileText, "// FIXTURE_CLASS: ");
for (String fixtureClass : fixtureClasses) {
TestFixtureExtension.Companion.loadFixture(fixtureClass, myFixture.getModule());
}
myFixture.configureByFile(path);
PsiElement caretElement =
InTextDirectivesUtils.isDirectiveDefined(mainFileText, "// FIND_BY_REF")
? TargetElementUtilBase.findTargetElement(myFixture.getEditor(),
TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED |
JavaTargetElementEvaluator.NEW_AS_CONSTRUCTOR)
: myFixture.getElementAtCaret();
assertNotNull(caretElement);
assertInstanceOf(caretElement, caretElementClass);
try {
extraConfig(path);
PsiFile containingFile = caretElement.getContainingFile();
boolean isLibraryElement = containingFile != null && ProjectRootsUtil.isLibraryFile(getProject(), containingFile.getVirtualFile());
OptionsParser parser = OptionsParser.getParserByPsiElementClass(caretElementClass);
FindUsagesOptions options = parser != null ? parser.parse(mainFileText, getProject()) : null;
String rootPath = path.substring(0, path.lastIndexOf("/") + 1);
// Ensure that search by sources (if present) and decompiled declarations gives the same results
if (isLibraryElement) {
PsiElement originalElement = caretElement.getOriginalElement();
findUsagesAndCheckResults(mainFileText, prefix, rootPath, originalElement, options);
File rootDir = new File(rootPath);
File[] extraFiles = rootDir.listFiles(
new FilenameFilter() {
@Override
public boolean accept(@NotNull File dir, @NotNull String name) {
if (!name.startsWith(prefix) || name.equals(mainFileName)) return false;
PsiElement navigationElement = caretElement.getNavigationElement();
if (navigationElement != originalElement) {
findUsagesAndCheckResults(mainFileText, prefix, rootPath, navigationElement, options);
String ext = FileUtilRt.getExtension(name);
return ext.equals("kt")
|| ext.equals("java")
|| ext.equals("xml")
|| ext.equals("properties")
|| (ext.equals("txt") && !name.endsWith(".results.txt"));
}
}
);
assert extraFiles != null;
for (File file : extraFiles) {
myFixture.configureByFile(rootPath + file.getName());
}
myFixture.configureByFile(path);
PsiElement caretElement =
InTextDirectivesUtils.isDirectiveDefined(mainFileText, "// FIND_BY_REF")
? TargetElementUtilBase.findTargetElement(myFixture.getEditor(),
TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED |
JavaTargetElementEvaluator.NEW_AS_CONSTRUCTOR)
: myFixture.getElementAtCaret();
assertNotNull(caretElement);
assertInstanceOf(caretElement, caretElementClass);
PsiFile containingFile = caretElement.getContainingFile();
boolean isLibraryElement = containingFile != null && ProjectRootsUtil.isLibraryFile(getProject(), containingFile.getVirtualFile());
FindUsagesOptions options = parser != null ? parser.parse(mainFileText, getProject()) : null;
// Ensure that search by sources (if present) and decompiled declarations gives the same results
if (isLibraryElement) {
PsiElement originalElement = caretElement.getOriginalElement();
findUsagesAndCheckResults(mainFileText, prefix, rootPath, originalElement, options);
PsiElement navigationElement = caretElement.getNavigationElement();
if (navigationElement != originalElement) {
findUsagesAndCheckResults(mainFileText, prefix, rootPath, navigationElement, options);
}
}
else {
findUsagesAndCheckResults(mainFileText, prefix, rootPath, caretElement, options);
}
}
else {
findUsagesAndCheckResults(mainFileText, prefix, rootPath, caretElement, options);
finally {
for (String fixtureClass : fixtureClasses) {
TestFixtureExtension.Companion.unloadFixture(fixtureClass);
}
}
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean"/>
</beans>
+6
View File
@@ -0,0 +1,6 @@
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtClass
// OPTIONS: usages
package a
class <caret>KotlinSpringBean
@@ -0,0 +1 @@
Usage in XML descriptor 5 <bean class="a.KotlinSpringBean" name="xmlKotlinBean"/>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<constructor-arg name="value" value="2"/>
<property name="value"/>
</bean>
</beans>
@@ -0,0 +1,6 @@
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtParameter
// OPTIONS: usages
package a
class KotlinSpringBean(var <caret>value: Int)
@@ -0,0 +1,2 @@
Usage in XML descriptor 6 <constructor-arg name="value" value="2"/>
Usage in XML descriptor 7 <property name="value"/>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="foo"/>
</bean>
</beans>
@@ -0,0 +1,8 @@
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtProperty
// OPTIONS: usages
package a
class KotlinSpringBean {
var <caret>foo: Int = 1
}
@@ -0,0 +1 @@
Usage in XML descriptor 6 <property name="foo"/>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="bar"/>
</bean>
</beans>
@@ -0,0 +1,10 @@
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtNamedFunction
// OPTIONS: usages
package a
class KotlinSpringBean {
fun <caret>setBar(value: Int) {
}
}
@@ -0,0 +1 @@
Usage in XML descriptor 6 <property name="bar"/>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean2" name="xmlKotlinBean"/>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean2
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean"/>
</beans>
@@ -0,0 +1,3 @@
package a
class /*rename*/KotlinSpringBean
@@ -0,0 +1,8 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "test.kt",
"springFileSet": ["spring-config.xml"],
"newName": "KotlinSpringBean2",
"withRuntime": "true"
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean2" name="xmlKotlinBean"/>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean2
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a./*rename*/KotlinSpringBean" name="xmlKotlinBean"/>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean
@@ -0,0 +1,9 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "spring-config.xml",
"springFileSet": ["spring-config.xml"],
"newName": "KotlinSpringBean2",
"byRef": "true",
"withRuntime": "true"
}
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<constructor-arg name="value2" value="2"/>
<property name="value2"/>
</bean>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean(var value2: Int)
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<constructor-arg name="value" value="2"/>
<property name="value"/>
</bean>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean(var /*rename*/value: Int)
@@ -0,0 +1,8 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "test.kt",
"springFileSet": ["spring-config.xml"],
"newName": "value2",
"withRuntime": "true"
}
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<constructor-arg name="value2" value="2"/>
<property name="value2"/>
</bean>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean(var value2: Int)
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<constructor-arg name="/*rename*/value" value="2"/>
<property name="value"/>
</bean>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean(var value: Int)
@@ -0,0 +1,9 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "spring-config.xml",
"springFileSet": ["spring-config.xml"],
"newName": "value2",
"byRef": "true",
"withRuntime": "true"
}
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<constructor-arg name="value2" value="2"/>
<property name="value2"/>
</bean>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean(var value2: Int)
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<constructor-arg name="value" value="2"/>
<property name="/*rename*/value"/>
</bean>
</beans>
@@ -0,0 +1,3 @@
package a
class KotlinSpringBean(var value: Int)
@@ -0,0 +1,9 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "spring-config.xml",
"springFileSet": ["spring-config.xml"],
"newName": "value2",
"byRef": "true",
"withRuntime": "true"
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="foo2"/>
</bean>
</beans>
@@ -0,0 +1,5 @@
package a
class KotlinSpringBean {
var foo2: Int = 1
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="foo"/>
</bean>
</beans>
@@ -0,0 +1,5 @@
package a
class KotlinSpringBean {
var /*rename*/foo: Int = 1
}
@@ -0,0 +1,8 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "test.kt",
"springFileSet": ["spring-config.xml"],
"newName": "foo2",
"withRuntime": "true"
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="foo2"/>
</bean>
</beans>
@@ -0,0 +1,5 @@
package a
class KotlinSpringBean {
var foo2: Int = 1
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="/*rename*/foo"/>
</bean>
</beans>
@@ -0,0 +1,5 @@
package a
class KotlinSpringBean {
var foo: Int = 1
}
@@ -0,0 +1,9 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "spring-config.xml",
"springFileSet": ["spring-config.xml"],
"newName": "foo2",
"byRef": "true",
"withRuntime": "true"
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="bar2"/>
</bean>
</beans>
@@ -0,0 +1,7 @@
package a
class KotlinSpringBean {
fun setBar2(value: Int) {
}
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="bar"/>
</bean>
</beans>
@@ -0,0 +1,7 @@
package a
class KotlinSpringBean {
fun /*rename*/setBar(value: Int) {
}
}
@@ -0,0 +1,8 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "test.kt",
"springFileSet": ["spring-config.xml"],
"newName": "setBar2",
"withRuntime": "true"
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="bar2"/>
</bean>
</beans>
@@ -0,0 +1,7 @@
package a
class KotlinSpringBean {
fun setBar2(value: Int) {
}
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="a.KotlinSpringBean" name="xmlKotlinBean">
<property name="/*rename*/bar"/>
</bean>
</beans>
@@ -0,0 +1,7 @@
package a
class KotlinSpringBean {
fun setBar(value: Int) {
}
}
@@ -0,0 +1,9 @@
{
"fixtureClasses": ["org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension"],
"type": "MARKED_ELEMENT",
"mainFile": "spring-config.xml",
"springFileSet": ["spring-config.xml"],
"newName": "setBar2",
"byRef": "true",
"withRuntime": "true"
}
@@ -0,0 +1,28 @@
/*
* 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.findUsages
import org.jetbrains.kotlin.findUsages.AbstractFindUsagesTest
import org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
import org.jetbrains.kotlin.idea.spring.tests.loadConfigByMainFilePath
import org.jetbrains.kotlin.idea.test.TestFixtureExtension
abstract class AbstractSpringFindUsagesTest : AbstractFindUsagesTest() {
override fun extraConfig(path: String) {
TestFixtureExtension.getFixture<SpringTestFixtureExtension>()!!.loadConfigByMainFilePath(path, myFixture)
}
}
@@ -0,0 +1,61 @@
/*
* 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.findUsages;
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/findUsages")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class SpringFindUsagesTestGenerated extends AbstractSpringFindUsagesTest {
public void testAllFilesPresentInFindUsages() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("ultimate/testData/spring/core/findUsages"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("classXml.kt")
public void testClassXml() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/findUsages/classXml.kt");
doTest(fileName);
}
@TestMetadata("primaryConstructorArgXml.kt")
public void testPrimaryConstructorArgXml() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/findUsages/primaryConstructorArgXml.kt");
doTest(fileName);
}
@TestMetadata("propertyXml.kt")
public void testPropertyXml() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/findUsages/propertyXml.kt");
doTest(fileName);
}
@TestMetadata("setterFunXml.kt")
public void testSetterFunXml() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/findUsages/setterFunXml.kt");
doTest(fileName);
}
}
@@ -35,6 +35,18 @@ public class SpringRenameTestGenerated extends AbstractSpringRenameTest {
KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("ultimate/testData/spring/core/rename"), Pattern.compile("^(.+)\\.test$"));
}
@TestMetadata("classWithXmlRefs/classWithXmlRef.test")
public void testClassWithXmlRefs_ClassWithXmlRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/classWithXmlRefs/classWithXmlRef.test");
doTest(fileName);
}
@TestMetadata("classWithXmlRefsByRef/classWithXmlRefByRef.test")
public void testClassWithXmlRefsByRef_ClassWithXmlRefByRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/classWithXmlRefsByRef/classWithXmlRefByRef.test");
doTest(fileName);
}
@TestMetadata("javaSpelRefToJava/javaSpelRefToJava.test")
public void testJavaSpelRefToJava_JavaSpelRefToJava() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/javaSpelRefToJava/javaSpelRefToJava.test");
@@ -82,4 +94,46 @@ public class SpringRenameTestGenerated extends AbstractSpringRenameTest {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/ktSpelRefToKtAnnotated/ktSpelRefToKtAnnotated.test");
doTest(fileName);
}
@TestMetadata("primaryConstructorArgWithXmlRefs/primaryConstructorArgWithXmlRef.test")
public void testPrimaryConstructorArgWithXmlRefs_PrimaryConstructorArgWithXmlRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/primaryConstructorArgWithXmlRefs/primaryConstructorArgWithXmlRef.test");
doTest(fileName);
}
@TestMetadata("primaryConstructorArgWithXmlRefsByRef1/primaryConstructorArgWithXmlRefByRef1.test")
public void testPrimaryConstructorArgWithXmlRefsByRef1_PrimaryConstructorArgWithXmlRefByRef1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/primaryConstructorArgWithXmlRefsByRef1/primaryConstructorArgWithXmlRefByRef1.test");
doTest(fileName);
}
@TestMetadata("primaryConstructorArgWithXmlRefsByRef2/primaryConstructorArgWithXmlRefByRef2.test")
public void testPrimaryConstructorArgWithXmlRefsByRef2_PrimaryConstructorArgWithXmlRefByRef2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/primaryConstructorArgWithXmlRefsByRef2/primaryConstructorArgWithXmlRefByRef2.test");
doTest(fileName);
}
@TestMetadata("propertyWithXmlRefs/propertyWithXmlRef.test")
public void testPropertyWithXmlRefs_PropertyWithXmlRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/propertyWithXmlRefs/propertyWithXmlRef.test");
doTest(fileName);
}
@TestMetadata("propertyWithXmlRefsByRef/propertyWithXmlRefByRef.test")
public void testPropertyWithXmlRefsByRef_PropertyWithXmlRefByRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/propertyWithXmlRefsByRef/propertyWithXmlRefByRef.test");
doTest(fileName);
}
@TestMetadata("setterFunWithXmlRefs/setterFunWithXmlRef.test")
public void testSetterFunWithXmlRefs_SetterFunWithXmlRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/setterFunWithXmlRefs/setterFunWithXmlRef.test");
doTest(fileName);
}
@TestMetadata("setterFunWithXmlRefsByRef/setterFunWithXmlRefByRef.test")
public void testSetterFunWithXmlRefsByRef_SetterFunWithXmlRefByRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("ultimate/testData/spring/core/rename/setterFunWithXmlRefsByRef/setterFunWithXmlRefByRef.test");
doTest(fileName);
}
}
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.tests
import org.jetbrains.kotlin.generators.tests.testGroup
import org.jetbrains.kotlin.idea.codeInsight.AbstractInspectionTest
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest
import org.jetbrains.kotlin.idea.spring.tests.findUsages.AbstractSpringFindUsagesTest
import org.jetbrains.kotlin.idea.spring.tests.generate.AbstractGenerateSpringDependencyActionTest
import org.jetbrains.kotlin.idea.spring.tests.gutter.AbstractSpringClassAnnotatorTest
import org.jetbrains.kotlin.idea.spring.tests.references.AbstractSpringReferenceCompletionHandlerTest
@@ -61,5 +62,9 @@ fun main(args: Array<String>) {
testClass<AbstractSpringRenameTest>() {
model("spring/core/rename", extension = "test", singleClass = true)
}
testClass<AbstractSpringFindUsagesTest>() {
model("spring/core/findUsages", pattern = """^(.+)\.kt$""")
}
}
}