Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for Swift 5.1 #1332

Merged
merged 5 commits into from Jan 5, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/rouge/lexers/swift.rb
Expand Up @@ -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(
Expand Down Expand Up @@ -110,6 +110,8 @@ class deinit enum convenience extension final func import init internal lazy let
groups Keyword, Text, Name::Variable
end

rule %r/\\\.(#{id})/, Keyword::Type
pyrmont marked this conversation as resolved.
Show resolved Hide resolved

rule %r/(let|var)\b(\s*)([(])/ do
groups Keyword, Text, Punctuation
push :tuple
Expand Down
19 changes: 19 additions & 0 deletions spec/visual/samples/swift
Expand Up @@ -432,4 +432,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