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

import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.lang.ASTNode
import com.intellij.lang.annotation.{Annotation, AnnotationHolder, AnnotationSession, HighlightSeverity}
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement

import scala.language.implicitConversions

class ScalaAnnotationHolderAdapter(innerHolder: AnnotationHolder) extends ScalaAnnotationHolder {

  private val showCompilerErrors =
    ScalaHighlightingMode.isShowErrorsFromCompilerEnabled(innerHolder.getCurrentAnnotationSession.getFile)

  override def createErrorAnnotation(elt: PsiElement, message: String): ScalaAnnotation =
    innerHolder.createErrorAnnotation(elt, ?(message))

  override def createErrorAnnotation(node: ASTNode, message: String): ScalaAnnotation =
    innerHolder.createErrorAnnotation(node, ?(message))

  override def createErrorAnnotation(range: TextRange, message: String): ScalaAnnotation =
    innerHolder.createErrorAnnotation(range, ?(message))

  override def createWarningAnnotation(elt: PsiElement, message: String): ScalaAnnotation =
    innerHolder.createWarningAnnotation(elt, ?(message))

  override def createWarningAnnotation(node: ASTNode, message: String): ScalaAnnotation =
    innerHolder.createWarningAnnotation(node, ?(message))

  override def createWarningAnnotation(range: TextRange, message: String): ScalaAnnotation =
    innerHolder.createWarningAnnotation(range, ?(message))

  override def createWeakWarningAnnotation(elt: PsiElement, message: String): ScalaAnnotation =
    innerHolder.createWeakWarningAnnotation(elt, ?(message))

  override def createWeakWarningAnnotation(node: ASTNode, message: String): ScalaAnnotation =
    innerHolder.createWeakWarningAnnotation(node, ?(message))

  override def createWeakWarningAnnotation(range: TextRange, message: String): ScalaAnnotation =
    innerHolder.createWeakWarningAnnotation(range, ?(message))

  override def createInfoAnnotation(elt: PsiElement, message: String): ScalaAnnotation =
    innerHolder.createInfoAnnotation(elt, ?(message))

  override def createInfoAnnotation(node: ASTNode, message: String): ScalaAnnotation =
    innerHolder.createInfoAnnotation(node, ?(message))

  override def createInfoAnnotation(range: TextRange, message: String): ScalaAnnotation =
    innerHolder.createInfoAnnotation(range, ?(message))

  override def createAnnotation(severity: HighlightSeverity, range: TextRange, message: String): ScalaAnnotation =
    innerHolder.createAnnotation(severity, range, ?(message))

  override def createAnnotation(severity: HighlightSeverity, range: TextRange, message: String, htmlTooltip: String): ScalaAnnotation =
    innerHolder.createAnnotation(severity, range, ?(message), ?(htmlTooltip))

  override def getCurrentAnnotationSession: AnnotationSession =
    innerHolder.getCurrentAnnotationSession

  override def isBatchMode: Boolean =
    innerHolder.isBatchMode

  private implicit def annotation2ScalaAnnotation(annotation: Annotation): ScalaAnnotation =
    if (showCompilerErrors) {
      annotation.setHighlightType(ProblemHighlightType.INFORMATION)
      new ScalaAnnotation(annotation) {
        override def setHighlightType(highlightType: ProblemHighlightType): Unit = ()
        override def setTooltip(tooltip: String): Unit = ()
      }
    } else {
      new ScalaAnnotation(annotation)
    }

  private def ?(msg: String): String =
    Option(msg)
      .filterNot(_ => showCompilerErrors)
      .orNull
}<commit_msg>Compilation error highlightings: bug fix - not show idea errors if compiler errors highlighting enabled #SCL-16983<commit_after>package org.jetbrains.plugins.scala
package annotator
package annotationHolder

import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.lang.ASTNode
import com.intellij.lang.annotation.{Annotation, AnnotationHolder, AnnotationSession, HighlightSeverity}
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement

import scala.language.implicitConversions

class ScalaAnnotationHolderAdapter(innerHolder: AnnotationHolder) extends ScalaAnnotationHolder {

  private val showCompilerErrors =
    ScalaHighlightingMode.isShowErrorsFromCompilerEnabled(innerHolder.getCurrentAnnotationSession.getFile)

  override def createErrorAnnotation(elt: PsiElement, message: String): ScalaAnnotation =
    convert1(elt, message)(innerHolder.createErrorAnnotation)

  override def createErrorAnnotation(node: ASTNode, message: String): ScalaAnnotation =
    convert2(node, message)(innerHolder.createErrorAnnotation)

  override def createErrorAnnotation(range: TextRange, message: String): ScalaAnnotation =
    convert3(range, message)(innerHolder.createErrorAnnotation)

  override def createWarningAnnotation(elt: PsiElement, message: String): ScalaAnnotation =
    convert1(elt, message)(innerHolder.createWarningAnnotation)

  override def createWarningAnnotation(node: ASTNode, message: String): ScalaAnnotation =
    convert2(node, message)(innerHolder.createWarningAnnotation)

  override def createWarningAnnotation(range: TextRange, message: String): ScalaAnnotation =
    convert3(range, message)(innerHolder.createWarningAnnotation)

  override def createWeakWarningAnnotation(elt: PsiElement, message: String): ScalaAnnotation =
    convert1(elt, message)(innerHolder.createWeakWarningAnnotation)

  override def createWeakWarningAnnotation(node: ASTNode, message: String): ScalaAnnotation =
    convert2(node, message)(innerHolder.createWeakWarningAnnotation)

  override def createWeakWarningAnnotation(range: TextRange, message: String): ScalaAnnotation =
    convert3(range, message)(innerHolder.createWeakWarningAnnotation)

  override def createInfoAnnotation(elt: PsiElement, message: String): ScalaAnnotation =
    convert1(elt, message)(innerHolder.createInfoAnnotation)

  override def createInfoAnnotation(node: ASTNode, message: String): ScalaAnnotation =
    convert2(node, message)(innerHolder.createInfoAnnotation)

  override def createInfoAnnotation(range: TextRange, message: String): ScalaAnnotation =
    convert3(range, message)(innerHolder.createInfoAnnotation)

  override def createAnnotation(severity: HighlightSeverity, range: TextRange, message: String): ScalaAnnotation =
    if (showCompilerErrors)
      innerHolder.createAnnotation(HighlightSeverity.INFORMATION, range, "")
    else
      innerHolder.createAnnotation(severity, range, message)

  override def createAnnotation(severity: HighlightSeverity, range: TextRange, message: String, htmlTooltip: String): ScalaAnnotation =
    if (showCompilerErrors)
      innerHolder.createAnnotation(HighlightSeverity.INFORMATION, range, "", "")
    else
      innerHolder.createAnnotation(severity, range, message, htmlTooltip)

  override def getCurrentAnnotationSession: AnnotationSession =
    innerHolder.getCurrentAnnotationSession

  override def isBatchMode: Boolean =
    innerHolder.isBatchMode

  private implicit def annotation2ScalaAnnotation(annotation: Annotation): ScalaAnnotation =
    if (showCompilerErrors) {
      annotation.setHighlightType(ProblemHighlightType.INFORMATION)
      new ScalaAnnotation(annotation) {
        override def setHighlightType(highlightType: ProblemHighlightType): Unit = ()
        override def setTooltip(tooltip: String): Unit = ()
      }
    } else {
      new ScalaAnnotation(annotation)
    }

  private def convert1(elt: PsiElement, message: String)
                      (f: (PsiElement, String) => Annotation): Annotation =
    if (showCompilerErrors)
      innerHolder.createInfoAnnotation(elt, "")
    else
      f(elt, message)

  private def convert2(node: ASTNode, message: String)
                      (f: (ASTNode, String) => Annotation): Annotation =
    if (showCompilerErrors)
      innerHolder.createInfoAnnotation(node, "")
    else
      f(node, message)

  private def convert3(range: TextRange, message: String)
                      (f: (TextRange, String) => Annotation): Annotation =
    if (showCompilerErrors)
      innerHolder.createInfoAnnotation(range, "")
    else
      f(range, message)
}
{'fraction_non_alphanumeric': 0.08262247136241774, 'fraction_numerical': 0.002680965147453083, 'mean_word_length': 5.87929589270746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1225780', 'n_tokens_mistral': 2169, 'n_tokens_neox': 2065, 'n_words': 482}