[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode d27b851 181/496: Add indentation rules for tern
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode d27b851 181/496: Add indentation rules for ternary operator |
Date: |
Sun, 29 Aug 2021 11:33:32 -0400 (EDT) |
branch: elpa/swift-mode
commit d27b85193906e9f76f43eb71fe02651014814c60
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>
Add indentation rules for ternary operator
---
swift-mode.el | 10 ++++
test/indentation-tests.el | 113 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 119 insertions(+), 4 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index a8dca0b..405f868 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -272,6 +272,16 @@
(pcase (cons kind token)
(`(:elem . basic) swift-indent-offset)
+ (`(:after . ":") 0)
+ (`(:before . ":")
+ (cond
+ ;; Rule for ternary operator in
+ ;; assignment expression.
+ ;; Static indentation relatively to =
+ ((smie-rule-parent-p "=") 2)
+ ;; Rule for the case statement.
+ ((smie-rule-parent-p "case") swift-indent-offset)))
+
(`(:after . "{")
(if (smie-rule-parent-p "switch")
(smie-rule-parent swift-indent-switch-case-offset)))
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index cb810b1..837108f 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -391,12 +391,12 @@ case y:
(check-indentation indents-case-statements-with-destucturing/1
"
switch true {
-case let(x, y):
+case let(x, y) where x < y:
|foo
}
" "
switch true {
-case let(x, y):
+case let(x, y) where x < y:
|foo
}
")
@@ -404,12 +404,12 @@ case let(x, y):
(check-indentation indents-case-statements-with-destucturing/2
"
switch true {
-case let .Foo(x):
+case let .Foo(x) where x > 0:
|foo
}
" "
switch true {
-case let .Foo(x):
+case let .Foo(x) where x > 0:
|foo
}
")
@@ -931,6 +931,111 @@ let foo = bar >
"
)
+(check-indentation conditional-operator/1
+ "
+let a = a
+ |? a +
+ 1
+ : a +
+ 1
+" "
+let a = a
+ |? a +
+ 1
+ : a +
+ 1
+")
+
+(check-indentation conditional-operator/2
+ "
+let a = a
+ ? a +
+ |1
+ : a +
+ 1
+" "
+let a = a
+ ? a +
+ |1
+ : a +
+ 1
+")
+
+(check-indentation conditional-operator/3
+ "
+let a = a
+ ? a +
+ 1
+ |: a +
+ 1
+" "
+let a = a
+ ? a +
+ 1
+ |: a +
+ 1
+")
+
+(check-indentation conditional-operator/4
+ "
+let a = a
+ ? a +
+ 1
+ : a +
+ |1
+" "
+let a = a
+ ? a +
+ 1
+ : a +
+ |1
+")
+
+(check-indentation conditional-operator/5
+ "
+let a = a ?
+|a : a
+" "
+let a = a ?
+ |a : a
+")
+
+(check-indentation conditional-operator/6
+ "
+let a = a ?
+ |b :
+ c
+" "
+let a = a ?
+ |b :
+ c
+")
+
+(check-indentation conditional-operator/7
+ "
+let a = a ?
+ b :
+ |c
+" "
+let a = a ?
+ b :
+ |c
+")
+
+(check-indentation blank-line/1
+ "
+func foo() {
+ let a = 1
+
+|let b = 1
+}
+" "
+func foo() {
+ let a = 1
+
+ |let b = 1
+}
+")
(provide 'indentation-tests)
- [nongnu] elpa/swift-mode 5e3ab8c 139/496: Apply swift-indent-multiline-statement-offset to the multi-line, (continued)
- [nongnu] elpa/swift-mode 5e3ab8c 139/496: Apply swift-indent-multiline-statement-offset to the multi-line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4e615b7 143/496: Merge pull request #50 from ap4y/string_interpolation_all_op, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9c716c1 155/496: Update README, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1753f23 149/496: Merge pull request #53 from ap4y/improve_smie_dot_exp_rule, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 8492a3d 157/496: Update copyright, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c8cdb81 153/496: Shortcut linked sources flycheck logic when corresponding variable is nil, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a3caf1d 163/496: Change '_' character class to 'symbol constituent', ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0ad5865 171/496: Merge pull request #71 from ap4y/access_modifiers_font_lock, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 69289fe 180/496: Lexer improvement: don't use implicit semicolon when ":" and "?" token, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7a7038b 202/496: Remove supported for trailing dot in multi-line expression (invalid, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d27b851 181/496: Add indentation rules for ternary operator,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 3026464 206/496: Merge pull request #79 from dougbeal/fix-custom-types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ae4f08b 253/496: Correct implicit semicolon rule for in keyword, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3aa3dcd 254/496: Add test code for checking tokens, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b97b570 260/496: Fix indent rule for '(' and pass all test, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 00393f7 262/496: Merge pull request #103 from uk-ar/fix-lexer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ed1ed46 264/496: Add test for forward-sexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a3377bf 266/496: Fix forward-sexp test by adding brackets, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 228b50c 267/496: Fix case-: for multiline case-exps, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3931734 283/496: fix multi-line expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e5b569e 284/496: Add keyword for attribute, ELPA Syncer, 2021/08/29