mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: don't lose type annotations when replacing clone return type
GitOrigin-RevId: 4ed18180ecbea99dfeff8a541c7a0b30c794054d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
edfb6b07f7
commit
3ddf2a2a3a
+3
-2
@@ -65,7 +65,8 @@ public class CloneReturnsClassTypeInspection extends BaseInspection {
|
||||
if (!(element instanceof PsiTypeElement)) {
|
||||
return;
|
||||
}
|
||||
final PsiElement parent = element.getParent();
|
||||
final PsiTypeElement typeElement = (PsiTypeElement)element;
|
||||
final PsiElement parent = typeElement.getParent();
|
||||
if (!(parent instanceof PsiMethod)) {
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +97,7 @@ public class CloneReturnsClassTypeInspection extends BaseInspection {
|
||||
commentTracker);
|
||||
}
|
||||
});
|
||||
element.replace(newTypeElement);
|
||||
typeElement.getFirstChild().replace(newTypeElement.getFirstChild());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
class TypeUseAnnotation implements Cloneable {
|
||||
|
||||
public @NonNull TypeUseAnnotation clone() throws CloneNotSupportedException {
|
||||
return (TypeUseAnnotation) super.clone();
|
||||
}
|
||||
}
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target({ElementType.TYPE_USE})
|
||||
@interface NonNull {}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
class TypeUseAnnotation implements Cloneable {
|
||||
|
||||
public @NonNull <caret>Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target({ElementType.TYPE_USE})
|
||||
@interface NonNull {}
|
||||
+1
@@ -18,6 +18,7 @@ public class CloneReturnsClassTypeFixTest extends IGQuickFixesTestCase {
|
||||
|
||||
public void testSimple() { doTest("Change return type to 'Simple'"); }
|
||||
public void testReturnNull() { doTest("Change return type to 'ReturnNull'"); }
|
||||
public void testTypeUseAnnotation() { doTest("Change return type to 'TypeUseAnnotation'"); }
|
||||
public void testCast() { doTest("Change return type to 'Cast'"); }
|
||||
public void testAnonymousClass() { doTest("Change return type to 'B'"); }
|
||||
public void testNested() { doTest("Change return type to 'Nested'"); }
|
||||
|
||||
Reference in New Issue
Block a user