Skip to content

Commit 3e4d4ee

Browse files
Revert clojure.string alias back to str
1 parent 82e4af4 commit 3e4d4ee

26 files changed

+135
-136
lines changed

.clj-kondo/config.edn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
:linters {:unused-private-var {:level :warning
55
:exclude [orchard.query-test/a-private orchard.query-test/docd-fn]}
66
:unresolved-symbol {:exclude [(clojure.test/is [match?])]}
7-
:consistent-alias {:aliases {clojure.string string}}
87
;; Enable this opt-in linter:
98
:unsorted-required-namespaces {:level :warning}}}

src/orchard/cljs/analysis.cljc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:added "0.5"}
55
(:refer-clojure :exclude [all-ns find-ns find-var ns-aliases ns-resolve])
66
(:require
7-
[clojure.string :as string]
7+
[clojure.string :as str]
88
[orchard.misc :as misc]))
99

1010
(defn all-ns [{namespaces :cljs.analyzer/namespaces}]
@@ -210,7 +210,7 @@
210210
* a var that is alias-qualified e.g. `foo/bar`."
211211
[env ns sym]
212212
(let [[referred-var-ns referred-var-symbol :as referred]
213-
(some-> env (referred-vars ns) (get sym) (str) (string/split #"/") (->> (map symbol)))]
213+
(some-> env (referred-vars ns) (get sym) (str) (str/split #"/") (->> (map symbol)))]
214214
(if referred
215215
(find-symbol-meta env referred-var-ns referred-var-symbol)
216216
(let [sym-ns (some-> sym namespace symbol)

src/orchard/indent.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"`:style/indent` inference."
33
(:require
44
[clojure.set :as set]
5-
[clojure.string :as string])
5+
[clojure.string :as str])
66
(:import
77
(java.util List)))
88

@@ -115,7 +115,7 @@
115115
(find clojure-mode-indents-fuzzy macro-name)
116116
(->> clojure-mode-indents-fuzzy
117117
(some (fn [[k _v :as entry]]
118-
(when (string/includes? macro-name k)
118+
(when (str/includes? macro-name k)
119119
entry)))))
120120
one-arglist? (-> arglists count (= 1))
121121
def-like? (re-find #"^def" macro-name)

src/orchard/inspect.clj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Pretty wild, right?"
1111
(:require
1212
[clojure.core.protocols :refer [datafy nav]]
13-
[clojure.string :as string]
13+
[clojure.string :as str]
1414
[orchard.print :as print])
1515
(:import
1616
(java.lang.reflect Constructor Field Method Modifier)
@@ -556,7 +556,7 @@
556556
(defn- render-indent-str-lines [inspector s]
557557
(reduce #(-> (render-indent %1 (str %2))
558558
(render-ln))
559-
inspector (string/split-lines s)))
559+
inspector (str/split-lines s)))
560560

561561
(defmethod inspect :string [inspector ^java.lang.String obj]
562562
(-> (render-class-name inspector obj)
@@ -581,13 +581,13 @@
581581
;; Ugly as hell, but easier than reimplementing all custom printing that
582582
;; java.lang.reflect does.
583583
(as-> member-string s
584-
(string/replace s #"[\w\.]+\.(\w+\()" "$1") ;; remove class from method name
585-
(string/replace s #"[\w\.]+\.(\w+)$" "$1") ;; remove class from field name
584+
(str/replace s #"[\w\.]+\.(\w+\()" "$1") ;; remove class from method name
585+
(str/replace s #"[\w\.]+\.(\w+)$" "$1") ;; remove class from field name
586586
;; Class might not have a canonical name, as per `.getCanonicalName` doc.
587587
(if-let [canonical (.getCanonicalName class)]
588-
(string/replace s canonical (.getSimpleName class))
588+
(str/replace s canonical (.getSimpleName class))
589589
s)
590-
(string/replace s #"java.lang.([A-Z])" "$1")))
590+
(str/replace s #"java.lang.([A-Z])" "$1")))
591591

592592
(defmethod inspect :default [inspector obj]
593593
(let [class-chain (loop [c (class obj), res ()]
@@ -763,7 +763,7 @@
763763
(if (and (seq path) (not-any? #(= % '<unknown>) path))
764764
(-> (render-section-header inspector "Path")
765765
(indent)
766-
(render-indent (string/join " " (:path inspector)))
766+
(render-indent (str/join " " (:path inspector)))
767767
(unindent))
768768
inspector)))
769769

src/orchard/java.clj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
(:require
55
[clojure.java.javadoc :as javadoc]
66
[clojure.reflect :as reflect]
7-
[clojure.string :as string]
7+
[clojure.string :as str]
88
[orchard.java.resource :as resource]
99
[orchard.java.source-files :as src-files]
1010
[orchard.misc :as misc]
@@ -71,8 +71,8 @@
7171
(defn javadoc-url
7272
"Return the relative `.html` javadoc path and member fragment."
7373
([class]
74-
(let [url (str (-> (string/replace (str class) "." "/")
75-
(string/replace "$" "."))
74+
(let [url (str (-> (str/replace (str class) "." "/")
75+
(str/replace "$" "."))
7676
".html")
7777
;; As of Java 11, Javadoc URLs begin with the module name.
7878
module (module-name class)]
@@ -82,8 +82,8 @@
8282
(str (javadoc-url class) "#" member
8383
(when argtypes
8484
(if (< misc/java-api-version 11) ; argtypes were munged before Java 11
85-
(str "-" (string/join "-" (map #(string/replace % #"\[\]" ":A") argtypes)) "-")
86-
(str "(" (string/join "," argtypes) ")"))))))
85+
(str "-" (str/join "-" (map #(str/replace % #"\[\]" ":A") argtypes)) "-")
86+
(str "(" (str/join "," argtypes) ")"))))))
8787

8888
;;; ## Class Metadata Assembly
8989
;;
@@ -105,7 +105,7 @@
105105
;; make the format match with that of `parser-next`:
106106
(mapv #(some-> %
107107
str
108-
(string/replace "$" ".")
108+
(str/replace "$" ".")
109109
symbol
110110
typesym)
111111
argtypes))
@@ -193,12 +193,12 @@
193193
sb (StringBuilder.)
194194
package-re (when package
195195
(re-pattern (str "^"
196-
(string/replace package "." "\\.")
196+
(str/replace package "." "\\.")
197197
"\\.")))
198198
shorten (fn [s]
199199
(cond-> s
200-
package (string/replace package-re "")
201-
true (string/replace #"^java\.lang\." "")))
200+
package (str/replace package-re "")
201+
true (str/replace #"^java\.lang\." "")))
202202
fill-arglist!
203203
(fn []
204204
(into []

src/orchard/java/parser_next.clj

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
{:added "0.15.0"}
2222
(:require
2323
[clojure.java.io :as io]
24-
[clojure.string :as string]
24+
[clojure.string :as str]
2525
[orchard.java.modules :as modules]
2626
[orchard.java.source-files :as src-files]
2727
[orchard.misc :as misc])
@@ -126,12 +126,12 @@
126126
"Using parse tree info, return the type's name equivalently to the `typesym`
127127
function in `orchard.java`."
128128
([n ^DocletEnvironment env]
129-
(let [t (string/replace (str n) #"<.*>" "") ; drop generics
129+
(let [t (str/replace (str n) #"<.*>" "") ; drop generics
130130
util (.getElementUtils env)]
131131
(if-let [c (.getTypeElement util t)]
132132
(let [pkg (str (.getPackageOf util c) ".")
133-
cls (-> (string/replace-first t pkg "")
134-
(string/replace "." "$"))]
133+
cls (-> (str/replace-first t pkg "")
134+
(str/replace "." "$"))]
135135
(symbol (str pkg cls))) ; classes
136136
(symbol t))))) ; primitives
137137

@@ -294,15 +294,15 @@
294294
xs))
295295

296296
(defn remove-left-margin [s]
297-
(->> (string/split s #"\r?\n" -1) ;; split-lines without losing trailing newlines
297+
(->> (str/split s #"\r?\n" -1) ;; split-lines without losing trailing newlines
298298
(map-indexed (fn [i s]
299299
(let [first? (zero? i)
300-
blank? (string/blank? s)]
300+
blank? (str/blank? s)]
301301
(cond-> s
302302
(and (not first?)
303303
(not blank?))
304-
(string/replace #"^ +" "")))))
305-
(string/join "\n")))
304+
(str/replace #"^ +" "")))))
305+
(str/join "\n")))
306306

307307
(defn cleanup-whitespace [fragments]
308308
(into []
@@ -311,13 +311,13 @@
311311
:as x}]
312312
(let [text? (= content-type "text")]
313313
(assoc x :content (-> content
314-
(string/replace #"^ +" " ")
315-
(string/replace #" +$" " ")
316-
(string/replace #"\s*\n+\s*\n+\s*" "\n\n")
317-
(string/replace #"\n +$" "\n")
314+
(str/replace #"^ +" " ")
315+
(str/replace #" +$" " ")
316+
(str/replace #"\s*\n+\s*\n+\s*" "\n\n")
317+
(str/replace #"\n +$" "\n")
318318
(cond-> text? remove-left-margin
319-
text? (string/replace #"^ +\." ".")
320-
text? (string/replace #"^ +," ",")))))))
319+
text? (str/replace #"^ +\." ".")
320+
text? (str/replace #"^ +," ",")))))))
321321
fragments))
322322

323323
(defn docstring
@@ -345,7 +345,7 @@
345345
:found-closing-tags-types
346346
found-closing-tags-types))
347347
:result)]
348-
{:doc (some-> env .getElementUtils (.getDocComment e) string/trim)
348+
{:doc (some-> env .getElementUtils (.getDocComment e) str/trim)
349349
:doc-first-sentence-fragments (-> first-sentence coalesce cleanup-whitespace)
350350
:doc-fragments (-> full-body coalesce cleanup-whitespace)
351351
:doc-block-tags-fragments (-> block-tags coalesce cleanup-whitespace)}))
@@ -382,12 +382,12 @@
382382
(= kind TypeKind/TYPEVAR)
383383
(upper-bound type))
384384
str
385-
(string/replace #"<.*>" "") ;; Remove generics
385+
(str/replace #"<.*>" "") ;; Remove generics
386386
symbol)]
387387
(some-> (or best
388388
(type->sym element))
389389
str
390-
(string/replace "$" ".")
390+
(str/replace "$" ".")
391391
symbol)))
392392
parameters)
393393
:argnames (mapv #(-> ^VariableElement % .getSimpleName str symbol) (.getParameters m))}))

src/orchard/java/source_files.clj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{:author "Oleksandr Yakushev"
55
:added "0.29"}
66
(:require [clojure.java.io :as io]
7-
[clojure.string :as string]
7+
[clojure.string :as str]
88
[orchard.misc :as misc])
99
(:import (java.io File IOException)
1010
(java.net URL)))
@@ -44,14 +44,14 @@
4444
(let [module (when (>= misc/java-api-version 11)
4545
((requiring-resolve 'orchard.java.modules/module-name) klass))
4646
classfile-name (-> (.getName klass)
47-
(string/replace #"\$.*" "") ;; Drop internal class.
48-
(string/replace "." "/")
47+
(str/replace #"\$.*" "") ;; Drop internal class.
48+
(str/replace "." "/")
4949
(str ".class"))]
5050
(cond->> classfile-name
5151
module (format "%s/%s" module))))
5252

5353
(defn- classfile-path->sourcefile-path [classfile-name]
54-
(string/replace classfile-name #"\.class$" ".java"))
54+
(str/replace classfile-name #"\.class$" ".java"))
5555

5656
(defn class->sourcefile-path
5757
"Infer a relative path to a source file of the given `klass`."
@@ -82,7 +82,7 @@
8282
;; function that prefixes the URL with jar:. This is fine.
8383
(try
8484
(let [uri-str (str (.toURI archive))]
85-
(when (string/starts-with? uri-str "file:")
85+
(when (str/starts-with? uri-str "file:")
8686
(io/as-url (format "jar:%s!/%s" uri-str relative-filename))))
8787
;; Exceptions might happen when creating an URL, protect users from them.
8888
(catch java.net.MalformedURLException _)))
@@ -169,7 +169,7 @@
169169
(recur (cons name acc) parent)
170170
acc)))]
171171
{:artifact artifact
172-
:group (string/join "." group-parts)
172+
:group (str/join "." group-parts)
173173
:version version})))
174174

175175
#_(infer-maven-coordinates-for-class clojure.lang.PersistentVector)
@@ -192,14 +192,14 @@
192192
#_(download-sources-using-invoke-tool (infer-maven-coordinates-for-class clojure.lang.PersistentVector))
193193

194194
(defn- run-subprocess [args]
195-
(println "[Orchard] Invoking subprocess:" (string/join " " args))
195+
(println "[Orchard] Invoking subprocess:" (str/join " " args))
196196
(let [process (.start (ProcessBuilder. ^java.util.List args))]
197197
(.waitFor process)
198198
(let [out (slurp (.getInputStream process))
199199
err (slurp (.getErrorStream process))]
200-
(when-not (string/blank? out)
200+
(when-not (str/blank? out)
201201
(println out))
202-
(when-not (string/blank? err)
202+
(when-not (str/blank? err)
203203
(binding [*out* *err*] (println err))))
204204
(.exitValue process)))
205205

src/orchard/meta.clj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(:require
44
[clojure.java.io :as io]
55
[clojure.pprint :as pprint]
6-
[clojure.string :as string]
6+
[clojure.string :as str]
77
[clojure.walk :as walk]
88
[orchard.cljs.analysis :as cljs-ana]
99
[orchard.clojuredocs :as cljdocs]
@@ -21,13 +21,13 @@
2121
(if (seq? description)
2222
(str "(" (->> description
2323
(map #(with-out-str (pprint/pprint %)))
24-
string/join
25-
string/trim-newline)
24+
str/join
25+
str/trim-newline)
2626
")")
2727
(->> description
2828
pprint/pprint
2929
with-out-str
30-
string/trim-newline)))
30+
str/trim-newline)))
3131

3232
(defn format-spec
3333
"Return sequence of [role spec-description] pairs."
@@ -52,7 +52,7 @@
5252
entry pointing to https://clojure.org/..."
5353
[info]
5454
(if-let [url (cond
55-
(not (string/blank? (:url info)))
55+
(not (str/blank? (:url info)))
5656
(str "https://clojure.org/" (:url info))
5757

5858
(:special-form info)
@@ -128,10 +128,10 @@
128128
- some.ns$eval1234$closing_over_fn__12345.invoke"
129129
[sym]
130130
(let [demunged (-> (Compiler/demunge (str sym))
131-
(string/replace #"--\d+" ""))
131+
(str/replace #"--\d+" ""))
132132
[_ wo-method] (re-matches #"(.+?)(?:\.(?:invoke|invokeStatic|doInvoke))?"
133133
demunged)
134-
[ns-str name-str] (->> (string/split wo-method #"/")
134+
[ns-str name-str] (->> (str/split wo-method #"/")
135135
(remove #(re-matches #"eval\d+" %)))
136136
ns (some-> ns-str symbol find-ns)
137137
resolved (when (and ns name-str)
@@ -297,10 +297,10 @@
297297
"(not documented)"))
298298
([n v]
299299
(->> (-> (var-doc v)
300-
(string/replace #"\s+" " ") ; normalize whitespace
301-
(string/split #"(?<=\.) ")) ; split sentences
300+
(str/replace #"\s+" " ") ; normalize whitespace
301+
(str/split #"(?<=\.) ")) ; split sentences
302302
(take n)
303-
(string/join " "))))
303+
(str/join " "))))
304304

305305
(defn var-code
306306
"Find the source of the var `v`.

src/orchard/misc.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(:refer-clojure :exclude [update-keys update-vals])
44
(:require
55
[clojure.java.io :as io]
6-
[clojure.string :as string]
6+
[clojure.string :as str]
77
[orchard.util.io :as util.io])
88
(:import
99
(java.util.concurrent.locks ReentrantLock)))
@@ -105,7 +105,7 @@
105105
"Parse a Java version string according to JEP 223 and return the appropriate
106106
version."
107107
[java-ver]
108-
(try (let [[major minor _] (string/split java-ver #"\.")
108+
(try (let [[major minor _] (str/split java-ver #"\.")
109109
major (Integer/parseInt major)]
110110
(if (> major 1)
111111
major
@@ -129,7 +129,7 @@
129129
[sym]
130130
(some-> sym
131131
str
132-
(string/replace #"\$macros" "")
132+
(str/replace #"\$macros" "")
133133
symbol))
134134

135135
(defn ns-obj?

0 commit comments

Comments
 (0)