|
7 | 7 | [clojure.reflect :as r]
|
8 | 8 | [clojure.string :as str]
|
9 | 9 | [orchard.java.classpath :as cp]
|
10 |
| - [orchard.misc :as util] |
| 10 | + [orchard.misc :as misc] |
11 | 11 | [orchard.java.resource :as resource])
|
12 | 12 | (:import
|
13 | 13 | (clojure.lang IPersistentMap)
|
|
62 | 62 | "The `tools.jar` path, for JDK8 and earlier. If found on the existing
|
63 | 63 | classpath, this is the corresponding classpath entry. Otherwise, if available,
|
64 | 64 | this is added to the classpath."
|
65 |
| - (when (<= util/java-api-version 8) |
| 65 | + (when (<= misc/java-api-version 8) |
66 | 66 | (or (some-> (io/resource "com/sun/javadoc/Doc.class")
|
67 | 67 | (.. openConnection getJarFileURL))
|
68 | 68 | (some-> (jdk-find "tools.jar") cp/add-classpath!))))
|
|
74 | 74 | ;; N.b. Where a method's bytecode signature differs from its declared signature
|
75 | 75 | ;; (other than collection generics), the javadoc method URL can't be inferred as
|
76 | 76 | ;; 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 |
78 | 78 | ;; just a URL fragment, the javadoc link will simply navigate to the parent
|
79 | 79 | ;; class in these cases.
|
80 | 80 |
|
|
84 | 84 | (defn javadoc-url
|
85 | 85 | "Return the relative `.html` javadoc path and member fragment."
|
86 | 86 | ([class]
|
87 |
| - (let [maybe-module (when (>= util/java-api-version 11) |
| 87 | + (let [maybe-module (when (>= misc/java-api-version 11) |
88 | 88 | (some-> (module-name class) (str "/")))]
|
89 | 89 | (str maybe-module
|
90 | 90 | (-> (str/replace (str class) "." "/")
|
|
93 | 93 | ([class member argtypes]
|
94 | 94 | (str (javadoc-url class) "#" member
|
95 | 95 | (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 |
97 | 97 | (str "-" (str/join "-" (map #(str/replace % #"\[\]" ":A") argtypes)) "-")
|
98 | 98 | (str "(" (str/join "," argtypes) ")"))))))
|
99 | 99 |
|
|
108 | 108 | (def source-info
|
109 | 109 | "When a Java parser is available, return class info from its parsed source;
|
110 | 110 | otherwise return nil."
|
111 |
| - (if (>= util/java-api-version 9) |
| 111 | + (if (>= misc/java-api-version 9) |
112 | 112 | (do (require '[orchard.java.parser :as src])
|
113 | 113 | (resolve 'src/source-info))
|
114 | 114 | (if jdk-tools
|
|
120 | 120 | "On JDK9+, return module name from the class if present; otherwise return nil"
|
121 | 121 | ;; NOTE This function exists in the parser namespace for conditional
|
122 | 122 | ;; loading on JDK9+; it does not require parsing.
|
123 |
| - (if (>= util/java-api-version 9) |
| 123 | + (if (>= misc/java-api-version 9) |
124 | 124 | (resolve 'src/module-name)
|
125 | 125 | (constantly nil)))
|
126 | 126 |
|
|
192 | 192 | (catch Exception _)
|
193 | 193 | (catch LinkageError _))]
|
194 | 194 | (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)) |
196 | 196 | (source-info class)
|
197 | 197 | {:name (-> c .getSimpleName symbol)
|
198 | 198 | :class (-> c .getName symbol)
|
|
355 | 355 | ;; 8, so we try our own thing first.
|
356 | 356 | (when (re-find #"^(java|javax|jdk|org.omg|org.w3c.dom|org.xml.sax)/" path)
|
357 | 357 | (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 |
360 | 360 | "/docs/api/"
|
361 | 361 | path]))
|
362 | 362 | ;; If that didn't work, _then_ we fallback on `*remote-javadocs*`.
|
|
0 commit comments