Skip to content

Conversation

@MathiasVP
Copy link
Collaborator

@MathiasVP MathiasVP commented Apr 23, 2025

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 Foo can look like foo, FOO, or even fOo.

Up until now many AST classes had a getName predicate that returned the name of whatever thing was in the source code, and you had to remember to call toLowercase before doing any comparisons.

This PR changes the API of these classes so that, instead of a getName we have a getLowerCaseName to make it explicit that we're returning a lower-case name. Furthermore, this PR adds getAName and matchesName predicates which will call toLowerCase on 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 toString on many entities now refer to the lower-case name. If we find this annoying we can change it in the future

The 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:

  • One warning was about an import of a module that's named the same as a file. When that happens QL favors importing the module instead of the file (and a warning describing this is emitted). In this case, it turns out that the module was dead code - so we can just delete it 🎉
  • The other warnings were about using recently-deprecated functionality from the shared SSA library. The references to these deprecated libraries were easily fixed since the relevant files are almost copy-pastes from GitHub's versions of these files.

Together, this should bring the number of warnings down to 0.

@MathiasVP MathiasVP force-pushed the powershell-better-api-for-normalizednames branch from 015a2f2 to 9e83dee Compare April 23, 2025 14:16
@MathiasVP MathiasVP changed the title PS: Better API for normalizing names PS: Better API for normalizing names + get rid of warnings Apr 23, 2025
@MathiasVP MathiasVP merged commit 4d00aa3 into main Apr 24, 2025
4 checks passed
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.

3 participants