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

Use new tools.analyzer features to simplify Eastwood linters #71

Closed
jafingerhut opened this issue Jun 8, 2014 · 3 comments
Closed

Use new tools.analyzer features to simplify Eastwood linters #71

jafingerhut opened this issue Jun 8, 2014 · 3 comments
Assignees

Comments

@jafingerhut
Copy link
Collaborator

Example suggested by Nicola:
defonce-or-defmulti-macro-expansion? could be written as

(some (fn [form]
        (and (seq? form)
             ('#{defonce defmulti} (first form))))
      (:raw-forms node))

Example interaction with tools.analyzer/analyze:

clojure.tools.analyzer.jvm> (-> (analyze '(defmulti x :op))
                                :raw-forms)

((defmulti x :op)
 (clojure.core/let [v__4114__auto__ (def x)]
   (clojure.core/when-not (clojure.core/and (.hasRoot v__4114__auto__)
                                            (clojure.core/instance? clojure.lang.MultiFn (clojure.core/deref v__4114__auto__)))
     (def x (new clojure.lang.MultiFn "x" :op :default #'clojure.core/global-hierarchy)))))

In general, :raw-forms is a sequence of forms, one for each 'level' of macroexpansion, until the last one in the sequence, where macroexpanding has no effect.

@jafingerhut
Copy link
Collaborator Author

From Nicola: if you need :raw-forms be sure to use 0.2.1/2-SNAPSHOT btw 0.2.0 had some passes that discarded it

@Bronsa Bronsa self-assigned this Aug 19, 2014
@Bronsa
Copy link
Collaborator

Bronsa commented Aug 19, 2014

@jafingerhut I'll have some the next week that I plan on dedicating to upgrading eastwood to the lastest t.a.jvm and polishing a bit the code to use the lastest features

@jafingerhut
Copy link
Collaborator Author

Nicola Mometto has committed these improvements some time back, with these commits:

Simplification & improvement in detection of defmulti and defonce forms: commit 9e46592

Similarly for defprotocol forms: commit 2509606

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

No branches or pull requests

2 participants