[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 5c09b07 289/496: Merge pull request #114 from u
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 5c09b07 289/496: Merge pull request #114 from uk-ar/fix-indent-for-ternary-operator |
Date: |
Sun, 29 Aug 2021 11:33:53 -0400 (EDT) |
branch: elpa/swift-mode
commit 5c09b0701ec3b81fe5cc33956cb917d2fb62fcf5
Merge: 064d4ee 1f39b11
Author: Arthur Evstifeev <mail@ap4y.me>
Commit: Arthur Evstifeev <mail@ap4y.me>
Merge pull request #114 from uk-ar/fix-indent-for-ternary-operator
Fix indent for ternary operator
---
swift-mode.el | 18 +++++++-----------
test/indentation-tests.el | 13 +++++++++++++
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 3440019..c071c73 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -88,13 +88,11 @@
(decl (decl ";" decl))
(decl (let-decl) (var-decl))
(let-decl
- ("let" id ":" type)
- ("let" id "=" exp)
- ("let" id ":" type "=" exp))
+ ("let" decl-exp)
+ ("let" decl-exp "=" exp))
(var-decl
- ("var" id ":" type)
- ("var" id "=" exp)
- ("var" id ":" type "=" exp))
+ ("var" decl-exp)
+ ("var" decl-exp "=" exp))
(top-level-sts (top-level-st) (top-level-st ";" top-level-st))
(top-level-st
@@ -125,7 +123,6 @@
(insts (inst) (insts ";" insts))
(inst (decl)
(exp "=" exp)
- (tern-exp)
(in-exp)
(dot-exp)
(dot-exp "{" closure "}")
@@ -147,7 +144,6 @@
(exp ("[" decl-exps "]"))
(in-exp (id "in" exp))
(guard-exp (exp "where" exp))
- (tern-exp (exp "?" exp ":" exp))
(enum-case ("ecase" assign-exp)
("ecase" "(" type ")"))
@@ -173,7 +169,7 @@
(closure (insts) (exp "in" insts) (exp "->" id "in" insts)))
;; Conflicts
- '((nonassoc "{") (assoc "in") (assoc ",") (assoc ";") (assoc ":") (right
"="))
+ '((nonassoc "{") (assoc "in") (assoc ",") (assoc ";") (right "=") (right
":"))
'((assoc "in") (assoc "where"))
'((assoc ";") (assoc "ecase"))
'((assoc "case")))
@@ -182,6 +178,7 @@
'(
(right "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" "&="
"^=" "|=" "&&=" "||=" "=") ;; Assignment
(Right associative, precedence level 90)
+ (right "?" ":") ;; Ternary
Conditional (Right associative, precedence level 100)
(left "||") ;; Disjunctive
(Left associative, precedence level 110)
(left "&&") ;; Conjunctive
(Left associative, precedence level 120)
(right "??") ;; Nil
Coalescing (Right associativity, precedence level 120)
@@ -386,8 +383,7 @@ We try to constraint those lookups by reasonable number of
lines.")
(cond
;; Rule for ternary operator in
;; assignment expression.
- ;; Static indentation relatively to =
- ((smie-rule-parent-p "=") 2)
+ ((and (smie-rule-parent-p "?") (smie-rule-bolp)) 0)
((smie-rule-parent-p ",") (smie-rule-parent swift-indent-offset))
;; Rule for the class definition.
((smie-rule-parent-p "class") (smie-rule-parent swift-indent-offset))))
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index c77666b..ce406b5 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1836,6 +1836,19 @@ func foo() {
}
")
+(check-indentation conditional-operator/11
+ "
+let a = a ? a +
+ 1
+ |: a +
+ 1
+" "
+let a = a ? a +
+ 1
+ |: a +
+ 1
+")
+
(check-indentation blank-line/1
"
func foo() {
- [nongnu] elpa/swift-mode d0c65bc 212/496: Fix bug with the closing parentheses in method calls and function, (continued)
- [nongnu] elpa/swift-mode d0c65bc 212/496: Fix bug with the closing parentheses in method calls and function, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 107195e 219/496: Improve lexer rule for generics with optional or implicit unwrapping, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cdf7ad4 220/496: Fix indentation issues with deep nested if cluase, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9941c27 224/496: Bring failing tests for #81 contributed in #82 by @dougbeal, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4ae6cc2 228/496: Fix indent when after comment, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 68a3a29 231/496: Support for choosing framework search paths., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 8e0f8d6 240/496: Merge pull request #94 from wiruzx/new-range-operator, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 17bf117 242/496: Merge pull request #95 from wiruzx/add-as!-operator, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b3af0b0 252/496: Constraint all look backs to the reasonable amount of lines, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 52a01b1 269/496: Add test case for backward-sexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5c09b07 289/496: Merge pull request #114 from uk-ar/fix-indent-for-ternary-operator,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 4e9da69 299/496: Release 0.4.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c303245 291/496: Merge pull request #115 from uk-ar/add-melpa-badge, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9211980 312/496: Bump version to 2.1.2, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3d27871 313/496: Tweak README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 86eb49c 323/496: Fix indentation of for-in, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 78cea9d 337/496: Improve CI, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 63580e8 339/496: Speed-up indentation for colon, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e91e924 347/496: Bump version to 2.2.4, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9892096 350/496: Bump version to 2.3.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 55ea958 354/496: Fix syntax error, ELPA Syncer, 2021/08/29