<commit_before>package scala.meta

import org.scalameta.adt._
import org.scalameta.annotations._
import scala.{Seq => _}
import scala.annotation.compileTimeOnly
import scala.collection.immutable.Seq
import scala.reflect.{ClassTag, classTag}

package object semantic {
  @root trait Mark
  def mark(): Mark = ???

  @root trait Attr
  object Attr {
    // TODO: design the attr hierarchy of semantic facts that can be figured out about trees
    // TODO: examples: a type a tree, a definition/definitions the tree refers to, maybe a desugaring, etc
    // TODO: see https://github.com/JetBrains/intellij-scala/blob/master/src/org/jetbrains/plugins/scala/lang/resolve/ScalaResolveResult.scala#L24
  }

  implicit class RichTree(val tree: Tree) extends AnyVal {
    @hosted def attrs: Seq[Attr] = delegate
  }

  implicit class SemanticTermOps(val tree: Term) extends AnyVal {
    @hosted def tpe: Type = ???
  }

  implicit class SemanticTypeOps(val tree: Type) extends AnyVal {
    @hosted def <:<(other: Type): Boolean = delegate
    @hosted def weak_<:<(other: Type): Boolean = ???
    @hosted def widen: Type = ???
    @hosted def dealias: Type = ???
    @hosted def erasure: Type = delegate
    @hosted def companion: Type.Ref = ???
  }

  @hosted def lub(tpes: Seq[Type]): Type = delegate
  @hosted def glb(tpes: Seq[Type]): Type = delegate

  implicit class SemanticRefOps(val tree: Ref) extends AnyVal {
    @hosted def defns: Seq[Member] = ???
    @hosted def defn: Member = ???
  }

  implicit class SemanticTypeRefOps(val tree: Type.Ref) extends AnyVal {
    // NOTE: we can't refine the return type of Ref.defns and Ref.defn
    // because a Type.Ref can refer to both types (regular types) and terms (singleton types)
  }

  implicit class SemanticTermRefOps(val tree: Term.Ref) extends AnyVal {
    @hosted def defns: Seq[Member.Term] = ???
    @hosted def defn: Member.Term = ???
  }

  implicit class SemanticMemberOps(val tree: Member) extends AnyVal {
    def ref: Ref = ???
    @hosted def parents: Seq[Member] = ???
    @hosted def children: Seq[Member] = ???
    def annots: Seq[Mod.Annot] = tree.mods.collect{ case annot: Mod.Annot => annot }
    def isVal: Boolean = ???
    def isVar: Boolean = ???
    def isDef: Boolean = ???
    def isMacro: Boolean = ???
    def isAbstractType: Boolean = ???
    def isAliasType: Boolean = ???
    def isClass: Boolean = ???
    def isTrait: Boolean = ???
    def isObject: Boolean = ???
    def isPkg: Boolean = ???
    def isPkgObject: Boolean = ???
    def isPrivate: Boolean = ???
    def isProtected: Boolean = ???
    def isPublic: Boolean = ???
    @hosted def accessBoundary: Member = ???
    def isImplicit: Boolean = ???
    def isFinal: Boolean = ???
    def isSealed: Boolean = ???
    @hosted def isOverride: Boolean = ???
    def isCase: Boolean = ???
    def isAbstract: Boolean = ???
    def isCovariant: Boolean = ???
    def isContravariant: Boolean = ???
    def isLazy: Boolean = ???
    def isAbstractOverride: Boolean = ???
    def isByNameParam: Boolean = ???
    def isVarargParam: Boolean = ???
    def isValParam: Boolean = ???
    def isVarParam: Boolean = ???
  }

  implicit class SemanticTermMemberOps(val tree: Member.Term) extends AnyVal {
    def ref: Term.Ref = ???
    @hosted def overridden: Seq[Member.Term] = ???
    @hosted def overriding: Seq[Member.Term] = ???
  }

  implicit class SemanticTypeMemberOps(val tree: Member.Type) extends AnyVal {
    def ref: Type.Ref = new SemanticMemberOps(tree).ref.asInstanceOf[Type.Ref]
    @hosted def overridden: Seq[Member.Type] = ???
    @hosted def overriding: Seq[Member.Type] = ???
  }

  implicit class SemanticDefMemberOps(val tree: Member.Def) extends AnyVal {
    @hosted def tpe: meta.Type = ???
  }

  implicit class SemanticTemplateMemberOps(val tree: Member.Template) extends AnyVal {
    @hosted def parents: Seq[Member.Template] = ???
    @hosted def children: Seq[Member.Template] = ???
    @hosted def self: Aux.Self = ???
    @hosted def companion: Member.Template = ???
  }

  implicit class SemanticDeclValOps(val tree: Decl.Val) extends AnyVal {
    @hosted def tpe: meta.Type = ???
  }

  implicit class SemanticDeclVarOps(val tree: Decl.Var) extends AnyVal {
    @hosted def tpe: meta.Type = ???
  }

  implicit class SemanticDefnValOps(val tree: Defn.Val) extends AnyVal {
    @hosted def tpe: meta.Type = ???
  }

  implicit class SemanticDefnVarOps(val tree: Defn.Var) extends AnyVal {
    @hosted def tpe: meta.Type = ???
  }

  implicit class SemanticDefnClassOps(val tree: Defn.Class) extends AnyVal {
    @hosted def companion: Object = ???
  }

  implicit class SemanticDefnTraitOps(val tree: Defn.Trait) extends AnyVal {
    @hosted def companion: Object = ???
  }

  implicit class SemanticDefnObjectOps(val tree: Defn.Object) extends AnyVal {
    @hosted def companion: Member.Template = ???
  }

  implicit class SemanticPkgObjectOps(val tree: Defn.Object) extends AnyVal {
    @hosted def companion: Member.Template = ???
  }

  implicit class SemanticCtorOps(val tree: Ctor) extends AnyVal {
    @hosted def tpe: meta.Type = ???
  }

  implicit class SemanticParentOps(val tree: Param) extends AnyVal {
    @hosted def ctor: Ctor = ???
  }

  implicit class SemanticSelfOps(val tree: Aux.Self) extends AnyVal {
    def ref: Term.This = ???
    @hosted def tpe: Type = ???
  }

  implicit class SemanticParamOps(val tree: Param) extends AnyVal {
    @hosted def tpe: Type.Arg = ???
  }

  implicit class SemanticTemplateOps(val tree: Aux.Template) extends AnyVal {
    @hosted def tpe: Type = ???
  }

  implicit class SemanticTreeOps(val tree: Tree) extends AnyVal {
    @hosted def owner: Scope = ???
  }

  implicit class SemanticScopeOps(val tree: Scope) extends AnyVal {
    @hosted def members: Seq[Member] = ???
    @hosted def members(name: Name): Seq[Member] = ???
  }

  implicit class SemanticTopLevelScopeOps(val tree: Scope.TopLevel) extends AnyVal {
    @hosted def packages: Seq[Pkg] = ???
    @hosted def packages(name: Name): Pkg = ???
    @hosted def packages(name: String): Pkg = ???
    @hosted def packages(name: scala.Symbol): Pkg = ???
    @hosted def pkgobject: Defn.Object = ???
  }

  implicit class SemanticTemplateScopeOps(val tree: Scope.Template) extends AnyVal {
    @hosted def parents: Seq[Member.Template] = ???
    @hosted def children: Seq[Member.Template] = ???
    @hosted def self: Aux.Self = ???
    @hosted def ctor: Ctor.Primary = ???
    @hosted def ctors: Seq[Ctor] = ???
  }

  implicit class SemanticBlockScopeOps(val tree: Scope.Block) extends AnyVal {
    @hosted def classes: Seq[Defn.Class] = ???
    @hosted def classes(name: Name): Defn.Class = ???<commit_msg>some simplification of semantic API<commit_after>package scala.meta

import org.scalameta.adt._
import org.scalameta.annotations._
import scala.{Seq => _}
import scala.annotation.compileTimeOnly
import scala.collection.immutable.Seq
import scala.reflect.{ClassTag, classTag}

package object semantic {
  @root trait Mark
  def mark(): Mark = ???

  @root trait Attr
  object Attr {
    // TODO: design the attr hierarchy of semantic facts that can be figured out about trees
    // TODO: examples: a type a tree, a definition/definitions the tree refers to, maybe a desugaring, etc
    // TODO: see https://github.com/JetBrains/intellij-scala/blob/master/src/org/jetbrains/plugins/scala/lang/resolve/ScalaResolveResult.scala#L24
  }

  implicit class SemanticTreeOps(val tree: Tree) extends AnyVal {
    @hosted def attrs: Seq[Attr] = delegate
    @hosted def owner: Scope = ???
  }

  sealed trait Typeable[+T, U]
  object Typeable {
    object Term extends Typeable[Term, Type]
    object MemberDef extends Typeable[Member.Def, Type]
    object DeclVal extends Typeable[Decl.Val, Type]
    object DeclVar extends Typeable[Decl.Var, Type]
    object DefnVal extends Typeable[Defn.Val, Type]
    object DefnVar extends Typeable[Defn.Var, Type]
    object Ctor extends Typeable[Ctor, Type]
    object Self extends Typeable[Aux.Self, Type]
    object Param extends Typeable[Param, Type.Arg]
    object Template extends Typeable[Aux.Template, Type]
  }

  implicit class SemanticTypeableOps[T <: Tree, U <: Tree](val tree: T)(implicit ev: Typeable[T, U]) {
    @hosted def tpe: U = ???
  }

  sealed trait Resolvable[+T, U]
  object Resolvable {
    object Ref extends Resolvable[Ref, Member]
    object TermRef extends Resolvable[Term.Ref, Member.Term]
    object TypeRef extends Resolvable[Type.Ref, Member] // Type.Ref can refer to both types (regular types) and terms (singleton types)
  }

  implicit class SemanticResolvableOps[T <: Tree, U <: Tree](val tree: T)(implicit ev: Resolvable[T, U]) {
    @hosted def defns: Seq[U] = ???
    @hosted def defn: U = ???
  }

  implicit class SemanticParentOps(val tree: Aux.Parent) extends AnyVal {
    @hosted def ctor: Ctor = ???
  }

  implicit class SemanticTermOps(val tree: Term) extends AnyVal {
  }

  implicit class SemanticTypeOps(val tree: Type) extends AnyVal {
    @hosted def <:<(other: Type): Boolean = delegate
    @hosted def weak_<:<(other: Type): Boolean = ???
    @hosted def widen: Type = ???
    @hosted def dealias: Type = ???
    @hosted def erasure: Type = delegate
    @hosted def companion: Type.Ref = ???
  }

  @hosted def lub(tpes: Seq[Type]): Type = delegate
  @hosted def glb(tpes: Seq[Type]): Type = delegate

  implicit class SemanticMemberOps(val tree: Member) extends AnyVal {
    def ref: Ref = ???
    @hosted def parents: Seq[Member] = ???
    @hosted def children: Seq[Member] = ???
    def annots: Seq[Mod.Annot] = tree.mods.collect{ case annot: Mod.Annot => annot }
    def isVal: Boolean = ???
    def isVar: Boolean = ???
    def isDef: Boolean = ???
    def isMacro: Boolean = ???
    def isAbstractType: Boolean = ???
    def isAliasType: Boolean = ???
    def isClass: Boolean = ???
    def isTrait: Boolean = ???
    def isObject: Boolean = ???
    def isPkg: Boolean = ???
    def isPkgObject: Boolean = ???
    def isPrivate: Boolean = ???
    def isProtected: Boolean = ???
    def isPublic: Boolean = ???
    @hosted def accessBoundary: Member = ???
    def isImplicit: Boolean = ???
    def isFinal: Boolean = ???
    def isSealed: Boolean = ???
    @hosted def isOverride: Boolean = ???
    def isCase: Boolean = ???
    def isAbstract: Boolean = ???
    def isCovariant: Boolean = ???
    def isContravariant: Boolean = ???
    def isLazy: Boolean = ???
    def isAbstractOverride: Boolean = ???
    def isByNameParam: Boolean = ???
    def isVarargParam: Boolean = ???
    def isValParam: Boolean = ???
    def isVarParam: Boolean = ???
  }

  implicit class SemanticTermMemberOps(val tree: Member.Term) extends AnyVal {
    def ref: Term.Ref = ???
    @hosted def parents: Seq[Member.Term] = ???
    @hosted def children: Seq[Member.Term] = ???
  }

  implicit class SemanticTypeMemberOps(val tree: Member.Type) extends AnyVal {
    def ref: Type.Ref = ???
    @hosted def parents: Seq[Member.Type] = ???
    @hosted def children: Seq[Member.Type] = ???
  }

  implicit class SemanticTemplateMemberOps(val tree: Member.Template) extends AnyVal {
    @hosted def parents: Seq[Member.Template] = ???
    @hosted def children: Seq[Member.Template] = ???
    @hosted def self: Aux.Self = ???
    @hosted def companion: Member.Template = ???
  }

  implicit class SemanticDefnClassOps(val tree: Defn.Class) extends AnyVal {
    @hosted def companion: Object = ???
  }

  implicit class SemanticDefnTraitOps(val tree: Defn.Trait) extends AnyVal {
    @hosted def companion: Object = ???
  }

  implicit class SemanticDefnObjectOps(val tree: Defn.Object) extends AnyVal {
    @hosted def companion: Member.Template = ???
  }

  implicit class SemanticScopeOps(val tree: Scope) extends AnyVal {
    @hosted def members: Seq[Member] = ???
    @hosted def members(name: Name): Seq[Member] = ???
  }

  implicit class SemanticTopLevelScopeOps(val tree: Scope.TopLevel) extends AnyVal {
    @hosted def packages: Seq[Pkg] = ???
    @hosted def packages(name: Name): Pkg = ???
    @hosted def packages(name: String): Pkg = ???
    @hosted def packages(name: scala.Symbol): Pkg = ???
    @hosted def pkgobject: Defn.Object = ???
  }

  implicit class SemanticTemplateScopeOps(val tree: Scope.Template) extends AnyVal {
    @hosted def parents: Seq[Member.Template] = ???
    @hosted def children: Seq[Member.Template] = ???
    @hosted def self: Aux.Self = ???
    @hosted def ctor: Ctor.Primary = ???
    @hosted def ctors: Seq[Ctor] = ???
  }

  implicit class SemanticBlockScopeOps(val tree: Scope.Block) extends AnyVal {
    @hosted def classes: Seq[Defn.Class] = ???
    @hosted def classes(name: Name): Defn.Class = ???
{'fraction_non_alphanumeric': 0.12542319502401386, 'fraction_numerical': 0.0003149358318242658, 'mean_word_length': 3.526728439059159, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '4916794', 'n_tokens_mistral': 4260, 'n_tokens_neox': 4223, 'n_words': 1195}