<commit_before>path = require 'path'
_ = require 'underscore-plus'
{$$$, View} = require 'atom'
SettingsPanel = require './settings-panel'

# View to display the grammars that a package has registered.
module.exports =
class PackageGrammarsView extends View
  @content: ->
    @section class: 'package-grammars', =>
      @div outlet: 'grammarSettings'

  initialize: (packagePath) ->
    @packagePath = path.join(packagePath, path.sep)
    @addGrammars()
    @subscribe atom.grammars, 'grammar-added grammar-updated', => @addGrammars()

  getPackageGrammars: ->
    packageGrammars = []
    grammars = atom.grammars.grammars ? []
    for grammar in grammars when grammar.path
      packageGrammars.push(grammar) if grammar.path.indexOf(@packagePath) is 0
    packageGrammars.sort (grammar1, grammar2) ->
      name1 = grammar1.name ? grammar1.scopeName ? ''
      name2 = grammar2.name ? grammar2.scopeName ? ''
      name1.localeCompare(name2)
<commit_msg>Don't use events on atom.grammars<commit_after>path = require 'path'
_ = require 'underscore-plus'
{CompositeDisposable} = require 'atom'
{$$$, View} = require 'atom-space-pen-views'
SettingsPanel = require './settings-panel'

# View to display the grammars that a package has registered.
module.exports =
class PackageGrammarsView extends View
  @content: ->
    @section class: 'package-grammars', =>
      @div outlet: 'grammarSettings'

  initialize: (packagePath) ->
    @disposables = new CompositeDisposable()
    @packagePath = path.join(packagePath, path.sep)
    @addGrammars()

    @disposables.add atom.grammars.onDidAddGrammar => @addGrammars()
    @disposables.add atom.grammars.onDidUpdateGrammar => @addGrammars()

  beforeRemove: ->
    @disposables.dispose()

  getPackageGrammars: ->
    packageGrammars = []
    grammars = atom.grammars.grammars ? []
    for grammar in grammars when grammar.path
      packageGrammars.push(grammar) if grammar.path.indexOf(@packagePath) is 0
    packageGrammars.sort (grammar1, grammar2) ->
      name1 = grammar1.name ? grammar1.scopeName ? ''
      name2 = grammar2.name ? grammar2.scopeName ? ''
      name1.localeCompare(name2)

{'fraction_non_alphanumeric': 0.12126865671641791, 'fraction_numerical': 0.010261194029850746, 'mean_word_length': 3.9310344827586206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '6624103', 'n_tokens_mistral': 730, 'n_tokens_neox': 697, 'n_words': 151}