clojure-complete
clojure-complete copied to clipboard
Partial class name completion patch
I have modified the code to auto-complete a partial classname, without needing the package name (makes it very easy to find/enter class when you forget the package name or even the exact class name). I found it useful in my personal work, so thought could help others too.
It behaves as below:
user> (complete.core/completions "JFr")
("javax.swing.JFrame")
user> (complete.core/completions "Rob")
("java.awt.Robot" "java.awt.peer.RobotPeer")
Wildcard '*' is supported and can be used as below:
user> (complete.core/completions "Win*Ad")
("java.awt.event.WindowAdapter")
user> (complete.core/completions "Mou*Li")
("java.awt.event.MouseListener" "java.awt.event.MouseMotionListener"
"java.awt.event.MouseWheelListener" "javax.swing.event.MouseInputListener")
user> (complete.core/completions "Mou*In*L")
("javax.swing.event.MouseInputListener")
Uploaded patch here: https://gist.github.com/3117608
Changes:
- Use class names as
potential-completionswhen there is a capital letter in the prefix (a curde assumption, I have to agree, that clojure vars may not have capitals). - Instead of
startsWith, use regular expression match to support wildcard too (seere-match). - Some tests are updated.
Let me know what you guys think about it.
Thank you