-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove laziness in Slamhound's "get-available-classes" #184
Conversation
Once the classpath gets big enough, this would cause a stack overflow, which from clj-refactor simply shows up as a timeout. Instead use transducers over lists as much as possible. Since the collection of available classes is only ever traversed sequentially, this provides the best performance as well.
(catch Exception e [])))) ; fail gracefully if jar is unreadable | ||
|
||
(defmethod path-class-files :dir | ||
;; Dispatch directories and files (excluding jars) recursively. | ||
[#^File d #^File loc] | ||
(let [fs (.listFiles d (proxy [FilenameFilter] [] | ||
(accept [d n] (not (jar? (file n))))))] | ||
(reduce concat (for [f fs] (path-class-files f loc))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line was actually asking for trouble..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup.
Tests are all green, including with mranderson. Anything I can do to move this forward? Thx! |
(into (map #(System/getProperty %) ["sun.boot.class.path" | ||
"java.ext.dirs" | ||
"java.class.path"]) | ||
(map #(.getName %) (cp/classpath-jarfiles)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied this logic over, although it seems strange to me that this is really the way to get the full classpath.
this looks awesome @plexus. give me a few days tops to have a proper look tho |
actually one small thing: can you pls add a one liner to the change log? |
Sure thing! If it's ok I'm gonna push a few more small cleanups, like replace |
👍 |
FileNameFilter is an interface, so reify does the job just fine, no need for proxy.
Error inherits directly from Throwable, so Errors are not Exceptions, they need to be handled separately. This category includes RuntimeError, StackOverflowError, and NoClassDefFoundError. In regular applications you would not catch these, but in our case letting them bubble means the nREPL handler dies without returning a response, causing the client to assume that the operation is taking too long and time out, without any useful feedback. This is bad UX, and it makes it hard to diagnose and debug problems like clojure-emacs#184. At least this way the user will see a stack trace that hints at the problem.
great work @plexus! thanks again for all your PRs this WE. |
Once the classpath gets big enough, this would cause a stack overflow, which
from clj-refactor simply shows up as a timeout.
Instead use transducers over lists as much as possible. Since the collection of
available classes is only ever traversed sequentially, this provides the best
performance as well.
lein do clean, test
)./build.sh install
-- takes a long time)Thanks!