<commit_before>package scala.meta.trees

import com.intellij.psi.{PsiClass, PsiElement, PsiMethod, PsiPackage}
import org.jetbrains.plugins.scala.lang.psi.api.ScPackage
import org.jetbrains.plugins.scala.lang.psi.api.base._
import org.jetbrains.plugins.scala.lang.psi.api.statements._
import org.jetbrains.plugins.scala.lang.psi.api.statements.params._
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef._
import org.jetbrains.plugins.scala.lang.psi.impl.ScPackageImpl
import org.jetbrains.plugins.scala.lang.psi.{api => p, impl, types => ptype}
import org.jetbrains.plugins.scala.lang.resolve.ScalaResolveResult

import scala.language.postfixOps
import scala.meta.internal.{ast => m, semantic => h}
import scala.meta.trees.error._

trait Attributes {
  self: TreeConverter =>


  protected implicit class RichAttributesTree[T <: m.Tree](ptree: T) {

    def fqnameToPrefix(fqn: String): h.Prefix = {
      fqn
        .split('.')
        .dropRight(1)
        .foldLeft(std.rootPackagePrefix) {
          (parent, name) => h.Prefix.Type(m.Type.Singleton(
            m.Term.Name(name).withAttrs(denot = h.Denotation.Single(parent, fqnameToSymbol(fqn.substring(0, fqn.indexOf(name) + name.length), toDrop = 0)),
                                        typingLike = h.Typing.Recursive)
            ).setTypechecked
          )
      }
    }

    def anonDenot[P <: PsiElement](elem: P): h.Denotation = {
      h.Denotation.Single(h.Prefix.Type(toType(elem)), toLocalSymbol(elem))<commit_msg>metahost: recursively find prefix for Name.Anonymous<commit_after>package scala.meta.trees

import com.intellij.psi.{PsiClass, PsiElement, PsiMethod, PsiPackage}
import org.jetbrains.plugins.scala.lang.psi.api.ScPackage
import org.jetbrains.plugins.scala.lang.psi.api.base._
import org.jetbrains.plugins.scala.lang.psi.api.statements._
import org.jetbrains.plugins.scala.lang.psi.api.statements.params._
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScToplevelElement
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef._
import org.jetbrains.plugins.scala.lang.psi.impl.ScPackageImpl
import org.jetbrains.plugins.scala.lang.psi.{api => p, impl, types => ptype}
import org.jetbrains.plugins.scala.lang.resolve.ScalaResolveResult

import scala.language.postfixOps
import scala.meta.internal.{ast => m, semantic => h}
import scala.meta.trees.error._

trait Attributes {
  self: TreeConverter =>


  protected implicit class RichAttributesTree[T <: m.Tree](ptree: T) {

    def fqnameToPrefix(fqn: String): h.Prefix = {
      fqn
        .split('.')
        .dropRight(1)
        .foldLeft(std.rootPackagePrefix) {
          (parent, name) => h.Prefix.Type(m.Type.Singleton(
            m.Term.Name(name).withAttrs(denot = h.Denotation.Single(parent, fqnameToSymbol(fqn.substring(0, fqn.indexOf(name) + name.length), toDrop = 0)),
                                        typingLike = h.Typing.Recursive)
            ).setTypechecked
          )
      }
    }

    def anonDenot[P <: PsiElement](elem: P): h.Denotation = {
      def walkUp(tree: PsiElement): PsiElement = {
        tree match {
          case t: ScMethodLike         => t
          case t: ScTemplateDefinition => t
          case t: ScToplevelElement    => t
          case _ => walkUp(tree.getParent)
        }
      }
      h.Denotation.Single(h.Prefix.Type(toType(walkUp(elem))), toLocalSymbol(elem))
{'fraction_non_alphanumeric': 0.12871870397643592, 'fraction_numerical': 0.0017673048600883653, 'mean_word_length': 3.156670746634027, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '2962138', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1114, 'n_words': 174}