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

import com.intellij.psi.PsiFile
import org.jetbrains.plugins.scala.lang.psi.api.ScalaFile
import com.intellij.codeInspection._
import org.jetbrains.plugins.scala.lang.psi.ScalaPsiUtil
import config.ScalaFacet
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.project.Project
import org.intellij.lang.annotations.Language

class ChainedPackageInspection extends LocalInspectionTool {
  def getGroupDisplayName: String = InspectionsUtil.SCALA

  def getDisplayName: String = "Chained Package Clause Inspection"

  def getShortName: String = "Chained Package Clause"

  override def isEnabledByDefault: Boolean = true

  @Language("HTML")
  override val getStaticDescription =
"""Files within a module should consistently use <a href="http://www.scala-lang.org/docu/files/package-clauses/packageclauses.html">Chained Package Clauses</a>
 starting with the base package configured in the Scala Facet.
"""

  override def getID: String = "ScalaChainedPackageClause"

  override def checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array[ProblemDescriptor] = {
    val basePackage: Option[String] = for {
      m <- Option(ScalaPsiUtil.getModule(file))
      facet <- ScalaFacet.findIn(m)
      p <- facet.basePackage
    } yield p
    (file, basePackage) match {
      case (sf: ScalaFile, Some(base)) if !sf.isScriptFile() =>
        sf.packagings.toList match {
          case p0 :: ps if p0.getPackageName != base && p0.getPackageName.startsWith(base) =>
            val fixes = Array[LocalQuickFix](new UseChainedPackageQuickFix(sf, base))
            val range: TextRange = sf.getPackagingRange
            val problem = manager.createProblemDescriptor(file, range, "Package declaration could use chained package clauses",
              ProblemHighlightType.WEAK_WARNING, false, fixes: _*)
            Array(problem)
          case _ => Array()<commit_msg>filter package inspection for non scala files.<commit_after>package org.jetbrains.plugins.scala
package codeInspection
package packageNameInspection

import com.intellij.psi.PsiFile
import org.jetbrains.plugins.scala.lang.psi.api.ScalaFile
import com.intellij.codeInspection._
import org.jetbrains.plugins.scala.lang.psi.ScalaPsiUtil
import config.ScalaFacet
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.project.Project
import org.intellij.lang.annotations.Language

class ChainedPackageInspection extends LocalInspectionTool {
  def getGroupDisplayName: String = InspectionsUtil.SCALA

  def getDisplayName: String = "Chained Package Clause Inspection"

  def getShortName: String = "Chained Package Clause"

  override def isEnabledByDefault: Boolean = true

  @Language("HTML")
  override val getStaticDescription =
"""Files within a module should consistently use <a href="http://www.scala-lang.org/docu/files/package-clauses/packageclauses.html">Chained Package Clauses</a>
 starting with the base package configured in the Scala Facet.
"""

  override def getID: String = "ScalaChainedPackageClause"

  override def checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array[ProblemDescriptor] = {
    if (!file.isInstanceOf[ScalaFile]) return Array.empty
    val basePackage: Option[String] = for {
      m <- Option(ScalaPsiUtil.getModule(file))
      facet <- ScalaFacet.findIn(m)
      p <- facet.basePackage
    } yield p
    (file, basePackage) match {
      case (sf: ScalaFile, Some(base)) if !sf.isScriptFile() =>
        sf.packagings.toList match {
          case p0 :: ps if p0.getPackageName != base && p0.getPackageName.startsWith(base) =>
            val fixes = Array[LocalQuickFix](new UseChainedPackageQuickFix(sf, base))
            val range: TextRange = sf.getPackagingRange
            val problem = manager.createProblemDescriptor(file, range, "Package declaration could use chained package clauses",
              ProblemHighlightType.WEAK_WARNING, false, fixes: _*)
            Array(problem)
          case _ => Array()
{'fraction_non_alphanumeric': 0.09203798392987582, 'fraction_numerical': 0.0014609203798392988, 'mean_word_length': 4.2, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5665309', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1177, 'n_words': 295}