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

- fix tests
- fixes to show external annotations

GitOrigin-RevId: 79cde38663de10c2985b72e76e98372fef214b20
This commit is contained in:
Mikhail Pyltsin
2024-06-26 20:34:48 +00:00
committed by intellij-monorepo-bot
parent 246f6ab1cc
commit 36f87ac0b6
11 changed files with 15 additions and 15 deletions
@@ -110,7 +110,7 @@ public final class MethodParameterInfoHandler
PsiMethod method = argumentList.getParent() instanceof PsiCall call ? call.resolveMethod() : null;
CandidateWithPresentation[] items = ContainerUtil.map2Array(candidates, CandidateWithPresentation.class,
c -> new CandidateWithPresentation(c,
MethodPresentation.from((PsiMethod)c.getElement(),
MethodPresentation.from((PsiMethod)c.getElement(),
getCandidateInfoSubstitutor(c, method != null && c.getElement() == method))));
context.setItemsToShow(items);
return argumentList;
@@ -794,7 +794,9 @@ public final class MethodParameterInfoHandler
String qualifiedName = annotation.getQualifiedName();
if (NON_DOCUMENTED_JETBRAINS_ANNOTATIONS.contains(qualifiedName)) continue;
}
if (resolved instanceof PsiClass cls && !AnnotationUtil.isInferredAnnotation(annotation) &&
if (resolved instanceof PsiClass cls &&
!AnnotationUtil.isInferredAnnotation(annotation) &&
!AnnotationUtil.isExternalAnnotation(annotation) &&
(!JavaDocInfoGenerator.isDocumentedAnnotationType(cls) ||
AnnotationTargetUtil.findAnnotationTarget(cls, PsiAnnotation.TargetType.TYPE_USE) != null)) {
continue;
@@ -872,7 +874,7 @@ public final class MethodParameterInfoHandler
public static @NotNull PsiMethod getMethodFromCandidate(@NotNull Object object) {
return ((CandidateWithPresentation)object).getMethod();
}
public static @Nullable PsiMethod tryGetMethodFromCandidate(@NotNull Object object) {
return object instanceof CandidateWithPresentation cwp ? cwp.getMethod() : null;
}
@@ -3,7 +3,7 @@ PsiJavaFileStub [org.jetbrains.annotations]
PsiModifierListStub[mask=1025]
PsiAnnotationStub[@java.lang.annotation.Documented]
PsiAnnotationStub[@java.lang.annotation.Retention(value=java.lang.annotation.RetentionPolicy.CLASS)]
PsiAnnotationStub[@java.lang.annotation.Target(value={java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.FIELD,java.lang.annotation.ElementType.PARAMETER,java.lang.annotation.ElementType.LOCAL_VARIABLE})]
PsiAnnotationStub[@java.lang.annotation.Target(value={java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.FIELD,java.lang.annotation.ElementType.PARAMETER,java.lang.annotation.ElementType.LOCAL_VARIABLE,java.lang.annotation.ElementType.TYPE_USE})]
PsiTypeParameterListStub
PsiRefListStub[EXTENDS_LIST:]
PsiRefListStub[IMPLEMENTS_LIST:]
@@ -12,4 +12,4 @@ PsiJavaFileStub [org.jetbrains.annotations]
PsiAnnotationStub[@org.jetbrains.annotations.NonNls]
PsiTypeParameterListStub
PsiParameterListStub
PsiRefListStub[THROWS_LIST:]
PsiRefListStub[THROWS_LIST:]
@@ -7,7 +7,7 @@ class Box {
}
@NotNull
private Data newMethod(String str1, String str2) {
private Box.Data newMethod(String str1, String str2) {
return new Data() {
@Override
public String getA() {
@@ -22,7 +22,7 @@ public class OutputVariableReused {
}
@Nullable
private X newMethod(String s, String left, String right) {
private OutputVariableReused.X newMethod(String s, String left, String right) {
String res = convert(s, left, right);
if (res != null) {
return new X(res);
@@ -28,7 +28,7 @@ class TooComplexCode {
}
@NotNull
private X newMethod(@NotNull X x) {
private TooComplexCode.X newMethod(@NotNull X x) {
return x.get();
}
}
@@ -15,7 +15,7 @@ public class NullableCheckBreakDuplicate {
}
@Nullable
private Pojo newMethod() {
private NullableCheckBreakDuplicate.Pojo newMethod() {
Pojo x = things.get(0);
if (x.it > 0) return null;
@@ -14,7 +14,7 @@ class Test {
}
@Nullable
private Pojo newMethod() {
private Test.Pojo newMethod() {
Pojo x = things.get(0);
if(x.it > 0) {
@@ -28,7 +28,7 @@ class TooComplexCode {
}
@NotNull
private X newMethod(@NotNull X x) {
private TooComplexCode.X newMethod(@NotNull X x) {
return x.get();
}
}
@@ -15,7 +15,7 @@ public class NullableCheckBreakDuplicate {
}
@Nullable
private Pojo newMethod() {
private NullableCheckBreakDuplicate.Pojo newMethod() {
Pojo x = things.get(0);
if (x.it > 0) return null;
@@ -98,8 +98,6 @@ public abstract class LightJavaCodeInsightTestCase extends LightPlatformCodeInsi
@Override
protected void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
//DefaultLightProjectDescriptor.addJetBrainsAnnotations(model);
DefaultLightProjectDescriptor.addJetBrainsAnnotationsJava8AndHigher(model);
}
else {
@@ -3,7 +3,7 @@ import java.util.*;
class MyTest {
Map<String, <error descr="'@Nls' not applicable to type use">@Nls</error> String> map = new HashMap<>();
Map<String, @Nls String> map = new HashMap<>();
@Nls String test(String s) {
return map.computeIfAbsent(s, x -> <warning descr="Hardcoded string literal: \"value\"">"value"</warning>);
}