Add indentation of "return" in sequence diagrams's activated blocks

The return keyword takes an optional label. Use it as shorthand for
"deactivate X[: LABEL]" when the block you want to deactivate is the
most recent activated one.
This commit is contained in:
Stig Brautaset 2021-03-28 00:13:49 +00:00
parent ea45a13707
commit bfa587d039
2 changed files with 87 additions and 1 deletions

View File

@ -610,7 +610,7 @@ or it is followed by line end.")
(defvar plantuml-indent-regexp-block-end "^\s*\\(?:}\\|endif\\|else\s*.*\\|end\\)\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-note-end "^\s*\\(end\s+note\\|end[rh]note\\)\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-group-end "^\s*end\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-activate-end "^\s*deactivate\s+.+$")
(defvar plantuml-indent-regexp-activate-end "^\s*\\(?:deactivate\s+.+\\|return.*\\)$")
(defvar plantuml-indent-regexp-box-end "^\s*end\s+box\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-ref-end "^\s*end\s+ref\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-title-end "^\s*end\s+title\s*\\('.*\\)?$")

View File

@ -302,6 +302,38 @@ activate participant_1
deactivate participant_1
"))
(ert-deftest plantuml-test-block-indentation/sequence/activate-return ()
"Test correct indentation of an activate-return block."
(plantuml-test-indent-block
"
activate participant_1
participant_1 -> participant_2 : f()
return
"
"
activate participant_1
participant_1 -> participant_2 : f()
return
"))
(ert-deftest plantuml-test-block-indentation/sequence/activate-return-nested ()
"Test correct indentation of two nested activate-deactivate blocks."
(plantuml-test-indent-block
"
activate participant_1
activate participant_2
participant_1 -> participant_2 : f()
return with a label
return
"
"
activate participant_1
activate participant_2
participant_1 -> participant_2 : f()
return with a label
return
"))
(ert-deftest plantuml-test-indentation/sequence-diagram ()
"Test correct indentation of plantuml sequence diagram elements.
@ -356,6 +388,60 @@ else Another type of failure
end
"))
(ert-deftest plantuml-test-indentation/nested-sequence-diagram ()
"Test correct indentation of plantuml nested sequence diagram elements."
(plantuml-test-indent-block
"
A -> foo
activate foo
foo --> bar
activate bar
bar->baz
activate baz
alt success case
baz --> baz: success
else
baz --> baz: fail
end
return
bar->quux
activate quux
note over quux
Cum sociis natoque
penatibus et magnis
dis parturient montes,
nascetur ridiculus mus.
end note
return
return
return
"
"
A -> foo
activate foo
foo --> bar
activate bar
bar->baz
activate baz
alt success case
baz --> baz: success
else
baz --> baz: fail
end
return
bar->quux
activate quux
note over quux
Cum sociis natoque
penatibus et magnis
dis parturient montes,
nascetur ridiculus mus.
end note
return
return
return
"))
(provide 'plantuml-indentation-sequence-test)