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

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

[nongnu] elpa/swift-mode 1122ab9 204/496: Add grammar rule for return st


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 1122ab9 204/496: Add grammar rule for return statement in function
Date: Sun, 29 Aug 2021 11:33:36 -0400 (EDT)

branch: elpa/swift-mode
commit 1122ab9ded38b233735b5e3a94118a783d54670e
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>

    Add grammar rule for return statement in function
---
 swift-mode.el             |  5 +++--
 test/indentation-tests.el | 30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/swift-mode.el b/swift-mode.el
index 3d6881b..967e8d2 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -112,7 +112,8 @@
         (decl)
         (func-decl))
 
-       (func (func-decl "{" insts "}"))
+       (func-body (insts) ("return" exp))
+       (func (func-decl "{" func-body "}"))
        (func-decl ("DECSPEC" "func" func-header)
                   (func-decl "->" type))
        (func-header (id "(" func-params ")"))
@@ -344,7 +345,7 @@
      (when (smie-rule-hanging-p)
        (if (smie-rule-parent-p "{")
            (+ swift-indent-offset swift-indent-multiline-statement-offset)
-          swift-indent-multiline-statement-offset)))
+         swift-indent-multiline-statement-offset)))
 
     ;; Indent second line of the multi-line class
     ;; definitions with swift-indent-offset
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index d985869..39ada7c 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1361,6 +1361,36 @@ let a = a ?
         |c
 ")
 
+(check-indentation conditional-operator/8
+                   "
+func foo() {
+    return order!.deliver ?
+         |OrderViewTableDeliveryCells.lastCellIndex.rawValue :
+           OrderViewTableTakeAwayCells.lastCellIndex.rawValue
+}
+" "
+func foo() {
+    return order!.deliver ?
+           |OrderViewTableDeliveryCells.lastCellIndex.rawValue :
+           OrderViewTableTakeAwayCells.lastCellIndex.rawValue
+}
+")
+
+(check-indentation conditional-operator/9
+                   "
+func foo() {
+    return order!.deliver ?
+           OrderViewTableDeliveryCells.lastCellIndex.rawValue :
+         |OrderViewTableTakeAwayCells.lastCellIndex.rawValue
+}
+" "
+func foo() {
+    return order!.deliver ?
+           OrderViewTableDeliveryCells.lastCellIndex.rawValue :
+           |OrderViewTableTakeAwayCells.lastCellIndex.rawValue
+}
+")
+
 (check-indentation blank-line/1
                    "
 func foo() {



reply via email to

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