Supported Kotlin in Java's automatic parameter renamer.
This commit is contained in:
+1
-1
@@ -65,7 +65,7 @@ open public class KotlinLightMethodForDeclaration(
|
||||
}, false)
|
||||
}
|
||||
|
||||
override fun getNavigationElement(): PsiElement = origin
|
||||
override fun getNavigationElement(): PsiElement = getOrigin()
|
||||
override fun getOriginalElement(): PsiElement = origin
|
||||
|
||||
override fun getDelegate(): PsiMethod = delegate
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package org.jetbrains.kotlin.asJava;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.PsiAnnotationOwner;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiModifierList;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.JetLanguage;
|
||||
@@ -103,6 +102,22 @@ public class KotlinLightParameter extends LightParameter implements KotlinLightE
|
||||
return setter != null ? setter.getParameter() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement getNavigationElement() {
|
||||
JetParameter origin = getOrigin();
|
||||
return origin != null ? origin : super.getNavigationElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
|
||||
JetParameter origin = getOrigin();
|
||||
if (origin != null) {
|
||||
origin.setName(name);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile getContainingFile() {
|
||||
JetDeclaration declaration = method.getOrigin();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class JavaSuper {
|
||||
void foo(int /*rename*/aa, String b) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class KotlinSub : JavaSuper() {
|
||||
override fun foo(aa: Int, b: String) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class JavaSuper {
|
||||
void foo(int /*rename*/a, String b) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class KotlinSub : JavaSuper() {
|
||||
override fun foo(a: Int, b: String) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"newName": "aa",
|
||||
"mainFile": "JavaSuper.java"
|
||||
}
|
||||
@@ -47,6 +47,12 @@ public class RenameTestGenerated extends AbstractRenameTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("automaticRenamerJavaParameter/parameter.test")
|
||||
public void testAutomaticRenamerJavaParameter_Parameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/automaticRenamerJavaParameter/parameter.test");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("automaticRenamerOverloads/package.test")
|
||||
public void testAutomaticRenamerOverloads_Package() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/automaticRenamerOverloads/package.test");
|
||||
|
||||
Reference in New Issue
Block a user