mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-highlighting] IDEA-253230 Editor should produce a red code in records with @SafeVarargs in Java 16
GitOrigin-RevId: 5da7b9733e75140ad066b7e9b8af6adb95fea297
This commit is contained in:
committed by
intellij-monorepo-bot
parent
32e37dbcb6
commit
4ae81fd62a
+10
@@ -566,6 +566,16 @@ public final class AnnotationsHighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
static HighlightInfo checkInvalidAnnotationOnRecordComponent(@NotNull PsiAnnotation annotation) {
|
||||
if (!Comparing.strEqual(annotation.getQualifiedName(), CommonClassNames.JAVA_LANG_SAFE_VARARGS)) return null;
|
||||
PsiAnnotationOwner owner = annotation.getOwner();
|
||||
if (!(owner instanceof PsiModifierList)) return null;
|
||||
PsiElement parent = ((PsiModifierList)owner).getParent();
|
||||
if (!(parent instanceof PsiRecordComponent)) return null;
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(annotation)
|
||||
.descriptionAndTooltip(JavaErrorBundle.message("safevararg.annotation.cannot.be.applied.for.record.component")).create();
|
||||
}
|
||||
|
||||
static HighlightInfo checkFunctionalInterface(@NotNull PsiAnnotation annotation, @NotNull LanguageLevel languageLevel) {
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && Comparing.strEqual(annotation.getQualifiedName(), CommonClassNames.JAVA_LANG_FUNCTIONAL_INTERFACE)) {
|
||||
final PsiAnnotationOwner owner = annotation.getOwner();
|
||||
|
||||
+1
@@ -286,6 +286,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkTargetAnnotationDuplicates(annotation));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkDuplicateAnnotations(annotation, myLanguageLevel));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkFunctionalInterface(annotation, myLanguageLevel));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkInvalidAnnotationOnRecordComponent(annotation));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkRepeatableAnnotation(annotation));
|
||||
if (CommonClassNames.JAVA_LANG_OVERRIDE.equals(annotation.getQualifiedName())) {
|
||||
PsiAnnotationOwner owner = annotation.getOwner();
|
||||
|
||||
@@ -511,4 +511,5 @@ text.improper.formed.type=Improper formed type; some type parameters are missing
|
||||
text.class.is.not.accessible={0} is not accessible in current context
|
||||
text.class.cannot.access=Cannot access {0}
|
||||
auto.closeable.resource=auto-closeable resource
|
||||
annotation.type.permits=No permits clause allowed for annotation type
|
||||
annotation.type.permits=No permits clause allowed for annotation type
|
||||
safevararg.annotation.cannot.be.applied.for.record.component=@SafeVarargs annotation cannot be applied for a record component
|
||||
+2
-1
@@ -71,4 +71,5 @@ record StaticFieldCollides(int i) {
|
||||
static int <error descr="Variable 'i' is already defined in the scope">i</error>;
|
||||
}
|
||||
record Incomplete(@<error descr="Class reference expected">i</error>nt a) {}
|
||||
record CStyle(int a[]) {}
|
||||
record CStyle(int a[]) {}
|
||||
record SafeVarargComponent(<error descr="@SafeVarargs annotation cannot be applied for a record component">@SafeVarargs</error> int... component) {}
|
||||
Reference in New Issue
Block a user