Skip to content

Commit

Permalink
Support nonisolated/isolated
Browse files Browse the repository at this point in the history
  • Loading branch information
taku0 committed Sep 25, 2021
1 parent 05a661e commit 9e220cb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion swift-mode-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ Return nil otherwise."
'("associatedtype" "class" "deinit" "enum" "extension" "fileprivate" "func"
"import" "init" "inout" "internal" "let" "open" "operator" "private"
"protocol" "public" "some" "static" "struct" "subscript" "typealias" "var"
"actor")
"actor" "nonisolated" "isolated")
"Keywords used in declarations.")

(defconst swift-mode:statement-keywords
Expand Down
9 changes: 5 additions & 4 deletions swift-mode-lexer.el
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,10 @@ Return nil otherwise."
;; Suppress implicit semicolon around keywords that cannot start or end
;; statements.
(member (swift-mode:token:text previous-token)
'("some" "inout" "in" "where"))
'("some" "inout" "in" "where" "isolated"))
(member (swift-mode:token:text next-token)
'("some" "inout" "throws" "rethrows" "async" "in" "where")))
'("some" "inout" "throws" "rethrows" "in" "where"
"isolated")))
nil)

;; Inserts semicolon before open curly bracket.
Expand All @@ -458,7 +459,7 @@ Return nil otherwise."
'("indirect" "convenience" "dynamic" "final" "infix" "lazy"
"mutating" "nonmutating" "optional" "override" "postfix"
"prefix" "required" "static" "unowned" "weak" "internal"
"private" "public" "open" "fileprivate"))
"private" "public" "open" "fileprivate" "nonisolated"))
nil)

;; internal(set) private(set) public(set) open(set) fileprivate(set)
Expand Down Expand Up @@ -491,7 +492,7 @@ Return nil otherwise."
'("indirect" "convenience" "dynamic" "final" "infix" "lazy"
"mutating" "nonmutating" "optional" "override" "postfix"
"prefix" "required" "static" "unowned" "weak" "internal"
"private" "public" "open" "fileprivate"))
"private" "public" "open" "fileprivate" "nonisolated"))
t)

;; Inserts implicit semicolon around keywords that forms single keyword
Expand Down
6 changes: 5 additions & 1 deletion test/swift-files/indent/declarations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ private
B>
(
x:
@A
isolated
inout
Int,
y:
Int
Expand Down Expand Up @@ -620,7 +623,8 @@ fileprivate
B =
D<E> {
func foo()
func foo()
nonisolated
func foo()
}


Expand Down
6 changes: 6 additions & 0 deletions test/swift-files/indent/identifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func foo() {
foo(
some: 1
)
foo(
nonisolated: 1
)
foo(
isolated: 1
)

// Keywords used in statements
foo(
Expand Down

0 comments on commit 9e220cb

Please sign in to comment.