(compile-matcher template)
creates a matcher given a datastructure declaring the actual template
((compile-matcher {:is 'hello}) (nav/parse-string "hello")) => true
creates a matcher given a datastructure declaring the actual template ((compile-matcher {:is 'hello}) (nav/parse-string "hello")) => true
(matcher f)
creates a matcher
((matcher string?) "hello") => true
creates a matcher ((matcher string?) "hello") => true
(matcher? x)
checks if element is a matcher
(matcher? (matcher string?)) => true
checks if element is a matcher (matcher? (matcher string?)) => true
(p-ancestor template)
checks that any parent container matches ((p-ancestor {:form 'if}) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true ((p-ancestor 'if) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true
checks that any parent container matches ((p-ancestor {:form 'if}) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true ((p-ancestor 'if) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true
(p-and & matchers)
takes multiple predicates and ensures that all are correct ((p-and (p-code #"defn") (p-type :token)) (nav/parse-string "(defn ^{:a 1} x [])")) => false
((p-and (p-code #"defn") (p-type :list)) (nav/parse-string "(defn ^{:a 1} x [])")) => true
takes multiple predicates and ensures that all are correct ((p-and (p-code #"defn") (p-type :token)) (nav/parse-string "(defn ^{:a 1} x [])")) => false ((p-and (p-code #"defn") (p-type :list)) (nav/parse-string "(defn ^{:a 1} x [])")) => true
(p-child template)
checks that there is a child of a container that has a certain characteristic ((p-child {:form '=}) (nav/parse-string "(if (= x y))")) => true
((p-child '=) (nav/parse-string "(if (= x y))")) => false
checks that there is a child of a container that has a certain characteristic ((p-child {:form '=}) (nav/parse-string "(if (= x y))")) => true ((p-child '=) (nav/parse-string "(if (= x y))")) => false
(p-code template)
checks if the form matches a string in the form of a regex expression ((p-code #"defn") (nav/parse-string "(defn ^{:a 1} x [])")) => true
checks if the form matches a string in the form of a regex expression ((p-code #"defn") (nav/parse-string "(defn ^{:a 1} x [])")) => true
(p-contains template)
checks that any element (deeply nested also) of the container matches ((p-contains '=) (nav/parse-string "(if (= x y))")) => true
((p-contains 'x) (nav/parse-string "(if (= x y))")) => true
checks that any element (deeply nested also) of the container matches ((p-contains '=) (nav/parse-string "(if (= x y))")) => true ((p-contains 'x) (nav/parse-string "(if (= x y))")) => true
(p-equal template)
checks if the node is equivalent, takes meta into account ((p-equal '^{:a 1} defn) (nav/parse-string "defn")) => false
((p-equal '^{:a 1} defn) (nav/parse-string "^{:a 1} defn")) => true
((p-equal '^{:a 1} defn) (nav/parse-string "^{:a 2} defn")) => false
checks if the node is equivalent, takes meta into account ((p-equal '^{:a 1} defn) (nav/parse-string "defn")) => false ((p-equal '^{:a 1} defn) (nav/parse-string "^{:a 1} defn")) => true ((p-equal '^{:a 1} defn) (nav/parse-string "^{:a 2} defn")) => false
(p-equal-loop expr template)
helper function for p-equal
((p-equal [1 2 3]) (nav/parse-string "[1 2 3]")) => true
((p-equal (list 'defn)) (nav/parse-string "(defn)")) => true
((p-equal '(defn)) (nav/parse-string "(defn)")) => true
helper function for `p-equal` ((p-equal [1 2 3]) (nav/parse-string "[1 2 3]")) => true ((p-equal (list 'defn)) (nav/parse-string "(defn)")) => true ((p-equal '(defn)) (nav/parse-string "(defn)")) => true
(p-first template)
checks that the first element of the container has a certain characteristic ((p-first 'defn) (-> (nav/parse-string "(defn x [])"))) => true
((p-first 'x) (-> (nav/parse-string "[x y z]"))) => true
((p-first 'x) (-> (nav/parse-string "[y z]"))) => false
checks that the first element of the container has a certain characteristic ((p-first 'defn) (-> (nav/parse-string "(defn x [])"))) => true ((p-first 'x) (-> (nav/parse-string "[x y z]"))) => true ((p-first 'x) (-> (nav/parse-string "[y z]"))) => false
(p-fn template)
takes a predicate function to check the state of the zipper ((p-fn (fn [nav] (-> nav (nav/tag) (= :symbol)))) (nav/parse-string "defn")) => true
takes a predicate function to check the state of the zipper ((p-fn (fn [nav] (-> nav (nav/tag) (= :symbol)))) (nav/parse-string "defn")) => true
(p-form template)
checks if it is a form with the symbol as the first element ((p-form 'defn) (nav/parse-string "(defn x [])")) => true ((p-form 'let) (nav/parse-string "(let [])")) => true
checks if it is a form with the symbol as the first element ((p-form 'defn) (nav/parse-string "(defn x [])")) => true ((p-form 'let) (nav/parse-string "(let [])")) => true
(p-is template)
checks if node is equivalent, does not meta into account ((p-is 'defn) (nav/parse-string "defn")) => true
((p-is '^{:a 1} defn) (nav/parse-string "defn")) => true
((p-is 'defn) (nav/parse-string "is")) => false
((p-is '(defn & _)) (nav/parse-string "(defn x [])")) => false
checks if node is equivalent, does not meta into account ((p-is 'defn) (nav/parse-string "defn")) => true ((p-is '^{:a 1} defn) (nav/parse-string "defn")) => true ((p-is 'defn) (nav/parse-string "is")) => false ((p-is '(defn & _)) (nav/parse-string "(defn x [])")) => false
(p-last template)
checks that the last element of the container has a certain characteristic ((p-last 1) (-> (nav/parse-string "(defn [] 1)"))) => true
((p-last 'z) (-> (nav/parse-string "[x y z]"))) => true
((p-last 'x) (-> (nav/parse-string "[y z]"))) => false
checks that the last element of the container has a certain characteristic ((p-last 1) (-> (nav/parse-string "(defn [] 1)"))) => true ((p-last 'z) (-> (nav/parse-string "[x y z]"))) => true ((p-last 'x) (-> (nav/parse-string "[y z]"))) => false
(p-left template)
checks that the element on the left has a certain characteristic ((p-left '=) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next nav/next)) => true
((p-left 'if) (-> (nav/parse-string "(if (= x y))") nav/down nav/next)) => true
checks that the element on the left has a certain characteristic ((p-left '=) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next nav/next)) => true ((p-left 'if) (-> (nav/parse-string "(if (= x y))") nav/down nav/next)) => true
(p-left-most bool)
checks that any element on the right has a certain characteristic ((p-left-most true) (-> (nav/parse-string "(= x y)") nav/down)) => true
((p-left-most true) (-> (nav/parse-string "(= x y)") nav/down nav/next)) => false
checks that any element on the right has a certain characteristic ((p-left-most true) (-> (nav/parse-string "(= x y)") nav/down)) => true ((p-left-most true) (-> (nav/parse-string "(= x y)") nav/down nav/next)) => false
(p-left-of template)
checks that any element on the left has a certain characteristic ((p-left-of '=) (-> (nav/parse-string "(= x y)") nav/down nav/next)) => true
((p-left-of '=) (-> (nav/parse-string "(= x y)") nav/down nav/next nav/next)) => true
checks that any element on the left has a certain characteristic ((p-left-of '=) (-> (nav/parse-string "(= x y)") nav/down nav/next)) => true ((p-left-of '=) (-> (nav/parse-string "(= x y)") nav/down nav/next nav/next)) => true
(p-meta template)
checks if meta is the same ((p-meta {:a 1}) (nav/down (nav/parse-string "^{:a 1} defn"))) => true
((p-meta {:a 1}) (nav/down (nav/parse-string "^{:a 2} defn"))) => false
checks if meta is the same ((p-meta {:a 1}) (nav/down (nav/parse-string "^{:a 1} defn"))) => true ((p-meta {:a 1}) (nav/down (nav/parse-string "^{:a 2} defn"))) => false
(p-not matcher)
checks if node is the inverse of the given matcher
((p-not (p-is 'if)) (nav/parse-string "defn")) => true
((p-not (p-is 'if)) (nav/parse-string "if")) => false
checks if node is the inverse of the given matcher ((p-not (p-is 'if)) (nav/parse-string "defn")) => true ((p-not (p-is 'if)) (nav/parse-string "if")) => false
(p-nth [num template])
checks that the last element of the container has a certain characteristic ((p-nth [0 'defn]) (-> (nav/parse-string "(defn [] 1)"))) => true
((p-nth [2 'z]) (-> (nav/parse-string "[x y z]"))) => true
((p-nth [2 'x]) (-> (nav/parse-string "[y z]"))) => false
checks that the last element of the container has a certain characteristic ((p-nth [0 'defn]) (-> (nav/parse-string "(defn [] 1)"))) => true ((p-nth [2 'z]) (-> (nav/parse-string "[x y z]"))) => true ((p-nth [2 'x]) (-> (nav/parse-string "[y z]"))) => false
(p-nth-ancestor [num template])
search for match n-levels up
((p-nth-ancestor [2 {:contains 3}]) (-> (nav/parse-string "(* (- (+ 1 2) 3) 4)") nav/down nav/right nav/down nav/right nav/down)) => true
search for match n-levels up ((p-nth-ancestor [2 {:contains 3}]) (-> (nav/parse-string "(* (- (+ 1 2) 3) 4)") nav/down nav/right nav/down nav/right nav/down)) => true
(p-nth-contains [num template])
search for match n-levels down
((p-nth-contains [2 {:contains 1}]) (nav/parse-string "(* (- (+ 1 2) 3) 4)")) => true
search for match n-levels down ((p-nth-contains [2 {:contains 1}]) (nav/parse-string "(* (- (+ 1 2) 3) 4)")) => true
(p-nth-left [num template])
checks that the last element of the container has a certain characteristic ((p-nth-left [0 'defn]) (-> (nav/parse-string "(defn [] 1)") nav/down)) => true
((p-nth-left [1 ^:& vector?]) (-> (nav/parse-string "(defn [] 1)") nav/down nav/right-most)) => true
checks that the last element of the container has a certain characteristic ((p-nth-left [0 'defn]) (-> (nav/parse-string "(defn [] 1)") nav/down)) => true ((p-nth-left [1 ^:& vector?]) (-> (nav/parse-string "(defn [] 1)") nav/down nav/right-most)) => true
(p-nth-right [num template])
checks that the last element of the container has a certain characteristic ((p-nth-right [0 'defn]) (-> (nav/parse-string "(defn [] 1)") nav/down)) => true
((p-nth-right [1 vector?]) (-> (nav/parse-string "(defn [] 1)") nav/down)) => true
checks that the last element of the container has a certain characteristic ((p-nth-right [0 'defn]) (-> (nav/parse-string "(defn [] 1)") nav/down)) => true ((p-nth-right [1 vector?]) (-> (nav/parse-string "(defn [] 1)") nav/down)) => true
(p-or & matchers)
takes multiple predicates and ensures that at least one is correct ((p-or (p-code #"defn") (p-type :token)) (nav/parse-string "(defn ^{:a 1} x [])")) => true
((p-or (p-code #"defn") (p-type :list)) (nav/parse-string "(defn ^{:a 1} x [])")) => true
takes multiple predicates and ensures that at least one is correct ((p-or (p-code #"defn") (p-type :token)) (nav/parse-string "(defn ^{:a 1} x [])")) => true ((p-or (p-code #"defn") (p-type :list)) (nav/parse-string "(defn ^{:a 1} x [])")) => true
(p-parent template)
checks that the parent of the element contains a certain characteristic ((p-parent 'defn) (-> (nav/parse-string "(defn x [])") nav/next nav/next)) => true
((p-parent {:parent 'if}) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true
((p-parent {:parent 'if}) (-> (nav/parse-string "(if (= x y))") nav/down)) => false
checks that the parent of the element contains a certain characteristic ((p-parent 'defn) (-> (nav/parse-string "(defn x [])") nav/next nav/next)) => true ((p-parent {:parent 'if}) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true ((p-parent {:parent 'if}) (-> (nav/parse-string "(if (= x y))") nav/down)) => false
(p-pattern template)
checks if the form matches a particular pattern ((p-pattern '(defn ^:% symbol? & _)) (nav/parse-string "(defn ^{:a 1} x [])")) => true
((p-pattern '(defn ^:% symbol? ^{:% true :? true} string? [])) (nav/parse-string "(defn ^{:a 1} x [])")) => true
checks if the form matches a particular pattern ((p-pattern '(defn ^:% symbol? & _)) (nav/parse-string "(defn ^{:a 1} x [])")) => true ((p-pattern '(defn ^:% symbol? ^{:% true :? true} string? [])) (nav/parse-string "(defn ^{:a 1} x [])")) => true
(p-right template)
checks that the element on the right has a certain characteristic ((p-right 'x) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true
((p-right {:form '=}) (-> (nav/parse-string "(if (= x y))") nav/down)) => true
checks that the element on the right has a certain characteristic ((p-right 'x) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true ((p-right {:form '=}) (-> (nav/parse-string "(if (= x y))") nav/down)) => true
(p-right-most bool)
checks that any element on the right has a certain characteristic ((p-right-most true) (-> (nav/parse-string "(= x y)") nav/down nav/next)) => false
((p-right-most true) (-> (nav/parse-string "(= x y)") nav/down nav/next nav/next)) => true
checks that any element on the right has a certain characteristic ((p-right-most true) (-> (nav/parse-string "(= x y)") nav/down nav/next)) => false ((p-right-most true) (-> (nav/parse-string "(= x y)") nav/down nav/next nav/next)) => true
(p-right-of template)
checks that any element on the right has a certain characteristic ((p-right-of 'x) (-> (nav/parse-string "(= x y)") nav/down)) => true
((p-right-of 'y) (-> (nav/parse-string "(= x y)") nav/down)) => true
((p-right-of 'z) (-> (nav/parse-string "(= x y)") nav/down)) => false
checks that any element on the right has a certain characteristic ((p-right-of 'x) (-> (nav/parse-string "(= x y)") nav/down)) => true ((p-right-of 'y) (-> (nav/parse-string "(= x y)") nav/down)) => true ((p-right-of 'z) (-> (nav/parse-string "(= x y)") nav/down)) => false
(p-sibling template)
checks that any element on the same level has a certain characteristic ((p-sibling '=) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => false
((p-sibling 'x) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true
checks that any element on the same level has a certain characteristic ((p-sibling '=) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => false ((p-sibling 'x) (-> (nav/parse-string "(if (= x y))") nav/down nav/next nav/next)) => true
(p-type template)
check on the type of element ((p-type :symbol) (nav/parse-string "defn")) => true
((p-type :symbol) (-> (nav/parse-string "^{:a 1} defn") nav/down nav/right)) => true
check on the type of element ((p-type :symbol) (nav/parse-string "defn")) => true ((p-type :symbol) (-> (nav/parse-string "^{:a 1} defn") nav/down nav/right)) => true
(tree-depth-search nav m-fn level dir1 dir2)
helper function for p-nth-contains
helper function for p-nth-contains
(tree-search nav m-fn dir1 dir2)
helper function for p-contains
helper function for p-contains
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close