Skip to content

Commit 221863c

Browse files
committed
1 parent 2b2e858 commit 221863c

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

swift-mode-font-lock.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ Return nil otherwise."
534534

535535
(defconst swift-mode:expression-keywords
536536
'("as" "catch" "dynamicType" "is" "rethrows" "super" "self" "Self" "throws"
537-
"throw" "try" "async" "await")
537+
"throw" "try" "async" "await" "consume")
538538
"Keywords used in expressions and types.
539539
540540
Excludes true, false, and keywords begin with a number sign.")

swift-mode-indent.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,7 @@ It is a Generic parameter list if:
16491649
"as" "as?" "as!"
16501650
"is"
16511651
"await"
1652+
"consume"
16521653
"in"
16531654
"init" "deinit" "get" "set" "willSet" "didSet" "subscript"
16541655
"for" "case" "default" "while" "let" "var" "repeat" "if" "else"

swift-mode-lexer.el

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ END is the point after the token."
9999

100100
;; Token types is one of the following symbols:
101101
;;
102-
;; - prefix-operator (including try, try?, try!, and await)
102+
;; - prefix-operator (including try, try?, try!, await, and consume)
103103
;; - postfix-operator
104104
;; - binary-operator (including as, as?, as!, is, =, ., and ->)
105105
;; - attribute (e.g. @objc, @abc(def))
@@ -987,7 +987,8 @@ Other properties are the same as the TOKEN."
987987
(type
988988
(cond
989989
(is-declaration 'identifier)
990-
((member text '("try" "try?" "try!" "await")) 'prefix-operator)
990+
((member text '("try" "try?" "try!" "await" "consume"))
991+
'prefix-operator)
991992
((equal text ".") 'binary-operator)
992993
((and has-preceding-space has-following-space) 'binary-operator)
993994
(has-preceding-space 'prefix-operator)
@@ -1145,7 +1146,7 @@ This function does not return `implicit-;' or `type-:'."
11451146
pos-after-comment
11461147
(point))))
11471148

1148-
;; Operator (other than as, try, is, or await)
1149+
;; Operator (other than as, try, is, await, or consume)
11491150
;;
11501151
;; Operators starts with a dot can contains dots. Other operators cannot
11511152
;; contain dots.
@@ -1244,7 +1245,7 @@ This function does not return `implicit-;' or `type-:'."
12441245
text
12451246
(- (point) (length text))
12461247
(point)))
1247-
((equal text "await")
1248+
((member text '("await" "consume"))
12481249
(swift-mode:token 'prefix-operator
12491250
text
12501251
(- (point) (length text))
@@ -1417,7 +1418,7 @@ This function does not return `implicit-;' or `type-:'."
14171418
(point)
14181419
pos-before-comment)))
14191420

1420-
;; Operator (other than as, try, is, or await)
1421+
;; Operator (other than as, try, is, await, or consume)
14211422
;;
14221423
;; Operators which starts with a dot can contain other dots. Other
14231424
;; operators cannot contain dots.
@@ -1499,7 +1500,7 @@ This function does not return `implicit-;' or `type-:'."
14991500
text
15001501
(point)
15011502
(+ (point) (length text))))
1502-
((member text '("try" "await"))
1503+
((member text '("try" "await" "consume"))
15031504
(swift-mode:token 'prefix-operator
15041505
text
15051506
(point)

test/swift-files/indent/expressions.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,3 +821,15 @@ func foo() {
821821
2
822822
}
823823
}
824+
825+
// consume operator
826+
// https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md
827+
828+
func foo() {
829+
// consume operator cannot be followed by a line break.
830+
let y =
831+
consume
832+
x
833+
834+
return y
835+
}

test/swift-files/indent/identifiers.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ func foo() {
212212
foo(
213213
await: 1
214214
)
215+
foo(
216+
consume: 1
217+
)
215218

216219
// Keywords reserved in particular contexts
217220
foo(

0 commit comments

Comments
 (0)