[java] IDEA-354964 Migrate standard descriptors like JAVA_21 to TYPE_USE annotations

- fix NullableManager, when it can't find annotation in type

GitOrigin-RevId: 121927429534971abb4a50d1f670afbed9384045
This commit is contained in:
Mikhail Pyltsin
2024-06-24 16:10:15 +02:00
committed by intellij-monorepo-bot
parent 638393e895
commit 330ba98e01
10 changed files with 21 additions and 17 deletions

View File

@@ -9,8 +9,8 @@ abstract class P2 {
}
Object o = new P2() {
@NotNull
@Override
@NotNull
String foo(String p) {
return "";
}

View File

@@ -2,8 +2,7 @@ import org.jetbrains.annotations.NonNls;
// "Annotate method 'doTest()' as '@NonNls'" "true-preview"
class Foo {
@NonNls
public String doTest() {
public @NonNls String doTest() {
return "text";
}
}

View File

@@ -30,7 +30,7 @@ class Mixed {
}
// Error due to mock limitation
<error descr="'@NotNull' not applicable to annotation type">@NotNull</error>
@NotNull
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@TypeQualifierDefault({ ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.TYPE_USE })

View File

@@ -28,7 +28,7 @@ class TooComplexCode {
}
@NotNull
private TooComplexCode.X newMethod(@NotNull X x) {
private X newMethod(@NotNull X x) {
return x.get();
}
}

View File

@@ -15,7 +15,7 @@ public class NullableCheckBreakDuplicate {
}
@Nullable
private NullableCheckBreakDuplicate.Pojo newMethod() {
private Pojo newMethod() {
Pojo x = things.get(0);
if (x.it > 0) return null;

View File

@@ -4,8 +4,7 @@ import org.jetbrains.annotations.Nullable;
class B {
public final A myDelegate = new A();
@Nullable
public Object methodFromA(@NotNull String s) {
public @Nullable Object methodFromA(@NotNull String s) {
return myDelegate.methodFromA(s);
}
}

View File

@@ -22,9 +22,8 @@ public class MakeInferredAnnotationExplicitTest extends LightJavaCodeInsightFixt
import org.jetbrains.annotations.NotNull;
class Foo {
@NotNull
@Contract(pure = true)
static String f<caret>oo() {
static @NotNull String f<caret>oo() {
return "s";
}
}""");

View File

@@ -24,7 +24,10 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
import com.intellij.psi.impl.light.LightMethodBuilder;
import com.intellij.psi.impl.source.PsiExtensibleClass;
import com.intellij.testFramework.*;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.NeedsIndex;
import com.intellij.testFramework.ServiceContainerUtil;
import com.intellij.tools.ide.metrics.benchmark.PerformanceTestUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
@@ -2882,7 +2885,7 @@ public class NormalCompletionTest extends NormalCompletionTestCase {
}
""");
myFixture.completeBasic();
assertEquals(List.of("NonNls", "NotNull"), myFixture.getLookupElementStrings());
assertEquals(List.of("NonNls", "NotNull", "UnknownNullability"), myFixture.getLookupElementStrings());
}
@NeedsIndex.Full