Skip to content

Commit

Permalink
Nuke support for Clojure 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Apr 22, 2024
1 parent ea3651f commit 7dfe8d2
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 310 deletions.
5 changes: 2 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:
#
# - run tests against the target matrix
# - Java 8, 11, 17, 21, 22
# - Clojure 1.9, 1.10, 1.11, master
# - Clojure 1.10, 1.11, master
# - linter, eastwood and cljfmt

workflows:
Expand All @@ -192,8 +192,7 @@ workflows:
alias: "test_code_jdk8"
parameters:
jdk_version: [openjdk8]
# Clojure 1.9 is tested only against JDK8.
clojure_version: ["1.9", "1.10", "1.11", "master"]
clojure_version: ["1.10", "1.11", "master"]
test_profiles: ["-user,-dev,+test,-provided", "-user,-dev,+test,+provided"]
# It doesn't make sense to exercise the newer Orchard Java parsers against JDK8
# (given that JDK8 is explicitly excluded by those parsers)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Documentation for the master branch as well as tagged releases are available

## Usage

**orchard requires Clojure 1.8+ and Java 8+.**
**orchard requires Clojure 1.10+ and Java 8+.**

Just add `orchard` as a dependency and start hacking.

Expand Down
8 changes: 2 additions & 6 deletions doc/inspector.org
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ different kinds of objects.
*** Class

Classes are rendered with their name, the implemented interfaces, the
available constructors, their fields and methods. In Clojure versions
>= 1.10 an optional =Datafy= section is added.
available constructors, their fields and methods, and their datafied
representation.

#+begin_src clojure :exports both :results output :wrap example
(inspect/inspect-print Boolean)
Expand Down Expand Up @@ -261,8 +261,6 @@ Since the [[https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/
section will only be rendered if the datafy-ed version of the object
is different than the original object.

Minimum requirement for this feature is a Clojure version >= 1.10.

#+begin_src clojure :exports both :results output :wrap example
(-> {:name "John Doe"}
(with-meta {'clojure.core.protocols/datafy
Expand Down Expand Up @@ -430,8 +428,6 @@ optional =Datafy= section. The ='clojure.core.protocols/nav= function
of the object will be used for navigation, instead of the default
implementation declared on object.

Minimum requirement for this feature is a Clojure version >= 1.10.

#+begin_src clojure :exports both :results output :wrap example
(-> {:name "John Doe"}
(with-meta {'clojure.core.protocols/nav
Expand Down
2 changes: 0 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
[org.clojure/clojure "1.11.2" :classifier "sources"]
[org.clojure/clojurescript "1.11.4"]]
:test-paths ["test-cljs"]}
:1.9 {:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojure "1.9.0" :classifier "sources"]]}
:1.10 {:dependencies [[org.clojure/clojure "1.10.3"]
[org.clojure/clojure "1.10.3" :classifier "sources"]]}
:1.11 {:dependencies [[org.clojure/clojure "1.11.2"]
Expand Down
10 changes: 0 additions & 10 deletions src-newer-jdks/orchard/java/parser_utils.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns orchard.java.parser-utils
"The common parts to the `parser` and `parser-next` namespaces."
{:added "0.15.0"}
(:refer-clojure :exclude [resolve])
(:require
[clojure.java.io :as io]
[clojure.string :as string])
Expand Down Expand Up @@ -88,15 +87,6 @@
{:name (-> f .getSimpleName str symbol)
:type (-> f .asType (typesym env))})

(defn- resolve
"Workaround for CLJ-1403, fixed in Clojure 1.10. Once 1.9 support is
discontinued, this function may simply be removed."
[sym]
(try
(clojure.core/resolve sym)
(catch Exception _
nil)))

(defn module-name
"Return the module name, or nil if modular"
[klass]
Expand Down
10 changes: 0 additions & 10 deletions src/orchard/info.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns orchard.info
"Retrieve the info map from var and symbols."
(:refer-clojure :exclude [qualified-symbol?])
(:require
[clojure.java.io :as io]
[orchard.cljs.analysis :as cljs-ana]
Expand All @@ -20,15 +19,6 @@
[ns sym]
(when sym (symbol (some-> ns str) (str sym))))

(defn qualified-symbol?
"Return true if `x` is a symbol with a namespace
This is only available from Clojure 1.9 so we backport it until we
drop support for Clojure 1.8."
{:added "0.5"}
[x]
(boolean (and (symbol? x) (namespace x) true)))

(defn normalize-params
"Normalize the info params.
Expand Down
20 changes: 4 additions & 16 deletions src/orchard/inspect.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,14 @@
Pretty wild, right?"
(:require
[clojure.core.protocols :refer [datafy nav]]
[clojure.string :as string]
[orchard.misc :as misc]
[orchard.print :as print])
(:import
(java.lang.reflect Constructor Field Method Modifier)
(java.util List Map)))

;; Datafy Nav and tap> are only available since Clojure 1.10
(require 'clojure.core.protocols)

(def ^:private datafy
(misc/call-when-resolved 'clojure.core.protocols/datafy))

(def ^:private nav
(misc/call-when-resolved 'clojure.core.protocols/nav))

(def ^:private maybe-tap>
(misc/call-when-resolved 'clojure.core/tap>))
;;
;; Navigating Inspector State
;;
Expand Down Expand Up @@ -272,13 +262,13 @@
(defn tap-current-value
"Tap the currently inspected value."
[inspector]
(maybe-tap> (:value inspector))
(tap> (:value inspector))
(inspect-render inspector))

(defn tap-indexed
"Tap the value found at `idx`, without navigating to it."
[{:keys [index] :as inspector} idx]
(maybe-tap> (get index idx))
(tap> (get index idx))
(inspect-render inspector))

(defn render-onto [inspector coll]
Expand Down Expand Up @@ -435,9 +425,7 @@
(map datafy data))))

(defn- render-datafy? [inspector obj]
(cond (not misc/datafy?)
false
(map? obj)
(cond (map? obj)
(not= obj (nav-datafy obj false))
(or (sequential? obj) (set? obj))
(not= (chunk-to-display inspector obj)
Expand Down
5 changes: 2 additions & 3 deletions src/orchard/java.clj
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,8 @@
(when (.startsWith classname prefix)
(str url path))))
(into @javadoc/*remote-javadocs*
;; clojure 1.8 has no javadoc for anything beyond java
;; 8. clojure 1.10.1 doesn't have 13. We just backport them
;; regardless of clojure version
;; Older Clojure versions don't have javadoc for newer JDKs.
;; We just backport them regardless of Clojure version.
(zipmap ["java." "javax." "org.ietf.jgss." "org.omg." "org.w3c.dom." "org.xml.sax"]
(repeat (or (javadoc-base-urls misc/java-api-version)
(javadoc-base-urls 11))))))
Expand Down
10 changes: 0 additions & 10 deletions src/orchard/misc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,6 @@
(catch Exception _ nil)))
(some-> sym find-var var-get)))

(def datafy?
"True if Datafy and Nav (added in Clojure 1.10) are supported,
otherwise false."
(some? (resolve 'clojure.core.protocols/datafy)))

(def tap?
"True if tap> (added in Clojure 1.10) is supported,
otherwise false."
(some? (resolve 'clojure.core/tap>)))

(defn call-when-resolved
"Return a fn that calls the fn resolved through `var-sym` with the
arguments passed to it. `var-sym` will be required and resolved
Expand Down
11 changes: 1 addition & 10 deletions src/orchard/xref.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@
[clojure.string :as string]
[orchard.query :as q]))

(defn- var->symbol
;; TODO: use `symbol` once we start targeting Clojure >= 1.10 after CIDER 1.8 is released.
"Normally one could just use `(symbol var-ref)`,
but that doesn't work in older Clojures."
[var-ref]
(let [{:keys [ns name]} (meta var-ref)]
(symbol (str (ns-name ns))
(str name))))

(defn- var->fn [var-ref]
(let [{:keys [test]} (meta var-ref)]
(if (fn? test)
Expand Down Expand Up @@ -99,7 +90,7 @@
;; group duplicates. This is important
;; because there can be two seemingly equal #'foo.bar/baz var objects in the result.
;; That can happen as one re-evaluates code and the old var hasn't been GC'd yet.
(keys (group-by var->symbol result))))))
(keys (group-by symbol result))))))

(defn fn-transitive-deps
"Returns a set with all the functions invoked inside `v` or inside those functions.
Expand Down
Loading

0 comments on commit 7dfe8d2

Please sign in to comment.