<commit_before>package org.jetbrains.plugins.scala.lang.psi.types

import com.intellij.psi._
import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope

trait ScType {

  def equiv(t: ScType): Boolean = t == this

  sealed def conforms(t: ScType): Boolean = Conformance.conforms(t, this)
}

case object Any extends ScType

case object Null extends ScType

case object AnyRef extends ScType

case object Nothing extends ScType

case object Singleton extends ScType

case object AnyVal extends ScType

abstract case class ValType(val name : String, val tSuper : Option[ValType]) extends ScType

object Unit extends ValType("Unit", None)
object Boolean extends ValType("Boolean", None)
object Char extends ValType("Char", Some(Int))
object Int extends ValType("Int", Some(Long))
object Long extends ValType("Long", Some(Float))
object Float extends ValType("Float", Some(Double))
object Double extends ValType("Double", None)
object Byte extends ValType("Byte", Some(Short))
object Short extends ValType("Float", Some(Int))

object ScType {
  def create(psiType : PsiType, project : Project) : ScType = {
    psiType match {
      case classType : PsiClassType => {
        val result = classType.resolveGenerics
        val clazz = result.getElement
        if (clazz != null) {
          return new ScParameterizedType(new ScDesignatorType(clazz), clazz.getTypeParameters.map
                  {tp => create(result.getSubstitutor.substitute(tp), project)})
        }
      }
      case arrayType : PsiArrayType => {
        val arrayClass = JavaPsiFacade.getInstance(project).findClass("scala.Array", GlobalSearchScope.allScope(project))
        if (arrayClass != null) {
          val tps = arrayClass.getTypeParameters
          if (tps.length == 1) {
            val typeArg = create(arrayType.getComponentType, project)
            return new ScParameterizedType(new ScDesignatorType(arrayClass), Array(typeArg))
          }
          return new ScDesignatorType(arrayClass)
        }
      }

      case PsiType.VOID => Unit
      case PsiType.BOOLEAN => Boolean
      case PsiType.CHAR => Char
      case PsiType.INT => Int
      case PsiType.LONG => Long
      case PsiType.FLOAT => Float
      case PsiType.DOUBLE => Double
      case PsiType.BYTE => Byte
      case PsiType.SHORT => Short
      case PsiType.NULL => Null
      case _ => Nothing
      //todo other cases
    }
    Nothing
  }
}<commit_msg>java types => scala types finalized<commit_after>package org.jetbrains.plugins.scala.lang.psi.types

import com.intellij.psi._
import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope

trait ScType {

  def equiv(t: ScType): Boolean = t == this

  sealed def conforms(t: ScType): Boolean = Conformance.conforms(t, this)
}

case object Any extends ScType

case object Null extends ScType

case object AnyRef extends ScType

case object Nothing extends ScType

case object Singleton extends ScType

case object AnyVal extends ScType

abstract case class ValType(val name : String, val tSuper : Option[ValType]) extends ScType

object Unit extends ValType("Unit", None)
object Boolean extends ValType("Boolean", None)
object Char extends ValType("Char", Some(Int))
object Int extends ValType("Int", Some(Long))
object Long extends ValType("Long", Some(Float))
object Float extends ValType("Float", Some(Double))
object Double extends ValType("Double", None)
object Byte extends ValType("Byte", Some(Short))
object Short extends ValType("Float", Some(Int))

object ScType {
  def create(psiType : PsiType, project : Project) : ScType = {
    psiType match {
      case classType : PsiClassType => {
        val result = classType.resolveGenerics
        val clazz = result.getElement
        if (clazz != null) {
          return new ScParameterizedType(new ScDesignatorType(clazz), clazz.getTypeParameters.map
                  {tp => create(result.getSubstitutor.substitute(tp), project)})
        }
      }
      case arrayType : PsiArrayType => {
        val arrayClass = JavaPsiFacade.getInstance(project).findClass("scala.Array", GlobalSearchScope.allScope(project))
        if (arrayClass != null) {
          val tps = arrayClass.getTypeParameters
          if (tps.length == 1) {
            val typeArg = create(arrayType.getComponentType, project)
            return new ScParameterizedType(new ScDesignatorType(arrayClass), Array(typeArg))
          }
          return new ScDesignatorType(arrayClass)
        }
      }

      case PsiType.VOID => Unit
      case PsiType.BOOLEAN => Boolean
      case PsiType.CHAR => Char
      case PsiType.INT => Int
      case PsiType.LONG => Long
      case PsiType.FLOAT => Float
      case PsiType.DOUBLE => Double
      case PsiType.BYTE => Byte
      case PsiType.SHORT => Short
      case PsiType.NULL => Null
      case wild : PsiWildcardType => new ScExistentialArgument(create(wild.getSuperBound, project),
                                                               create(wild.getExtendsBound, project))
      case _ => throw new IllegalArgumentException("psi type should not be converted to scala type" + psiType)
    }
    Nothing
  }
}
{'fraction_non_alphanumeric': 0.09247104247104247, 'fraction_numerical': 0.0003861003861003861, 'mean_word_length': 3.1849757673667205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6273453', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1449, 'n_words': 426}