<commit_before>(ns net.sekao.nightcode.projects
  (:require [clojure.java.io :as io])
  (:import [java.io File FilenameFilter]
           [javafx.scene.control TreeItem TreeCell]
           [javafx.collections FXCollections]))

(defn file-node [file]
  (let [path (.getCanonicalPath file)
        custom-file (proxy [File] [path]
                      (toString []
                        (.getName this)))]
    (proxy [TreeItem] [custom-file]
      (getChildren []
        (let [files (.listFiles file
                      (reify FilenameFilter
                        (accept [this dir filename]
                          (not (.startsWith filename ".")))))
              children (FXCollections/observableArrayList)]
          (run! #(.add children (file-node %)) files)
          children))
      (isLeaf []
        (not (.isDirectory file))))))

(defn root-node [state]
  (let [project-files (->> (:project-set state)
                           (map #(io/file %))
                           (sort-by #(.getName %)))]
    (proxy [TreeItem] []
      (getChildren []
        (let [children (FXCollections/observableArrayList)]
          (run! #(.add children (file-node %)) project-files)
          children))
      (isLeaf []
        false))))<commit_msg>Populate the project tree correctly<commit_after>(ns net.sekao.nightcode.projects
  (:require [clojure.java.io :as io])
  (:import [java.io File FilenameFilter]
           [javafx.scene.control TreeItem TreeCell]
           [javafx.collections FXCollections]))

(declare file-node)

(defn get-children [files]
  (let [children (FXCollections/observableArrayList)]
    (run! #(.add children (file-node %)) files)
    children))

(defn file-node [file]
  (let [path (.getCanonicalPath file)
        custom-file (proxy [File] [path]
                      (toString []
                        (.getName this)))
        children (->> (reify FilenameFilter
                        (accept [this dir filename]
                          (not (.startsWith filename "."))))
                      (.listFiles file)
                      get-children
                      delay)]
    (proxy [TreeItem] [custom-file]
      (getChildren []
        (if-not (realized? children)
          (doto (proxy-super getChildren)
            (.addAll @children))
          (proxy-super getChildren)))
      (isLeaf []
        (not (.isDirectory file))))))

(defn root-node [state]
  (let [project-files (->> (:project-set state)
                           (map #(io/file %))
                           (sort-by #(.getName %)))
        children (delay (get-children project-files))]
    (proxy [TreeItem] []
      (getChildren []
        (if-not (realized? children)
          (doto (proxy-super getChildren)
            (.addAll @children))
          (proxy-super getChildren)))
      (isLeaf []
        false))))
{'fraction_non_alphanumeric': 0.13728932584269662, 'fraction_numerical': 0.0, 'mean_word_length': 1.763336566440349, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2348232', 'n_tokens_mistral': 822, 'n_tokens_neox': 785, 'n_words': 191}