<commit_before>package org.jetbrains.plugins.scala
package console

import com.intellij.openapi.actionSystem.{PlatformDataKeys, AnActionEvent, AnAction}
import com.intellij.openapi.util.TextRange
import java.io.{IOException, OutputStream}
import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.diagnostic.Logger

/**
 * @author Ksenia.Sautina
 * @since 9/18/12
 */
class ScalaConsoleExecuteAction extends AnAction {
  override def update(e: AnActionEvent) {
    val editor = e.getData(PlatformDataKeys.EDITOR)
    if (!editor.isInstanceOf[EditorEx]) {
      e.getPresentation.setEnabled(false)
      return
    }
    val console = ScalaConsoleInfo.getConsole(editor)
    if (console == null)  {
      e.getPresentation.setEnabled(false)
      return
    }
    val isEnabled: Boolean = !editor.asInstanceOf[EditorEx].isRendererMode &&
      !ScalaConsoleInfo.getProcessHandler(editor).isProcessTerminated

    e.getPresentation.setEnabled(isEnabled)
  }

  def actionPerformed(e: AnActionEvent) {
    val editor = e.getData(PlatformDataKeys.EDITOR)
    if (editor == null) {
      return
    }
    val console = ScalaConsoleInfo.getConsole(editor)
    val processHandler = ScalaConsoleInfo.getProcessHandler(editor)
    val model = ScalaConsoleInfo.getModel(editor)
    if (editor != null && console != null && processHandler != null && model != null) {
      val document = console.getEditorDocument
      val text = document.getText

      // Process input and add to history
      extensions.inWriteAction {<commit_msg>EA-40274<commit_after>package org.jetbrains.plugins.scala
package console

import com.intellij.openapi.actionSystem.{PlatformDataKeys, AnActionEvent, AnAction}
import com.intellij.openapi.util.TextRange
import java.io.{IOException, OutputStream}
import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.diagnostic.Logger

/**
 * @author Ksenia.Sautina
 * @since 9/18/12
 */
class ScalaConsoleExecuteAction extends AnAction {
  override def update(e: AnActionEvent) {
    val editor = e.getData(PlatformDataKeys.EDITOR)
    if (editor == null || !editor.isInstanceOf[EditorEx]) {
      e.getPresentation.setEnabled(false)
      return
    }
    val console = ScalaConsoleInfo.getConsole(editor)
    if (console == null)  {
      e.getPresentation.setEnabled(false)
      return
    }
    val isEnabled: Boolean = !editor.asInstanceOf[EditorEx].isRendererMode &&
      !ScalaConsoleInfo.getProcessHandler(editor).isProcessTerminated

    e.getPresentation.setEnabled(isEnabled)
  }

  def actionPerformed(e: AnActionEvent) {
    val editor = e.getData(PlatformDataKeys.EDITOR)
    if (editor == null) {
      return
    }
    val console = ScalaConsoleInfo.getConsole(editor)
    val processHandler = ScalaConsoleInfo.getProcessHandler(editor)
    val model = ScalaConsoleInfo.getModel(editor)
    if (editor != null && console != null && processHandler != null && model != null) {
      val document = console.getEditorDocument
      val text = document.getText

      // Process input and add to history
      extensions.inWriteAction {
{'fraction_non_alphanumeric': 0.09919224555735057, 'fraction_numerical': 0.004846526655896607, 'mean_word_length': 3.914285714285714, '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': '4628611', 'n_tokens_mistral': 936, 'n_tokens_neox': 920, 'n_words': 184}