diff --git a/src/basic-languages/swift/swift.test.ts b/src/basic-languages/swift/swift.test.ts index 5f5d32f861..ee7210309c 100644 --- a/src/basic-languages/swift/swift.test.ts +++ b/src/basic-languages/swift/swift.test.ts @@ -9,12 +9,12 @@ testTokenization('swift', [ // Attributes [ { - line: '@noescape', + line: '@escaping', tokens: [ { startIndex: 0, type: 'keyword.control.swift' - } /* '@noescape' */ + } /* '@escaping' */ ] } ], diff --git a/src/basic-languages/swift/swift.ts b/src/basic-languages/swift/swift.ts index 2ecef407a9..4a4e7a10fa 100644 --- a/src/basic-languages/swift/swift.ts +++ b/src/basic-languages/swift/swift.ts @@ -38,33 +38,84 @@ export const language = { // TODO(owensd): Support the full range of unicode valid identifiers. identifier: /[a-zA-Z_][\w$]*/, - // TODO(owensd): Support the @availability macro properly. + attributes: [ - '@autoclosure', - '@noescape', - '@noreturn', + '@GKInspectable', + '@IBAction', + '@IBDesignable', + '@IBInspectable', + '@IBOutlet', + '@IBSegueAction', '@NSApplicationMain', '@NSCopying', '@NSManaged', - '@objc', + '@Sendable', '@UIApplicationMain', + + '@autoclosure', + '@actorIndependent', + '@asyncHandler', + '@available', + '@convention', + '@derivative', // Swift for TensorFlow + '@differentiable', // Swift for TensorFlow + '@discardableResult', + '@dynamicCallable', + '@dynamicMemberLookup', + '@escaping', + '@frozen', + '@globalActor', + '@inlinable', + '@inline', + '@main', + '@nonobjc', '@noreturn', - '@availability', - '@IBAction', - '@IBDesignable', - '@IBInspectable', - '@IBOutlet' + '@objc', + '@objcMembers', + '@propertyWrapper', + '@requires_stored_property_inits', + '@resultBuilder', + '@testable', + '@unchecked', + '@unknown', + '@usableFromInline', + '@warn_unqualified_access' ], - accessmodifiers: ['public', 'private', 'fileprivate', 'internal'], + accessmodifiers: ['open', 'public', 'internal', 'fileprivate', 'private'], keywords: [ - '__COLUMN__', - '__FILE__', - '__FUNCTION__', - '__LINE__', + '#available', + '#colorLiteral', + '#column', + '#dsohandle', + '#else', + '#elseif', + '#endif', + '#error', + '#file', + '#fileID', + '#fileLiteral', + '#filePath', + '#function', + '#if', + '#imageLiteral', + '#keyPath', + '#line', + '#selector', + '#sourceLocation', + '#warning', + + 'Any', + 'Protocol', + 'Self', + 'Type', + + 'actor', 'as', - 'as!', - 'as?', + 'assignment', + 'associatedtype', 'associativity', + 'async', + 'await', 'break', 'case', 'catch', @@ -72,6 +123,7 @@ export const language = { 'continue', 'convenience', 'default', + 'defer', 'deinit', 'didSet', 'do', @@ -81,44 +133,53 @@ export const language = { 'enum', 'extension', 'fallthrough', + 'false', 'fileprivate', 'final', 'for', 'func', 'get', 'guard', + 'higherThan', 'if', 'import', 'in', + 'indirect', 'infix', 'init', 'inout', 'internal', 'is', + 'isolated', 'lazy', 'left', 'let', + 'lowerThan', 'mutating', 'nil', 'none', + 'nonisolated', 'nonmutating', + 'open', 'operator', 'optional', 'override', 'postfix', 'precedence', + 'precedencegroup', 'prefix', 'private', 'protocol', - 'Protocol', 'public', 'repeat', 'required', + 'rethrows', 'return', 'right', + 'safe', 'self', - 'Self', 'set', + 'some', 'static', 'struct', 'subscript', @@ -126,18 +187,19 @@ export const language = { 'switch', 'throw', 'throws', + 'true', 'try', - 'try!', - 'Type', 'typealias', 'unowned', + 'unsafe', 'var', 'weak', 'where', 'while', 'willSet', - 'FALSE', - 'TRUE' + + '__consuming', + '__owned' ], symbols: /[=(){}\[\].,:;@#\_&\-<>`?!+*\\\/]/,