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:
parent
ea45a13707
commit
bfa587d039
|
@ -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-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-note-end "^\s*\\(end\s+note\\|end[rh]note\\)\s*\\('.*\\)?$")
|
||||||
(defvar plantuml-indent-regexp-group-end "^\s*end\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-box-end "^\s*end\s+box\s*\\('.*\\)?$")
|
||||||
(defvar plantuml-indent-regexp-ref-end "^\s*end\s+ref\s*\\('.*\\)?$")
|
(defvar plantuml-indent-regexp-ref-end "^\s*end\s+ref\s*\\('.*\\)?$")
|
||||||
(defvar plantuml-indent-regexp-title-end "^\s*end\s+title\s*\\('.*\\)?$")
|
(defvar plantuml-indent-regexp-title-end "^\s*end\s+title\s*\\('.*\\)?$")
|
||||||
|
|
|
@ -302,6 +302,38 @@ activate participant_1
|
||||||
deactivate 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 ()
|
(ert-deftest plantuml-test-indentation/sequence-diagram ()
|
||||||
"Test correct indentation of plantuml sequence diagram elements.
|
"Test correct indentation of plantuml sequence diagram elements.
|
||||||
|
@ -356,6 +388,60 @@ else Another type of failure
|
||||||
end
|
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)
|
(provide 'plantuml-indentation-sequence-test)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue