File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## master (unreleased)
4
4
5
+ ## New features
6
+
7
+ * ` orchard.java ` : add ` *analyze-sources* ` dynamic var.
8
+ * You can bind this to ` false ` in order to increase performance / decrease the amount of information returned.
9
+
5
10
## 0.19.0 (2023-11-04)
6
11
7
12
## New features
Original file line number Diff line number Diff line change 84
84
`add-cognitest)]}
85
85
86
86
; ; Development tools
87
- :dev {:plugins [[cider/cider-nrepl " 0.41.0 " ]
87
+ :dev {:plugins [[cider/cider-nrepl " 0.43.1 " ]
88
88
[refactor-nrepl " 3.9.0" ]]
89
89
:dependencies [[nrepl/nrepl " 1.0.0" ]
90
90
[org.clojure/tools.namespace " 1.4.4" ]]
Original file line number Diff line number Diff line change 312
312
; ; for dynamically loaded classes:
313
313
:reflector (JavaReflector. (.getClassLoader c))))
314
314
315
+ (def ^:dynamic *analyze-sources*
316
+ " Whether to analyze .java sources in addition to reflection-gathered info.
317
+
318
+ Bind this to `false` in order to increase performance / decrease the amount of information returned."
319
+ true )
320
+
315
321
(defn class-info*
316
322
" For the class symbol, return Java class and member info. Members are indexed
317
323
first by name, and then by argument types to list all overloads."
321
327
(catch LinkageError _))]
322
328
(let [package (some-> c package symbol)
323
329
{:keys [members] :as result} (misc/deep-merge (reflect-info (reflection-for c))
324
- (source-info class)
330
+ (when *analyze-sources*
331
+ (source-info class))
325
332
{:name (-> c .getSimpleName symbol)
326
333
:class (-> c .getName symbol)
327
334
:package package
378
385
info (if (and cached stale)
379
386
(class-info* class)
380
387
info)]
381
- (when (or (not cached) stale)
388
+ (when (and
389
+ ; ; Only cache full values that possibly were slowly computed.
390
+ ; ; It would be a mistake to cache the fast values, letting them shadow a full computation:
391
+ *analyze-sources*
392
+ (or (not cached) stale))
382
393
(.put cache class {:info info, :last-modified last-modified}))
383
394
info))
384
395
Original file line number Diff line number Diff line change 528
528
(is (not (string/includes? s " ^function.Function java.util.function.Function" )))
529
529
(is (not (string/includes? s " ^java.util.function.Function java.util.function.Function" )))
530
530
(assert (is (not (string/includes? s " java.lang" ))))))))))
531
+
532
+ (when (and util/has-enriched-classpath?
533
+ @@sut/parser-next-available?)
534
+ (deftest *analyze-sources*-test
535
+ (with-redefs [cache (LruMap. 100 )]
536
+ (binding [sut/*analyze-sources* false ]
537
+ (is (nil? (:doc (sut/resolve-symbol 'user `Thread/activeCount)))
538
+ " Binding this var to `false` results in source info being omitted" ))
539
+ (is (seq (:doc (sut/resolve-symbol 'user `Thread/activeCount)))
540
+ " Subsequent calls aren't affected, since there's no caching interference" ))))
You can’t perform that action at this time.
0 commit comments