<commit_before>'use babel'

/* @flow */

import invariant from 'assert'
import {CompositeDisposable, Disposable} from 'atom'
import {Editor} from './editor'
import {getElement as getGutterElement} from './elements/gutter'
import {getEditorsMap, getMessageClass} from './helpers'
import type {TextBuffer, TextEditor, TextEditorMarker} from 'atom'
import type {Linter$Message, Linter$Difference, Buffer$Difference} from './types'

type Buffer = {
  markers: Map<Linter$Message, TextEditorMarker>,
  textBuffer: TextBuffer,
  subscriptions: CompositeDisposable
}

export class Editors {
  buffers: Set<Buffer>;
  messages: Array<Linter$Message>;
  textEditors: Map<TextEditor, Editor>;
  subscriptions: CompositeDisposable;
  highlightIssues: boolean;

  constructor() {
    this.buffers = new Set()
    this.messages = []
    this.textEditors = new Map()
    this.subscriptions = new CompositeDisposable()
    this.highlightIssues = atom.config.get('linter-ui-default.highlightIssues')
  }
  activate() {
    // TODO: Support textBuffer.onDidChangePath
    this.subscriptions.add(atom.workspace.observeTextEditors(textEditor => {
      const textBuffer = textEditor.getBuffer()
      const subscriptions = new CompositeDisposable()
      const editor = new Editor(textEditor)
      const buffer = this.getBuffer(textBuffer)
      subscriptions.add(editor.onDidDestroy(() => {
        buffer.subscriptions.remove(subscriptions)
        this.textEditors.delete(textEditor)<commit_msg>:fire: Remove an unnecessary todo<commit_after>'use babel'

/* @flow */

import invariant from 'assert'
import {CompositeDisposable, Disposable} from 'atom'
import {Editor} from './editor'
import {getElement as getGutterElement} from './elements/gutter'
import {getEditorsMap, getMessageClass} from './helpers'
import type {TextBuffer, TextEditor, TextEditorMarker} from 'atom'
import type {Linter$Message, Linter$Difference, Buffer$Difference} from './types'

type Buffer = {
  markers: Map<Linter$Message, TextEditorMarker>,
  textBuffer: TextBuffer,
  subscriptions: CompositeDisposable
}

export class Editors {
  buffers: Set<Buffer>;
  messages: Array<Linter$Message>;
  textEditors: Map<TextEditor, Editor>;
  subscriptions: CompositeDisposable;
  highlightIssues: boolean;

  constructor() {
    this.buffers = new Set()
    this.messages = []
    this.textEditors = new Map()
    this.subscriptions = new CompositeDisposable()
    this.highlightIssues = atom.config.get('linter-ui-default.highlightIssues')
  }
  activate() {
    this.subscriptions.add(atom.workspace.observeTextEditors(textEditor => {
      const textBuffer = textEditor.getBuffer()
      const subscriptions = new CompositeDisposable()
      const editor = new Editor(textEditor)
      const buffer = this.getBuffer(textBuffer)
      subscriptions.add(editor.onDidDestroy(() => {
        buffer.subscriptions.remove(subscriptions)
        this.textEditors.delete(textEditor)
{'fraction_non_alphanumeric': 0.11050477489768076, 'fraction_numerical': 0.0, 'mean_word_length': 4.728515625, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '4960143', 'n_tokens_mistral': 865, 'n_tokens_neox': 849, 'n_words': 198}