<commit_before>package com.karateca.ddescriber.toolWindow;

import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileAdapter;
import com.intellij.openapi.vfs.VirtualFileEvent;
import com.intellij.openapi.vfs.VirtualFileManager;

import java.util.HashMap;
import java.util.Map;

/**
 * @author <NAME>.
 */
public class VirtualFileListener {

  private Map<VirtualFile, CallbackHolder> filesToListenFor = new HashMap<VirtualFile, CallbackHolder>();

  public VirtualFileListener() {
    VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
      @Override
      public void contentsChanged(VirtualFileEvent event) {
        System.out.println("contents changed " + event);
        VirtualFile virtualFile = event.getFile();
        if (filesToListenFor.containsKey(virtualFile)) {
          filesToListenFor.get(virtualFile).doCallback();
        }
      }
    });
  }

  public void registerForChangeEvent(JasmineFile jasmineFile, ChangeCallback callback) {
    CallbackHolder callbackHolder = new CallbackHolder(jasmineFile, callback);
    filesToListenFor.put(jasmineFile.getVirtualFile(), callbackHolder);
  }

  class CallbackHolder {
    final JasmineFile jasmineFile;
    final ChangeCallback callback;
<commit_msg>remove System.out.println<commit_after>package com.karateca.ddescriber.toolWindow;

import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileAdapter;
import com.intellij.openapi.vfs.VirtualFileEvent;
import com.intellij.openapi.vfs.VirtualFileManager;

import java.util.HashMap;
import java.util.Map;

/**
 * @author <NAME>.
 */
public class VirtualFileListener {

  private Map<VirtualFile, CallbackHolder> filesToListenFor = new HashMap<VirtualFile, CallbackHolder>();

  public VirtualFileListener() {
    VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
      @Override
      public void contentsChanged(VirtualFileEvent event) {
        VirtualFile virtualFile = event.getFile();
        if (filesToListenFor.containsKey(virtualFile)) {
          filesToListenFor.get(virtualFile).doCallback();
        }
      }
    });
  }

  public void registerForChangeEvent(JasmineFile jasmineFile, ChangeCallback callback) {
    CallbackHolder callbackHolder = new CallbackHolder(jasmineFile, callback);
    filesToListenFor.put(jasmineFile.getVirtualFile(), callbackHolder);
  }

  class CallbackHolder {
    final JasmineFile jasmineFile;
    final ChangeCallback callback;

{'fraction_non_alphanumeric': 0.09455701231624951, 'fraction_numerical': 0.0, 'mean_word_length': 4.709750566893424, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6719717', 'n_tokens_mistral': 730, 'n_tokens_neox': 707, 'n_words': 128}