<commit_before>package scala.tasty.internal
package convert

import scala.tasty.internal.dotc.core.{ Names => t }
import scala.language.implicitConversions
import scala.tasty.internal.dotc.core.StdNames
  import scala.collection.JavaConversions._

trait NameConverter {
  self: API =>

  val nameCache = new java.util.IdentityHashMap[g.Name, t.Name]();

  private def convertName[TN <: t.Name](name: g.Name)(convertFn: g.Name => TN): TN = {
    nameCache.getOrElse(name,
      {
        val convertedName = convertFn(name)
        nameCache += (name -> convertedName)
        convertedName
      }).asInstanceOf[TN]
  }

  def syntheticName(name: g.Name) = name.append('$')

  import StdNames.nme.EXPAND_SEPARATOR

  //TODO check/improve this implementation
  def isExpandedName(name: t.Name) = name.contains(EXPAND_SEPARATOR)

  def expandedName(base: self.Symbols.Symbol, name: t.Name, separator: t.Name): t.Name =
    expandedName(if (base.hasExpandedName) base.name else base.fullNameSeparated("$"), name, separator)

  def expandedName(base: self.Symbols.Symbol, name: t.Name): t.Name = expandedName(base, name, EXPAND_SEPARATOR)

  def expandedName(prefix: t.Name, name: t.Name, separator: t.Name = EXPAND_SEPARATOR): t.Name =
    name.fromName(prefix ++ separator ++ name)

  object GlobalToTName {
    implicit def convertToName(name: g.Name): t.Name =
      if (name.isTermName) convertToTermName(name) else convertToTypeName(name)

    def convertToTermName(name: g.Name): t.TermName = {
      convertName(name){ (fname: g.Name) =>
        fname match {
          case _ if fname == g.nme.EMPTY_PACKAGE_NAME => StdNames.nme.EMPTY_PACKAGE
          case _ if fname.isEmpty                     => StdNames.nme.EMPTY<commit_msg>isExpandedName is fixed<commit_after>package scala.tasty.internal
package convert

import scala.tasty.internal.dotc.core.{ Names => t }
import scala.language.implicitConversions
import scala.tasty.internal.dotc.core.StdNames
  import scala.collection.JavaConversions._

trait NameConverter {
  self: API =>

  val nameCache = new java.util.IdentityHashMap[g.Name, t.Name]();

  private def convertName[TN <: t.Name](name: g.Name)(convertFn: g.Name => TN): TN = {
    nameCache.getOrElse(name,
      {
        val convertedName = convertFn(name)
        nameCache += (name -> convertedName)
        convertedName
      }).asInstanceOf[TN]
  }

  def syntheticName(name: g.Name) = name.append('$')

  import StdNames.nme.EXPAND_SEPARATOR

  //TODO check/improve this implementation
  def isExpandedName(name: t.Name) = name.lastIndexOfSlice(EXPAND_SEPARATOR) > 0

  def expandedName(base: self.Symbols.Symbol, name: t.Name, separator: t.Name): t.Name =
    expandedName(if (base.hasExpandedName) base.name else base.fullNameSeparated("$"), name, separator)

  def expandedName(base: self.Symbols.Symbol, name: t.Name): t.Name = expandedName(base, name, EXPAND_SEPARATOR)

  def expandedName(prefix: t.Name, name: t.Name, separator: t.Name = EXPAND_SEPARATOR): t.Name =
    name.fromName(prefix ++ separator ++ name)

  object GlobalToTName {
    implicit def convertToName(name: g.Name): t.Name =
      if (name.isTermName) convertToTermName(name) else convertToTypeName(name)

    def convertToTermName(name: g.Name): t.TermName = {
      convertName(name){ (fname: g.Name) =>
        fname match {
          case _ if fname == g.nme.EMPTY_PACKAGE_NAME => StdNames.nme.EMPTY_PACKAGE
          case _ if fname.isEmpty                     => StdNames.nme.EMPTY
{'fraction_non_alphanumeric': 0.12056128293241695, 'fraction_numerical': 0.000286368843069874, 'mean_word_length': 3.663551401869159, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, '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': '2144709', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1154, 'n_words': 242}