<commit_before>package org.jetbrains.plugins.scala.codeInspection.deprecation

import com.intellij.codeInsight.daemon.impl.HighlightInfoType
import org.jetbrains.plugins.scala.codeInspection.InspectionsUtil
import com.intellij.psi._
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod
import infos.MethodCandidateInfo
import com.intellij.psi.PsiClassType.ClassResolveResult
import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil
import com.intellij.codeInsight.daemon.JavaErrorMessages
import org.jetbrains.plugins.scala.lang.psi.api.statements.ScFunction
import org.jetbrains.plugins.scala.lang.psi.api.base.ScReferenceElement
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.imports.{ScImportSelector, ScImportExpr}
import com.intellij.codeInspection._
import collection.mutable.ArrayBuffer
import org.jetbrains.plugins.scala.lang.psi.api.{ScalaRecursiveElementVisitor, ScalaElementVisitor}
import org.jetbrains.plugins.scala.lang.psi.ScalaPsiUtil

/**
 * User: <NAME>
 * Date: 13.04.2010
 */

class ScalaDeprecationInspection extends LocalInspectionTool {
  override def checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array[ProblemDescriptor] = {
    val res = new ArrayBuffer[ProblemDescriptor]
    def checkDeprecated(refElement: PsiElement, elementToHighlight: PsiElement, name: String): Unit = {
      if (refElement == null) return
      if (!refElement.isInstanceOf[PsiNamedElement]) return
      val context = ScalaPsiUtil.nameContext(refElement.asInstanceOf[PsiNamedElement])
      if (!context.isInstanceOf[PsiDocCommentOwner]) return
      if (!(context.asInstanceOf[PsiDocCommentOwner]).isDeprecated) return
      var description: String = "Symbol " + name + " is deprecated"
      res += manager.createProblemDescriptor(elementToHighlight, description, false, ProblemHighlightType.LIKE_DEPRECATED)
    }
    val visitor = new ScalaRecursiveElementVisitor {
      override def visitFunction(fun: ScFunction): Unit = {
        //todo: check super method is deprecated
      }

      override def visitReference(ref: ScReferenceElement): Unit = {
        checkDeprecated(ref.resolve, ref.nameId, ref.refName)
      }
    }
    file.accept(visitor)
    res.toArray
  }<commit_msg>SCL-2237<commit_after>package org.jetbrains.plugins.scala.codeInspection.deprecation

import com.intellij.codeInsight.daemon.impl.HighlightInfoType
import org.jetbrains.plugins.scala.codeInspection.InspectionsUtil
import com.intellij.psi._
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod
import infos.MethodCandidateInfo
import com.intellij.psi.PsiClassType.ClassResolveResult
import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil
import com.intellij.codeInsight.daemon.JavaErrorMessages
import org.jetbrains.plugins.scala.lang.psi.api.statements.ScFunction
import org.jetbrains.plugins.scala.lang.psi.api.base.ScReferenceElement
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.imports.{ScImportSelector, ScImportExpr}
import com.intellij.codeInspection._
import collection.mutable.ArrayBuffer
import org.jetbrains.plugins.scala.lang.psi.api.{ScalaRecursiveElementVisitor, ScalaElementVisitor}
import org.jetbrains.plugins.scala.lang.psi.ScalaPsiUtil

/**
 * User: <NAME>
 * Date: 13.04.2010
 */

class ScalaDeprecationInspection extends LocalInspectionTool {
  override def checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array[ProblemDescriptor] = {
    val res = new ArrayBuffer[ProblemDescriptor]
    def checkDeprecated(refElement: PsiElement, elementToHighlight: PsiElement, name: String): Unit = {
      if (refElement == null) return
      if (!refElement.isInstanceOf[PsiNamedElement]) return
      val context = ScalaPsiUtil.nameContext(refElement.asInstanceOf[PsiNamedElement])
      if (!context.isInstanceOf[PsiDocCommentOwner]) return
      if (!(context.asInstanceOf[PsiDocCommentOwner]).isDeprecated) return
      val description: String = "Symbol " + name + " is deprecated"
      res += manager.createProblemDescriptor(elementToHighlight, description, true, ProblemHighlightType.LIKE_DEPRECATED)
    }
    val visitor = new ScalaRecursiveElementVisitor {
      override def visitFunction(fun: ScFunction): Unit = {
        //todo: check super method is deprecated
      }

      override def visitReference(ref: ScReferenceElement): Unit = {
        checkDeprecated(ref.resolve, ref.nameId, ref.refName)
      }
    }
    file.accept(visitor)
    res.toArray
  }
{'fraction_non_alphanumeric': 0.09343098091433644, 'fraction_numerical': 0.004438526409232135, 'mean_word_length': 5.173972602739726, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6444817', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1323, 'n_words': 232}