<commit_before>path = require 'path'
_ = require 'underscore-plus'
{Point, CompositeDisposable} = require 'atom'
{
  saveEditorState
  isActiveEditor
  paneForItem
  getAdjacentPaneOrSplit
  getFirstCharacterPositionForBufferRow
} = require '../utils'
UI = require '../ui'
settings = require '../settings'
Input = null

module.exports =
class ProviderBase
  needRestoreEditorState: true
  boundToEditor: false
  includeHeaderGrammar: false

  indentTextForLineHeader: ""
  ignoreSideMovementOnSyncToEditor: true
  showLineHeader: false
  showColumnOnLineHeader: false
  updateGrammarOnQueryChange: true
  useHighlighter: false

  supportDirectEdit: false
  supportCacheItems: false
  editor: null

  # used by search, atom-scan, scan
  searchWholeWord: null
  searchIgnoreCase: null
  showSearchOption: false

  getName: ->
    @constructor.name

  getDashName: ->
    _.dasherize(@getName())

  getConfig: (name) ->
    settings.get("#{@getName()}.#{name}")

  initialize: ->
    # to override

  # Event is object contains {newEditor, oldEditor}
  onBindEditor: (event) ->
    # to override

  checkReady: ->
    Promise.resolve(true)

  bindEditor: (editor) ->
    @editorSubscriptions?.dispose()
    @editorSubscriptions = new CompositeDisposable
    event = {
      newEditor: editor
      oldEditor: @editor
    }
    @editor = editor
    @onBindEditor(event)

  getPane: ->
    # If editor was pending item, it will destroyed on next pending-item opened
    if pane = paneForItem(@editor) and pane?.isAlive()
      @lastPane = pane

    if @lastPane?.isAlive()
      @lastPane
    else
      null

  isActive: ->
    isActiveEditor(@editor)

  constructor: (editor, @options={}) ->
    @subscriptions = new CompositeDisposable
    @restoreEditorState = saveEditorState(editor)
    @bindEditor(editor)
    @ui = new UI(this, query: @options.query)

    @checkReady().then (ready) =>
      if ready
        @initialize()
        @ui.start()<commit_msg>pre-released-degradation fix<commit_after>path = require 'path'
_ = require 'underscore-plus'
{Point, CompositeDisposable} = require 'atom'
{
  saveEditorState
  isActiveEditor
  paneForItem
  getAdjacentPaneOrSplit
  getFirstCharacterPositionForBufferRow
} = require '../utils'
UI = require '../ui'
settings = require '../settings'
Input = null

module.exports =
class ProviderBase
  needRestoreEditorState: true
  boundToEditor: false
  includeHeaderGrammar: false

  indentTextForLineHeader: ""
  ignoreSideMovementOnSyncToEditor: true
  showLineHeader: false
  showColumnOnLineHeader: false
  updateGrammarOnQueryChange: true
  useHighlighter: false

  supportDirectEdit: false
  supportCacheItems: false
  editor: null

  # used by search, atom-scan, scan
  searchWholeWord: null
  searchIgnoreCase: null
  showSearchOption: false

  getName: ->
    @constructor.name

  getDashName: ->
    _.dasherize(@getName())

  getConfig: (name) ->
    settings.get("#{@getName()}.#{name}")

  initialize: ->
    # to override

  # Event is object contains {newEditor, oldEditor}
  onBindEditor: (event) ->
    # to override

  checkReady: ->
    Promise.resolve(true)

  bindEditor: (editor) ->
    @editorSubscriptions?.dispose()
    @editorSubscriptions = new CompositeDisposable
    event = {
      newEditor: editor
      oldEditor: @editor
    }
    @editor = editor
    @onBindEditor(event)

  getPane: ->
    # If editor was pending item, it will destroyed on next pending-item opened
    if (pane = paneForItem(@editor)) and pane?.isAlive()
      @lastPane = pane

    if @lastPane?.isAlive()
      @lastPane
    else
      null

  isActive: ->
    isActiveEditor(@editor)

  constructor: (editor, @options={}) ->
    @subscriptions = new CompositeDisposable
    @restoreEditorState = saveEditorState(editor)
    @bindEditor(editor)
    @ui = new UI(this, query: @options.query)

    @checkReady().then (ready) =>
      if ready
        @initialize()
        @ui.start()
{'fraction_non_alphanumeric': 0.10633426609005342, 'fraction_numerical': 0.0, 'mean_word_length': 3.4988558352402745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '502030', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1187, 'n_words': 288}