[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 23b9227 492/496: Support async/await
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 23b9227 492/496: Support async/await |
Date: |
Sun, 29 Aug 2021 11:34:34 -0400 (EDT) |
branch: elpa/swift-mode
commit 23b9227693c380fabdd028b874b565a78c8965c1
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Support async/await
Imenu and indentation.
---
swift-mode-indent.el | 1 +
swift-mode-lexer.el | 21 +++++---
.../beginning-of-defun/beginning-of-defun.swift | 1 +
test/swift-files/imenu/imenu-expected.el | 60 +++++++++++-----------
test/swift-files/imenu/imenu.swift | 2 +-
test/swift-files/indent/declarations.swift | 2 +
test/swift-files/indent/expressions.swift | 35 ++++++++++++-
test/swift-files/indent/identifiers.swift | 6 +++
test/swift-files/indent/statements.swift | 11 ++++
test/swift-files/indent/types.swift | 15 ++++++
10 files changed, 114 insertions(+), 40 deletions(-)
diff --git a/swift-mode-indent.el b/swift-mode-indent.el
index 715c34a..5c002f4 100644
--- a/swift-mode-indent.el
+++ b/swift-mode-indent.el
@@ -1501,6 +1501,7 @@ It is a Generic parameter list if:
"try" "try?" "try!"
"as" "as?" "as!"
"is"
+ "await"
"in"
"init" "deinit" "get" "set" "willSet" "didSet" "subscript"
"for" "case" "default" "while" "let" "var" "repeat" "if" "else"
diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el
index 1448128..1f00212 100644
--- a/swift-mode-lexer.el
+++ b/swift-mode-lexer.el
@@ -99,7 +99,7 @@ END is the point after the token."
;; Token types is one of the following symbols:
;;
-;; - prefix-operator (including try, try?, and try!)
+;; - prefix-operator (including try, try?, try!, and await)
;; - postfix-operator
;; - binary-operator (including as, as?, as!, is, =, ., and ->)
;; - attribute (e.g. @objc, @abc(def))
@@ -402,9 +402,9 @@ Return nil otherwise."
(memq (swift-mode:token:type next-token)
'(binary-operator \; \, :))
- ;; Suppresses implicit semicolon after try, try?, and try!.
+ ;; Suppresses implicit semicolon after try, try?, try!, and await.
(member (swift-mode:token:text previous-token)
- '("try" "try?" "try!"))
+ '("try" "try?" "try!" "await"))
;; Suppress implicit semicolon after open brackets or before close
;; brackets.
@@ -433,7 +433,7 @@ Return nil otherwise."
(member (swift-mode:token:text previous-token)
'("some" "inout" "in" "where"))
(member (swift-mode:token:text next-token)
- '("some" "inout" "throws" "rethrows" "in" "where")))
+ '("some" "inout" "throws" "rethrows" "async" "in" "where")))
nil)
;; Inserts semicolon before open curly bracket.
@@ -779,7 +779,7 @@ Other properties are the same as the TOKEN."
(type
(cond
(is-declaration 'identifier)
- ((member text '("try" "try?" "try!")) 'prefix-operator)
+ ((member text '("try" "try?" "try!" "await")) 'prefix-operator)
((equal text ".") 'binary-operator)
((and has-preceding-space has-following-space) 'binary-operator)
(has-preceding-space 'prefix-operator)
@@ -925,7 +925,7 @@ This function does not return `implicit-;' or `type-:'."
(forward-char)
(swift-mode:token '> ">" (1- (point)) (point)))
- ;; Operator (other than as, try, or is)
+ ;; Operator (other than as, try, is, or await)
;;
;; Operators starts with a dot can contains dots. Other operators cannot
;; contain dots.
@@ -1019,6 +1019,11 @@ This function does not return `implicit-;' or `type-:'."
text
(- (point) (length text))
(point)))
+ ((equal text "await")
+ (swift-mode:token 'prefix-operator
+ text
+ (- (point) (length text))
+ (point)))
(t
(swift-mode:token 'identifier
text
@@ -1173,7 +1178,7 @@ This function does not return `implicit-;' or `type-:'."
(backward-char)
(swift-mode:token '> ">" (point) (1+ (point))))
- ;; Operator (other than as, try, or is)
+ ;; Operator (other than as, try, is, or await)
;;
;; Operators which starts with a dot can contain other dots. Other
;; operators cannot contain dots.
@@ -1254,7 +1259,7 @@ This function does not return `implicit-;' or `type-:'."
text
(point)
(+ (point) (length text))))
- ((equal text "try")
+ ((member text '("try" "await"))
(swift-mode:token 'prefix-operator
text
(point)
diff --git a/test/swift-files/beginning-of-defun/beginning-of-defun.swift
b/test/swift-files/beginning-of-defun/beginning-of-defun.swift
index 5f38a34..b23fbef 100644
--- a/test/swift-files/beginning-of-defun/beginning-of-defun.swift
+++ b/test/swift-files/beginning-of-defun/beginning-of-defun.swift
@@ -141,6 +141,7 @@ foo() {
]/*]*/
}
)
+ async
throws
->
@Foo
diff --git a/test/swift-files/imenu/imenu-expected.el
b/test/swift-files/imenu/imenu-expected.el
index 9aaf8fb..0da371b 100644
--- a/test/swift-files/imenu/imenu-expected.el
+++ b/test/swift-files/imenu/imenu-expected.el
@@ -1,26 +1,26 @@
-((precedencegroup (identifier "precedenceGroup" 2753 2768) nil)
- (operator (identifier "*****" 2713 2718) nil)
- (operator (identifier "-----" 2673 2678) nil)
- (operator (identifier "+++++" 2634 2639) nil)
- (extension (identifier "FooClass" 2469 2477)
- ((class (identifier "NestedClass1" 2509 2521)
- ((class (identifier "NestedClass2" 2538 2550)
- ((class (identifier "NestedClass3" 2571 2583)
nil)))))))
- (protocol (identifier "FooProtocol" 2209 2220)
- ((var (identifier "protocolProperty" 2236 2252) nil)
- (func (identifier "protocolMethod(a:b:)" 2278 2292) nil)
- (init (identifier "init(a:b:c:)" 2320 2324) nil)
- (subscript (identifier "subscript(_:bbb:)" 2355 2364) nil)
- (associatedtype (identifier "AssociatedType" 2436 2450) nil)))
- (actor (identifier "FooActor" 2181 2189) nil)
- (struct (identifier "FooStruct" 2155 2164) nil)
- (enum (identifier "FooEnum2" 2090 2098)
- ((case (identifier "case1" 2115 2120) nil)
- (case (identifier "case2" 2135 2140) nil)))
- (enum (identifier "FooEnum1" 1955 1963)
- ((case (identifier "case1" 2002 2007) nil)
- (case (identifier "case2" 2033 2038) nil)
- (case (identifier "case3" 2062 2067) nil)))
+((precedencegroup (identifier "precedenceGroup" 2759 2774) nil)
+ (operator (identifier "*****" 2719 2724) nil)
+ (operator (identifier "-----" 2679 2684) nil)
+ (operator (identifier "+++++" 2640 2645) nil)
+ (extension (identifier "FooClass" 2475 2483)
+ ((class (identifier "NestedClass1" 2515 2527)
+ ((class (identifier "NestedClass2" 2544 2556)
+ ((class (identifier "NestedClass3" 2577 2589)
nil)))))))
+ (protocol (identifier "FooProtocol" 2215 2226)
+ ((var (identifier "protocolProperty" 2242 2258) nil)
+ (func (identifier "protocolMethod(a:b:)" 2284 2298) nil)
+ (init (identifier "init(a:b:c:)" 2326 2330) nil)
+ (subscript (identifier "subscript(_:bbb:)" 2361 2370) nil)
+ (associatedtype (identifier "AssociatedType" 2442 2456) nil)))
+ (actor (identifier "FooActor" 2187 2195) nil)
+ (struct (identifier "FooStruct" 2161 2170) nil)
+ (enum (identifier "FooEnum2" 2096 2104)
+ ((case (identifier "case1" 2121 2126) nil)
+ (case (identifier "case2" 2141 2146) nil)))
+ (enum (identifier "FooEnum1" 1961 1969)
+ ((case (identifier "case1" 2008 2013) nil)
+ (case (identifier "case2" 2039 2044) nil)
+ (case (identifier "case3" 2068 2073) nil)))
(class (identifier "FooClass" 597 605)
((var (identifier "classVariable1" 674 688) nil)
(class (identifier "final" 724 729) nil)
@@ -28,13 +28,13 @@
(var (identifier "observedProperty" 911 927) nil)
(typealias (identifier "TypeAlias" 1075 1084) nil)
(func (identifier "function1(aaa:_:ddd:eee:)" 1139 1148) nil)
- (func (identifier "function2()" 1336 1345) nil)
- (func (identifier "function3(a:)" 1419 1428) nil)
- (func (identifier "+(_:_:)" 1563 1564) nil)
- (subscript (identifier "subscript(_:bbb:)" 1725 1734) nil)
- (init (identifier "init(a:)" 1873 1877) nil)
- (init (identifier "init(b:)" 1900 1904) nil)
- (deinit (identifier "deinit" 1927 1933) nil)))
+ (func (identifier "function2()" 1342 1351) nil)
+ (func (identifier "function3(a:)" 1425 1434) nil)
+ (func (identifier "+(_:_:)" 1569 1570) nil)
+ (subscript (identifier "subscript(_:bbb:)" 1731 1740) nil)
+ (init (identifier "init(a:)" 1879 1883) nil)
+ (init (identifier "init(b:)" 1906 1910) nil)
+ (deinit (identifier "deinit" 1933 1939) nil)))
(var (identifier "globalVariable2" 560 575) nil)
(var (identifier "globalVariable1" 530 545) nil)
(let (identifier "globalConstant2" 496 511) nil)
diff --git a/test/swift-files/imenu/imenu.swift
b/test/swift-files/imenu/imenu.swift
index 67fc1dd..a9be705 100644
--- a/test/swift-files/imenu/imenu.swift
+++ b/test/swift-files/imenu/imenu.swift
@@ -44,7 +44,7 @@ import func FooModule3.importedFunction
@AAA internal typealias TypeAlias<A: AA, B: BB, C: CC> = AAA
- @AAA class final func function1<A: AA, B: BB, C: CC>(aaa bbb: Int, _ ccc:
Int, ddd: Int = 1, eee: inout Int = 2) throws -> AAA {
+ @AAA class final func function1<A: AA, B: BB, C: CC>(aaa bbb: Int, _ ccc:
Int, ddd: Int = 1, eee: inout Int = 2) async throws -> AAA {
let a = 1
var b = 2
diff --git a/test/swift-files/indent/declarations.swift
b/test/swift-files/indent/declarations.swift
index abb2b80..f00c54c 100644
--- a/test/swift-files/indent/declarations.swift
+++ b/test/swift-files/indent/declarations.swift
@@ -81,6 +81,7 @@ class Foo {
Int,
Int
)
+ async
throws
->
[
@@ -314,6 +315,7 @@ private
Int
...
)
+ async
throws
->
[A]
diff --git a/test/swift-files/indent/expressions.swift
b/test/swift-files/indent/expressions.swift
index 6be2c34..50d9be8 100644
--- a/test/swift-files/indent/expressions.swift
+++ b/test/swift-files/indent/expressions.swift
@@ -12,7 +12,7 @@ foo(
&x
)
-// Try operators
+// Try and await operators
let foo = try
a() + try
@@ -38,6 +38,36 @@ let foo = a+try?
a() + b+try?
b()
+
+let foo = await
+ a() + await
+ b()
+
+let foo = a+await
+ a() +b+await
+ b()
+
+let foo = try await
+ a() + try await
+ b()
+
+let foo = a+try await
+ a() +b+try await
+ b()
+
+let foo = try
+ await
+ a() + try
+ await
+ b()
+
+let foo = a+try
+ await
+ a() +b+try
+ await
+ b()
+
+
// Binary expressions
// See also operators.swift
@@ -305,6 +335,7 @@ let x = { (
x: Int,
y: Int
)
+ async
throws
->
Foo
@@ -325,6 +356,7 @@ let x = { [
x: Int,
y: Int
)
+ async
throws
->
Foo
@@ -344,6 +376,7 @@ let x = {
x: Int,
y: Int
)
+ async
throws
->
Foo
diff --git a/test/swift-files/indent/identifiers.swift
b/test/swift-files/indent/identifiers.swift
index 85ced6c..9c4afa0 100644
--- a/test/swift-files/indent/identifiers.swift
+++ b/test/swift-files/indent/identifiers.swift
@@ -195,8 +195,14 @@ func foo() {
throw: 1
)
foo(
+ async: 1
+ )
+ foo(
try: 1
)
+ foo(
+ await: 1
+ )
// Keywords reserved in particular contexts
foo(
diff --git a/test/swift-files/indent/statements.swift
b/test/swift-files/indent/statements.swift
index a58cec8..2778c27 100644
--- a/test/swift-files/indent/statements.swift
+++ b/test/swift-files/indent/statements.swift
@@ -322,6 +322,17 @@ for
{
}
+for
+ try
+ await
+ x
+ in
+ xs() {
+ foo()
+ foo()
+}
+
+
// While statements
while foo
diff --git a/test/swift-files/indent/types.swift
b/test/swift-files/indent/types.swift
index c9e0ae3..31c45b7 100644
--- a/test/swift-files/indent/types.swift
+++ b/test/swift-files/indent/types.swift
@@ -258,6 +258,21 @@ let foo
B
= abc
+let foo:
+ (A, B)
+ async
+ throws
+ ->
+ (A)
+ async
+ rethrows
+ ->
+ (A)
+ async
+ ->
+ B
+ = abc
+
// Optional types
- [nongnu] elpa/swift-mode 4e22279 390/496: Bump version to 4.1.1, (continued)
- [nongnu] elpa/swift-mode 4e22279 390/496: Bump version to 4.1.1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0e6b044 408/496: Make highlighting symbols in standard library optional, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 71c82e9 418/496: Add compilation before testing, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1759977 440/496: Fix typo, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 323bb97 457/496: Update copyright notices, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7d93c75 464/496: Bump version to 8.1.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e65a80a 465/496: Support full-indent for switch cases, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9676f90 485/496: Update CI versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e9e493e 487/496: Set `comment-line-break-function`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode fd3c824 484/496: Bump version to 8.2.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 23b9227 492/496: Support async/await,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 6546ad5 040/496: Fix auto-mode-alist regex, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 760710c 031/496: fixup! Update readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode bf224ad 049/496: Organize links, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e46584a 054/496: Add @bbatsov to contributors in readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5adb37d 070/496: More indentation tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 34be010 074/496: Update features in readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 6553249 062/496: Rename predicate (add question mark), ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ff32221 068/496: Add font lock tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5f97c99 060/496: Add tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c3a0a66 065/496: Fix custom variable types, ELPA Syncer, 2021/08/29