Drop rewrite-analysis from ReplaceCollectionToArrayArgWithEmptyArray - #1029
Merged
Conversation
`UsesInvocation` documents itself as equivalent to `UsesMethod` and only exists because `MethodMatcher` has no base interface; since the matcher here is a plain `MethodMatcher`, `UsesMethod` applies directly and uses the indexed `TypesInUse.hasMethodUse(..)` rather than iterating every used method. `InvocationMatcher.advanced().isFirstArgument(..)` expands to a cursor walk to the enclosing `MethodCall` plus an identity check on its first argument, so it is inlined against `MethodMatcher.matches(MethodCall)`, which is identical to the `InvocationMatcher` default it replaced. The dependency remains for the recipes that use its dataflow engine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 recipe was the only user of
rewrite-analysisthat did not need its dataflow engine, so it can rely onrewrite-javaalone.UsesInvocationis swapped forUsesMethod— its own Javadoc calls it "equivalent toUsesMethodbut for anyInvocationMatcher", and its@implNotesays it only exists becauseMethodMatcherhas no base interface; since the matcher here is a plainMethodMatcher,UsesMethodapplies directly and is faster, using the indexedTypesInUse.hasMethodUse(..)instead of iteratinggetUsedMethods().InvocationMatcher.advanced().isFirstArgument(..)is inlined to the cursor walk it expands to (parent tree cursor is aMethodCall, first argument is identity-equal to the array), matched withMethodMatcher.matches(MethodCall), which delegates tomatches(getMethodType())exactly as theInvocationMatcherdefault did.No behavior change, and the existing
ReplaceCollectionToArrayArgWithEmptyArrayTest(4 tests) passes unchanged. Therewrite-analysisdependency stays inbuild.gradle.ktsforReplaceStackWithDeque,ReplaceLegacyCollection, andFindNewExceptionWithoutCause, which do use its dataflow and taint analysis.