Skip to content
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

Move leftover code from the info middleware to orchard #594

Merged
merged 4 commits into from
Jun 3, 2019

Conversation

arichiardi
Copy link
Contributor

This patch copies the leftover "business logic" from the info middleware to
the orchard info function. This will make the info function in orchard
self-contained, which is easier to test and more portable (one could use
orchard without the nrepl protocol for instance - say for a Language Server
Protocol implementation).

  • The commits are consistent with our contribution guidelines
  • You've added tests to cover your change(s)
  • [] All tests are passing

@arichiardi arichiardi force-pushed the orchard-contained-info branch 2 times, most recently from 4ee0d0a to 17ce4a5 Compare February 24, 2019 20:30
@cichli
Copy link
Member

cichli commented Feb 25, 2019

Just to clarify: this is dependent on clojure-emacs/orchard#37, right?

@arichiardi
Copy link
Contributor Author

Yep

@arichiardi arichiardi force-pushed the orchard-contained-info branch from 17ce4a5 to 9194473 Compare February 27, 2019 00:47
@arichiardi
Copy link
Contributor Author

Problem found it this stash the stacktrace here:

{:id 2, :msg clojure.lang.Compiler.currentNS(Compiler.java:7397)
clojure.lang.Compiler.lookupVar(Compiler.java:7359)
clojure.lang.Compiler.isMacro(Compiler.java:6820)
clojure.lang.Compiler.macroexpand1(Compiler.java:6904)
clojure.core$macroexpand_1.invokeStatic(core.clj:3990)
clojure.core$macroexpand.invokeStatic(core.clj:3992)
clojure.core$macroexpand.invoke(core.clj:3992)
mranderson049.orchard.v0v4v42.orchard.meta$macroexpand_all$fn__13131.invoke(meta.clj:295)
mranderson049.orchard.v0v4v42.orchard.meta$macroexpand_all.invokeStatic(meta.clj:295)
mranderson049.orchard.v0v4v42.orchard.meta$macroexpand_all.doInvoke(meta.clj:284)
clojure.lang.RestFn.invoke(RestFn.java:423)
cider.nrepl.middleware.util.instrument$instrument_tagged_code.invokeStatic(instrument.clj:336)
cider.nrepl.middleware.util.instrument$instrument_tagged_code.invoke(instrument.clj:312)
cider.nrepl.middleware.debug$instrument_var_for_step_in.invokeStatic(debug.clj:406)
cider.nrepl.middleware.debug$instrument_var_for_step_in.invoke(debug.clj:393)
cider.nrepl.middleware.debug$step_in_QMARK_.invokeStatic(debug.clj:429)
cider.nrepl.middleware.debug$step_in_QMARK_.invoke(debug.clj:419)
cider.nrepl.middleware.debug$apply_instrumented_maybe.invokeStatic(debug.clj:512)
cider.nrepl.middleware.debug$apply_instrumented_maybe.invoke(debug.clj:509)
user.test.step_in$eval17747$foo__17748.invoke(form-init1787543005378177910.clj:2)
user.test.step_in$eval17751.invokeStatic(form-init1787543005378177910.clj:1)
user.test.step_in$eval17751.invoke(form-init1787543005378177910.clj:1)
clojure.lang.Compiler.eval(Compiler.java:7062)
clojure.lang.Compiler.eval(Compiler.java:7025)
clojure.core$eval.invokeStatic(core.clj:3206)
clojure.core$eval.invoke(core.clj:3202)
clojure.main$repl$read_eval_print__8572$fn__8575.invoke(main.clj:243)
clojure.main$repl$read_eval_print__8572.invoke(main.clj:243)
clojure.main$repl$fn__8581.invoke(main.clj:261)
clojure.main$repl.invokeStatic(main.clj:261)
clojure.main$repl.doInvoke(main.clj:177)
clojure.lang.RestFn.invoke(RestFn.java:1523)
nrepl.middleware.interruptible_eval$evaluate.invokeStatic(interruptible_eval.clj:79)
nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:55)
nrepl.middleware.interruptible_eval$interruptible_eval$fn__9620$fn__9624.invoke(interruptible_eval.clj:142)
clojure.lang.AFn.run(AFn.java:22)
nrepl.middleware.session$session_exec$main_loop__9811$fn__9815.invoke(session.clj:171)
nrepl.middleware.session$session_exec$main_loop__9811.invoke(session.clj:170)
clojure.lang.AFn.run(AFn.java:22)
java.lang.Thread.run(Thread.java:748), :session 73e2cde7-fa8f-4bcb-a3c2-aa47e610cf2b, :status [notification], :type error}

@arichiardi arichiardi force-pushed the orchard-contained-info branch 2 times, most recently from cf70594 to a2891f5 Compare February 27, 2019 23:39
@arichiardi arichiardi changed the title WIP - Move leftover code from the info middleware to orchard Move leftover code from the info middleware to orchard Feb 28, 2019
@arichiardi
Copy link
Contributor Author

arichiardi commented Feb 28, 2019

This part should be done as well, will check the tests and try CircleCI.

Now I am eager to expand on it so that I can finally go to my original issue of having spec in ClojureScript 😄

@arichiardi arichiardi force-pushed the orchard-contained-info branch from a2891f5 to c29508f Compare April 4, 2019 02:39
@arichiardi
Copy link
Contributor Author

After rebasing I started receiving a:

clojure.lang.Compiler$CompilerException: clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: No reader function for tag Inf, compiling:(mranderson/inlined/parallel/v0v10/parallel/core.clj:323:31)
 at clojure.lang.Compiler.load (Compiler.java:7386)
    clojure.lang.RT.loadResourceScript (RT.java:372)
    clojure.lang.RT.loadResourceScript (RT.java:363)
    ...

Will need to understand what is going on.

@arichiardi arichiardi force-pushed the orchard-contained-info branch from c29508f to e5412e6 Compare April 4, 2019 02:49
@arichiardi
Copy link
Contributor Author

Going back to the commit before the MrAnderson (2249b55) bump to 0.5.0 solves the problem here

@bbatsov
Copy link
Member

bbatsov commented Apr 4, 2019

Please, create an issue in MrAnderson. I'm sure @benedekfazekas will quickly figure out what went wrong.

@benedekfazekas
Copy link
Member

benedekfazekas commented Apr 4, 2019

After rebasing I started receiving a:

clojure.lang.Compiler$CompilerException: clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: No reader function for tag Inf, compiling:(mranderson/inlined/parallel/v0v10/parallel/core.clj:323:31)
 at clojure.lang.Compiler.load (Compiler.java:7386)
    clojure.lang.RT.loadResourceScript (RT.java:372)
    clojure.lang.RT.loadResourceScript (RT.java:363)
    ...

Will need to understand what is going on.

parallel the library used in MrAnderson to process files in parallel depends on at least clojure version 1.8.0 and also leiningen 2.8.3. (leining because it pulls in a certain version of clojure too). So the above error should disappear if you make sure you run MrAnderson step in the build with at least clojure 1.8.0. This does not mean you are restricted to whatever lein/clojure versions in the subsequent build steps. Hope this makes sense

@arichiardi
Copy link
Contributor Author

@bbatsov @benedekfazekas

Is there a way to test this against the latest orchard (or is -SNAPSHOT) the only one.

I get the following in CircleCI:

Caused by: java.io.FileNotFoundException: Could not locate orchard/cljs/analysis__init.class, orchard/cljs/analysis.clj or orchard/cljs/analysis.cljc on classpath.
	at clojure.lang.RT.load(RT.java:466)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:703)
	at cider.nrepl.middleware.ns$eval14706$loading__6706__auto____14707.invoke(ns.clj:1)
	at cider.nrepl.middleware.ns$eval14706.invokeStatic(ns.clj:1)
	at cider.nrepl.middleware.ns$eval14706.invoke(ns.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7165)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	... 69 more

@arichiardi arichiardi force-pushed the orchard-contained-info branch from 77aac29 to 8e32ea2 Compare May 10, 2019 18:18
@arichiardi
Copy link
Contributor Author

Rebased this boy as well.

@arichiardi
Copy link
Contributor Author

@bbatsov Maybe you've already told me this, but do you think this xref function should call the new orchard.info namespace? It seems to me a good thing to do.

@arichiardi arichiardi force-pushed the orchard-contained-info branch 3 times, most recently from e8fdaff to 6ca8bd9 Compare May 27, 2019 18:16
@arichiardi
Copy link
Contributor Author

I see these tests failing but I they do not fail on my machine for some reason.

@arichiardi
Copy link
Contributor Author

arichiardi commented May 27, 2019

@bbatsov I am trying to understand why the code is failing in xref-test and I receive a:

#### __prefix__
{:err
 "java.lang.IllegalArgumentException: Symbol must be namespace-qualified\n at clojure.lang.Var.find (Var.java:140)\n    clojure.core$find_var.invokeStatic (core.clj:2012)\n    clojure.core$find_var.invoke (core.clj:2007)\n    cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$as_val.invokeStatic (form-init550670566856777087.clj:14)\n    cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$as_val.invoke (form-init550670566856777087.clj:8)\n    cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$fn_deps.invokeStatic (form-init550670566856777087.clj:22)\n    cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$fn_deps.invoke (form-init550670566856777087.clj:17)\n    clojure.core$map$fn__5587.invoke (core.clj:2747)\n    clojure.lang.LazySeq.sval (LazySeq.java:40)\n    clojure.lang.LazySeq.seq (LazySeq.java:49)\n    clojure.lang.Cons.next (Cons.java:39)\n    clojure.lang.RT.next (RT.java:706)\n    clojure.core$next__5108.invokeStatic (core.clj:64)\n    clojure.core$zipmap.invokeStatic (core.clj:3071)\n    clojure.core$zipmap.invoke (core.clj:3063)\n    cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$fn_refs.invokeStatic (form-init550670566856777087.clj:53)\n    cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$fn_refs.invoke (form-init550670566856777087.clj:45)\n    cider.nrepl.middleware.xref$fn_refs_reply.invokeStatic (xref.clj:22)\n    cider.nrepl.middleware.xref$fn_refs_reply.invoke (xref.clj:20)\n    cider.nrepl.middleware.util.error_handling$eval4196$fn__4197.invoke (error_handling.clj:160)\n    clojure.lang.MultiFn.invoke (MultiFn.java:233)\n    cider.nrepl.middleware.xref$handle_xref.invokeStatic (xref.clj:29)\n    cider.nrepl.middleware.xref$handle_xref.invoke (xref.clj:28)\n    clojure.lang.Var.invoke (Var.java:385)\n    cider.nrepl$wrap_xref$fn__1885.invoke (nrepl.clj:466)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_macroexpand$fn__1781.invoke (nrepl.clj:243)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_undef$fn__1869.invoke (nrepl.clj:448)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_spec$fn__1829.invoke (nrepl.clj:374)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_complete$fn__1729.invoke (nrepl.clj:116)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    nrepl.middleware.interruptible_eval$interruptible_eval$fn__932.invoke (interruptible_eval.clj:144)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_debug$fn__1739.invoke (nrepl.clj:136)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_enlighten$fn__1747.invoke (nrepl.clj:162)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    nrepl.middleware.load_file$wrap_load_file$fn__970.invoke (load_file.clj:81)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_version$fn__1877.invoke (nrepl.clj:456)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    nrepl.middleware.session$add_stdin$fn__1081.invoke (session.clj:326)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_profile$fn__1805.invoke (nrepl.clj:299)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_test$fn__1845.invoke (nrepl.clj:400)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_resource$fn__1821.invoke (nrepl.clj:362)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_info$fn__1763.invoke (nrepl.clj:180)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.piggieback$wrap_cljs_repl$fn__1624.invoke (piggieback.clj:316)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_inspect$fn__1773.invoke (nrepl.clj:199)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_tracker$fn__1861.invoke (nrepl.clj:437)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    nrepl.middleware.caught$wrap_caught$fn__878.invoke (caught.clj:97)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_out$fn__1797.invoke (nrepl.clj:290)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    nrepl.middleware.session$session$fn__1066.invoke (session.clj:272)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    cider.nrepl$wrap_content_type$fn__1697.invoke (nrepl.clj:82)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    nrepl.middleware.print$wrap_print$fn__845.invoke (print.clj:234)\n    nrepl.middleware$wrap_conj_descriptor$fn__621.invoke (middleware.clj:16)\n    nrepl.server$handle_STAR_.invokeStatic (server.clj:18)\n    nrepl.server$handle_STAR_.invoke (server.clj:15)\n    nrepl.server$handle$fn__1103.invoke (server.clj:27)\n    clojure.core$binding_conveyor_fn$fn__5476.invoke (core.clj:2022)\n    clojure.lang.AFn.call (AFn.java:18)\n    java.util.concurrent.FutureTask.run (FutureTask.java:266)\n    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)\n    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)\n    java.lang.Thread.run (Thread.java:748)\n",
 :ex "class java.lang.IllegalArgumentException",
 :id "11e6a6c5-181b-49f6-b110-2e0fa657f20b",
 :pp-stacktrace
 [{:class "java.lang.IllegalArgumentException",
   :message "Symbol must be namespace-qualified",
   :stacktrace
   [{:class "clojure.lang.Var",
     :file "Var.java",
     :file-url [],
     :flags ["java"],
     :line 140,
     :method "find",
     :name "clojure.lang.Var/find",
     :type "java"}
    {:fn "find-var",
     :method "invokeStatic",
     :ns "clojure.core",
     :name "clojure.core$find_var/invokeStatic",
     :file "core.clj",
     :type "clj",
     :file-url
     "jar:file:/home/arichiardi/.m2/repository/org/clojure/clojure/1.9.0/clojure-1.9.0.jar!/clojure/core.clj",
     :line 2012,
     :var "clojure.core/find-var",
     :class "clojure.core$find_var",
     :flags ["clj"]}
    {:fn "find-var",
     :method "invoke",
     :ns "clojure.core",
     :name "clojure.core$find_var/invoke",
     :file "core.clj",
     :type "clj",
     :file-url
     "jar:file:/home/arichiardi/.m2/repository/org/clojure/clojure/1.9.0/clojure-1.9.0.jar!/clojure/core.clj",
     :line 2007,
     :var "clojure.core/find-var",
     :class "clojure.core$find_var",
     :flags ["clj"]}
    {:fn "as-val",
     :method "invokeStatic",
     :ns "cider.nrepl.inlined-deps.orchard.v0v5v0-beta4.orchard.xref",
     :name
     "cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$as_val/invokeStatic",
     :file "form-init550670566856777087.clj",
     :type "clj",
     :file-url
     "file:/home/arichiardi/git/cider-nrepl/target/srcdeps/cider/nrepl/inlined_deps/orchard/v0v5v0_beta4/orchard/xref.clj",
     :line 14,
     :var "cider.nrepl.inlined-deps.orchard.v0v5v0-beta4.orchard.xref/as-val",
     :class
     "cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$as_val",
     :flags ["tooling" "project" "repl" "clj"]}
    {:fn "as-val",
     :method "invoke",
     :ns "cider.nrepl.inlined-deps.orchard.v0v5v0-beta4.orchard.xref",
     :name
     "cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$as_val/invoke",
     :file "form-init550670566856777087.clj",
     :type "clj",
     :file-url
     "file:/home/arichiardi/git/cider-nrepl/target/srcdeps/cider/nrepl/inlined_deps/orchard/v0v5v0_beta4/orchard/xref.clj",
     :line 8,
     :var "cider.nrepl.inlined-deps.orchard.v0v5v0-beta4.orchard.xref/as-val",
     :class
     "cider.nrepl.inlined_deps.orchard.v0v5v0_beta4.orchard.xref$as_val",
     :flags ["tooling" "project" "repl" "clj"]}
...

The input find-var is trying to process is before the exception is __prefix__.

Does it ring any bell 🔔 😄 ?

@arichiardi
Copy link
Contributor Author

Ping @bbatsov 😄

@bbatsov
Copy link
Member

bbatsov commented May 29, 2019

@bbatsov Maybe you've already told me this, but do you think this xref function should call the new orchard.info namespace? It seems to me a good thing to do.

Yeah, maybe.

@bbatsov I am trying to understand why the code is failing in xref-test and I receive a:

Which code triggers this?

Does it ring any bell 🔔 😄 ?

Haven't seen this, but it seems obvious what the problem is looking at the stacktrace.

@arichiardi
Copy link
Contributor Author

arichiardi commented May 29, 2019

@bbatsov
Copy link
Member

bbatsov commented May 29, 2019

The input find-var is trying to process is before the exception is prefix.

Hmm, I guess I was running the test locally without running MrAnderson. Does the test pass for you without it?

@arichiardi
Copy link
Contributor Author

You mean on master? I will try haven't tried it yet.

@arichiardi
Copy link
Contributor Author

Ok so I can confirm this happens on master and I opened an issue. It also means that this PR is ready to go and integration tests for info all seem to pass.

@arichiardi arichiardi force-pushed the orchard-contained-info branch from 6ca8bd9 to 1832c4e Compare May 29, 2019 17:15
@bbatsov
Copy link
Member

bbatsov commented May 30, 2019

You'll also have to remove the duplicated boot-related code. Grep for boot and you'll see what I mean.

@arichiardi
Copy link
Contributor Author

Ok cool will do

@arichiardi
Copy link
Contributor Author

arichiardi commented Jun 2, 2019

TODOs here (for myself mainly):

… orchard

This patch copies the leftover "business logic" from the `info` middleware to
the `orchard` `info` function. This will make the `info` function in `orchard`
self-contained, which is easier to test and more portable (one could use
`orchard` without the `nrepl` protocol for instance - say for a Language Server
Protocol implementation). It also moves calls to cljs-analysis to the ones in
the orchard.

Only completion is still done in cljs-tooling.
Given that orchard now returns a namespace symbol instead of an object, we have
to trigger a find-ns in the debug middleware instrumentation code.
@arichiardi arichiardi force-pushed the orchard-contained-info branch from 1832c4e to b02a8bd Compare June 2, 2019 19:20
@bbatsov bbatsov merged commit 9cdee22 into clojure-emacs:master Jun 3, 2019
@arichiardi arichiardi deleted the orchard-contained-info branch June 3, 2019 15:01
@arichiardi
Copy link
Contributor Author

Woot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants