@@ -329,7 +329,7 @@ private static boolean isAnnotationRepeatedTwice(@Nonnull PsiAnnotationOwner own
329329
330330 @ Nullable
331331 @ RequiredReadAction
332- public static HighlightInfo checkMissingAttributes (PsiAnnotation annotation ) {
332+ public static HighlightInfo . Builder checkMissingAttributes (PsiAnnotation annotation ) {
333333 PsiJavaCodeReferenceElement nameRef = annotation .getNameReferenceElement ();
334334 if (nameRef == null ) {
335335 return null ;
@@ -371,8 +371,7 @@ public static HighlightInfo checkMissingAttributes(PsiAnnotation annotation) {
371371 .descriptionAndTooltip (JavaErrorLocalize .annotationMissingAttribute (buff ))
372372 .registerFix (
373373 QuickFixFactory .getInstance ().createAddMissingRequiredAnnotationParametersFix (annotation , annotationMethods , missed )
374- )
375- .create ();
374+ );
376375 }
377376 }
378377
@@ -396,14 +395,13 @@ public static HighlightInfo.Builder checkConstantExpression(PsiExpression expres
396395
397396 @ Nullable
398397 @ RequiredReadAction
399- public static HighlightInfo checkValidAnnotationType (PsiType type , PsiTypeElement typeElement ) {
398+ public static HighlightInfo . Builder checkValidAnnotationType (PsiType type , PsiTypeElement typeElement ) {
400399 if (type != null && type .accept (AnnotationReturnTypeVisitor .INSTANCE )) {
401400 return null ;
402401 }
403402 return HighlightInfo .newHighlightInfo (HighlightInfoType .ERROR )
404403 .range (typeElement )
405- .descriptionAndTooltip (JavaErrorLocalize .annotationInvalidAnnotationMemberType (type != null ? type .getPresentableText () : "?" ))
406- .create ();
404+ .descriptionAndTooltip (JavaErrorLocalize .annotationInvalidAnnotationMemberType (type != null ? type .getPresentableText () : "?" ));
407405 }
408406
409407 private static final ElementPattern <PsiElement > ANY_ANNOTATION_ALLOWED = psiElement ().andOr (
@@ -465,8 +463,7 @@ public static HighlightInfo.Builder checkApplicability(
465463 else if (owner instanceof PsiModifierList modifierList ) {
466464 PsiElement nextElement =
467465 PsiTreeUtil .skipSiblingsForward (modifierList , PsiComment .class , PsiWhiteSpace .class , PsiTypeParameterList .class );
468- if (nextElement instanceof PsiTypeElement ) {
469- PsiTypeElement typeElement = (PsiTypeElement )nextElement ;
466+ if (nextElement instanceof PsiTypeElement typeElement ) {
470467 PsiType type = typeElement .getType ();
471468 if (PsiType .VOID .equals (type )) {
472469 return annotationError (annotation , JavaErrorLocalize .annotationNotAllowedVoid ());
@@ -526,37 +523,34 @@ private static PsiJavaCodeReferenceElement getOutermostReferenceElement(@Nullabl
526523 return null ;
527524 }
528525
529- PsiElement qualifier ;
530- while ((qualifier = ref .getQualifier ()) instanceof PsiJavaCodeReferenceElement ) {
531- ref = (PsiJavaCodeReferenceElement )qualifier ;
526+ while (ref .getQualifier () instanceof PsiJavaCodeReferenceElement javaCodeRef ) {
527+ ref = javaCodeRef ;
532528 }
533529 return ref ;
534530 }
535531
536532 @ Nullable
537533 @ RequiredReadAction
538- public static HighlightInfo checkAnnotationType (PsiAnnotation annotation ) {
534+ public static HighlightInfo . Builder checkAnnotationType (PsiAnnotation annotation ) {
539535 PsiJavaCodeReferenceElement nameRefElem = annotation .getNameReferenceElement ();
540536 if (nameRefElem != null && (!(nameRefElem .resolve () instanceof PsiClass annotationClass ) || !annotationClass .isAnnotationType ())) {
541537 return HighlightInfo .newHighlightInfo (HighlightInfoType .ERROR )
542538 .range (nameRefElem )
543- .descriptionAndTooltip (JavaErrorLocalize .annotationAnnotationTypeExpected ())
544- .create ();
539+ .descriptionAndTooltip (JavaErrorLocalize .annotationAnnotationTypeExpected ());
545540 }
546541 return null ;
547542 }
548543
549544 @ Nullable
550545 @ RequiredReadAction
551- public static HighlightInfo checkCyclicMemberType (PsiTypeElement typeElement , PsiClass aClass ) {
546+ public static HighlightInfo . Builder checkCyclicMemberType (PsiTypeElement typeElement , PsiClass aClass ) {
552547 LOG .assertTrue (aClass .isAnnotationType ());
553548 PsiType type = typeElement .getType ();
554549 Set <PsiClass > checked = new HashSet <>();
555550 if (cyclicDependencies (aClass , type , checked , aClass .getManager ())) {
556551 return HighlightInfo .newHighlightInfo (HighlightInfoType .ERROR )
557552 .range (typeElement )
558- .descriptionAndTooltip (JavaErrorLocalize .annotationCyclicElementType ())
559- .create ();
553+ .descriptionAndTooltip (JavaErrorLocalize .annotationCyclicElementType ());
560554 }
561555 return null ;
562556 }
@@ -580,8 +574,9 @@ private static boolean cyclicDependencies(PsiClass aClass, PsiType type, @Nonnul
580574 return false ;
581575 }
582576
577+ @ Nullable
583578 @ RequiredReadAction
584- public static HighlightInfo checkClashesWithSuperMethods (@ Nonnull PsiAnnotationMethod psiMethod ) {
579+ public static HighlightInfo . Builder checkClashesWithSuperMethods (@ Nonnull PsiAnnotationMethod psiMethod ) {
585580 PsiIdentifier nameIdentifier = psiMethod .getNameIdentifier ();
586581 if (nameIdentifier != null ) {
587582 PsiMethod [] methods = psiMethod .findDeepestSuperMethods ();
@@ -596,8 +591,7 @@ public static HighlightInfo checkClashesWithSuperMethods(@Nonnull PsiAnnotationM
596591 .descriptionAndTooltip (
597592 "@interface member clashes with '" + JavaHighlightUtil .formatMethod (method ) +
598593 "' in " + HighlightUtil .formatClass (containingClass )
599- )
600- .create ();
594+ );
601595 }
602596 }
603597 }
@@ -643,7 +637,7 @@ public static HighlightInfo checkPackageAnnotationContainingFile(PsiPackageState
643637
644638 @ Nullable
645639 @ RequiredReadAction
646- public static HighlightInfo checkTargetAnnotationDuplicates (PsiAnnotation annotation ) {
640+ public static HighlightInfo . Builder checkTargetAnnotationDuplicates (PsiAnnotation annotation ) {
647641 PsiJavaCodeReferenceElement nameRef = annotation .getNameReferenceElement ();
648642 if (nameRef == null ) {
649643 return null ;
@@ -671,8 +665,7 @@ public static HighlightInfo checkTargetAnnotationDuplicates(PsiAnnotation annota
671665 if (targets .contains (target )) {
672666 return HighlightInfo .newHighlightInfo (HighlightInfoType .ERROR )
673667 .range (initializer )
674- .descriptionAndTooltip (JavaErrorLocalize .repeatedAnnotationTarget ())
675- .create ();
668+ .descriptionAndTooltip (JavaErrorLocalize .repeatedAnnotationTarget ());
676669 }
677670 targets .add (target );
678671 }
@@ -683,7 +676,7 @@ public static HighlightInfo checkTargetAnnotationDuplicates(PsiAnnotation annota
683676
684677 @ Nullable
685678 @ RequiredReadAction
686- public static HighlightInfo checkFunctionalInterface (@ Nonnull PsiAnnotation annotation , @ Nonnull LanguageLevel languageLevel ) {
679+ public static HighlightInfo . Builder checkFunctionalInterface (@ Nonnull PsiAnnotation annotation , @ Nonnull LanguageLevel languageLevel ) {
687680 if (languageLevel .isAtLeast (LanguageLevel .JDK_1_8 )
688681 && Comparing .strEqual (annotation .getQualifiedName (), JavaClassNames .JAVA_LANG_FUNCTIONAL_INTERFACE )) {
689682 PsiAnnotationOwner owner = annotation .getOwner ();
@@ -696,8 +689,7 @@ public static HighlightInfo checkFunctionalInterface(@Nonnull PsiAnnotation anno
696689 if (errorMessage != null ) {
697690 return HighlightInfo .newHighlightInfo (HighlightInfoType .ERROR )
698691 .range (annotation )
699- .descriptionAndTooltip (errorMessage )
700- .create ();
692+ .descriptionAndTooltip (errorMessage );
701693 }
702694 }
703695 }
@@ -706,7 +698,7 @@ public static HighlightInfo checkFunctionalInterface(@Nonnull PsiAnnotation anno
706698
707699 @ Nullable
708700 @ RequiredReadAction
709- public static HighlightInfo checkRepeatableAnnotation (PsiAnnotation annotation ) {
701+ public static HighlightInfo . Builder checkRepeatableAnnotation (PsiAnnotation annotation ) {
710702 String qualifiedName = annotation .getQualifiedName ();
711703 if (!JavaClassNames .JAVA_LANG_ANNOTATION_REPEATABLE .equals (qualifiedName )) {
712704 return null ;
@@ -718,8 +710,7 @@ public static HighlightInfo checkRepeatableAnnotation(PsiAnnotation annotation)
718710 if (containerRef != null ) {
719711 return HighlightInfo .newHighlightInfo (HighlightInfoType .ERROR )
720712 .range (containerRef )
721- .descriptionAndTooltip (description )
722- .create ();
713+ .descriptionAndTooltip (description );
723714 }
724715 }
725716
0 commit comments