<commit_before>/* NSC -- new Scala compiler
 * Copyright 2005-2006 LAMP/EPFL
 * @author <NAME>
 */
// $Id$

package scala.tools.nsc.transform

import scala.collection.mutable.{Map, HashMap}

/** A base class for transforms.
 *  A transform contains a compiler phase which applies a tree transformer.
 */
trait TypingTransformers {

  val global: Global
  import global._

  abstract class TypingTransformer(unit: CompilationUnit) extends Transformer {
    var localTyper: analyzer.Typer = analyzer.newTyper(
      analyzer.rootContext(unit, EmptyTree, true))
    private var curTree: Tree = _

    var typers: Map[Symbol, analyzer.Typer] = new HashMap

    override def atOwner[A](owner: Symbol)(trans: => A): A = atOwner(curTree, owner)(trans)

    def atOwner[A](tree: Tree, owner: Symbol)(trans: => A): A = {
      val savedLocalTyper = localTyper
      localTyper = localTyper.atOwner(tree, owner)
      typers += owner -> localTyper;
      val result = super.atOwner(owner)(trans)
      localTyper = savedLocalTyper
      typers.excl(owner);
      result
    }

    override def transform(tree: Tree): Tree = {
      curTree = tree
      tree match {
        case Template(_, _) =>
          // enter template into context chain
          atOwner(currentOwner) { super.transform(tree) }
        case _ =>
          super.transform(tree)
      }
    }
  }
}
<commit_msg>Added comment.<commit_after>/* NSC -- new Scala compiler
 * Copyright 2005-2006 LAMP/EPFL
 * @author <NAME>
 */
// $Id$

package scala.tools.nsc.transform

import scala.collection.mutable.{Map, HashMap}

/** A base class for transforms.
 *  A transform contains a compiler phase which applies a tree transformer.
 */
trait TypingTransformers {

  val global: Global
  import global._

  abstract class TypingTransformer(unit: CompilationUnit) extends Transformer {
    var localTyper: analyzer.Typer = analyzer.newTyper(
      analyzer.rootContext(unit, EmptyTree, true))
    private var curTree: Tree = _

    /** a typer for each enclosing class */
    var typers: Map[Symbol, analyzer.Typer] = new HashMap

    override def atOwner[A](owner: Symbol)(trans: => A): A = atOwner(curTree, owner)(trans)

    def atOwner[A](tree: Tree, owner: Symbol)(trans: => A): A = {
      val savedLocalTyper = localTyper
      localTyper = localTyper.atOwner(tree, owner)
      typers += owner -> localTyper;
      val result = super.atOwner(owner)(trans)
      localTyper = savedLocalTyper
      typers.excl(owner);
      result
    }

    override def transform(tree: Tree): Tree = {
      curTree = tree
      tree match {
        case Template(_, _) =>
          // enter template into context chain
          atOwner(currentOwner) { super.transform(tree) }
        case _ =>
          super.transform(tree)
      }
    }
  }
}

{'fraction_non_alphanumeric': 0.10884353741496598, 'fraction_numerical': 0.005728607232366631, 'mean_word_length': 2.8751733703190014, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '4554632', 'n_tokens_mistral': 867, 'n_tokens_neox': 831, 'n_words': 233}