mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-174043 Implement method with @NotNull/@Nullable array return type
GitOrigin-RevId: a539db556458ab54411d9b87c40d20e58954382e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3600ba1491
commit
f344906e7b
@@ -274,6 +274,12 @@ public class GenerateMembersUtil {
|
||||
PsiSubstitutor collisionResolvedSubstitutor =
|
||||
substituteTypeParameters(factory, target, sourceMethod.getTypeParameterList(), resultMethod.getTypeParameterList(), substitutor, sourceMethod);
|
||||
substituteReturnType(PsiManager.getInstance(project), resultMethod, sourceMethod.getReturnType(), collisionResolvedSubstitutor);
|
||||
PsiTypeElement typeElement = resultMethod.getReturnTypeElement();
|
||||
if (typeElement != null && typeElement.getText().startsWith("@")) {
|
||||
// If return type is annotated, substituteReturnType will add the annotation into type element,
|
||||
// so the method should be reparsed to move it to the modifier list
|
||||
resultMethod = factory.createMethodFromText(resultMethod.getText(), target);
|
||||
}
|
||||
substituteParameters(factory, codeStyleManager, sourceMethod.getParameterList(), resultMethod.getParameterList(), collisionResolvedSubstitutor, target);
|
||||
copyDocComment(sourceMethod, resultMethod, factory);
|
||||
GlobalSearchScope scope = sourceMethod.getResolveScope();
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// "Implement methods" "true"
|
||||
package org.jetbrains.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.METHOD, ElementType.TYPE_USE})
|
||||
@interface Nullable{}
|
||||
|
||||
@Target({ElementType.METHOD, ElementType.TYPE_USE})
|
||||
@interface NotNull{}
|
||||
|
||||
interface A {
|
||||
@Nullable Object @NotNull [] getNotNullArrayOfNullableObjects();
|
||||
@NotNull Object @Nullable [] getNullableArrayOfNotNullObjects();
|
||||
}
|
||||
|
||||
class B implements A {
|
||||
@Override
|
||||
public @Nullable Object @NotNull [] getNotNullArrayOfNullableObjects() {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Object @Nullable [] getNullableArrayOfNotNullObjects() {
|
||||
return new Object[0];
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Implement methods" "true"
|
||||
package org.jetbrains.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.METHOD, ElementType.TYPE_USE})
|
||||
@interface Nullable{}
|
||||
|
||||
@Target({ElementType.METHOD, ElementType.TYPE_USE})
|
||||
@interface NotNull{}
|
||||
|
||||
interface A {
|
||||
@Nullable Object @NotNull [] getNotNullArrayOfNullableObjects();
|
||||
@NotNull Object @Nullable [] getNullableArrayOfNotNullObjects();
|
||||
}
|
||||
|
||||
class <caret>B implements A {}
|
||||
Reference in New Issue
Block a user