<commit_before>package org.jetbrains.plugins.scala
package debugger.evaluation

import com.intellij.codeInsight.PsiEquivalenceUtil
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator
import com.intellij.debugger.impl.{DebuggerManagerAdapter, DebuggerSession}
import com.intellij.debugger.{DebuggerManagerEx, SourcePosition}
import com.intellij.openapi.components.AbstractProjectComponent
import com.intellij.openapi.project.Project
import com.intellij.psi.{PsiElement, PsiFile}

import scala.collection.mutable

/**
 * Nikolay.Tropin
 * 2014-06-03
 */
class ScalaEvaluatorCache(project: Project) extends AbstractProjectComponent(project) {

  private val cachedEvaluators = mutable.HashMap[(PsiFile, Int), mutable.HashMap[PsiElement, ExpressionEvaluator]]()
  private val cachedStamp = mutable.HashMap[PsiFile, Long]()

  override def projectOpened() = {
    DebuggerManagerEx.getInstanceEx(project).addDebuggerManagerListener(
      new DebuggerManagerAdapter {
        override def sessionDetached(session: DebuggerSession) = clear()
      }
    )
  }

  def clear() {
    cachedEvaluators.values.foreach(_.clear())
    cachedEvaluators.clear()<commit_msg>don't store PsiFiles in ScalaEvaluatorCache after debugger session ends<commit_after>package org.jetbrains.plugins.scala
package debugger.evaluation

import com.intellij.codeInsight.PsiEquivalenceUtil
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator
import com.intellij.debugger.impl.{DebuggerManagerAdapter, DebuggerSession}
import com.intellij.debugger.{DebuggerManagerEx, SourcePosition}
import com.intellij.openapi.components.AbstractProjectComponent
import com.intellij.openapi.project.Project
import com.intellij.psi.{PsiElement, PsiFile}

import scala.collection.mutable

/**
 * Nikolay.Tropin
 * 2014-06-03
 */
class ScalaEvaluatorCache(project: Project) extends AbstractProjectComponent(project) {

  private val cachedEvaluators = mutable.HashMap[(PsiFile, Int), mutable.HashMap[PsiElement, ExpressionEvaluator]]()
  private val cachedStamp = mutable.HashMap[PsiFile, Long]()

  override def projectOpened() = {
    DebuggerManagerEx.getInstanceEx(project).addDebuggerManagerListener(
      new DebuggerManagerAdapter {
        override def sessionDetached(session: DebuggerSession) = clear()
      }
    )
  }

  def clear() {
    cachedEvaluators.values.foreach(_.clear())
    cachedEvaluators.clear()
    cachedStamp.clear()
{'fraction_non_alphanumeric': 0.0946938775510204, 'fraction_numerical': 0.006530612244897959, 'mean_word_length': 5.7894736842105265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1466698', 'n_tokens_mistral': 741, 'n_tokens_neox': 731, 'n_words': 122}