branch: elpa/swift-mode commit a84f5c82f7aa832746e8dc2417ba53f58bb85daa Author: taku0 <mxxouy6x3m_git...@tatapa.org> Commit: taku0 <mxxouy6x3m_git...@tatapa.org>
Support multi-parttern catch clauses https://github.com/apple/swift-evolution/blob/master/proposals/0276-multi-pattern-catch-clauses.md --- swift-mode-indent.el | 13 ++++++++-- test/swift-files/indent/statements.swift | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/swift-mode-indent.el b/swift-mode-indent.el index 3fc0258..bc7793b 100644 --- a/swift-mode-indent.el +++ b/swift-mode-indent.el @@ -1137,10 +1137,19 @@ comma at eol." ;; , E ;; , F ;; } + ;; + ;; https://github.com/apple/swift-evolution/blob/master/proposals/0276-multi-pattern-catch-clauses.md + ;; do { + ;; } catch Foo(let a), + ;; Bar(let a) { + ;; foo(a) + ;; } (let ((pos (point)) (parent (swift-mode:backward-sexps-until ;; Includes "if" to stop at the last else-if. - (append swift-mode:statement-parent-tokens '("if" \( \[ <)) + ;; Includes "catch" to stop at the last catch. + (append swift-mode:statement-parent-tokens + '("if" "catch" \( \[ <)) (if utrecht-style nil '(\,)) (if utrecht-style '(\,) nil)))) (cond @@ -1151,7 +1160,7 @@ comma at eol." (goto-char pos) (swift-mode:backward-sexps-until '(< "where"))) - ((equal (swift-mode:token:text parent) "if") + ((member (swift-mode:token:text parent) '("if" "catch")) parent) (t diff --git a/test/swift-files/indent/statements.swift b/test/swift-files/indent/statements.swift index efc72ae..fa3cbab 100644 --- a/test/swift-files/indent/statements.swift +++ b/test/swift-files/indent/statements.swift @@ -1041,6 +1041,50 @@ catch foo() } +// Multi-Pattern Catch Clauses +// https://github.com/apple/swift-evolution/blob/master/proposals/0276-multi-pattern-catch-clauses.md + +do { +} catch Foo(let a) + where + foo + .bar(), + Bar(let a) + where + foo + .bar(), + Baz(let a) where + foo + .bar() { + foo(a) +} catch Foo(let a) + where + foo + .bar() + , Bar(let a) + where + foo + .bar() + , Baz(let a) where + foo + .bar() { + foo(a) +} catch + Foo(let a) + where + foo + .bar(), + Bar(let a) + where + foo + .bar(), + Baz(let a) where + foo + .bar() { + foo(a) +} + + // Conditional control statements func foo() {