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

#56350 - Give Identifier a hasUnderscoredNaming() helper #72048

Merged
merged 1 commit into from Mar 5, 2024

Conversation

Jamezzzb
Copy link
Contributor

@Jamezzzb Jamezzzb commented Mar 2, 2024

#56350
I gave Identifier a hasUnderscoredNaming() helper. Which is just:

bool hasUnderscoredNaming() const {
   return str().startswith("_");
}

I put it right under hasDollarPrefix figuring that made the most sense. I also replaced parts of the code using str().startsWith("_") to use the new helper. I think the helper makes intention more clear and it is definitely more convenient (especially with code completion).

I then reran swift/test:
Screenshot 2024-03-02 at 5 30 41 PM

There are 6 failures but these same tests always fail for me. I haven't looked too much into the failures (one is a module not being found, another is I am missing some python stuff) but I don't think they are related to the changes.

Copy link
Contributor

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @Jamezzzb. Looks good to me. One tiny suggestion to clean things up a little further.

Comment on lines 1338 to 1339
auto name = PropertyWrapper->getName();
return !name.hasUnderscoredNaming();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could shorten this even further now

Suggested change
auto name = PropertyWrapper->getName();
return !name.hasUnderscoredNaming();
return !PropertyWrapper->getName().hasUnderscoredNaming();

Copy link
Contributor Author

@Jamezzzb Jamezzzb Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahoppen Thanks! I like this better but hadn't thought of it. With suggestions is there a preference whether I do it locally so I can squash or is it okay to apply it here? In terms of keeping the commit history clean.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squashing would be appreciated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright done. Thank you.

…aces currently using str().startsWith, change it to use the new helper.
@ahoppen
Copy link
Contributor

ahoppen commented Mar 5, 2024

@swift-ci Please smoke test

@ahoppen ahoppen enabled auto-merge March 5, 2024 00:40
@ahoppen ahoppen merged commit aa95565 into apple:main Mar 5, 2024
3 checks passed
@Jamezzzb Jamezzzb deleted the #56350 branch March 5, 2024 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants