Function: combobulate-query-search

combobulate-query-search is a natively compiled function defined in combobulate-navigation.el.

Signature

(combobulate-query-search QUERY-NODE QUERY &optional LABELLED-NODES-ONLY NO-LABELS NESTED-LABELS)

Documentation

Execute QUERY starting at QUERY-NODE.

QUERY must be a well-formed query. The query language is very similar, but not identical, to that of tree-sitter's own query language.

Supported constructs:

  (start-node (node)) matches start-node against query-node and
  matches if start-node has a child node.

  (_) can be used in lieu of an explicit node name to match any
  named node.

  _ can be used in lieu of an explicit node name to match any
  named or anonymous node.

  (start-node field: (match-node)) asserts that start-node
  must have a field named field followed by a match-node.

  @label, !label and *label are used to name node
  sequences. @label returns the node; !label returns the
  node text; and *label the node type.

If LABELLED-NODES-ONLY is non-nil, then only matches with labels are returned. Additionally, if NO-LABELS is set, the labels are removed.

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-navigation.el
(defun combobulate-query-search (query-node query &optional labelled-nodes-only no-labels nested-labels)
  "Execute QUERY starting at QUERY-NODE.

QUERY must be a well-formed query. The query language is very
similar, but not identical, to that of tree-sitter's own query
language.

Supported constructs:

  `(start-node (node))' matches start-node against query-node and
  matches if `start-node' has a child `node'.

  `(_)' can be used in lieu of an explicit node name to match any
  named node.

  `_' can be used in lieu of an explicit node name to match any
  named or anonymous node.

  `(start-node field: (match-node))' asserts that `start-node'
  must have a field named `field' followed by a `match-node'.

  `@label', `!label' and `*label' are used to name node
  sequences. `@label' returns the node; `!label' returns the
  node text; and `*label' the node type.

If LABELLED-NODES-ONLY is non-nil, then only matches with labels
are returned. Additionally, if NO-LABELS is set, the labels are
removed."
  (when combobulate-debug
    (message "Query: `%s' against `%s'" query query-node))
  (catch 'error
    (let* ((combobulate-query--labelled-nodes nil)
           (combobulate-query--nested-labels nested-labels)
           (result (combobulate-query-search-1 query-node query)))
      (if labelled-nodes-only
          (if no-labels
              (mapcar 'cdr (reverse combobulate-query--labelled-nodes))
            (reverse combobulate-query--labelled-nodes))
        result))))