-
Notifications
You must be signed in to change notification settings - Fork 44
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 unecessary code #206
Conversation
I do think at least some of that code being deleted is needed, to enable the completion code to be loaded into any application that doesn't already have it as a dependency. Is there behavior you're seeing that's broken? Also, looks like this fails a test, which makes sense since the app in that test doesn't have the
(and for easier readability of the actual error the PR code would hit in the remote-app scenario):
|
OK, I think I see the arity issue you're alluding to in #205 - I can see how that difference could potentially cause issues - I haven't seen them myself yet (I guess no tests yet around whatever the scenario is, and I'm also not using Clojure much these days), but it seems like a diff that preserves the core |
The issue I encountered involved autocompleting a protocol method in an aliased namespace, e.g.: (require '[blah :as b])
(b/some-f Tabbing resulted in an arity exception. |
I'm struggling to imagine a situation in which the try/catch is relevant, except in the repl-y tests nREPL integration tests, due to them being run with a different ClassLoader. Maybe I'm misunderstanding something of the nature of classpath magic, but surely one can assume that 1. |
; hack for 1.2 support until we release the next clojure-complete version | ||
~(export-definition 'reply.initialization/resolve-class) | ||
(~'reply.exports/intern-with-meta | ||
'~'incomplete.core '~'resolve-class ~'#'resolve-class) |
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.
These four lines do appear to be safe to delete, as well as the definition of resolve-class
above.
Great - thanks, I've got the bug reproduced locally now:
Details on the classpath situation: in the most typical use case that I'm aware of (e.g. via
In the I'm all for the majority of this change - just want to make sure we preserve being able to inject completion code across processes. I'm pretty sure this PR will work great if you just delete these 4 lines from the We should add a regression test for the above scenario while we're in there - the test suite is unfortunately fairly light, to my eternal shame. Here's what I think will work: diff --git a/spec/reply/integration_spec.clj b/spec/reply/integration_spec.clj
index f0ec927..4870e46 100644
--- a/spec/reply/integration_spec.clj
+++ b/spec/reply/integration_spec.clj
@@ -107,6 +107,15 @@
(should-contain "mapcat" (str @fake-out))
(should-contain "map-indexed" (str @fake-out)))
+ (it "tab-completes fns in aliased namespaces"
+ (main/launch-standalone {:input-stream
+ (java.io.ByteArrayInputStream.
+ (.getBytes "(require '[clojure.string :as s])\ns/\tsplit\nexit\n"))
+ :output-stream @fake-out})
+ (should= "" (str @fake-err))
+ (should-contain "s/split" (str @fake-out))
+ (should-contain "s/replace" (str @fake-out)))
+
(it "tab-completes without putting results into *1"
(main/launch-standalone {:input-stream
(java.io.ByteArrayInputStream.
@@ -182,7 +191,6 @@
(str @fake-out))))
(describe "completion"
-
(it "tab-completes clojure.core fns"
(main/launch-nrepl {:attach (str *server-port*)
:input-stream
@@ -191,4 +199,14 @@
:output-stream @fake-out})
(should= "" (str @fake-err))
(should-contain "mapcat" (str @fake-out))
- (should-contain "map-indexed" (str @fake-out)))))
+ (should-contain "map-indexed" (str @fake-out)))
+
+ (it "tab-completes fns in aliased namespaces"
+ (main/launch-nrepl {:attach (str *server-port*)
+ :input-stream
+ (java.io.ByteArrayInputStream.
+ (.getBytes "(require '[clojure.string :as s])\ns/\tsplit\nexit\n"))
+ :output-stream @fake-out})
+ (should= "" (str @fake-err))
+ (should-contain "s/split" (str @fake-out))
+ (should-contain "s/replace" (str @fake-out)))))
diff --git a/src/clj/reply/initialization.clj b/src/clj/reply/initialization.clj
index d114b54..7fe857b 100644
--- a/src/clj/reply/initialization.clj
+++ b/src/clj/reply/initialization.clj
@@ -32,15 +32,6 @@
(defn export-definition [s]
(read-string (clojure.repl/source-fn s)))
-(def resolve-class
- (fn [sym]
- (try (let [val (resolve sym)]
- (when (class? val) val))
- (catch Exception e
- (when (not= ClassNotFoundException
- (class (clojure.main/repl-exception e)))
- (throw e))))))
-
(defn unresolve
"Given a var, return a sequence of all symbols that resolve to the
var from the current namespace *ns*."
@@ -149,11 +140,6 @@
(defn completion-code []
`(try
(require '[incomplete.core])
- ; hack for 1.2 support until we release the next clojure-complete version
- ~(export-definition 'reply.initialization/resolve-class)
- (~'reply.exports/intern-with-meta
- '~'incomplete.core '~'resolve-class ~'#'resolve-class)
-
(catch Exception e#
(try
(eval
|
Just let me know how you want to handle it, @hsartoris-bard. I'd be excited to take an updated PR that preserves the completion code being injected - but also happy to apply something like the above diff myself if you don't have bandwidth. |
I didn't see this PR and I've opened anther one deleting just the code for which I'm fairly certain it's fine to remove. Pretty much what @trptcolin had suggested here as well. I wish I first saw this ticket, so I wouldn't have to do the research myself. :D |
Okay, now I see that @trptcolin also added some tests in his proposed patch, so I guess that'd be the best course of action for now. And sorry for pitching in so late! |
Yeah @bbatsov @hsartoris-bard if one of y'all have time to update one of your PRs to include a test for the thing that's broken (feel free to grab from that diff above), I'm all for it. 👍 👍 Sorry, a bit slammed today but I should be able to get a release out sometime tomorrow that includes this fix as well as the other two cleanup things @bbatsov. |
@trptcolin I've just updated my PR. |
Going to go ahead and close since we've got the fix in the other PR - thanks y'all! |
Fixes #205