[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 42669da 343/496: Fix indentation for keywords u
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 42669da 343/496: Fix indentation for keywords used as parameter names |
Date: |
Sun, 29 Aug 2021 11:34:03 -0400 (EDT) |
branch: elpa/swift-mode
commit 42669da0b68bba2d12f9d5fc38f30def118bb999
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Fix indentation for keywords used as parameter names
```
foo(
in: 1
)
foo(
where: 1
)
```
---
swift-mode-font-lock.el | 1 -
swift-mode-indent.el | 106 +++++++--------
test/swift-files/identifiers.swift | 255 +++++++++++++++++++++++++++++++++++++
3 files changed, 308 insertions(+), 54 deletions(-)
diff --git a/swift-mode-font-lock.el b/swift-mode-font-lock.el
index b99b012..66faa0a 100644
--- a/swift-mode-font-lock.el
+++ b/swift-mode-font-lock.el
@@ -126,7 +126,6 @@ Return nil otherwise."
"\\<catch\\>"
"\\<dynamicType\\>"
"\\<is\\>"
- "\\<nil\\>"
"\\<rethrows\\>"
"\\<super\\>"
"\\<self\\>"
diff --git a/swift-mode-indent.el b/swift-mode-indent.el
index bcd3d68..e7e4951 100644
--- a/swift-mode-indent.el
+++ b/swift-mode-indent.el
@@ -217,46 +217,6 @@ declaration and its offset is `swift-mode:basic-offset'."
(goto-char (swift-mode:token:start previous-token))
(swift-mode:calculate-indent-after-comma))
- ;; Before "in" on the same line
- ((and next-is-on-same-line (equal next-text "in"))
- ;; When it is for-in statement, align with the token after "for":
- ;;
- ;; for
- ;; x
- ;; in
- ;; foo
- ;;
- ;; for x
- ;; in
- ;; foo
- ;;
- ;; When it is anonymous function, align with the token after {:
- ;;
- ;; foo {
- ;; x
- ;; in
- ;; ...
- ;; }
- ;;
- ;;
- ;; foo { x
- ;; in
- ;; ...
- ;; }
- ;;
- ;; foo { [
- ;; weak self
- ;; ]
- ;; (
- ;; x,
- ;; y
- ;; )
- ;; -> Void
- ;; in
- ;; a
- ;; }
- (swift-mode:find-and-align-with-parents '("for" {)))
-
;; Before "case" or "default" on the same line, for switch statement
((and
next-is-on-same-line
@@ -340,6 +300,59 @@ declaration and its offset is `swift-mode:basic-offset'."
swift-mode:statement-parent-tokens
swift-mode:multiline-statement-offset))
+ ;; After {
+ ((eq previous-type '{)
+ (goto-char (swift-mode:token:start previous-token))
+ (swift-mode:calculate-indent-after-open-curly-brace
+ swift-mode:basic-offset))
+
+ ;; After ( or [
+ ((memq previous-type '(\( \[))
+ (goto-char (swift-mode:token:start previous-token))
+ (swift-mode:calculate-indent-of-expression
+ swift-mode:parenthesized-expression-offset
+ swift-mode:parenthesized-expression-offset))
+
+ ;; Before "in" on the same line
+ ((and next-is-on-same-line (equal next-text "in"))
+ ;; When it is for-in statement, align with the token after "for":
+ ;;
+ ;; for
+ ;; x
+ ;; in
+ ;; foo
+ ;;
+ ;; for x
+ ;; in
+ ;; foo
+ ;;
+ ;; When it is anonymous function, align with the token after {:
+ ;;
+ ;; foo {
+ ;; x
+ ;; in
+ ;; ...
+ ;; }
+ ;;
+ ;;
+ ;; foo { x
+ ;; in
+ ;; ...
+ ;; }
+ ;;
+ ;; foo { [
+ ;; weak self
+ ;; ]
+ ;; (
+ ;; x,
+ ;; y
+ ;; )
+ ;; -> Void
+ ;; in
+ ;; a
+ ;; }
+ (swift-mode:find-and-align-with-parents '("for" {)))
+
;; Before "where" on the same line
((and next-is-on-same-line (equal next-text "where"))
;; switch {
@@ -411,19 +424,6 @@ declaration and its offset is `swift-mode:basic-offset'."
'(<))
swift-mode:multiline-statement-offset)))))
- ;; After {
- ((eq previous-type '{)
- (goto-char (swift-mode:token:start previous-token))
- (swift-mode:calculate-indent-after-open-curly-brace
- swift-mode:basic-offset))
-
- ;; After ( or [
- ((memq previous-type '(\( \[))
- (goto-char (swift-mode:token:start previous-token))
- (swift-mode:calculate-indent-of-expression
- swift-mode:parenthesized-expression-offset
- swift-mode:parenthesized-expression-offset))
-
;; After "where"
((equal previous-text "where")
;; switch {
diff --git a/test/swift-files/identifiers.swift
b/test/swift-files/identifiers.swift
index 7bff27f..519ed39 100644
--- a/test/swift-files/identifiers.swift
+++ b/test/swift-files/identifiers.swift
@@ -33,6 +33,261 @@ let foo = foo.var
let x = foo.where +
a
+// keywords as parameter names
+
+func foo() {
+ // Keywords used in declarations
+ foo(
+ associatedtype: 1
+ )
+ foo(
+ class: 1
+ )
+ foo(
+ deinit: 1
+ )
+ foo(
+ enum: 1
+ )
+ foo(
+ extension: 1
+ )
+ foo(
+ fileprivate: 1
+ )
+ foo(
+ func: 1
+ )
+ foo(
+ import: 1
+ )
+ foo(
+ init: 1
+ )
+ foo(
+ inout: 1
+ )
+ foo(
+ internal: 1
+ )
+ foo(
+ let: 1
+ )
+ foo(
+ open: 1
+ )
+ foo(
+ operator: 1
+ )
+ foo(
+ private: 1
+ )
+ foo(
+ protocol: 1
+ )
+ foo(
+ public: 1
+ )
+ foo(
+ static: 1
+ )
+ foo(
+ struct: 1
+ )
+ foo(
+ subscript: 1
+ )
+ foo(
+ typealias: 1
+ )
+ foo(
+ var: 1
+ )
+
+ // Keywords used in statements
+ foo(
+ break: 1
+ )
+ foo(
+ case: 1
+ )
+ foo(
+ continue: 1
+ )
+ foo(
+ default: 1
+ )
+ foo(
+ defer: 1
+ )
+ foo(
+ do: 1
+ )
+ foo(
+ else: 1
+ )
+ foo(
+ fallthrough: 1
+ )
+ foo(
+ for: 1
+ )
+ foo(
+ guard: 1
+ )
+ foo(
+ if: 1
+ )
+ foo(
+ in: 1
+ )
+ foo(
+ repeat: 1
+ )
+ foo(
+ return: 1
+ )
+ foo(
+ switch: 1
+ )
+ foo(
+ where: 1
+ )
+ foo(
+ while: 1
+ )
+
+ // Keywords used in expressions and types (without true, false, and
keywords begin with a number sign)
+ foo(
+ as: 1
+ )
+ foo(
+ catch: 1
+ )
+ foo(
+ dynamicType: 1
+ )
+ foo(
+ is: 1
+ )
+ foo(
+ rethrows: 1
+ )
+ foo(
+ super: 1
+ )
+ foo(
+ self: 1
+ )
+ foo(
+ Self: 1
+ )
+ foo(
+ throws: 1
+ )
+ foo(
+ throw: 1
+ )
+ foo(
+ try: 1
+ )
+
+ // Keywords reserved in particular contexts
+ foo(
+ Protocol: 1
+ )
+ foo(
+ Type: 1
+ )
+ foo(
+ and: 1
+ )
+ foo(
+ assignment: 1
+ )
+ foo(
+ associativity: 1
+ )
+ foo(
+ convenience: 1
+ )
+ foo(
+ didSet: 1
+ )
+ foo(
+ dynamic: 1
+ )
+ foo(
+ final: 1
+ )
+ foo(
+ get: 1
+ )
+ foo(
+ higherThan: 1
+ )
+ foo(
+ indirect: 1
+ )
+ foo(
+ infix: 1
+ )
+ foo(
+ lazy: 1
+ )
+ foo(
+ left: 1
+ )
+ foo(
+ lowerThan: 1
+ )
+ foo(
+ mutating: 1
+ )
+ foo(
+ none: 1
+ )
+ foo(
+ nonmutating: 1
+ )
+ foo(
+ optional: 1
+ )
+ foo(
+ override: 1
+ )
+ foo(
+ postfix: 1
+ )
+ foo(
+ precedence: 1
+ )
+ foo(
+ precedencegroup: 1
+ )
+ foo(
+ prefix: 1
+ )
+ foo(
+ required: 1
+ )
+ foo(
+ right: 1
+ )
+ foo(
+ set: 1
+ )
+ foo(
+ unowned: 1
+ )
+ foo(
+ weak: 1
+ )
+ foo(
+ willSet: 1
+ )
+}
+
// Unicode identifiers
let こんにちは = 你好 +
- [nongnu] elpa/swift-mode 174bccc 309/496: Tweak .travis.yml, (continued)
- [nongnu] elpa/swift-mode 174bccc 309/496: Tweak .travis.yml, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f9f4bc5 311/496: Fix `beginning/end-of-defun`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c659c45 329/496: Highlight anchor point for debugging., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b6512fa 325/496: Fix indentation of attributes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1d43501 330/496: Fix indentation of attributes at begging of the buffer., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 193de68 327/496: Fix end-of-defun at eob, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a07be7a 335/496: Fix `swift-mode:beginning-of-defun`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f03db1a 331/496: Fix indentation of switch., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a489024 344/496: indent-new-comment-line: Inherit slashes from the previous line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 75cbae2 345/496: Bump version to 2.2.3, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 42669da 343/496: Fix indentation for keywords used as parameter names,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 0cab4b2 346/496: Fix indentation for catch blocks without patterns, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 92f8eba 349/496: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2cd111f 351/496: Fix indentation of multiline strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3bcdf32 353/496: Add more keywords with number sign, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 030b1b8 356/496: Update documentations and wordings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d68af3c 365/496: Update copyright, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 359efc0 379/496: Fix indentation of function parameter clauses, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 25944c2 378/496: Add test for beginning/end-of-defun, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ea029a0 370/496: Suppress implicit semicolons inside interpolated expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b5602c1 375/496: Add beginning/end-of-sentence to README.md, ELPA Syncer, 2021/08/29