diff --git a/lib/rouge/lexers/swift.rb b/lib/rouge/lexers/swift.rb index ba19b2b7be..45c04c56f9 100644 --- a/lib/rouge/lexers/swift.rb +++ b/lib/rouge/lexers/swift.rb @@ -25,7 +25,7 @@ class Swift < RegexLexer ) declarations = Set.new %w( - class deinit enum convenience extension final func import init internal lazy let optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate + class deinit enum convenience extension final func import init internal lazy let optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate some ) constants = Set.new %w( @@ -67,6 +67,7 @@ class deinit enum convenience extension final func import init internal lazy let state :root do mixin :whitespace + rule %r/\$(([1-9]\d*)?\d)/, Name::Variable rule %r{[()\[\]{}:;,?\\]}, Punctuation diff --git a/spec/visual/samples/swift b/spec/visual/samples/swift index 52b05013d8..bb12c0db72 100644 --- a/spec/visual/samples/swift +++ b/spec/visual/samples/swift @@ -416,6 +416,7 @@ var `var` = 3 // keypath let keypath = \Person.firstName +var keyPath: KeyPath = \.isEmpty // tuple destructuring let (t1, t2) = (1, 2) @@ -432,4 +433,23 @@ funcWithLambdaArg { x in x + 5 } funcWithLambdaArg { $0 + 5 } funcWithLambdaArg({ x in x + 5 }) +func newView() -> some View { + ViewRegistry.find(\.MyView.name) +} + +@frozen +public enum Types { + case a, b, c + case d +} + +func test(t: Types?) -> Bool { + switch t { + case .a?: return true + case .b?: return true + case .c: return true + default: return false + } +} + foo() // end-of-file comment