Skip to content

Partial class name completion patch #12

@nkkarthik

Description

@nkkarthik

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:

  1. Use class names as potential-completions when there is a capital
    letter in the prefix
    (a curde assumption, I have to agree, that
    clojure vars may not have capitals).
  2. Instead of startsWith, use regular expression match to support
    wildcard too (see re-match).
  3. Some tests are updated.

Let me know what you guys think about it.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions