forked from k2n/saml20-clj
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{:lint-as {potemkin.collections/compile-if clojure.core/if | ||
potemkin.collections/reify-map-type clojure.core/reify | ||
potemkin.collections/def-map-type clj-kondo.lint-as/def-catch-all | ||
potemkin.collections/def-derived-map clj-kondo.lint-as/def-catch-all | ||
|
||
potemkin.types/reify+ clojure.core/reify | ||
potemkin.types/defprotocol+ clojure.core/defprotocol | ||
potemkin.types/deftype+ clojure.core/deftype | ||
potemkin.types/defrecord+ clojure.core/defrecord | ||
potemkin.types/definterface+ clojure.core/defprotocol | ||
potemkin.types/extend-protocol+ clojure.core/extend-protocol | ||
potemkin.types/def-abstract-type clj-kondo.lint-as/def-catch-all | ||
|
||
potemkin.utils/doit clojure.core/doseq | ||
potemkin.utils/doary clojure.core/doseq | ||
potemkin.utils/condp-case clojure.core/condp | ||
potemkin.utils/fast-bound-fn clojure.core/bound-fn | ||
|
||
potemkin.walk/prewalk clojure.walk/prewalk | ||
potemkin.walk/postwalk clojure.walk/postwalk | ||
potemkin.walk/walk clojure.walk/walk | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;;; top-level from import-vars | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
||
;; Have hooks | ||
;;potemkin/import-fn potemkin.namespaces/import-fn | ||
;;potemkin/import-macro potemkin.namespaces/import-macro | ||
;;potemkin/import-def potemkin.namespaces/import-def | ||
|
||
;; Internal, not transitive | ||
;;potemkin/unify-gensyms potemkin.macros/unify-gensyms | ||
;;potemkin/normalize-gensyms potemkin.macros/normalize-gensyms | ||
;;potemkin/equivalent? potemkin.macros/equivalent? | ||
|
||
potemkin/condp-case clojure.core/condp | ||
potemkin/doit potemkin.utils/doit | ||
potemkin/doary potemkin.utils/doary | ||
|
||
potemkin/def-abstract-type clj-kondo.lint-as/def-catch-all | ||
potemkin/reify+ clojure.core/reify | ||
potemkin/defprotocol+ clojure.core/defprotocol | ||
potemkin/deftype+ clojure.core/deftype | ||
potemkin/defrecord+ clojure.core/defrecord | ||
potemkin/definterface+ clojure.core/defprotocol | ||
potemkin/extend-protocol+ clojure.core/extend-protocol | ||
|
||
potemkin/reify-map-type clojure.core/reify | ||
potemkin/def-derived-map clj-kondo.lint-as/def-catch-all | ||
potemkin/def-map-type clj-kondo.lint-as/def-catch-all} | ||
|
||
;; leave import-vars alone, kondo special-cases it | ||
:hooks {:macroexpand {#_#_potemkin.namespaces/import-vars potemkin.namespaces/import-vars | ||
potemkin.namespaces/import-fn potemkin.namespaces/import-fn | ||
potemkin.namespaces/import-macro potemkin.namespaces/import-macro | ||
potemkin.namespaces/import-def potemkin.namespaces/import-def | ||
|
||
#_#_potemkin/import-vars potemkin.namespaces/import-vars | ||
potemkin/import-fn potemkin.namespaces/import-fn | ||
potemkin/import-macro potemkin.namespaces/import-macro | ||
potemkin/import-def potemkin.namespaces/import-def}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
(ns potemkin.namespaces | ||
(:require [clj-kondo.hooks-api :as api])) | ||
|
||
(defn import-macro* | ||
([sym] | ||
`(def ~(-> sym name symbol) ~sym)) | ||
([sym name] | ||
`(def ~name ~sym))) | ||
|
||
(defmacro import-fn | ||
([sym] | ||
(import-macro* sym)) | ||
([sym name] | ||
(import-macro* sym name))) | ||
|
||
(defmacro import-macro | ||
([sym] | ||
(import-macro* sym)) | ||
([sym name] | ||
(import-macro* sym name))) | ||
|
||
(defmacro import-def | ||
([sym] | ||
(import-macro* sym)) | ||
([sym name] | ||
(import-macro* sym name))) | ||
|
||
#_ | ||
(defmacro import-vars | ||
"Imports a list of vars from other namespaces." | ||
[& syms] | ||
(let [unravel (fn unravel [x] | ||
(if (sequential? x) | ||
(->> x | ||
rest | ||
(mapcat unravel) | ||
(map | ||
#(symbol | ||
(str (first x) | ||
(when-let [n (namespace %)] | ||
(str "." n))) | ||
(name %)))) | ||
[x])) | ||
syms (mapcat unravel syms) | ||
result `(do | ||
~@(map | ||
(fn [sym] | ||
(let [vr (resolve sym) | ||
m (meta vr)] | ||
(cond | ||
(nil? vr) `(throw (ex-info (format "`%s` does not exist" '~sym) {})) | ||
(:macro m) `(def ~(-> sym name symbol) ~sym) | ||
(:arglists m) `(def ~(-> sym name symbol) ~sym) | ||
:else `(def ~(-> sym name symbol) ~sym)))) | ||
syms))] | ||
result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
/.lein-failures | ||
/.lein-plugins | ||
/.lein-repl-history | ||
/.lsp | ||
/.nrepl-port | ||
/build.xml | ||
/checkouts | ||
|