branch: elpa/swift-mode commit 1122ab9ded38b233735b5e3a94118a783d54670e Author: ap4y <l...@pisem.net> Commit: ap4y <l...@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() {