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
Add missing keywords for Swift #3021
Comments
Thank you very much!
What does |
It's an availability API to make the compiler happy when using latest API's while also supporting older iOS/macOS versions. It has the same syntax of functions, which I guess is the reason for its current highlighting. In Swift, it's called a declaration attribute: https://docs.swift.org/swift-book/ReferenceManual/Attributes.html |
But attributes start with an Also, attributes seem to be very generic in Swift (devs can even define their own). It might be better to have a generic attribute pattern (e.g. |
That's actually a good point you raise. Property wrappers, for example, can lead to all kinds of @ statements. Though, the highlighting in that linked article about property wrappers does match what I see in Xcode: It's hard for me to give a call on using a generic attribute in such that I don't know if it adds more than it breaks? If it even breaks anything, not sure either! |
My guess is that XCode knows that We could do the same thing. Using the class-name detection from #3022, we could split attributes in two. All attributes starting with an upper-case letter are assumed to be property wrappers and will be highlighted as
Prism's languages are an implementation detail. We can change whatever we want (hopefully for the better). |
That makes sense!
That should do the trick, indeed. There are a few exceptions though, like |
Hmmm, that's a problem. Would it even be possible to distinguish property wrappers from other attributes without compiling the program? In that case, it might be best to be consistent to highlight all attributes in the same way. That's also what GitHub's highlighter does. @propertyWrapper
@escaping
@MainActor
@SampleFile |
That makes the most sense to me too, indeed! |
Does #3022 also include this? I did not see a new commit since our discussion here. If so, yes! Otherwise, the PR should include an update for highlighting those keywords. |
It does. I pushed the commit adding GitHub-like attribute highlighting before we talked about attributes here. |
Perfect, thanks a lot @RunDevelopment. I'll make sure to test it out thoroughly on my blog and keep seeking for improvements over time 💪 |
Information
Description
Some of Swift's keywords are missing. This issue is here for myself to make a collection over the upcoming week, after which I'm happy to implement this myself. If you're reading this, feel free to open up a PR adding support for these keywords!
associatedtype
@autoclosure
@discardableResult
@dynamicMemberLookup
fileprivate
@resultBuilder
@unknown
Also, not sure if this code is currently highlighted wrong as well:
Available
Current:
Expected:
The text was updated successfully, but these errors were encountered: