Skip to content

Commit

Permalink
More tests and commensurate nav tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeynp committed Feb 26, 2024
1 parent f68ee0b commit e947ee8
Show file tree
Hide file tree
Showing 85 changed files with 2,031 additions and 51 deletions.
13 changes: 6 additions & 7 deletions combobulate-html.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,17 @@
;; comments. This is not a problem in HTML where they have
;; beginnings and ends.
(setq combobulate-procedure-discard-rules nil)
(setq combobulate-display-ignored-node-types '("start_tag" "self_closing_tag" "end_tag" "tag_name"))
(setq combobulate-navigation-sibling-procedures
'((:activation-nodes
((:nodes
((rule "fragment") "comment")
:has-parent ((rule "fragment") "fragment")))
:selector (:match-children (:match-rules (exclude (all) "start_tag" "end_tag" "self_closing_tag"))))
("attribute")))
:selector (:choose node :match-siblings (:match-rules ("attribute"))))
(:activation-nodes
((:nodes
("attribute")
:has-parent ("start_tag" "self_closing_tag")))
:selector (:match-children
(:match-rules ("attribute"))))))
((rule "fragment") "comment")
:has-parent ((rule "fragment") "fragment" "start_tag" "self_closing_tag")))
:selector (:match-children (:match-rules (exclude (all) "start_tag" "end_tag" "self_closing_tag"))))))
(setq combobulate-pretty-print-node-name-function #'combobulate-html-pretty-print))

(provide 'combobulate-html)
Expand Down
16 changes: 3 additions & 13 deletions combobulate-procedure.el
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,6 @@ without explicitly setting `:default-mark'"))

(defun combobulate-procedure-debug-print-result (procedure-result)
"Print PROCEDURE-RESULT in a human-readable format."
;; pretty-print the cldefstruct
;; (cl-defstruct combobulate-procedure-result
;; "The result of a procedure."
;; activation-node
;; action-node
;; parent-node
;; selected-nodes
;; matched-nodes
;; (matched-activation nil)
;; (matched-selection nil))
(pcase procedure-result
((cl-struct combobulate-procedure-result
(activation-node activation-node)
Expand Down Expand Up @@ -546,9 +536,9 @@ defaults to `combobulate'. `:discard-rules' is a list of rules
(if rules
;; some node types are supertypes, meaning they exist outside
;; the actual parse tree TS can generate. However, the rules
;; for these supertypes are defined in the same way as for the
;; actual parse tree. So, we need to expand the supertypes
;; here.
;; for these supertypes are defined and used in the parser and
;; exported in the node rules also. If we encounter a
;; supertype, we expand it inline.
(mapcan
(lambda (n)
;; check if n is a supertype; if it is, expand it.
Expand Down
31 changes: 16 additions & 15 deletions tests/combobulate-test-prelude.el
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,22 @@ function."
(setq current-choice (pop remaining-choices))
(when ,call-action-fn
(and ,error-if-missing (should (<= current-choice (length nodes))))
(let ((picked-node (nth current-choice nodes))
(let ((cg (prepare-change-group))
(picked-node (nth current-choice nodes))
(stubbed-refactor-id (combobulate-refactor-setup)))
(activate-change-group cg)
(setq choice-node picked-node)
;; Not necessary??
;; (combobulate-refactor (:id stubbed-refactor-id)
;; ;; signature: (index current-node proxy-nodes refactor-id)
;; (funcall (or ,replacement-action-fn action-fn)
;; current-choice
;; choice-node
;; nodes
;; stubbed-refactor-id)
;; (if (eq accept-action 'rollback)
;; (rollback)
;; (commit)))
))
(combobulate-refactor (:id stubbed-refactor-id)
(funcall (or ,replacement-action-fn action-fn)
(combobulate-proffer-action-create
:index current-choice
:current-node (combobulate-make-proxy picked-node)
;; :proxy-nodes (combobulate-make-proxy nodes)
:refactor-id stubbed-refactor-id))
(if (eq accept-action 'rollback)
(rollback)
(commit)))
(cancel-change-group cg)))
choice-node)))
,@body)))

Expand Down Expand Up @@ -314,8 +315,8 @@ of updating the prop line."
files)))
(delete-other-windows)
(mapc (lambda (buf) (display-buffer buf `(display-buffer-in-direction
. ((direction . right)
(window-width . 0.2)))))
. ((direction . right)
(window-width . 0.2)))))
(mapcar #'find-file-noselect
(alist-get (completing-read "Pick command " (seq-uniq (mapcar #'car grouped-cmd-files) #'string=))
grouped-cmd-files nil nil #'string=)))
Expand Down
8 changes: 6 additions & 2 deletions tests/combobulate-test-suite.el
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ doesn't exist."
(css-mode . css-ts-mode)
(yaml-mode . yaml-ts-mode)
(json-mode . json-ts-mode)
(html-mode . html-ts-mode)
(mhtml-mode . html-ts-mode)
(js-json-mode . json-ts-mode)))
(combobulate-flash-node nil)
(target-fn (concat (oref obj target-dir) (format "test-%s.gen.el" (oref obj collection-name))))
Expand Down Expand Up @@ -419,9 +421,11 @@ doesn't exist."
(with-current-buffer (oref obj output-buffer)
(let* ((numbers)
(fixture-buf (find-file-noselect fixture-file-name))
(fixture-language) (fixture-major-mode))
(fixture-language) (fixture-major-mode) (lang))
(with-current-buffer fixture-buf
(setq fixture-language (combobulate-parser-language (car (combobulate-parser-list))))
(setq lang (car (combobulate-parser-list)))
(cl-assert (not (null lang)) nil "No language found in `%s' (major mode: `%s')" fixture-file-name major-mode)
(setq fixture-language (combobulate-parser-language lang))
(setf fixture-major-mode major-mode)
(setq numbers (seq-sort #'< (mapcar (lambda (ov) (overlay-get ov 'combobulate-test-number))
(combobulate--with-test-overlays)))))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 187) (2 outline 204) (3 outline 229)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo> <tag id="1">
<bar
aria-foo="bar"
id="1"
class="boooo"
/>
</tag>

<bar
id="1"
aria-foo="bar"
class="boooo"
/>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 187) (2 outline 204) (3 outline 229)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo> <tag id="1">
<bar
id="1"
class="boooo"
aria-foo="bar"
/>
</tag>

<bar
id="1"
aria-foo="bar"
class="boooo"
/>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 187) (2 outline 204) (3 outline 229)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo> <tag id="1">
<bar
id="1"
aria-foo="bar"
class="boooo"
/>
</tag>

<bar
id="1"
aria-foo="bar"
class="boooo"
/>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 187) (2 outline 204) (3 outline 229)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo> <tag id="1">
<bar
id="1"
aria-foo="bar"
class="boooo"
/>
</tag>

<bar
id="1"
aria-foo="bar"
class="boooo"
/>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 187) (2 outline 204) (3 outline 229)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo> <tag id="1">
<bar
aria-foo="bar"
id="1"
class="boooo"
/>
</tag>

<bar
id="1"
aria-foo="bar"
class="boooo"
/>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 187) (2 outline 204) (3 outline 229)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo> <tag id="1">
<bar
id="1"
class="boooo"
aria-foo="bar"
/>
</tag>

<bar
id="1"
aria-foo="bar"
class="boooo"
/>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- -*- combobulate-test-point-overlays: ((1 outline 225) (2 outline 234) (3 outline 244) (4 outline 258) (5 outline 294) (6 outline 353) (7 outline 374)); eval: (combobulate-test-fixture-mode t); -*- -->
<foo>
<bar>
Text
<hr/>
Text here
<div>
Sub text
</div>
<very
id="1"
long="node">

</very>
<!-- comment -->
more text
</bar>
</foo>
Loading

0 comments on commit e947ee8

Please sign in to comment.