br-baker-01
br-baker-01

Reputation: 27

Arg cannot be resolved when using defresource

I'm trying to use liberator macro defresource but the intellij IDE keeps returning the error "(arg) cannot be resolved"

I'm doing a project using clojure, ring and liberator, in this project i have the dependecies as

:dependencies [[org.clojure/clojure "1.10.0"]
                 [liberator "0.15.3"]
                 [compojure "1.6.0"]
                 [ring/ring-core "1.7.1"]]

in the code

(:require [liberator.core :refer [defresource resource]]
           [ring.middleware.params :refer [wrap-params]]
           [compojure.core :refer [defroutes ANY]]))
(defresource ok
             :available-media-types ["text/html"]
             :handle-ok "This is iia")
(defroutes app
           (ANY "/test" [] ok))
(def handler
  (-> app
      wrap-params))

when using defresource ok the message "ok cannot be resolved" keeps showing

Upvotes: 0

Views: 286

Answers (2)

Andrei Galatyn
Andrei Galatyn

Reputation: 3432

I guess you are using IntelliJ+Cursive:

  1. Put cursor at defresource.
  2. Alt+Enter on keyboard (or Show Context Actions from popup menu).
  3. You should see popup menu with two items, click Resolve liberator.core/defresource as....
  4. You should see some suggestions, click defn.

After that IntelliJ should treat all defresource in the code as defn and related warnings should disappear.

Upvotes: 0

dpassen
dpassen

Reputation: 1306

If you're using Cursive, you should be able to tell IntelliJ to treat defresource as a def.

See Cursive's macro docs.

Upvotes: 0

Related Questions