-
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
(swift) does not recognize core Apple foundational libraries #2758
Comments
Are all the same built-in classes equally valid in Swift as in ObjC? var API_CLASS = {
className: 'built_in',
begin: '\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+',
}; Right now Swift doesn't get any points for them while ObjC does which is why your code is being flagged as ObjC. (so many library mentions) |
Since I encountered this as a Stack Overflow user, does this mean the question has to have the Swift tag? |
There are a few new frameworks like WidgetKit which are Swift-only, but I'm not sure if that's part of the problem. |
Damn, my question was too broad. :-) All all the class prefixes listed there valid for use in Swift code also? I think you're saying the answer is yes? I'm thinking we should add them to our Swift grammar so they can be highlighted and help out for auto-detecting, yes? Right now swift is highlighting them as "types" but they have no relevance score, so it doesn't make it more likely that your code is Swift like it would if we added those API classes as an explicit list. |
@AustinConlon Ping. |
Yup, all of the frameworks for those prefixes are Swift as well, none are exclusive to Objective-C. |
@AustinConlon Want to take a pass at making a PR to pull over that rule from Objective-C, and balance the languages out? |
Will do. |
And if you happened to have the time: #2819 :-) |
@svanimpe Any chance you might be willing to tackle this also? Should be easy. |
I would prefer not to highlight these classes any differently. They are imported Objective-C types, not "built-in" to Swift in any way, and we don't even highlight the built-in types from the Standard Library. Is it not enough that they're highlighted as types? |
The Foundational libraries are used often in both ObjC and Swift code so seeing them doesn't imply one language on the Honestly I'd consider them in the same category of built-ins... thinking about Swift as a larger platform and what code is COMMON, not just the language itself. But at the very least we need the relevance to fix issues with ObjC claiming Swift code just because a lot of foundational classes are used. |
So I could for example, highlight them as types, but match them separately for a relevance boost? Import statements could also be relevance boosters:
However, since we're talking about highlighting code snippets here (not full projects), it's unlikely that these are present. |
Many languages have imports though... it's the very unique apple names that matter, not the imports themselves.
Exactly. |
Sounds like a start. |
I found this while writing this on Stack Overflow. I'm not sure what the root of the problem is, but I'm guessing it starts in the function signature. Here's the code:
The text was updated successfully, but these errors were encountered: