<commit_before>{TextEditor, Emitter, CompositeDisposable} = require('atom')

class EditorLinter
  constructor: (@editor) ->
    throw new Error("Given editor isn't really an editor") unless @editor instanceof TextEditor
    @status = true # Overall linting status
    @emitter = new Emitter
    @subscriptions = new CompositeDisposable
    @subscriptions.add @editor.onDidDestroy =>
      @emitter.emit 'did-destroy'

    @subscriptions.add @editor.onDidSave => @emitter.emit('should-lint', false)
    # The onDidStopChanging callbacks are invoked immediately, and we want to avoid it
    setImmediate =>
      @subscriptions.add @editor.onDidStopChanging => setImmediate => @emitter.emit('should-lint', true)
      cursorImmediate = null
      @subscriptions.add @editor.onDidChangeCursorPosition ({oldBufferPosition, newBufferPosition}) =>
        if newBufferPosition.row isnt oldBufferPosition.row
          clearImmediate(cursorImmediate)
          cursorImmediate = setImmediate => @emitter.emit('should-update-line-messages')
        @emitter.emit('should-update-bubble')

  onShouldUpdateBubble: (callback) ->
    return @emitter.on('should-update-bubble', callback)

  onShouldUpdateLineMessages: (callback) ->
    return @emitter.on('should-update-line-messages', callback)

  onShouldLint: (callback) ->
    return @emitter.on('should-lint', callback)

  onDidDestroy: (callback) ->
    return @emitter.on('did-destroy', callback)

  deactivate: ->
    @emitter.dispose()
    @subscriptions.dispose()

module.exports = EditorLinter<commit_msg>:new: Add EditorLinter::lint<commit_after>{TextEditor, Emitter, CompositeDisposable} = require('atom')

class EditorLinter
  constructor: (@editor) ->
    throw new Error("Given editor isn't really an editor") unless @editor instanceof TextEditor
    @status = true # Overall linting status
    @emitter = new Emitter
    @subscriptions = new CompositeDisposable
    @subscriptions.add @editor.onDidDestroy =>
      @emitter.emit 'did-destroy'

    @subscriptions.add @editor.onDidSave => @emitter.emit('should-lint', false)
    # The onDidStopChanging callbacks are invoked immediately, and we want to avoid it
    setImmediate =>
      @subscriptions.add @editor.onDidStopChanging => setImmediate => @emitter.emit('should-lint', true)
      cursorImmediate = null
      @subscriptions.add @editor.onDidChangeCursorPosition ({oldBufferPosition, newBufferPosition}) =>
        if newBufferPosition.row isnt oldBufferPosition.row
          clearImmediate(cursorImmediate)
          cursorImmediate = setImmediate => @emitter.emit('should-update-line-messages')
        @emitter.emit('should-update-bubble')

  lint: ->
    # Only for legacy external or maybe internal APIs
    @emitter.emit('should-lint')

  onShouldUpdateBubble: (callback) ->
    return @emitter.on('should-update-bubble', callback)

  onShouldUpdateLineMessages: (callback) ->
    return @emitter.on('should-update-line-messages', callback)

  onShouldLint: (callback) ->
    return @emitter.on('should-lint', callback)

  onDidDestroy: (callback) ->
    return @emitter.on('did-destroy', callback)

  deactivate: ->
    @emitter.dispose()
    @subscriptions.dispose()

module.exports = EditorLinter
{'fraction_non_alphanumeric': 0.11638733705772812, 'fraction_numerical': 0.0, 'mean_word_length': 4.173354735152488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '84804', 'n_tokens_mistral': 947, 'n_tokens_neox': 896, 'n_words': 205}