<commit_before>package org.jetbrains.plugins.scala.runner

import com.intellij.codeInsight.runner.JavaMainMethodProvider
import com.intellij.psi._
import lang.psi.api.ScalaFile
import lang.psi.api.toplevel.typedef.ScObject

/**
 * @author ilyas
 */

class ScalaMainMethodProvider extends JavaMainMethodProvider {
  def hasMainMethod(clazz: PsiClass) = findMainInClass(clazz) != null

  def findMainInClass(clazz: PsiClass): PsiMethod = clazz match {
    case o: ScObject if clazz.getContainingFile.asInstanceOf[ScalaFile].isScriptFile == false => {
      val mainMethods = o.findMethodsByName("main", true)
      for (m <- mainMethods) {
        if (isMainMethod(m)) return m
      }
      null
    }
    case _ => null
  }

  def isMainMethod(m: PsiMethod) =
    m != null &&
    m.getReturnType == PsiType.VOID &&
    m.hasModifierProperty(PsiModifier.PUBLIC) &&
    {
      val params = m.getParameterList.getParameters
      params.length == 1 && {
        val tpe = params(0).getType
        tpe match {
          case pat: PsiArrayType => pat.getComponentType.equalsToText("java.lang.String")
          case _ => false
        }
      }
    }

  def isApplicable(clazz: PsiClass) = clazz.getContainingFile.isInstanceOf[ScalaFile]
}<commit_msg>cleanup<commit_after>package org.jetbrains.plugins.scala.runner

import com.intellij.codeInsight.runner.JavaMainMethodProvider
import com.intellij.psi._
import lang.psi.api.ScalaFile
import lang.psi.api.toplevel.typedef.ScObject

/**
 * @author ilyas
 */

class ScalaMainMethodProvider extends JavaMainMethodProvider {
  def hasMainMethod(clazz: PsiClass) = findMainInClass(clazz) != null

  def findMainInClass(clazz: PsiClass): PsiMethod = clazz match {
    case o: ScObject if clazz.getContainingFile.asInstanceOf[ScalaFile].isScriptFile == false => {
      val mainMethods = o.findMethodsByName("main", true)
      for (m <- mainMethods) {
        if (isMainMethod(m)) return m
      }
      null
    }
    case _ => null
  }

  private def isMainMethod(m: PsiMethod) =
    m != null &&
    m.getReturnType == PsiType.VOID &&
    m.hasModifierProperty(PsiModifier.PUBLIC) &&
    {
      val params = m.getParameterList.getParameters
      params.length == 1 && {
        val tpe = params(0).getType
        tpe match {
          case pat: PsiArrayType => pat.getComponentType.equalsToText("java.lang.String")
          case _ => false
        }
      }
    }

  def isApplicable(clazz: PsiClass) = clazz.getContainingFile.isInstanceOf[ScalaFile]
}
{'fraction_non_alphanumeric': 0.1088, 'fraction_numerical': 0.0016, 'mean_word_length': 3.182274247491639, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '3403561', 'n_tokens_mistral': 828, 'n_tokens_neox': 814, 'n_words': 151}