Skip to content

Commit 53090ce

Browse files
committed
Normalize references to the orchard.misc ns
1 parent 0016d05 commit 53090ce

File tree

10 files changed

+55
-55
lines changed

10 files changed

+55
-55
lines changed

src/orchard/apropos.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
(:require
55
[orchard.meta :refer [var-name var-doc] :as m]
66
[orchard.query :as query]
7-
[orchard.misc :as u])
7+
[orchard.misc :as misc])
88
(:import
99
[clojure.lang MultiFn]))
1010

@@ -48,8 +48,8 @@
4848
:manipulate-vars
4949
(fn [nss vars]
5050
(if (first (filter #(= (find-ns 'clojure.core) %) nss))
51-
(concat (keys (or (u/require-and-resolve 'clojure.repl/special-doc-map)
52-
(u/require-and-resolve 'cljs.repl/special-doc-map)))
51+
(concat (keys (or (misc/require-and-resolve 'clojure.repl/special-doc-map)
52+
(misc/require-and-resolve 'cljs.repl/special-doc-map)))
5353
'[& catch finally]
5454
vars)
5555
vars))))

src/orchard/cljs/analysis.cljc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:author "Gary Trakhman"
33
:added "0.6.0"}
44
orchard.cljs.analysis
5-
(:require [orchard.misc :as u])
5+
(:require [orchard.misc :as misc])
66
(:refer-clojure :exclude [find-ns find-var all-ns ns-aliases]))
77

88
(defn all-ns
@@ -154,8 +154,8 @@
154154
[m]
155155
(-> m
156156
(assoc :ns (or (:ns m) (:name m)))
157-
(update :ns u/namespace-sym)
158-
(update :name u/name-sym)))
157+
(update :ns misc/namespace-sym)
158+
(update :name misc/name-sym)))
159159

160160
(defn var-meta
161161
"Return meta for the var, we wrap it in order to support both JVM and
@@ -164,37 +164,37 @@
164164
(cond-> {}
165165
(map? var) (merge var)
166166
(var? var) (-> (merge (meta var))
167-
(update :ns #(cond-> % (u/ns-obj? %) ns-name)))
167+
(update :ns #(cond-> % (misc/ns-obj? %) ns-name)))
168168
true sanitize-ns
169-
#?@(:cljs [true (-> (update :ns u/remove-macros)
170-
(update :name u/remove-macros))])))
169+
#?@(:cljs [true (-> (update :ns misc/remove-macros)
170+
(update :name misc/remove-macros))])))
171171

172172
(defn ns-meta
173173
"Return meta for the var, we wrap it in order to support both JVM and
174174
self-host."
175175
[var]
176176
(cond-> {}
177177
(map? var) (merge var)
178-
(u/ns-obj? var) (merge {:ns (ns-name var)
178+
(misc/ns-obj? var) (merge {:ns (ns-name var)
179179
:name (ns-name var)})
180180
true sanitize-ns
181-
#?@(:cljs [true (-> (update :ns u/remove-macros)
182-
(update :name u/remove-macros))])))
181+
#?@(:cljs [true (-> (update :ns misc/remove-macros)
182+
(update :name misc/remove-macros))])))
183183

184184
(defn find-symbol-meta
185185
"Given a namespace-qualified var name, gets the analyzer metadata for that
186186
var."
187187
[env sym]
188-
(let [ns (find-ns env (u/namespace-sym sym))]
188+
(let [ns (find-ns env (misc/namespace-sym sym))]
189189
(some-> (:defs ns)
190-
(get (u/name-sym sym))
190+
(get (misc/name-sym sym))
191191
var-meta)))
192192

193193
(defn special-meta
194194
"Given a special symbol, gets the analyzer metadata."
195195
[_ sym]
196-
(when-let [meta #?(:clj (or (get (u/require-and-resolve 'cljs.repl/special-doc-map) sym)
197-
(get (u/require-and-resolve 'cljs.repl/repl-special-doc-map) sym))
196+
(when-let [meta #?(:clj (or (get (misc/require-and-resolve 'cljs.repl/special-doc-map) sym)
197+
(get (misc/require-and-resolve 'cljs.repl/repl-special-doc-map) sym))
198198
:cljs (or (get special/special-doc-map sym)
199199
(get special/repl-special-doc-map sym)))]
200200
(merge {:name sym

src/orchard/cljs/meta.cljc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:added "0.6.0"}
44
orchard.cljs.meta
55
(:require [orchard.cljs.analysis :as a #?@(:cljs [:include-macros true])]
6-
[orchard.misc :as u #?@(:cljs [:include-macros true])]))
6+
[orchard.misc :as misc #?@(:cljs [:include-macros true])]))
77

88
(defn normalize-ns-meta
99
"Normalize cljs namespace metadata to look like a clj."
@@ -27,7 +27,7 @@
2727
a/var-meta
2828
:file)
2929
:cljs (some-> env
30-
(a/ns-interns-from-env (u/add-ns-macros ns))
30+
(a/ns-interns-from-env (misc/add-ns-macros ns))
3131
first
3232
val
3333
:file))
@@ -56,16 +56,16 @@
5656
(defn scoped-var-meta
5757
[env sym & [context-ns]]
5858
(or (a/find-symbol-meta env sym)
59-
(let [scope (u/namespace-sym sym)
59+
(let [scope (misc/namespace-sym sym)
6060
aliased-ns (a/ns-alias env scope context-ns)
61-
sym (symbol (str (or aliased-ns context-ns) "/" (u/name-sym sym)))]
61+
sym (symbol (str (or aliased-ns context-ns) "/" (misc/name-sym sym)))]
6262
(a/find-symbol-meta env sym))))
6363

6464
(defn macro-namespace
6565
"Compute the namespace of a macro symbol."
6666
[env sym & [context-ns]]
6767
{:pre [(symbol? sym)]}
68-
(let [ns-from-sym (u/as-sym (namespace sym))]
68+
(let [ns-from-sym (misc/as-sym (namespace sym))]
6969
(or (a/macro-ns-alias env ns-from-sym context-ns)
7070
ns-from-sym
7171
context-ns)))
@@ -77,7 +77,7 @@
7777
(when (and ns (find-ns ns))
7878
(some-> env
7979
(a/public-macros #?(:clj ns
80-
:cljs (u/add-ns-macros ns)))
80+
:cljs (misc/add-ns-macros ns)))
8181
(get sym)
8282
a/var-meta))))
8383

@@ -92,7 +92,7 @@
9292
:cljs (let [referred-ns (symbol (namespace referred))
9393
referred-sym (symbol (name referred))]
9494
(-> env
95-
(a/ns-interns-from-env (u/add-ns-macros referred-ns))
95+
(a/ns-interns-from-env (misc/add-ns-macros referred-ns))
9696
(get referred-sym)
9797
a/var-meta))))))
9898

@@ -101,7 +101,7 @@
101101
(let [ns (macro-namespace env sym context-ns)]
102102
(some-> env
103103
(a/macro-ns-alias sym ns)
104-
#?(:cljs u/add-ns-macros)
104+
#?(:cljs misc/add-ns-macros)
105105
find-ns)))
106106

107107
(defn special-sym-meta

src/orchard/info.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[orchard.cljs.meta :as cljs-meta]
1010
[orchard.java :as java]
1111
[orchard.meta :as m]
12-
[orchard.misc :as u]
12+
[orchard.misc :as misc]
1313
[orchard.java.resource :as resource]))
1414

1515
(defn normalize-ns-meta
@@ -58,8 +58,8 @@
5858
;; (name 'mount.core) ;;=> "mount.core
5959
(qualified-symbol? sym)
6060
(assoc :qualified-sym sym
61-
:unqualified-sym (u/name-sym sym)
62-
:computed-ns (u/namespace-sym sym))
61+
:unqualified-sym (misc/name-sym sym)
62+
:computed-ns (misc/namespace-sym sym))
6363

6464
(and sym (not (qualified-symbol? sym)))
6565
(assoc :unqualified-sym (-> sym name symbol))
@@ -181,7 +181,7 @@ resolved (real) namespace and name here"}
181181

182182
(merge (when-let [file-path (:file meta)]
183183
{:file (cond-> file-path
184-
(u/boot-project?) cp/classpath-file-relative-path)})))))
184+
(misc/boot-project?) cp/classpath-file-relative-path)})))))
185185

186186
(defn info
187187
"Provide the info map for the input ns and sym.

src/orchard/java.clj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[clojure.reflect :as r]
88
[clojure.string :as str]
99
[orchard.java.classpath :as cp]
10-
[orchard.misc :as util]
10+
[orchard.misc :as misc]
1111
[orchard.java.resource :as resource])
1212
(:import
1313
(clojure.lang IPersistentMap)
@@ -62,7 +62,7 @@
6262
"The `tools.jar` path, for JDK8 and earlier. If found on the existing
6363
classpath, this is the corresponding classpath entry. Otherwise, if available,
6464
this is added to the classpath."
65-
(when (<= util/java-api-version 8)
65+
(when (<= misc/java-api-version 8)
6666
(or (some-> (io/resource "com/sun/javadoc/Doc.class")
6767
(.. openConnection getJarFileURL))
6868
(some-> (jdk-find "tools.jar") cp/add-classpath!))))
@@ -74,7 +74,7 @@
7474
;; N.b. Where a method's bytecode signature differs from its declared signature
7575
;; (other than collection generics), the javadoc method URL can't be inferred as
7676
;; done below. (Specifically, this applies to varargs and non-collection
77-
;; generics, e.g. `java/util/Arrays.html#asList(T...)`.) Since the member is
77+
;; generics, e.g. `java/misc/Arrays.html#asList(T...)`.) Since the member is
7878
;; just a URL fragment, the javadoc link will simply navigate to the parent
7979
;; class in these cases.
8080

@@ -84,7 +84,7 @@
8484
(defn javadoc-url
8585
"Return the relative `.html` javadoc path and member fragment."
8686
([class]
87-
(let [maybe-module (when (>= util/java-api-version 11)
87+
(let [maybe-module (when (>= misc/java-api-version 11)
8888
(some-> (module-name class) (str "/")))]
8989
(str maybe-module
9090
(-> (str/replace (str class) "." "/")
@@ -93,7 +93,7 @@
9393
([class member argtypes]
9494
(str (javadoc-url class) "#" member
9595
(when argtypes
96-
(if (<= util/java-api-version 9) ; argtypes were munged before Java 10
96+
(if (<= misc/java-api-version 9) ; argtypes were munged before Java 10
9797
(str "-" (str/join "-" (map #(str/replace % #"\[\]" ":A") argtypes)) "-")
9898
(str "(" (str/join "," argtypes) ")"))))))
9999

@@ -108,7 +108,7 @@
108108
(def source-info
109109
"When a Java parser is available, return class info from its parsed source;
110110
otherwise return nil."
111-
(if (>= util/java-api-version 9)
111+
(if (>= misc/java-api-version 9)
112112
(do (require '[orchard.java.parser :as src])
113113
(resolve 'src/source-info))
114114
(if jdk-tools
@@ -120,7 +120,7 @@
120120
"On JDK9+, return module name from the class if present; otherwise return nil"
121121
;; NOTE This function exists in the parser namespace for conditional
122122
;; loading on JDK9+; it does not require parsing.
123-
(if (>= util/java-api-version 9)
123+
(if (>= misc/java-api-version 9)
124124
(resolve 'src/module-name)
125125
(constantly nil)))
126126

@@ -192,7 +192,7 @@
192192
(catch Exception _)
193193
(catch LinkageError _))]
194194
(let [r (JavaReflector. (.getClassLoader c))] ; for dynamically loaded classes
195-
(util/deep-merge (reflect-info (r/reflect c :reflector r))
195+
(misc/deep-merge (reflect-info (r/reflect c :reflector r))
196196
(source-info class)
197197
{:name (-> c .getSimpleName symbol)
198198
:class (-> c .getName symbol)
@@ -355,8 +355,8 @@
355355
;; 8, so we try our own thing first.
356356
(when (re-find #"^(java|javax|jdk|org.omg|org.w3c.dom|org.xml.sax)/" path)
357357
(apply str ["https://docs.oracle.com"
358-
(if (>= util/java-api-version 11) "/en/java/javase/" "/javase/")
359-
util/java-api-version
358+
(if (>= misc/java-api-version 11) "/en/java/javase/" "/javase/")
359+
misc/java-api-version
360360
"/docs/api/"
361361
path]))
362362
;; If that didn't work, _then_ we fallback on `*remote-javadocs*`.

src/orchard/java/classpath.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[clojure.java.io :as io]
55
[clojure.string :as str]
66
[dynapath.util :as dp]
7-
[orchard.misc :as u])
7+
[orchard.misc :as misc])
88
(:import
99
(java.io File)
1010
(java.net URI URL)
@@ -79,7 +79,7 @@
7979
as relative paths"
8080
[^URL url]
8181
(let [f (io/as-file url)]
82-
(if (u/archive? url)
82+
(if (misc/archive? url)
8383
(->> (enumeration-seq (.entries (JarFile. f)))
8484
(filter #(not (.isDirectory ^JarEntry %)))
8585
(map #(.getName ^JarEntry %)))
@@ -107,7 +107,7 @@
107107

108108
(defn boot-aware-classloader
109109
[]
110-
(if (u/boot-project?)
110+
(if (misc/boot-project?)
111111
(boot-classloader)
112112
(context-classloader)))
113113

src/orchard/meta.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[clojure.string :as str]
77
[clojure.walk :as walk]
88
[orchard.namespace :as ns]
9-
[orchard.misc :as u]
9+
[orchard.misc :as misc]
1010
[orchard.spec :as spec]
1111
[orchard.cljs.meta :as cljs-meta])
1212
(:import
@@ -107,9 +107,9 @@
107107
(defn repl-special-meta*
108108
"Return the REPL specials info."
109109
[sym]
110-
(or (when-let [f (u/require-and-resolve 'clojure.repl/special-doc)]
110+
(or (when-let [f (misc/require-and-resolve 'clojure.repl/special-doc)]
111111
(f sym))
112-
(when-let [f (u/require-and-resolve 'cljs.repl/special-doc)]
112+
(when-let [f (misc/require-and-resolve 'cljs.repl/special-doc)]
113113
(f sym))))
114114

115115
(def repl-special-meta

src/orchard/namespace.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[clojure.java.io :as io]
66
[clojure.string :as str]
77
[orchard.java.classpath :as cp]
8-
[orchard.misc :as u])
8+
[orchard.misc :as misc])
99
(:import
1010
(clojure.lang Namespace)
1111
(java.io File PushbackReader)))
@@ -50,7 +50,7 @@
5050
(defn in-project?
5151
"Whether the URL is in the current project's directory"
5252
[url]
53-
(let [path (if (u/os-windows?) (comp str/lower-case str) str)]
53+
(let [path (if (misc/os-windows?) (comp str/lower-case str) str)]
5454
(.startsWith (path url) (path project-root))))
5555

5656
(defn inlined-dependency?
@@ -90,7 +90,7 @@
9090
classpath URLs"
9191
([classpath-urls]
9292
(->> (mapcat cp/classpath-seq classpath-urls)
93-
(filter u/clj-file?)
93+
(filter misc/clj-file?)
9494
(map (comp read-namespace io/resource))
9595
(filter identity)
9696
(sort)))
@@ -101,7 +101,7 @@
101101
"Returns all namespaces defined in sources within the current project."
102102
[]
103103
(->> (cp/classpath)
104-
(filter (every-pred u/directory? in-project?))
104+
(filter (every-pred misc/directory? in-project?))
105105
(classpath-namespaces)))
106106

107107
(defn loaded-project-namespaces

test/orchard/java/classpath_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[clojure.string :as str]
66
[clojure.test :refer :all]
77
[orchard.java.classpath :as cp]
8-
[orchard.misc :as u])
8+
[orchard.misc :as misc])
99
(:import
1010
(java.io File)
1111
(java.net URL)))
@@ -25,7 +25,7 @@
2525
(cp/classpath))))
2626
(testing "directory paths have a trailing slash"
2727
(is (->> (cp/classpath)
28-
(filter u/directory?)
28+
(filter misc/directory?)
2929
(every? #(.endsWith (.getPath %) "/")))))
3030
(testing "contains expected entries"
3131
(let [project-root (System/getProperty "user.dir")]

test/orchard/java_test.clj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
[clojure.test :refer :all]
55
[dynapath.util :as dp]
66
[orchard.java :refer :all]
7-
[orchard.misc :as u]))
7+
[orchard.misc :as misc]))
88

9-
(def jdk-parser? (or (>= u/java-api-version 9) jdk-tools))
9+
(def jdk-parser? (or (>= misc/java-api-version 9) jdk-tools))
1010

1111
(deftest resources-test
1212
;; If the JDK resources we wish to load dynamically are present on the file
@@ -161,7 +161,7 @@
161161
(deftest javadoc-urls-test
162162
(testing "Javadoc URL"
163163
(testing "for Java < 11" ; JDK8 - JDK11
164-
(with-redefs [u/java-api-version 8
164+
(with-redefs [misc/java-api-version 8
165165
cache (atom {})]
166166
(testing "of a class"
167167
(is (= (:javadoc (class-info 'java.lang.String))
@@ -196,9 +196,9 @@
196196
"java/util/Hashtable.html#putAll-java.util.Map-"))))))
197197

198198
;; Java 11+ URLs require module information, which is only available on Java 9+.
199-
(when (>= u/java-api-version 9)
199+
(when (>= misc/java-api-version 9)
200200
(testing "for Java 11+"
201-
(with-redefs [u/java-api-version 11
201+
(with-redefs [misc/java-api-version 11
202202
cache (atom {})]
203203
(testing "of a class"
204204
(is (= (:javadoc (class-info 'java.lang.String))

0 commit comments

Comments
 (0)