enh(swift) `@unchecked` and `@Sendable` support (#3808)

* @Sendable is a keyword attribute

* Add @unchecked for Sendable conformance

* Use scope spelling for attribute rules

* @unchecked is not actually contextual

* Revert unneeded changes

* Update CHANGES.md
This commit is contained in:
Bradley Mackey 2023-06-16 01:00:31 +01:00 committed by GitHub
parent 88dcae86d4
commit fcefad4a6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 3 deletions

View File

@ -14,6 +14,7 @@ Core Grammars:
- enh(swift) support `macro` keyword [Bradley Mackey][]
- enh(swift) support parameter pack keywords [Bradley Mackey][]
- enh(swift) regex literal support [Bradley Mackey][]
- enh(swift) `@unchecked` and `@Sendable` support [Bradley Mackey][]
Dev tool:

View File

@ -305,8 +305,10 @@ export const keywordAttributes = [
'propertyWrapper',
'requires_stored_property_inits',
'resultBuilder',
'Sendable',
'testable',
'UIApplicationMain',
'unchecked',
'unknown',
'usableFromInline'
];

View File

@ -243,7 +243,7 @@ export default function(hljs) {
// https://docs.swift.org/swift-book/ReferenceManual/Attributes.html
const AVAILABLE_ATTRIBUTE = {
match: /(@|#(un)?)available/,
className: "keyword",
scope: 'keyword',
starts: { contains: [
{
begin: /\(/,
@ -258,11 +258,11 @@ export default function(hljs) {
] }
};
const KEYWORD_ATTRIBUTE = {
className: 'keyword',
scope: 'keyword',
match: concat(/@/, either(...Swift.keywordAttributes))
};
const USER_DEFINED_ATTRIBUTE = {
className: 'meta',
scope: 'meta',
match: concat(/@/, Swift.identifier)
};
const ATTRIBUTES = [

View File

@ -5,5 +5,7 @@
<span class="hljs-keyword">@propertyWrapper</span>
<span class="hljs-meta">@SomeWrapper</span>(value: <span class="hljs-number">1.0</span>, other: <span class="hljs-string">&quot;string&quot;</span>, bool: <span class="hljs-literal">false</span>)
<span class="hljs-keyword">@resultBuilder</span>
<span class="hljs-keyword">@Sendable</span>
<span class="hljs-keyword">@unchecked</span>
@ notAnAttribute

View File

@ -5,5 +5,7 @@
@propertyWrapper
@SomeWrapper(value: 1.0, other: "string", bool: false)
@resultBuilder
@Sendable
@unchecked
@ notAnAttribute