[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 221863c4e2 1/9: Add `consume` operator
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 221863c4e2 1/9: Add `consume` operator |
Date: |
Sat, 30 Sep 2023 07:01:17 -0400 (EDT) |
branch: elpa/swift-mode
commit 221863c4e2569194420b869f285012974bd5733f
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Add `consume` operator
https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md
---
swift-mode-font-lock.el | 2 +-
swift-mode-indent.el | 1 +
swift-mode-lexer.el | 13 +++++++------
test/swift-files/indent/expressions.swift | 12 ++++++++++++
test/swift-files/indent/identifiers.swift | 3 +++
5 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/swift-mode-font-lock.el b/swift-mode-font-lock.el
index 23ffb907b0..cd2e030ced 100644
--- a/swift-mode-font-lock.el
+++ b/swift-mode-font-lock.el
@@ -534,7 +534,7 @@ Return nil otherwise."
(defconst swift-mode:expression-keywords
'("as" "catch" "dynamicType" "is" "rethrows" "super" "self" "Self" "throws"
- "throw" "try" "async" "await")
+ "throw" "try" "async" "await" "consume")
"Keywords used in expressions and types.
Excludes true, false, and keywords begin with a number sign.")
diff --git a/swift-mode-indent.el b/swift-mode-indent.el
index 3ab465e69f..c1ce92386b 100644
--- a/swift-mode-indent.el
+++ b/swift-mode-indent.el
@@ -1649,6 +1649,7 @@ It is a Generic parameter list if:
"as" "as?" "as!"
"is"
"await"
+ "consume"
"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 fd3ebfce73..d6f30bb128 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?, try!, and await)
+;; - prefix-operator (including try, try?, try!, await, and consume)
;; - postfix-operator
;; - binary-operator (including as, as?, as!, is, =, ., and ->)
;; - attribute (e.g. @objc, @abc(def))
@@ -987,7 +987,8 @@ Other properties are the same as the TOKEN."
(type
(cond
(is-declaration 'identifier)
- ((member text '("try" "try?" "try!" "await")) 'prefix-operator)
+ ((member text '("try" "try?" "try!" "await" "consume"))
+ 'prefix-operator)
((equal text ".") 'binary-operator)
((and has-preceding-space has-following-space) 'binary-operator)
(has-preceding-space 'prefix-operator)
@@ -1145,7 +1146,7 @@ This function does not return `implicit-;' or `type-:'."
pos-after-comment
(point))))
- ;; Operator (other than as, try, is, or await)
+ ;; Operator (other than as, try, is, await, or consume)
;;
;; Operators starts with a dot can contains dots. Other operators cannot
;; contain dots.
@@ -1244,7 +1245,7 @@ This function does not return `implicit-;' or `type-:'."
text
(- (point) (length text))
(point)))
- ((equal text "await")
+ ((member text '("await" "consume"))
(swift-mode:token 'prefix-operator
text
(- (point) (length text))
@@ -1417,7 +1418,7 @@ This function does not return `implicit-;' or `type-:'."
(point)
pos-before-comment)))
- ;; Operator (other than as, try, is, or await)
+ ;; Operator (other than as, try, is, await, or consume)
;;
;; Operators which starts with a dot can contain other dots. Other
;; operators cannot contain dots.
@@ -1499,7 +1500,7 @@ This function does not return `implicit-;' or `type-:'."
text
(point)
(+ (point) (length text))))
- ((member text '("try" "await"))
+ ((member text '("try" "await" "consume"))
(swift-mode:token 'prefix-operator
text
(point)
diff --git a/test/swift-files/indent/expressions.swift
b/test/swift-files/indent/expressions.swift
index 21e2c6abda..4b5ff2a27c 100644
--- a/test/swift-files/indent/expressions.swift
+++ b/test/swift-files/indent/expressions.swift
@@ -821,3 +821,15 @@ func foo() {
2
}
}
+
+// consume operator
+//
https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md
+
+func foo() {
+ // consume operator cannot be followed by a line break.
+ let y =
+ consume
+ x
+
+ return y
+}
diff --git a/test/swift-files/indent/identifiers.swift
b/test/swift-files/indent/identifiers.swift
index b960169899..f57c79d3c8 100644
--- a/test/swift-files/indent/identifiers.swift
+++ b/test/swift-files/indent/identifiers.swift
@@ -212,6 +212,9 @@ func foo() {
foo(
await: 1
)
+ foo(
+ consume: 1
+ )
// Keywords reserved in particular contexts
foo(
- [nongnu] elpa/swift-mode updated (2b2e8581ba -> e58417ec87), ELPA Syncer, 2023/09/30
- [nongnu] elpa/swift-mode 6194d9578d 2/9: Add `borrowing` and `consuming` modifiers and `copy` operator, ELPA Syncer, 2023/09/30
- [nongnu] elpa/swift-mode 221863c4e2 1/9: Add `consume` operator,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 6b19157def 3/9: Add `package` modifier, ELPA Syncer, 2023/09/30
- [nongnu] elpa/swift-mode 1339e24d23 4/9: Add `discard self`, ELPA Syncer, 2023/09/30
- [nongnu] elpa/swift-mode 1178d72a37 5/9: Add init accessors, ELPA Syncer, 2023/09/30
- [nongnu] elpa/swift-mode ef36acf2c5 6/9: Add value and type parameter packs, ELPA Syncer, 2023/09/30
- [nongnu] elpa/swift-mode a22f053c2b 7/9: Add macro declaration, ELPA Syncer, 2023/09/30
- [nongnu] elpa/swift-mode 73d20b686f 8/9: Open .swiftinterface files in Swift mode, ELPA Syncer, 2023/09/30
- [nongnu] elpa/swift-mode e58417ec87 9/9: Bump version to 9.1.0, ELPA Syncer, 2023/09/30