[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 0b1f29d 334/496: Fix indentation of setter
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 0b1f29d 334/496: Fix indentation of setter |
Date: |
Sun, 29 Aug 2021 11:34:01 -0400 (EDT) |
branch: elpa/swift-mode
commit 0b1f29daa9e441dd7d24b6898131bdbcc14970c2
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Fix indentation of setter
---
swift-mode-lexer.el | 60 ++++++++++++++++++++++---------------
test/swift-files/declarations.swift | 22 ++++++++++++++
2 files changed, 58 insertions(+), 24 deletions(-)
diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el
index 4224f1e..4c616bb 100644
--- a/swift-mode-lexer.el
+++ b/swift-mode-lexer.el
@@ -302,17 +302,6 @@ END is the point after the token."
'("get" "set" "willSet" "didSet" "subscript" "init" "deinit"))
t)
- ;; Suppress implicit semicolon after keywords that behave like method
- ;; names.
- ;;
- ;; Note that binary operators take precedence over this:
- ;;
- ;; self . // not insert semicolon here
- ;; init
- ((member (swift-mode:token:text previous-token)
- '("set" "willSet" "didSet" "subscript" "init" "deinit"))
- nil)
-
;; Suppress implicit semicolon after declaration starters.
((member (swift-mode:token:text previous-token)
'("class" "struct" "protocol" "enum" "extension" "func"
@@ -341,6 +330,42 @@ END is the point after the token."
(swift-mode:forward-token-simple)))
"<")))
+ ;; Inserts semicolon before open curly bracket.
+ ;;
+ ;; Open curly bracket may continue the previous line, but we do not indent
+ ;; there. For example, the code below is parsed as `(foo() { x in ... })'
+ ;; by the Swift compiler, but we indent it like `foo(); { x in ... }'.
+ ;;
+ ;; foo()
+ ;; { // does not indent here
+ ;; x in
+ ;; ...
+ ;; }
+ ((eq (swift-mode:token:type next-token) '\{) t)
+
+ ;; Suppress implicit semicolon after keywords that behave like method
+ ;; names.
+ ;;
+ ;; Note that binary operators take precedence over this:
+ ;;
+ ;; self . // not insert semicolon here
+ ;; init
+ ;;
+ ;; var x {
+ ;; set // not insert semicolon here
+ ;; (x) {
+ ;; }
+ ;; }
+ ;;
+ ;; var x {
+ ;; set // inserts semicolon here
+ ;; {
+ ;; }
+ ;; }
+ ((member (swift-mode:token:text previous-token)
+ '("set" "willSet" "didSet" "subscript" "init" "deinit"))
+ nil)
+
;; Inserts implicit semicolon before open square bracket.
;;
;; Open square bracket for array indexing cannot appear at the start of a
@@ -371,19 +396,6 @@ END is the point after the token."
;; )
((eq (swift-mode:token:type next-token) '\() t)
- ;; Inserts semicolon before open curly bracket.
- ;;
- ;; Open curly bracket may continue the previous line, but we do not indent
- ;; there. For example, the code below is parsed as `(foo() { x in ... })'
- ;; by the Swift compiler, but we indent it like `foo(); { x in ... }'.
- ;;
- ;; foo()
- ;; { // does not indent here
- ;; x in
- ;; ...
- ;; }
- ((eq (swift-mode:token:type next-token) '\{) t)
-
;; Otherwise, inserts implicit semicolon.
(t t))))
diff --git a/test/swift-files/declarations.swift
b/test/swift-files/declarations.swift
index ecb8fcf..88eb98f 100644
--- a/test/swift-files/declarations.swift
+++ b/test/swift-files/declarations.swift
@@ -180,6 +180,28 @@ class Foo {
foo()
}
}
+
+ var x {
+ get {
+ 1
+ }
+
+ set {
+ foo()
+ }
+ }
+
+ var x {
+ get
+ {
+ 1
+ }
+
+ set
+ {
+ foo()
+ }
+ }
}
// Type alias declaration
- [nongnu] elpa/swift-mode 1563e8b 300/496: Bump the development version to 0.5.0-snapshot, (continued)
- [nongnu] elpa/swift-mode 1563e8b 300/496: Bump the development version to 0.5.0-snapshot, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a5e1acf 297/496: Merge pull request #122 from N4tr0n/make-install-fix-issue120, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cfaeaff 294/496: Update MELPA URL, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9471669 304/496: Merge taku0/swift3-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 848d088 310/496: Fix indentation after attributes with arguments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cad72a1 306/496: Fix a link in README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0a75736 317/496: Fix indentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c1f7ec2 321/496: Fix indentation of switch-case body, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7423f68 324/496: Simplify code, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 58f31cc 340/496: Speed-up indentation for colon, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0b1f29d 334/496: Fix indentation of setter,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 812d202 341/496: Fix REPL prompt corruption, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f755479 333/496: Fix anchor highlighting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 56ee9b2 359/496: Add comment style option, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode dba539e 394/496: Tweak and clean-up font-lock, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode dca378a 400/496: Rename constants, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c532c1e 402/496: Update documents, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d35275b 417/496: Remove unused variables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 8a7be9c 424/496: Use remap for keymap, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 56e21f8 427/496: Simplify autoloads, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 922dc52 445/496: Fix code format, ELPA Syncer, 2021/08/29