Skip to content

Nuke support for Clojure 1.9 #245

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

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## Changes

* [#245](https://github.com/clojure-emacs/orchard/issues/245): Drop support for Clojure 1.9.
* [#241](https://github.com/clojure-emacs/orchard/issues/241): Extract inspector value printing into a separate namespace `orchard.print`.
* [#244](https://github.com/clojure-emacs/orchard/issues/244): Make `orchard.inspect/start` the single entrypoint to the inspector, deprecate `orchard.inspect/fresh` and `orchard.inspect/clear`.

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
21 changes: 4 additions & 17 deletions src/orchard/inspect.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,13 @@

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 +261,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 +424,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
32 changes: 13 additions & 19 deletions src/orchard/java.clj
Original file line number Diff line number Diff line change
Expand Up @@ -516,20 +516,16 @@
:class
type-info)))

(def javadoc-base-urls
"Copied from clojure.java.javadoc. These are the base urls for
javadocs from `clojure.java.javadoc/*core-java-api*`. It is here for
two reasons:
1. Add Java 13+ to this list
2. Backport newer data to older Clojure releases"
{8 "https://docs.oracle.com/javase/8/docs/api/"
9 "https://docs.oracle.com/javase/9/docs/api/"
10 "https://docs.oracle.com/javase/10/docs/api/"
11 "https://docs.oracle.com/en/java/javase/11/docs/api/"
12 "https://docs.oracle.com/en/java/javase/12/docs/api/"
13 "https://docs.oracle.com/en/java/javase/13/docs/api/"
14 "https://docs.oracle.com/en/java/javase/14/docs/api/"
15 "https://docs.oracle.com/en/java/javase/15/docs/api/"})
(defn javadoc-base-url
"Re-implementation of `clojure.java.javadoc/*core-java-api*` because it doesn't
contain newer JDK versions, especially in older Clojure."
[jdk-version]
(cond (<= jdk-version 10)
(format "https://docs.oracle.com/javase/%s/docs/api/" jdk-version)
(<= 11 jdk-version 22)
(format "https://docs.oracle.com/en/java/javase/%s/docs/api/" jdk-version)
:else ;; For newer JDK version, default to latest LTS.
(recur 21)))

(defn resolve-javadoc-path
"Resolve a relative javadoc path to a URL and return as a map. Prefer javadoc
Expand All @@ -542,12 +538,10 @@
(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))))))
(repeat (javadoc-base-url misc/java-api-version)))))
path))

(defn- initialize-cache!* []
Expand Down
31 changes: 9 additions & 22 deletions src/orchard/misc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,18 @@
(apply f (filter identity xs))))

(defn parse-java-version
"Parse a Java version string according to JEP 223 and return the appropriate version."
"Parse a Java version string according to JEP 223 and return the appropriate
version."
[java-ver]
(try
;; the no-opt split is because a java version string can end with
;; an optional string consisting of a hyphen followed by other characters
(let [[no-opt _] (string/split java-ver #"-")
[major minor _] (string/split no-opt #"\.")
major (Integer/parseInt major)]
(if (> major 1)
major
(Integer/parseInt (or minor "7"))))
(catch Exception _ 7)))
(try (let [[major minor _] (string/split java-ver #"\.")
major (Integer/parseInt major)]
(if (> major 1)
major
(Integer/parseInt minor)))
(catch Exception _ 8)))

(def java-api-version
(parse-java-version (System/getProperty "java.version")))
(parse-java-version (System/getProperty "java.specification.version")))

;; TODO move back to analysis.cljs
(defn add-ns-macros
Expand Down Expand Up @@ -160,16 +157,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