<commit_before>{BufferedProcess, Emitter} = require 'atom'
path                       = require 'path'

class Executor
  constructor: ->
    @resetFlags()

  startDebugger: ->
    debuggerPath = path.join(__dirname, "debugger.jar")
    command = "java"
    args = ["-jar", debuggerPath]
    stdout = (output) => @handleOutput(output)
    exit = (code) => @handleExit()
    @process = new BufferedProcess({command, args, stdout, exit})
    @emitter = new Emitter()

  handleExit: ->
    @emitStop()
    @resetFlags()

  handleOutput: (output) ->
    if (output.indexOf("!!!VIEWCHANNELREADY!!!") > -1)
      @viewChannelReady = true

    if (output.indexOf("!!!RUNTIMECHANNELREADY!!!") > -1)
      @runtimeChannelReady = true

    if (@viewChannelReady && @runtimeChannelReady)
      @emitReady()
      @resetFlags()

  stopDebugger: ->
    @process.kill()
    @emitStop()

  emitStop: ->
    @emitter.emit('execution-stopped')

  onStop: (callback) ->
    @emitter.on('execution-stopped', callback)

  emitReady: ->
    @emitter.emit('debugger-ready')

  onReady: (callback) ->
    @emitter.on('debugger-ready', callback)

  resetFlags: ->
    @runtimeChannelReady = false
    @viewChannelReady = false

module.exports =
class ExecutorProvider
  instance = null
  @getInstance: ->
    instance ?= new Executor()<commit_msg>Made some minor tweaks to the executor module<commit_after>{BufferedProcess, Emitter} = require 'atom'
path                       = require 'path'

class Executor
  constructor: ->
    @resetFlags()

  startDebugger: ->
    debuggerPath = path.join(__dirname, "debugger.jar")
    command = "java"
    args = ["-jar", debuggerPath]
    stdout = (output) => @handleOutput(output)
    exit = (code) => @handleExit(code)
    @process = new BufferedProcess({command, args, stdout, exit})
    @emitter = new Emitter()

  handleExit: (code) ->
    @emitStop()
    @resetFlags()

  handleOutput: (output) ->
    if (output.indexOf('!!!VIEWCHANNELREADY!!!') > -1)
      @viewChannelReady = true

    if (output.indexOf('!!!RUNTIMECHANNELREADY!!!') > -1)
      @runtimeChannelReady = true

    if (@viewChannelReady && @runtimeChannelReady)
      @emitReady()
      @resetFlags()

  stopDebugger: ->
    @process.kill()
    @emitStop()

  emitStop: ->
    @emitter.emit('execution-stopped')

  onStop: (callback) ->
    @emitter.on('execution-stopped', callback)

  emitReady: ->
    @emitter.emit('debugger-ready')

  onReady: (callback) ->
    @emitter.on('debugger-ready', callback)

  resetFlags: ->
    @runtimeChannelReady = false
    @viewChannelReady = false

module.exports =
class ExecutorProvider
  instance = null

  @getInstance: ->
    instance ?= new Executor()
{'fraction_non_alphanumeric': 0.15104166666666666, 'fraction_numerical': 0.001488095238095238, 'mean_word_length': 3.2147335423197494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '4199997', 'n_tokens_mistral': 865, 'n_tokens_neox': 824, 'n_words': 175}