change the origin of light methods for property accessors to the property itself
This commit is contained in:
@@ -149,6 +149,9 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
|
||||
@Override
|
||||
public PsiMethod invoke(PsiMethod method) {
|
||||
JetDeclaration declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(method);
|
||||
if (declaration instanceof JetPropertyAccessor) {
|
||||
declaration = PsiTreeUtil.getParentOfType(declaration, JetProperty.class);
|
||||
}
|
||||
|
||||
if (declaration != null) {
|
||||
return !isTraitFakeOverride(declaration) ?
|
||||
|
||||
@@ -146,7 +146,18 @@ public class LightClassUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiMethod getLightClassAccessorMethod(@NotNull JetPropertyAccessor accessor) {
|
||||
return getPsiMethodWrapper(accessor);
|
||||
JetProperty property = PsiTreeUtil.getParentOfType(accessor, JetProperty.class);
|
||||
if (property == null) {
|
||||
return null;
|
||||
}
|
||||
List<PsiMethod> wrappers = getPsiMethodWrappers(property, true);
|
||||
for (PsiMethod wrapper : wrappers) {
|
||||
if ((accessor.isGetter() && !wrapper.getName().startsWith(JvmAbi.SETTER_PREFIX)) ||
|
||||
(accessor.isSetter() && wrapper.getName().startsWith(JvmAbi.SETTER_PREFIX))) {
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -331,13 +342,13 @@ public class LightClassUtil {
|
||||
|
||||
for (PsiMethod wrapper : wrappers) {
|
||||
if (wrapper.getName().startsWith(JvmAbi.SETTER_PREFIX)) {
|
||||
assert setterWrapper == null : String.format(
|
||||
assert setterWrapper == null || setterWrapper == specialSetter: String.format(
|
||||
"Setter accessor isn't expected to be reassigned (old: %s, new: %s)", setterWrapper, wrapper);
|
||||
|
||||
setterWrapper = wrapper;
|
||||
}
|
||||
else {
|
||||
assert getterWrapper == null : String.format(
|
||||
assert getterWrapper == null || getterWrapper == specialGetter: String.format(
|
||||
"Getter accessor isn't expected to be reassigned (old: %s, new: %s)", getterWrapper, wrapper);
|
||||
|
||||
getterWrapper = wrapper;
|
||||
|
||||
+1
-1
@@ -30,6 +30,6 @@ public class KotlinWrapperForJavaUsageInfos(
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other == this || (other is KotlinWrapperForJavaUsageInfos && javaChangeInfo.getMethod() == other.javaChangeInfo.getMethod())
|
||||
return other === this || (other is KotlinWrapperForJavaUsageInfos && javaChangeInfo.getMethod() == other.javaChangeInfo.getMethod())
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
[javaAndKotlinOverrides.0.kt] Unclassified usage (13: 9) set(value: String) {
|
||||
[javaAndKotlinOverrides.0.kt] Unclassified usage (25: 18) override var foo: String = ""
|
||||
[javaAndKotlinOverrides.0.kt] Unclassified usage (9: 9) get() {
|
||||
[javaAndKotlinOverrides.0.kt] Unclassified usage (8: 18) override var foo: String
|
||||
[javaAndKotlinOverrides.1.java] Unclassified usage (12: 17) public void setFoo(String s) {
|
||||
[javaAndKotlinOverrides.1.java] Unclassified usage (7: 19) public String getFoo() {
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
[javaAndKotlinOverrides2.0.kt] Unclassified usage (11: 9) set(value: String) {
|
||||
[javaAndKotlinOverrides2.0.kt] Unclassified usage (23: 18) override var foo: String = ""
|
||||
[javaAndKotlinOverrides2.0.kt] Unclassified usage (26: 30) open class E<T>(override var foo: T): A<T>(foo)
|
||||
[javaAndKotlinOverrides2.0.kt] Unclassified usage (7: 9) get() {
|
||||
[javaAndKotlinOverrides2.0.kt] Unclassified usage (6: 18) override var foo: String
|
||||
[javaAndKotlinOverrides2.1.java] Unclassified usage (12: 17) public void setFoo(String s) {
|
||||
[javaAndKotlinOverrides2.1.java] Unclassified usage (7: 19) public String getFoo() {
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package testing;
|
||||
|
||||
import testing.rename.*;
|
||||
|
||||
class GroovyClient {
|
||||
public void foo(AP ap, DP dp) {
|
||||
ap.getSecond
|
||||
new BP().getSecond
|
||||
new CP().getSecond
|
||||
|
||||
dp.getSecond
|
||||
new EP().second
|
||||
new FP().second
|
||||
}
|
||||
|
||||
public interface DP extends AP {
|
||||
}
|
||||
|
||||
public static class EP implements DP {
|
||||
@Override
|
||||
public int getSecond() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FP extends EP {
|
||||
@Override
|
||||
public int getSecond() {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
package testing;
|
||||
|
||||
import testing.rename.*;
|
||||
|
||||
class GroovyClient {
|
||||
public void foo(AP ap, DP dp) {
|
||||
ap.first
|
||||
new BP().first
|
||||
new CP().first
|
||||
|
||||
dp.first
|
||||
new EP().first
|
||||
new FP().first
|
||||
}
|
||||
|
||||
public interface DP extends AP {
|
||||
}
|
||||
|
||||
public static class EP implements DP {
|
||||
@Override
|
||||
public int getFirst() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FP extends EP {
|
||||
@Override
|
||||
public int getFirst() {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,11 +241,8 @@ public class JetJavaFacadeTest extends JetLightCodeInsightFixtureTestCase {
|
||||
// Should not fail!
|
||||
LightClassUtil.PropertyAccessorsPsiMethods propertyAccessors = LightClassUtil.getLightClassPropertyMethods(jetProperty);
|
||||
|
||||
JetPropertyAccessor getter = jetProperty.getGetter();
|
||||
JetPropertyAccessor setter = jetProperty.getSetter();
|
||||
|
||||
checkDeclarationMethodWrapped(shouldWrapGetter, getter != null ? getter : jetProperty, propertyAccessors.getGetter());
|
||||
checkDeclarationMethodWrapped(shouldWrapSetter, setter != null ? setter : jetProperty, propertyAccessors.getSetter());
|
||||
checkDeclarationMethodWrapped(shouldWrapGetter, jetProperty, propertyAccessors.getGetter());
|
||||
checkDeclarationMethodWrapped(shouldWrapSetter, jetProperty, propertyAccessors.getSetter());
|
||||
}
|
||||
|
||||
private void doTestWrapPropertyAccessor(boolean shouldWrapAccessor) {
|
||||
@@ -253,7 +250,9 @@ public class JetJavaFacadeTest extends JetLightCodeInsightFixtureTestCase {
|
||||
|
||||
// Should not fail!
|
||||
PsiMethod propertyAccessors = LightClassUtil.getLightClassAccessorMethod(jetPropertyAccessor);
|
||||
checkDeclarationMethodWrapped(shouldWrapAccessor, jetPropertyAccessor, propertyAccessors);
|
||||
checkDeclarationMethodWrapped(shouldWrapAccessor,
|
||||
PsiTreeUtil.getParentOfType(jetPropertyAccessor, JetProperty.class),
|
||||
propertyAccessors);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user