alexander-yakushev / compliment

Clojure completion library that you deserve

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

completion of non static members does not work unless the class is imported to the name space

behrica opened this issue · comments

In this scenario, we get no candidates,

  • start new repl
(use 'compliment.sources.class-members)
(def blob (javax.sql.rowset.serial.SerialBlob. (byte-array 1)))
(map :candidate (members-candidates "." (find-ns 'user) (ctx/parse-context '(__prefix__ blob)) ))

()

so no candidates are found.
expected behavior: all and only members of class SerialBlob are returned
found behavior: no members are returned

It does work, when class is imported first:

(require '[compliment.context :as ctx])
 (use 'compliment.sources.class-members)
 (import javax.sql.rowset.serial.SerialBlob)
(def blob (SerialBlob. (byte-array 1)))
(map :candidate (members-candidates "." (find-ns 'user) (ctx/parse-context '(__prefix__ blob)) ))


(".getBinaryStream" ".setBytes" ".free" ".setBinaryStream" ".getBytes" ".position" ".length" ".truncate" ".clone" ".hashCode" ".equals")

Maybe on more comment, why I don't use the "import" in the first place ...

I discovered the issue by using the library
https://github.com/vvvvalvalval/scope-capture

A debugging tool which allows to "inject" reflectively captured local vars as global vars in the current name space (or any other name space)

So it creates the vars reflectively without me instantiating the java objects myself (so I neither used "import" nor the full qualified class name directly, but scope-capture does the instantiation via reflection)

So a kind of special case, but would be nice to get it work to avoid surprises of users.

@behrica The class no longer needs to be imported for completion to work if the class can be resolved from the context. The docstring will not work though, as that's a separate thing in CIDER now.

Would you be so kind to test this out with the latest CIDER snapshot?

commented

Hi there!

Today @cjohansen was expressing the same issue over Clojurians #cider.

I wonder if there's a unit test for instance method access such as (.| (java.time.LocalDate/now))? Tried searching it, no luck.

I can confirm that completions from the pipe in (.| (java.time.LocalDate/now)) does not find members on LocalDate if the class has not been imported, even when the REPL can evaluate (java.time.LocalDate/now).