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

[Exception when refactoring] I can not apply refactoring to use url-for to certain file, it will throw exception #32

Open
humorless opened this issue Sep 4, 2024 · 0 comments

Comments

@humorless
Copy link
Member

I encountered a wired bug, which is that I could not do the same refactor in the filters.clj

Change

  • The Code of html/iflters/clj
diff --git a/src/co/gaiwan/compass/html/filters.clj b/src/co/gaiwan/compass/html/filters.clj
index 6a0f2f2..f950543 100644
--- a/src/co/gaiwan/compass/html/filters.clj
+++ b/src/co/gaiwan/compass/html/filters.clj
@@ -2,10 +2,11 @@
   {:ornament/prefix "filters-"}
   (:require
    [co.gaiwan.compass.html.components :as c]
+   [co.gaiwan.compass.http.routing :refer [url-for]]
    [lambdaisland.ornament :as o]))
 
 (def filter-props
-  {:hx-put "/filters"
+  {:hx-put (url-for :filters/index)
    :hx-include "#filters input"
    :hx-swap "none"})
 
@@ -22,7 +23,7 @@
   :my-3
   [#{:button :.btn c/toggle-button} :font-normal :flex-grow]
   ([state]
-   [:<> {:hx-get     "/filters"
+   [:<> {:hx-get     (url-for :filters/index)
          :hx-trigger "filters-updated from:body"
          :hx-swap    "outerHTML"}
 
@@ -54,5 +55,4 @@
      {:id :spots-available,
       :caption "Spots Available",
       :checked? (get state :spots-available)}]
-    #_[:a.btn {:href "/sessions/new" :hx-boost "false"} "Create An Activity"]
-    ]))
+    #_[:a.btn {:href (url-for :session/new) :hx-boost "false"} "Create An Activity"]]))
  • The code of routes/filters.clj
diff --git a/src/co/gaiwan/compass/routes/filters.clj b/src/co/gaiwan/compass/routes/filters.clj
index cc16a38..4c5f622 100644
--- a/src/co/gaiwan/compass/routes/filters.clj
+++ b/src/co/gaiwan/compass/routes/filters.clj
@@ -21,7 +21,7 @@
 
 (defn routes []
   ["/filters"
-   {:name :filters
+   {:name :filters/index
     :put {:handler PUT-filters}
     :get {:handler GET-filters}}])

The Exception

laurencechen compass $  bin/launchpad dev --go --portal
Launching Clojure on nREPL port 58195
Options: go, portal
Aliases: dev
[clojure] SLF4J(I): Connected with provider of type [ch.qos.logback.classic.spi.LogbackServiceProvider]
[clojure] (user/go) failed #error {
[clojure]  :cause Cannot invoke "clojure.lang.IFn.invoke()"
[clojure]  :via
[clojure]  [{:type clojure.lang.Compiler$CompilerException
[clojure]    :message Syntax error macroexpanding at (filters.clj:9:12).
[clojure]    :data #:clojure.error{:phase :execution, :line 9, :column 12, :source filters.clj}
[clojure]    :at [clojure.lang.Compiler$InvokeExpr eval Compiler.java 3719]}
[clojure]   {:type java.lang.NullPointerException
[clojure]    :message Cannot invoke "clojure.lang.IFn.invoke()"
[clojure]    :at [co.gaiwan.compass.http.routing$router invokeStatic routing.clj 8]}]
[clojure]  :trace
[clojure]  [[co.gaiwan.compass.http.routing$router invokeStatic routing.clj 8]
[clojure]   [co.gaiwan.compass.http.routing$router invoke routing.clj 7]
[clojure]   [co.gaiwan.compass.http.routing$url_for invokeStatic routing.clj 22]
[clojure]   [co.gaiwan.compass.http.routing$url_for invoke routing.clj 10]
[clojure]   [co.gaiwan.compass.http.routing$url_for invokeStatic routing.clj 20]
[clojure]   [co.gaiwan.compass.http.routing$url_for invoke routing.clj 10]
[clojure]   [clojure.lang.AFn applyToHelper AFn.java 154]
[clojure]   [clojure.lang.AFn applyTo AFn.java 144]
[clojure]   [clojure.lang.Compiler$InvokeExpr eval Compiler.java 3714]
[clojure]   [clojure.lang.Compiler$MapExpr eval Compiler.java 3066]
[clojure]   [clojure.lang.Compiler$DefExpr eval Compiler.java 457]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7206]
[clojure]   [clojure.lang.Compiler load Compiler.java 7659]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 381]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 372]
[clojure]   [clojure.lang.RT load RT.java 459]
[clojure]   [clojure.lang.RT load RT.java 424]
[clojure]   [clojure.core$load$fn__6908 invoke core.clj 6162]
[clojure]   [clojure.core$load invokeStatic core.clj 6161]
[clojure]   [clojure.core$load doInvoke core.clj 6145]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 408]
[clojure]   [clojure.core$load_one invokeStatic core.clj 5934]
[clojure]   [clojure.core$load_one invoke core.clj 5929]
[clojure]   [clojure.core$load_lib$fn__6850 invoke core.clj 5976]
[clojure]   [clojure.core$load_lib invokeStatic core.clj 5975]
[clojure]   [clojure.core$load_lib doInvoke core.clj 5954]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 142]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$load_libs invokeStatic core.clj 6017]
[clojure]   [clojure.core$load_libs doInvoke core.clj 6001]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 137]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$require invokeStatic core.clj 6039]
[clojure]   [clojure.core$require doInvoke core.clj 6039]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 436]
[clojure]   [co.gaiwan.compass.routes.filters$eval34813$loading__6789__auto____34814 invoke filters.clj 1]
[clojure]   [co.gaiwan.compass.routes.filters$eval34813 invokeStatic filters.clj 1]
[clojure]   [co.gaiwan.compass.routes.filters$eval34813 invoke filters.clj 1]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7201]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7190]
[clojure]   [clojure.lang.Compiler load Compiler.java 7659]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 381]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 372]
[clojure]   [clojure.lang.RT load RT.java 459]
[clojure]   [clojure.lang.RT load RT.java 424]
[clojure]   [clojure.core$load$fn__6908 invoke core.clj 6162]
[clojure]   [clojure.core$load invokeStatic core.clj 6161]
[clojure]   [clojure.core$load doInvoke core.clj 6145]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 408]
[clojure]   [clojure.core$load_one invokeStatic core.clj 5934]
[clojure]   [clojure.core$load_one invoke core.clj 5929]
[clojure]   [clojure.core$load_lib$fn__6850 invoke core.clj 5976]
[clojure]   [clojure.core$load_lib invokeStatic core.clj 5975]
[clojure]   [clojure.core$load_lib doInvoke core.clj 5954]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 142]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$load_libs invokeStatic core.clj 6017]
[clojure]   [clojure.core$load_libs doInvoke core.clj 6001]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 137]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$require invokeStatic core.clj 6039]
[clojure]   [clojure.core$require doInvoke core.clj 6039]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 551]
[clojure]   [co.gaiwan.compass.http.routes$eval34773$loading__6789__auto____34774 invoke routes.clj 1]
[clojure]   [co.gaiwan.compass.http.routes$eval34773 invokeStatic routes.clj 1]
[clojure]   [co.gaiwan.compass.http.routes$eval34773 invoke routes.clj 1]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7201]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7190]
[clojure]   [clojure.lang.Compiler load Compiler.java 7659]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 381]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 372]
[clojure]   [clojure.lang.RT load RT.java 459]
[clojure]   [clojure.lang.RT load RT.java 424]
[clojure]   [clojure.core$load$fn__6908 invoke core.clj 6162]
[clojure]   [clojure.core$load invokeStatic core.clj 6161]
[clojure]   [clojure.core$load doInvoke core.clj 6145]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 408]
[clojure]   [clojure.core$load_one invokeStatic core.clj 5934]
[clojure]   [clojure.core$load_one invoke core.clj 5929]
[clojure]   [clojure.core$load_lib$fn__6850 invoke core.clj 5976]
[clojure]   [clojure.core$load_lib invokeStatic core.clj 5975]
[clojure]   [clojure.core$load_lib doInvoke core.clj 5954]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 142]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$load_libs invokeStatic core.clj 6017]
[clojure]   [clojure.core$load_libs doInvoke core.clj 6001]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 137]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$require invokeStatic core.clj 6039]
[clojure]   [clojure.core$require doInvoke core.clj 6039]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 930]
[clojure]   [co.gaiwan.compass.http$eval22583$loading__6789__auto____22584 invoke http.clj 1]
[clojure]   [co.gaiwan.compass.http$eval22583 invokeStatic http.clj 1]
[clojure]   [co.gaiwan.compass.http$eval22583 invoke http.clj 1]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7201]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7190]
[clojure]   [clojure.lang.Compiler load Compiler.java 7659]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 381]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 372]
[clojure]   [clojure.lang.RT load RT.java 459]
[clojure]   [clojure.lang.RT load RT.java 424]
[clojure]   [clojure.core$load$fn__6908 invoke core.clj 6162]
[clojure]   [clojure.core$load invokeStatic core.clj 6161]
[clojure]   [clojure.core$load doInvoke core.clj 6145]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 408]
[clojure]   [clojure.core$load_one invokeStatic core.clj 5934]
[clojure]   [clojure.core$load_one invoke core.clj 5929]
[clojure]   [clojure.core$load_lib$fn__6850 invoke core.clj 5976]
[clojure]   [clojure.core$load_lib invokeStatic core.clj 5975]
[clojure]   [clojure.core$load_lib doInvoke core.clj 5954]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 142]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$load_libs invokeStatic core.clj 6017]
[clojure]   [clojure.core$load_libs doInvoke core.clj 6001]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 137]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$require invokeStatic core.clj 6039]
[clojure]   [clojure.core$require doInvoke core.clj 6039]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 436]
[clojure]   [co.gaiwan.compass$eval11404 invokeStatic compass.clj 19]
[clojure]   [co.gaiwan.compass$eval11404 invoke compass.clj 19]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7201]
[clojure]   [clojure.lang.Compiler load Compiler.java 7659]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 381]
[clojure]   [clojure.lang.RT loadResourceScript RT.java 372]
[clojure]   [clojure.lang.RT load RT.java 459]
[clojure]   [clojure.lang.RT load RT.java 424]
[clojure]   [clojure.core$load$fn__6908 invoke core.clj 6162]
[clojure]   [clojure.core$load invokeStatic core.clj 6161]
[clojure]   [clojure.core$load doInvoke core.clj 6145]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 408]
[clojure]   [clojure.core$load_one invokeStatic core.clj 5934]
[clojure]   [clojure.core$load_one invoke core.clj 5929]
[clojure]   [clojure.core$load_lib$fn__6850 invoke core.clj 5976]
[clojure]   [clojure.core$load_lib invokeStatic core.clj 5975]
[clojure]   [clojure.core$load_lib doInvoke core.clj 5954]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 142]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$load_libs invokeStatic core.clj 6017]
[clojure]   [clojure.core$load_libs doInvoke core.clj 6001]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 137]
[clojure]   [clojure.core$apply invokeStatic core.clj 669]
[clojure]   [clojure.core$require invokeStatic core.clj 6039]
[clojure]   [clojure.core$require doInvoke core.clj 6039]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 137]
[clojure]   [clojure.core$apply invokeStatic core.clj 667]
[clojure]   [clojure.core$serialized_require invokeStatic core.clj 6115]
[clojure]   [clojure.core$requiring_resolve invokeStatic core.clj 6124]
[clojure]   [clojure.core$requiring_resolve invoke core.clj 6118]
[clojure]   [user$go invokeStatic user.clj 7]
[clojure]   [user$go doInvoke user.clj 6]
[clojure]   [clojure.lang.RestFn invoke RestFn.java 397]
[clojure]   [user$eval8004 invokeStatic NO_SOURCE_FILE 1]
[clojure]   [user$eval8004 invoke NO_SOURCE_FILE 1]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7201]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7190]
[clojure]   [clojure.lang.Compiler eval Compiler.java 7156]
[clojure]   [clojure.core$eval invokeStatic core.clj 3216]
[clojure]   [clojure.main$eval_opt invokeStatic main.clj 488]
[clojure]   [clojure.main$eval_opt invoke main.clj 482]
[clojure]   [clojure.main$initialize invokeStatic main.clj 508]
[clojure]   [clojure.main$null_opt invokeStatic main.clj 542]
[clojure]   [clojure.main$null_opt invoke main.clj 539]
[clojure]   [clojure.main$main invokeStatic main.clj 664]
[clojure]   [clojure.main$main doInvoke main.clj 616]
[clojure]   [clojure.lang.RestFn applyTo RestFn.java 137]
[clojure]   [clojure.lang.Var applyTo Var.java 705]
[clojure]   [clojure.main main main.java 40]]}
[clojure] nREPL server started on port 58195 on host localhost - nrepl://localhost:58195
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

No branches or pull requests

1 participant