Liking cljdoc? Tell your friends :D

code.query.match


compile-matcherclj

(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
raw docstring

matcherclj

(matcher f)

creates a matcher

((matcher string?) "hello") => true

creates a matcher

((matcher string?) "hello")
=> true
raw docstring

matcher?clj

(matcher? x)

checks if element is a matcher

(matcher? (matcher string?)) => true

checks if element is a matcher

(matcher? (matcher string?))
=> true
raw docstring

p-ancestorclj

(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
raw docstring

p-andclj

(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
raw docstring

p-childclj

(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
raw docstring

p-codeclj

(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
raw docstring

p-containsclj

(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
raw docstring

p-equalclj

(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
raw docstring

p-equal-loopclj

(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
raw docstring

p-firstclj

(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
raw docstring

p-fnclj

(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
raw docstring

p-formclj

(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
raw docstring

p-isclj

(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
raw docstring

p-lastclj

(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
raw docstring

p-leftclj

(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
raw docstring

p-left-mostclj

(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
raw docstring

p-left-ofclj

(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
raw docstring

p-metaclj

(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
raw docstring

p-notclj

(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
raw docstring

p-nthclj

(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
raw docstring

p-nth-ancestorclj

(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
raw docstring

p-nth-containsclj

(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
raw docstring

p-nth-leftclj

(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
raw docstring

p-nth-rightclj

(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
raw docstring

p-orclj

(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
raw docstring

p-parentclj

(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
raw docstring

p-patternclj

(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
raw docstring

p-rightclj

(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
raw docstring

p-right-mostclj

(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
raw docstring

p-right-ofclj

(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
raw docstring

p-siblingclj

(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
raw docstring

p-typeclj

(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
raw docstring

(tree-depth-search nav m-fn level dir1 dir2)

helper function for p-nth-contains

helper function for p-nth-contains
raw docstring

(tree-search nav m-fn dir1 dir2)

helper function for p-contains

helper function for p-contains
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close