[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 7a7038b 202/496: Remove supported for trailing
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 7a7038b 202/496: Remove supported for trailing dot in multi-line expression (invalid |
Date: |
Sun, 29 Aug 2021 11:33:36 -0400 (EDT) |
branch: elpa/swift-mode
commit 7a7038bd30ab2b76edc075a0165b3526a51d352c
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>
Remove supported for trailing dot in multi-line expression (invalid
swift code) and improve support for several form of multi-line
expressions
---
swift-mode.el | 16 ++++---
test/indentation-tests.el | 117 ++++++++++++++++++++++++++++++++++++++++------
2 files changed, 111 insertions(+), 22 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 3ae3e6a..5c6a106 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -330,18 +330,20 @@
(smie-rule-parent swift-indent-offset)))
;; Apply swift-indent-multiline-statement-offset only if
- ;; - dot is followed by newline, or
- ;; - if dot is a first token on the line
+ ;; - if is a first token on the line
(`(:before . ".")
- (if (or (smie-rule-hanging-p)
- (smie-rule-bolp))
- swift-indent-multiline-statement-offset))
+ (when (smie-rule-bolp)
+ (if (smie-rule-parent-p "{")
+ (+ swift-indent-offset swift-indent-multiline-statement-offset)
+ swift-indent-multiline-statement-offset)))
;; Apply swift-indent-multiline-statement-offset if
;; operator is the last symbol on the line
(`(:before . "OP")
- (if (smie-rule-hanging-p)
- swift-indent-multiline-statement-offset))
+ (when (smie-rule-hanging-p)
+ (if (smie-rule-parent-p "{")
+ (+ swift-indent-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 6508ae0..d985869 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1058,6 +1058,103 @@ let options =
NSRegularExpressionOptions.CaseInsensitive &
|NSRegularExpressionOptions.DotMatchesLineSeparators
")
+(check-indentation indents-multiline-expressions/9
+ "
+foo?[bar] +
+ |a
+" "
+foo?[bar] +
+ |a
+")
+
+(check-indentation indents-multiline-expressions/10
+ "
+foo?(bar) +
+ |a
+" "
+foo?(bar) +
+ |a
+")
+
+(check-indentation indents-multiline-expressions/11
+ "
+func a () {
+ a +
+|a
+" "
+func a () {
+ a +
+ |a
+")
+
+(check-indentation indents-multiline-expressions/12
+ "
+func a () {
+ a
+|.a()
+" "
+func a () {
+ a
+ |.a()
+")
+
+(check-indentation indents-multiline-expressions/13
+ "
+if (a
+|.b)
+" "
+if (a
+ |.b)
+")
+
+(check-indentation indents-multiline-expressions/14
+ "
+a ??
+|b
+" "
+a ??
+ |b
+")
+
+(check-indentation indents-multiline-expressions/15
+ "
+a as
+|b
+" "
+a as
+ |b
+")
+
+(check-indentation indents-multiline-expressions/16
+ "
+a as?
+|b
+" "
+a as?
+ |b
+")
+
+(check-indentation indents-multiline-expressions/17
+ "
+a is
+|b
+" "
+a is
+ |b
+")
+
+(check-indentation indents-multiline-expressions/18
+ "
+CGPoint(x: aaaaaaaaaaaaaaa.x +
+|bbbbbbbbbbbbbbbb,
+ y: aaaaaaaaaaaaaaa.y +
+ bbbbbbbbbbbbbbbb)
+" "
+CGPoint(x: aaaaaaaaaaaaaaa.x +
+ |bbbbbbbbbbbbbbbb,
+ y: aaaaaaaaaaaaaaa.y +
+ bbbbbbbbbbbbbbbb)
+")
(check-indentation indents-long-parameters/1
"
@@ -1093,16 +1190,6 @@ aaaaaa.aaaaaaaaaaaaaaaaaaaaa(
(check-indentation indents-multiline-expressions-to-user-defined-offset/1
"
-NSNotificationCenter.defaultCenter().
-|postNotificationName(foo, object: nil)
-" "
-NSNotificationCenter.defaultCenter().
- |postNotificationName(foo, object: nil)
-"
-((swift-indent-multiline-statement-offset 4)))
-
-(check-indentation indents-multiline-expressions-to-user-defined-offset/2
- "
NSNotificationCenter.defaultCenter()
|.postNotificationName(foo, object: nil)
" "
@@ -1111,7 +1198,7 @@ NSNotificationCenter.defaultCenter()
"
((swift-indent-multiline-statement-offset 4)))
-(check-indentation indents-multiline-expressions-to-user-defined-offset/3
+(check-indentation indents-multiline-expressions-to-user-defined-offset/2
"
let json_ary = NSJSONSerialization
|.JSONObjectWithData(data, options: nil, error: &json_err) as
NSArray
@@ -1121,7 +1208,7 @@ let json_ary = NSJSONSerialization
"
((swift-indent-multiline-statement-offset 4)))
-(check-indentation indents-multiline-expressions-to-user-defined-offset/4
+(check-indentation indents-multiline-expressions-to-user-defined-offset/3
"
let options = NSRegularExpressionOptions.CaseInsensitive &
|NSRegularExpressionOptions.DotMatchesLineSeparators
@@ -1174,12 +1261,12 @@ let foo = bar >
(check-indentation indents-multiline-operators-only-once
"
1 +
- 2 + 5 *
+ 2 + 5 *
|3
" "
1 +
- 2 + 5 *
- |3
+ 2 + 5 *
+ |3
"
)
- [nongnu] elpa/swift-mode 2eb3952 136/496: Merge pull request #45 from ap4y/dot_in_string_interpolation, (continued)
- [nongnu] elpa/swift-mode 2eb3952 136/496: Merge pull request #45 from ap4y/dot_in_string_interpolation, ELPA Syncer, 2021/08/29
- [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 <=
- [nongnu] elpa/swift-mode d27b851 181/496: Add indentation rules for ternary operator, ELPA Syncer, 2021/08/29
- [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