<commit_before>'use babel'

/* @flow */

import {CompositeDisposable, Emitter} from 'atom'
import type {Disposable} from 'atom'

export class Projects {
  paths: Set<string>;
  emitter: Emitter;
  subscriptions: CompositeDisposable;

  constructor() {
    this.paths = new Set()
    this.emitter = new Emitter()
    this.subscriptions = new CompositeDisposable()

    this.subscriptions.add(this.emitter)
  }
  activate() {
    this.subscriptions.add(atom.project.onDidChangePaths(() => this.detectChanges()))
    this.detectChanges()
  }
  detectChanges() {
    const paths = new Set(atom.project.getPaths())
    for (const path of paths) {
      if (!this.paths.has(path)) {
        this.paths.add(path)
        this.emitter.emit('did-add-path', path)
      }
    }
    for (const path of this.paths) {
      if (!paths.has(path)) {
        this.paths.delete(path)
        this.emitter.emit('did-remove-path', path)
      }
    }
  }
  getPaths(): Set<string> {
    return this.paths
  }
  onDidAddPath(callback: ((path: string) => void)): Disposable {
    return this.emitter.on('did-add-path', callback)
  }
  onDidRemovePath(callback: ((path: string) => void)): Disposable {
    return this.emitter.on('did-remove-path', callback)
  }
  dispose() {
    this.subscriptions.dispose()
  }
}
<commit_msg>:shirt: Properly clear paths on dispose in projects<commit_after>'use babel'

/* @flow */

import {CompositeDisposable, Emitter} from 'atom'
import type {Disposable} from 'atom'

export class Projects {
  paths: Set<string>;
  emitter: Emitter;
  subscriptions: CompositeDisposable;

  constructor() {
    this.paths = new Set()
    this.emitter = new Emitter()
    this.subscriptions = new CompositeDisposable()

    this.subscriptions.add(this.emitter)
  }
  activate() {
    this.subscriptions.add(atom.project.onDidChangePaths(() => this.detectChanges()))
    this.detectChanges()
  }
  detectChanges() {
    const paths = new Set(atom.project.getPaths())
    for (const path of paths) {
      if (!this.paths.has(path)) {
        this.paths.add(path)
        this.emitter.emit('did-add-path', path)
      }
    }
    for (const path of this.paths) {
      if (!paths.has(path)) {
        this.paths.delete(path)
        this.emitter.emit('did-remove-path', path)
      }
    }
  }
  getPaths(): Set<string> {
    return this.paths
  }
  onDidAddPath(callback: ((path: string) => void)): Disposable {
    return this.emitter.on('did-add-path', callback)
  }
  onDidRemovePath(callback: ((path: string) => void)): Disposable {
    return this.emitter.on('did-remove-path', callback)
  }
  dispose() {
    this.paths.clear()
    this.subscriptions.dispose()
  }
}

{'fraction_non_alphanumeric': 0.1482590789966305, 'fraction_numerical': 0.0, 'mean_word_length': 3.142635658914729, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '5062759', 'n_tokens_mistral': 904, 'n_tokens_neox': 864, 'n_words': 176}