Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: alexander-yakushev/compliment
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b3ba3ffc46da447e560a69ee1409c7f7f56ec081
Choose a base ref
..
head repository: alexander-yakushev/compliment
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ea3f16158c8a6a5cfb6713f9110239e01cf04232
Choose a head ref
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/compliment/utils.clj
15 changes: 7 additions & 8 deletions src/compliment/utils.clj
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
(java.util.jar JarFile JarEntry)
java.util.function.Consumer))

;; Disable reflection warnings in this file because we must use reflection to
;; support both JDK8 and JDK9+.
(set! *warn-on-reflection* false)

(def ^:dynamic *extra-metadata*
"Signals to downstream sources which additional information about completion
candidates they should attach . Should be a set of keywords."
@@ -157,22 +161,17 @@
of-system (.getMethod mf-class "ofSystem" (into-array Class []))
mfinder (.invoke of-system nil (object-array 0))

findAll-method (.getMethod mf-class "findAll" (into-array Class []))
mrefs (.invoke findAll-method mfinder (into-array Class []))

mrefs (.findAll mfinder)
mref-class (Class/forName "java.lang.module.ModuleReference")
open-method (.getMethod mref-class "open" (into-array Class []))

mrdr-class (Class/forName "java.lang.module.ModuleReader")
list-method (.getMethod mrdr-class "list" (into-array Class []))

classes (volatile! (transient []))
consumer (reify Consumer (accept [_ v] (vswap! classes conj! v)))]
(doseq [mref mrefs
:let [mrdr (.invoke open-method mref (object-array 0))
^java.util.stream.Stream stream (.invoke list-method mrdr (into-array Class []))]]
^java.util.stream.Stream stream (.list mrdr)]]
(.forEach stream consumer)
(.close ^java.io.Closeable mrdr))
(.close mrdr))

(persistent! @classes)))