[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 6194d9578d 2/9: Add `borrowing` and `consuming`
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 6194d9578d 2/9: Add `borrowing` and `consuming` modifiers and `copy` operator |
Date: |
Sat, 30 Sep 2023 07:01:18 -0400 (EDT) |
branch: elpa/swift-mode
commit 6194d9578d6e02e49343fc02089a093dbcbcdbfc
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Add `borrowing` and `consuming` modifiers and `copy` operator
https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md
---
swift-mode-font-lock.el | 5 +++--
swift-mode-indent.el | 2 +-
swift-mode-lexer.el | 19 ++++++++++---------
test/swift-files/indent/declarations.swift | 2 ++
test/swift-files/indent/expressions.swift | 10 ++++++++++
test/swift-files/indent/identifiers.swift | 9 +++++++++
6 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/swift-mode-font-lock.el b/swift-mode-font-lock.el
index cd2e030ced..f37ab79de6 100644
--- a/swift-mode-font-lock.el
+++ b/swift-mode-font-lock.el
@@ -524,7 +524,8 @@ Return nil otherwise."
'("associatedtype" "class" "deinit" "enum" "extension" "fileprivate" "func"
"import" "init" "inout" "internal" "let" "open" "operator" "private"
"protocol" "public" "any" "some" "static" "struct" "subscript" "typealias"
- "var" "actor" "nonisolated" "isolated" "distributed")
+ "var" "actor" "nonisolated" "isolated" "distributed"
+ "borrowing" "consuming")
"Keywords used in declarations.")
(defconst swift-mode:statement-keywords
@@ -534,7 +535,7 @@ Return nil otherwise."
(defconst swift-mode:expression-keywords
'("as" "catch" "dynamicType" "is" "rethrows" "super" "self" "Self" "throws"
- "throw" "try" "async" "await" "consume")
+ "throw" "try" "async" "await" "consume" "copy")
"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 c1ce92386b..bf3e2839f9 100644
--- a/swift-mode-indent.el
+++ b/swift-mode-indent.el
@@ -1649,7 +1649,7 @@ It is a Generic parameter list if:
"as" "as?" "as!"
"is"
"await"
- "consume"
+ "consume" "copy"
"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 d6f30bb128..2f1d3c3a21 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!, await, and consume)
+;; - prefix-operator (including try, try?, try!, await, consume, and copy)
;; - postfix-operator
;; - binary-operator (including as, as?, as!, is, =, ., and ->)
;; - attribute (e.g. @objc, @abc(def))
@@ -609,10 +609,11 @@ return non-nil."
;; Suppress implicit semicolon around keywords that cannot start or end
;; statements.
(member (swift-mode:token:text previous-token)
- '("any" "some" "inout" "in" "where" "isolated"))
+ '("any" "some" "inout" "borrowing" "consuming" "in" "where"
+ "isolated"))
(member (swift-mode:token:text next-token)
- '("any" "some" "inout" "throws" "rethrows" "in" "where"
- "isolated")))
+ '("any" "some" "inout" "borrowing" "consuming" "throws"
+ "rethrows" "in" "where" "isolated")))
nil)
;; Before async
@@ -987,7 +988,7 @@ Other properties are the same as the TOKEN."
(type
(cond
(is-declaration 'identifier)
- ((member text '("try" "try?" "try!" "await" "consume"))
+ ((member text '("try" "try?" "try!" "await" "consume" "copy"))
'prefix-operator)
((equal text ".") 'binary-operator)
((and has-preceding-space has-following-space) 'binary-operator)
@@ -1146,7 +1147,7 @@ This function does not return `implicit-;' or `type-:'."
pos-after-comment
(point))))
- ;; Operator (other than as, try, is, await, or consume)
+ ;; Operator (other than as, try, is, await, consume, or copy)
;;
;; Operators starts with a dot can contains dots. Other operators cannot
;; contain dots.
@@ -1245,7 +1246,7 @@ This function does not return `implicit-;' or `type-:'."
text
(- (point) (length text))
(point)))
- ((member text '("await" "consume"))
+ ((member text '("await" "consume" "copy"))
(swift-mode:token 'prefix-operator
text
(- (point) (length text))
@@ -1418,7 +1419,7 @@ This function does not return `implicit-;' or `type-:'."
(point)
pos-before-comment)))
- ;; Operator (other than as, try, is, await, or consume)
+ ;; Operator (other than as, try, is, await, consume, or copy)
;;
;; Operators which starts with a dot can contain other dots. Other
;; operators cannot contain dots.
@@ -1500,7 +1501,7 @@ This function does not return `implicit-;' or `type-:'."
text
(point)
(+ (point) (length text))))
- ((member text '("try" "await" "consume"))
+ ((member text '("try" "await" "consume" "copy"))
(swift-mode:token 'prefix-operator
text
(point)
diff --git a/test/swift-files/indent/declarations.swift
b/test/swift-files/indent/declarations.swift
index f0dae56b6d..96743692e8 100644
--- a/test/swift-files/indent/declarations.swift
+++ b/test/swift-files/indent/declarations.swift
@@ -343,11 +343,13 @@ private
inout
Int,
y:
+ borrowing
Int
=
1,
z,
w:
+ consuming
Int
...
)
diff --git a/test/swift-files/indent/expressions.swift
b/test/swift-files/indent/expressions.swift
index 4b5ff2a27c..2d8d6abf74 100644
--- a/test/swift-files/indent/expressions.swift
+++ b/test/swift-files/indent/expressions.swift
@@ -833,3 +833,13 @@ func foo() {
return y
}
+
+
+// copy operator
+//
https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md
+
+func foo() {
+ // copy operator cannot be followed by a line break.
+ copy
+ x
+}
diff --git a/test/swift-files/indent/identifiers.swift
b/test/swift-files/indent/identifiers.swift
index f57c79d3c8..54fd89dd0c 100644
--- a/test/swift-files/indent/identifiers.swift
+++ b/test/swift-files/indent/identifiers.swift
@@ -67,6 +67,12 @@ func foo() {
foo(
inout: 1
)
+ foo(
+ borrowing: 1
+ )
+ foo(
+ consuming: 1
+ )
foo(
internal: 1
)
@@ -215,6 +221,9 @@ func foo() {
foo(
consume: 1
)
+ foo(
+ copy: 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 <=
- [nongnu] elpa/swift-mode 221863c4e2 1/9: Add `consume` operator, ELPA Syncer, 2023/09/30
- [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