<commit_before>package scala.meta.internal.scalacp

import org.langmeta.internal.io.PathIO
import scala.meta.internal.metacp._
import scala.meta.internal.{semanticdb3 => s}
import scala.meta.internal.semanticdb3.Accessibility.{Tag => a}
import scala.meta.internal.semanticdb3.{Language => l}
import scala.meta.internal.semanticdb3.SymbolInformation.{Kind => k}
import scala.meta.internal.semanticdb3.SymbolInformation.{Property => p}
import scala.meta.internal.semanticdb3.Type.{Tag => t}

object Scalalib {
  def anyClass: ToplevelInfos = {
    val symbols = List(
      builtinMethod("Any", List(p.ABSTRACT), "equals", Nil, List("that" -> "scala.Any#"), "scala.Boolean#"),
      builtinMethod("Any", List(p.FINAL), "==", Nil, List("that" -> "scala.Any#"), "scala.Boolean#"),
      builtinMethod("Any", List(p.FINAL), "!=", Nil, List("that" -> "scala.Any#"), "scala.Boolean#"),
      builtinMethod("Any", List(p.ABSTRACT), "hashCode", Nil, Nil, "scala.Int#"),
      builtinMethod("Any", List(p.FINAL), "##", Nil, Nil, "scala.Int#"),
      builtinMethod("Any", List(p.ABSTRACT), "toString", Nil, Nil, "java.lang.String#"),
      // TODO: Return type of getClass can't be expressed in the SemanticDB type system.
      // The method is special-cased in both the Java and Scala compilers, so we'll slack a little bit too for the time being.
      builtinMethod("Any", List(p.FINAL), "getClass", Nil, Nil, "java.lang.Class#"),
      builtinMethod("Any", List(p.FINAL), "isInstanceOf", List("A"), Nil, "scala.Boolean#"),
      builtinMethod("Any", List(p.FINAL), "asInstanceOf", List("A"), Nil, "scala.Any.asInstanceOf(A).[A]"))
    builtinClass(List(p.ABSTRACT), "Any", Nil, symbols.flatten)
  }

  def anyValClass: ToplevelInfos = {
    builtinClass(List(p.ABSTRACT), "AnyVal", List("scala.Any#"), Nil)
  }

  def anyRefClass: ToplevelInfos = {
    // TODO: We're not including methods from java.lang.Object here.
    // The relationship between AnyRef and Object needs more thinking.
    val symbols = List(
      builtinMethod("AnyRef", List(p.FINAL), "eq", Nil, List("that" -> "scala.AnyRef#"), "scala.Boolean#"),
      builtinMethod("AnyRef", List(p.FINAL), "ne", Nil, List("that" -> "scala.AnyRef#"), "scala.Boolean#"),
      builtinMethod("AnyRef", List(p.FINAL), "synchronized", List("T"), List("body" -> "scala.AnyRef.synchronized(T).[T]"), "scala.AnyRef.synchronized(T).[T]"))
    builtinClass(Nil, "AnyRef", List("scala.Any#"), symbols.flatten)
  }

  def nothingClass: ToplevelInfos = {
    builtinClass(List(p.ABSTRACT, p.FINAL), "Nothing", List("scala.Any#"), Nil)
  }

  def nullClass: ToplevelInfos = {
    builtinClass(List(p.ABSTRACT, p.FINAL), "Null", List("scala.AnyRef#"), Nil)
  }

  def singletonTrait: ToplevelInfos = {
    builtinTrait(List(p.FINAL), "Singleton", List("scala.Any#"), Nil)
  }

  private def builtinClass(
      props: List[s.SymbolInformation.Property],
      name: String,
      bases: List[String],
      symbols: List[s.SymbolInformation]
  ): ToplevelInfos = {
    builtinClassOrTrait(props, name, bases, symbols, isTrait = false)
  }

  private def builtinTrait(
      props: List[s.SymbolInformation.Property],
      name: String,
      bases: List[String],
      symbols: List[s.SymbolInformation]
  ): ToplevelInfos = {
    builtinClassOrTrait(props, name, bases, symbols, isTrait = true)
  }

  private def builtinClassOrTrait(
      props: List[s.SymbolInformation.Property],
      name: String,
      bases: List[String],
      symbols: List[s.SymbolInformation],
      isTrait: Boolean): ToplevelInfos = {
    val parents = bases.map { base =>
      s.Type(tag = t.TYPE_REF, typeRef = Some(s.TypeRef(None, base, Nil)))
    }
    val symbol = "scala." + name + "#"
    val builtinTpe = s.Type(tag = t.TYPE_REF, typeRef = Some(s.TypeRef(None, symbol, Nil)))
    val ctorSig = s.MethodType(Nil, List(s.MethodType.ParameterList(Nil)), Some(builtinTpe))
    val ctor = s.SymbolInformation(
      symbol = symbol + "`<init>`().",
      language = l.SCALA,
      kind = k.CONSTRUCTOR,
      properties = p.PRIMARY.value,
      name = "<init>",
      tpe = Some(s.Type(tag = t.METHOD_TYPE, methodType = Some(ctorSig))),
      accessibility = Some(s.Accessibility(a.PUBLIC)),
      owner = symbol
    )
    val builtinSig = {
      val decls = symbols.filter(_.kind == k.METHOD)
      val declSymbols = decls.map(_.symbol)
      val declarations = if (isTrait) declSymbols else ctor.symbol +: declSymbols
      val tpe = s.ClassInfoType(Nil, parents, declarations)
      s.Type(tag = t.CLASS_INFO_TYPE, classInfoType = Some(tpe))
    }
    val builtin = s.SymbolInformation(
      symbol = symbol,
      language = l.SCALA,
      kind = if (isTrait) k.TRAIT else k.CLASS,
      properties = props.foldLeft(0)((acc, prop) => acc | prop.value),
      name = name,
      tpe = Some(builtinSig),
      accessibility = Some(s.Accessibility(a.PUBLIC)),
      owner = "scala."
    )
    val syntheticBase = PathIO.workingDirectory<commit_msg>Address review comments<commit_after>package scala.meta.internal.scalacp

import org.langmeta.internal.io.PathIO
import scala.meta.internal.metacp._
import scala.meta.internal.{semanticdb3 => s}
import scala.meta.internal.semanticdb3.Accessibility.{Tag => a}
import scala.meta.internal.semanticdb3.{Language => l}
import scala.meta.internal.semanticdb3.SymbolInformation.{Kind => k}
import scala.meta.internal.semanticdb3.SymbolInformation.{Property => p}
import scala.meta.internal.semanticdb3.Type.{Tag => t}

object Scalalib {
  def anyClass: ToplevelInfos = {
    val symbols = List(
      builtinMethod("Any", List(p.ABSTRACT), "equals", Nil, List("that" -> "scala.Any#"), "scala.Boolean#"),
      builtinMethod("Any", List(p.FINAL), "==", Nil, List("that" -> "scala.Any#"), "scala.Boolean#"),
      builtinMethod("Any", List(p.FINAL), "!=", Nil, List("that" -> "scala.Any#"), "scala.Boolean#"),
      builtinMethod("Any", List(p.ABSTRACT), "hashCode", Nil, Nil, "scala.Int#"),
      builtinMethod("Any", List(p.FINAL), "##", Nil, Nil, "scala.Int#"),
      builtinMethod("Any", List(p.ABSTRACT), "toString", Nil, Nil, "java.lang.String#"),
      // TODO: Return type of getClass can't be expressed in the SemanticDB type system.
      // The method is special-cased in both the Java and Scala compilers, so we'll slack a little bit too for the time being.
      builtinMethod("Any", List(p.FINAL), "getClass", Nil, Nil, "java.lang.Class#"),
      builtinMethod("Any", List(p.FINAL), "isInstanceOf", List("A"), Nil, "scala.Boolean#"),
      builtinMethod("Any", List(p.FINAL), "asInstanceOf", List("A"), Nil, "scala.Any.asInstanceOf(A).[A]"))
    builtin(k.CLASS, List(p.ABSTRACT), "Any", Nil, symbols.flatten)
  }

  def anyValClass: ToplevelInfos = {
    builtin(k.CLASS, List(p.ABSTRACT), "AnyVal", List("scala.Any#"), Nil)
  }

  def anyRefClass: ToplevelInfos = {
    // TODO: We're not including methods from java.lang.Object here.
    // The relationship between AnyRef and Object needs more thinking.
    val symbols = List(
      builtinMethod("AnyRef", List(p.FINAL), "eq", Nil, List("that" -> "scala.AnyRef#"), "scala.Boolean#"),
      builtinMethod("AnyRef", List(p.FINAL), "ne", Nil, List("that" -> "scala.AnyRef#"), "scala.Boolean#"),
      builtinMethod("AnyRef", List(p.FINAL), "synchronized", List("T"), List("body" -> "scala.AnyRef.synchronized(T).[T]"), "scala.AnyRef.synchronized(T).[T]"))
    builtin(k.CLASS, Nil, "AnyRef", List("scala.Any#"), symbols.flatten)
  }

  def nothingClass: ToplevelInfos = {
    builtin(k.CLASS, List(p.ABSTRACT, p.FINAL), "Nothing", List("scala.Any#"), Nil)
  }

  def nullClass: ToplevelInfos = {
    builtin(k.CLASS, List(p.ABSTRACT, p.FINAL), "Null", List("scala.AnyRef#"), Nil)
  }

  def singletonTrait: ToplevelInfos = {
    builtin(k.TRAIT, List(p.FINAL), "Singleton", List("scala.Any#"), Nil)
  }

  private def builtin(
      kind: s.SymbolInformation.Kind,
      props: List[s.SymbolInformation.Property],
      name: String,
      bases: List[String],
      symbols: List[s.SymbolInformation]): ToplevelInfos = {
    val parents = bases.map { base =>
      s.Type(tag = t.TYPE_REF, typeRef = Some(s.TypeRef(None, base, Nil)))
    }
    val symbol = "scala." + name + "#"
    val builtinTpe = s.Type(tag = t.TYPE_REF, typeRef = Some(s.TypeRef(None, symbol, Nil)))
    val ctorSig = s.MethodType(Nil, List(s.MethodType.ParameterList(Nil)), Some(builtinTpe))
    val ctor = s.SymbolInformation(
      symbol = symbol + "`<init>`().",
      language = l.SCALA,
      kind = k.CONSTRUCTOR,
      properties = p.PRIMARY.value,
      name = "<init>",
      tpe = Some(s.Type(tag = t.METHOD_TYPE, methodType = Some(ctorSig))),
      accessibility = Some(s.Accessibility(a.PUBLIC)),
      owner = symbol
    )
    val builtinSig = {
      val decls = symbols.filter(_.kind == k.METHOD)
      val declSymbols = decls.map(_.symbol)
      val declarations = if (kind == k.CLASS) ctor.symbol +: declSymbols else declSymbols
      val tpe = s.ClassInfoType(Nil, parents, declarations)
      s.Type(tag = t.CLASS_INFO_TYPE, classInfoType = Some(tpe))
    }
    val builtin = s.SymbolInformation(
      symbol = symbol,
      language = l.SCALA,
      kind = kind,
      properties = props.foldLeft(0)((acc, prop) => acc | prop.value),
      name = name,
      tpe = Some(builtinSig),
      accessibility = Some(s.Accessibility(a.PUBLIC)),
      owner = "scala."
    )
    val syntheticBase = PathIO.workingDirectory
{'fraction_non_alphanumeric': 0.1667725540025413, 'fraction_numerical': 0.0014824227022448115, 'mean_word_length': 3.7036852589641436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, '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': '1466161', 'n_tokens_mistral': 3344, 'n_tokens_neox': 3225, 'n_words': 684}