<commit_before>IncompatiblePackagesView = null

viewUri = 'atom://incompatible-packages'
createView = (state) ->
  IncompatiblePackagesView ?= require './incompatible-packages-view'
  new IncompatiblePackagesView(state)

atom.deserializers.add
  name: 'IncompatiblePackagesView'
  deserialize: (state) -> createView(state)

incompatiblePackagesStatusView = null
openerSubscription = null
workspaceSubscription = null

module.exports =
  activate: ->
    openerSubscription = atom.workspace.addOpener (filePath) ->
      createView(uri: viewUri) if filePath is viewUri

    workspaceSubscription = atom.commands.add 'atom-workspace',
      'incompatible-packages:view': ->
        atom.workspace.open(viewUri)

      'incompatible-packages:clear-cache': ->
        for key, data of global.localStorage
          if key.indexOf('installed-packages:') is 0
            global.localStorage.removeItem(key)

      'incompatible-packages:reload-atom-and-recheck-packages': ->
        workspaceView = atom.views.getView(atom.workspace)
        atom.commands.dispatch(workspaceView, 'incompatible-packages:clear-cache')
        atom.commands.dispatch(workspaceView, 'window:reload')

    if statusBar = document.querySelector('status-bar')
      createStatusBarView(statusBar)
    else
      atom.packages.onDidActivateAll ->
        statusBar = document.querySelector('status-bar')
        createStatusBarView(statusBar) if statusBar?

  deactivate: ->
    incompatiblePackagesStatusView?.destroy()
    incompatiblePackagesStatusView = null

    openerSubscription?.dispose()
    openerSubscription = null

    workspaceSubscription?.dispose()
    workspaceSubscription = null

createStatusBarView = (statusBar) ->
  incompatibleCount = 0
  for pack in atom.packages.getLoadedPackages()
    incompatibleCount++ unless pack.isCompatible()

  if incompatibleCount > -1
    IncompatiblePackagesStatusView = require './incompatible-packages-status-view'
    incompatiblePackagesStatusView ?= new IncompatiblePackagesStatusView(statusBar, incompatibleCount)<commit_msg>Only show status when at least one incompatible package<commit_after>IncompatiblePackagesView = null

viewUri = 'atom://incompatible-packages'
createView = (state) ->
  IncompatiblePackagesView ?= require './incompatible-packages-view'
  new IncompatiblePackagesView(state)

atom.deserializers.add
  name: 'IncompatiblePackagesView'
  deserialize: (state) -> createView(state)

incompatiblePackagesStatusView = null
openerSubscription = null
workspaceSubscription = null

module.exports =
  activate: ->
    openerSubscription = atom.workspace.addOpener (filePath) ->
      createView(uri: viewUri) if filePath is viewUri

    workspaceSubscription = atom.commands.add 'atom-workspace',
      'incompatible-packages:view': ->
        atom.workspace.open(viewUri)

      'incompatible-packages:clear-cache': ->
        for key, data of global.localStorage
          if key.indexOf('installed-packages:') is 0
            global.localStorage.removeItem(key)

      'incompatible-packages:reload-atom-and-recheck-packages': ->
        workspaceView = atom.views.getView(atom.workspace)
        atom.commands.dispatch(workspaceView, 'incompatible-packages:clear-cache')
        atom.commands.dispatch(workspaceView, 'window:reload')

    if statusBar = document.querySelector('status-bar')
      createStatusBarView(statusBar)
    else
      atom.packages.onDidActivateAll ->
        statusBar = document.querySelector('status-bar')
        createStatusBarView(statusBar) if statusBar?

  deactivate: ->
    incompatiblePackagesStatusView?.destroy()
    incompatiblePackagesStatusView = null

    openerSubscription?.dispose()
    openerSubscription = null

    workspaceSubscription?.dispose()
    workspaceSubscription = null

createStatusBarView = (statusBar) ->
  incompatibleCount = 0
  for pack in atom.packages.getLoadedPackages()
    incompatibleCount++ unless pack.isCompatible()

  if incompatibleCount > 0
    IncompatiblePackagesStatusView = require './incompatible-packages-status-view'
    incompatiblePackagesStatusView ?= new IncompatiblePackagesStatusView(statusBar, incompatibleCount)
{'fraction_non_alphanumeric': 0.09651022864019254, 'fraction_numerical': 0.001444043321299639, 'mean_word_length': 4.234256926952141, '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': '2919868', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1140, 'n_words': 205}