PS: Better API for normalizing names + get rid of warnings #213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is basically two PRs concatenated together. I hope that's okay!
The first PR
Since PowerShell is case insensitive pretty much everywhere we must be careful to use "normalized" names during analysis. For example, a call to a cmdlet
Foocan look likefoo,FOO, or evenfOo.Up until now many AST classes had a
getNamepredicate that returned the name of whatever thing was in the source code, and you had to remember to calltoLowercasebefore doing any comparisons.This PR changes the API of these classes so that, instead of a
getNamewe have agetLowerCaseNameto make it explicit that we're returning a lower-case name. Furthermore, this PR addsgetANameandmatchesNamepredicates which will calltoLowerCaseon the argument/result automatically.This should ensure that we don't forget to normalize names in the future!
No functionality is changed by this PR. Some .expected files change because the
toStringon many entities now refer to the lower-case name. If we find this annoying we can change it in the futureThe second PR
The "second PR" is all about getting rid of some unnecessary PowerShell warnings that @dilanbhalla brought to my attention.
There are two sets of warnings:
Together, this should bring the number of warnings down to 0.