-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
enh(swift) Improved highlighting for types and generic arguments (#2920) #2920
Conversation
Awesome, more PRs this size would be great. :) |
Any comments about the relevance? Should any be set to 0 (or to 1, in case I set them to 0)? |
I didn't see any issues. We want relevance for the "Apple like" libraries (for parity with Obj-C)... but nothing else is worthy of relevance... they are mostly too common "!?" or things that we don't typically give relevance for (random identifiers). |
src/languages/swift.js
Outdated
} | ||
); | ||
// Generic arguments | ||
TYPE.contains.push({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TYPE.contains.push({ | |
TYPE.contains.push(TEMPLATE_WHATEVER_THINGY) |
Should we perhaps give this rule a name with a constant vs just inlining it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets tweak the release notes slightly but otherwise this looks good... perhaps consider if we should have a constant for that one thing or not, but I'm ok either way.
One thing I should note here is that the following will still result in false matches: (var: Int, let: Double) Here, I will look into this with my next PR, as this is very similar to function parameters, which also need improving. |
Doesn't need to happen here, but I wonder if we should just expand |
I don't think such a list even exists, and if it did, it would change every year. Apple just reserves all two-letter prefixes for its own use, even though it now also uses some three-letter prefixes. Personally, I don't think the current list even belongs here, because Swift doesn't use prefixes. You only see these prefixes when interacting with Objective-C frameworks. I've only included it here to avoid misdetection :) |
Right, but some of these frameworks are super-common frameworks that a lot of swift code might interact with because they are platform libraries, no? When you reference them in Swift you'd do it by name, no? A lot of Apple frameworks are still Obj-C are they not? |
Yes, Swift development on Apple platform still involves talking to a lot of Objective-C frameworks. So the prefixes are still relevant in that aspect, but they should become less relevant over the coming years, as people switch to SwiftUI. |
Here's the next step for the Swift grammar rewrite:
<
,>
,?
,!
,...
, and&
) from being highlighted as operators.With these improvements, I should be able to write a new grammar for function declarations, to fix the remaining issues #2895 and #2857