<commit_before>package org.jetbrains.plugins.scala
package annotator
package template

import com.intellij.lang.annotation.{AnnotationHolder, Annotator}
import com.intellij.psi.{PsiAnonymousClass, PsiElement, PsiJavaCodeReferenceElement, PsiReferenceList}
import org.jetbrains.plugins.scala.extensions._

final class SealedJavaInheritance extends Annotator {

  override def annotate(element: PsiElement, holder: AnnotationHolder): Unit =
    SealedJavaInheritance.annotate(element)(holder)
}

object SealedJavaInheritance {

  private def annotate(element: PsiElement)
                      (implicit holder: AnnotationHolder): Unit = element match {
    case list: PsiReferenceList => annotateReferences(list.getReferenceElements: _*)
    case clazz: PsiAnonymousClass => annotateReferences(clazz.getBaseClassReference)
    case _ =>
  }

  import SealedClassInheritance.ErrorAnnotationMessage

  private[this] def annotateReferences(references: PsiJavaCodeReferenceElement*)
                                      (implicit holder: AnnotationHolder): Unit =
    references.foreach {
      case reference@ResolvesTo(ErrorAnnotationMessage(message)) =>
        holder.createErrorAnnotation(reference, message)
      case _ =>
    }
}<commit_msg>Fix false positives in SealedJavaInheritance annotator<commit_after>package org.jetbrains.plugins.scala
package annotator
package template

import com.intellij.lang.annotation.{AnnotationHolder, Annotator}
import com.intellij.psi.{PsiAnonymousClass, PsiElement, PsiJavaCodeReferenceElement, PsiReferenceList}
import org.jetbrains.plugins.scala.extensions._

final class SealedJavaInheritance extends Annotator {

  override def annotate(element: PsiElement, holder: AnnotationHolder): Unit =
    SealedJavaInheritance.annotate(element)(holder)
}

object SealedJavaInheritance {
  private[this] def isValidRole(role: PsiReferenceList.Role): Boolean =
    role == PsiReferenceList.Role.EXTENDS_LIST ||
      role == PsiReferenceList.Role.IMPLEMENTS_LIST

  private def annotate(element: PsiElement)(implicit holder: AnnotationHolder): Unit = element match {
    case list: PsiReferenceList if isValidRole(list.getRole) => annotateReferences(list.getReferenceElements: _*)
    case clazz: PsiAnonymousClass                            => annotateReferences(clazz.getBaseClassReference)
    case _                                                   => ()
  }

  import SealedClassInheritance.ErrorAnnotationMessage

  private[this] def annotateReferences(references: PsiJavaCodeReferenceElement*)
                                      (implicit holder: AnnotationHolder): Unit =
    references.foreach {
      case reference@ResolvesTo(ErrorAnnotationMessage(message)) =>
        holder.createErrorAnnotation(reference, message)
      case _ =>
    }
}
{'fraction_non_alphanumeric': 0.07703332139018274, 'fraction_numerical': 0.0, 'mean_word_length': 4.113553113553113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4337759', 'n_tokens_mistral': 783, 'n_tokens_neox': 731, 'n_words': 147}