Back
as-relative-path (clj)
(source)function
(as-relative-path x)
Take an as-file-able thing and return a string if it is
a relative path, else IllegalArgumentException.
Examples
clojure-lsp/clojure-lsp
(ns integration.java-interop-test
(:require
[clojure.java.io :as io]
[clojure.string :as string]
[clojure.test :refer [deftest is testing]]
[integration.fixture :as fixture]
[integration.helper :as h]
[integration.lsp :as lsp]))
(let [result (lsp/request! (fixture/definition-request (h/source-path->uri "java_interop/a.clj") 9 5))]
(testing "We find java compiled class first"
(h/assert-submap
{:uri (-> "integration-test/sample-test/.lsp/.cache/java/decompiled/clojure/lang/PersistentVector.java"
io/as-relative-path
io/file
h/file->uri)
:range {:start {:line 0 :character 0}
:end {:line 0 :character 0}}}
result))
(let [result (lsp/request! (fixture/definition-request (h/source-path->uri "java_interop/a.clj") 9 5))]
(testing "We find java compiled class first"
(h/assert-submap
{:uri (-> "integration-test/sample-test/.lsp/.cache/java/decompiled/clojure/lang/PersistentVector.java"
io/as-relative-path
io/file
h/file->uri)
:range {:start {:line 0 :character 0}
:end {:line 0 :character 0}}}
result))
reborg/clojure-essential-reference
(require '[clojure.java.io :as io])
(map io/as-relative-path (file-seq (io/file "root"))) ; <3>
;; ("root" "root/a" "root/c" "root/c/1" "root/b")