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

package scala.tools.nsc

import scala.reflect.internal.util.{ SourceFile, NoSourceFile, FreshNameCreator }
import scala.collection.mutable
import scala.collection.mutable.{ LinkedHashSet, ListBuffer }

trait CompilationUnits { global: Global =>

  /** An object representing a missing compilation unit.
   */
  object NoCompilationUnit extends CompilationUnit(NoSourceFile) {
    override lazy val isJava = false
    override def exists = false
    override def toString() = "NoCompilationUnit"
  }

  /** Creates a `FreshNameCreator` that reports an error if it is used during the typer phase */
  final def warningFreshNameCreator: FreshNameCreator = new FreshNameCreator {
    override def newName(prefix: String): String = {
      if (global.phase == currentRun.typerPhase) {
        Thread.dumpStack()
        reporter.error(lastSeenContext.owner.pos, "Typer phase should not use the compilation unit scoped fresh name creator")
      }
      super.newName(prefix)
    }
  }

  /** One unit of compilation that has been submitted to the compiler.
    * It typically corresponds to a single file of source code.  It includes
    * error-reporting hooks.  */
  class CompilationUnit(val source: SourceFile, freshNameCreator: FreshNameCreator) extends CompilationUnitContextApi { self =>
    def this(source: SourceFile) = this(source, new FreshNameCreator)
    /** the fresh name creator */
    implicit val fresh: FreshNameCreator = freshNameCreator
    def freshTermName(prefix: String = nme.FRESH_TERM_NAME_PREFIX) = global.freshTermName(prefix)
    def freshTypeName(prefix: String)                              = global.freshTypeName(prefix)

    /** the content of the compilation unit in tree form */
    var body: Tree = EmptyTree

    /** The position of the first xml literal encountered while parsing this compilation unit.
     * NoPosition if there were none. Write-once.
     */
    private[this] var _firstXmlPos: Position = NoPosition

    /** Record that we encountered XML. Should only be called once. */
    protected[nsc] def encounteredXml(pos: Position) = _firstXmlPos = pos

    /** Does this unit contain XML? */
    def hasXml = _firstXmlPos ne NoPosition

    /** Position of first XML literal in this unit. */
    def firstXmlPos = _firstXmlPos<commit_msg>Tone error down to a dev warning<commit_after>/* NSC -- new Scala compiler
 * Copyright 2005-2013 LAMP/EPFL
 * @author  <NAME>
 */

package scala.tools.nsc

import scala.reflect.internal.util.{ SourceFile, NoSourceFile, FreshNameCreator }
import scala.collection.mutable
import scala.collection.mutable.{ LinkedHashSet, ListBuffer }

trait CompilationUnits { global: Global =>

  /** An object representing a missing compilation unit.
   */
  object NoCompilationUnit extends CompilationUnit(NoSourceFile) {
    override lazy val isJava = false
    override def exists = false
    override def toString() = "NoCompilationUnit"
  }

  /** Creates a `FreshNameCreator` that reports an error if it is used during the typer phase */
  final def warningFreshNameCreator: FreshNameCreator = new FreshNameCreator {
    override def newName(prefix: String): String = {
      if (global.phase == currentRun.typerPhase) {
        devWarningDumpStack("Typer phase should not use the compilation unit scoped fresh name creator", 32)
      }
      super.newName(prefix)
    }
  }

  /** One unit of compilation that has been submitted to the compiler.
    * It typically corresponds to a single file of source code.  It includes
    * error-reporting hooks.  */
  class CompilationUnit(val source: SourceFile, freshNameCreator: FreshNameCreator) extends CompilationUnitContextApi { self =>
    def this(source: SourceFile) = this(source, new FreshNameCreator)
    /** the fresh name creator */
    implicit val fresh: FreshNameCreator = freshNameCreator
    def freshTermName(prefix: String = nme.FRESH_TERM_NAME_PREFIX) = global.freshTermName(prefix)
    def freshTypeName(prefix: String)                              = global.freshTypeName(prefix)

    /** the content of the compilation unit in tree form */
    var body: Tree = EmptyTree

    /** The position of the first xml literal encountered while parsing this compilation unit.
     * NoPosition if there were none. Write-once.
     */
    private[this] var _firstXmlPos: Position = NoPosition

    /** Record that we encountered XML. Should only be called once. */
    protected[nsc] def encounteredXml(pos: Position) = _firstXmlPos = pos

    /** Does this unit contain XML? */
    def hasXml = _firstXmlPos ne NoPosition

    /** Position of first XML literal in this unit. */
    def firstXmlPos = _firstXmlPos
{'fraction_non_alphanumeric': 0.08003369839932603, 'fraction_numerical': 0.0037910699241786015, 'mean_word_length': 3.454971857410882, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6955101', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1273, 'n_words': 458}