emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/swift-mode a84f5c8 460/496: Support multi-parttern catch c


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode a84f5c8 460/496: Support multi-parttern catch clauses
Date: Sun, 29 Aug 2021 11:34:28 -0400 (EDT)

branch: elpa/swift-mode
commit a84f5c82f7aa832746e8dc2417ba53f58bb85daa
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@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() {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]