Skip to content

Commit

Permalink
enh(swift) add actor keyword (#3171)
Browse files Browse the repository at this point in the history
* (swift) add `actor` keyword

Coming in Swift 5.5, per [Swift Evolution](https://github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md)

* (swift) add markup tests for all type constructors

These appeared to be missing before, so are now tested to be keywords.

* (swift) treat 'actor' similarly to 'class' and others

* (swift) move type definition tests to seperate suite

* (swift) fix type definition tests

* (swift) remove trailing line from type definition test case

* (swift) add extension and protocol to type definition test suite
  • Loading branch information
bradleymackey committed May 2, 2021
1 parent 58698d5 commit bd312ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Parser:

Grammars:

- enh(swift) add `actor` keyword (#3171) [Bradley Mackey][]
- enh(crystal) highlight variables (#3154) [Josh Goebel][]
- fix(ruby) Heredoc without interpolation (#3154) [Josh Goebel][]
- enh(swift) add `@resultBuilder` attribute (#3151) [Bradley Mackey][]
Expand Down
1 change: 1 addition & 0 deletions src/languages/lib/kws_swift.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const keywords = [
// strings below will be fed into the regular `keywords` engine while regex
// will result in additional modes being created to scan for those keywords to
// avoid conflicts with other rules
'actor',
'associatedtype',
'async',
'await',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/swift.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export default function(hljs) {
FUNCTION,
INIT_SUBSCRIPT,
{
beginKeywords: 'struct protocol class extension enum',
beginKeywords: 'struct protocol class extension enum actor',
end: '\\{',
excludeEnd: true,
keywords: KEYWORDS,
Expand Down
6 changes: 6 additions & 0 deletions test/markup/swift/type-definition.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<span class="hljs-keyword">class</span> <span class="hljs-title class_">TestClass</span> {}
<span class="hljs-keyword">struct</span> <span class="hljs-title class_">TestStruct</span> {}
<span class="hljs-keyword">enum</span> <span class="hljs-title class_">TestEnum</span> {}
<span class="hljs-keyword">actor</span> <span class="hljs-title class_">TestActor</span> {}
<span class="hljs-keyword">extension</span> <span class="hljs-title class_">TestExtension</span> {}
<span class="hljs-keyword">protocol</span> <span class="hljs-title class_">TestProtocol</span> {}
6 changes: 6 additions & 0 deletions test/markup/swift/type-definition.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class TestClass {}
struct TestStruct {}
enum TestEnum {}
actor TestActor {}
extension TestExtension {}
protocol TestProtocol {}

0 comments on commit bd312ab

Please sign in to comment.