fix(manager/gradle): preserve next token for parsing in case dependency interpolation fails #18330
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.
Changes
Return
{}
instead ofnull
for errors inprocessDepInterpolation
.tryMatch()
won't try other matchers but assume it was the correct one and that only handling failed.Currently,
token.shift()
removes the next token if a) no matching sequence was found or b) it was found but an error occurred during processing. This is problematic if there is another potential match following directly afterwards, as it will miss the first token for matching.This PR addresses this only for
processDepInterpolation
, although there are other spots in the code where the same behavior could show up (processLongFormDep
,processDepString
). Switching to{}
everywhere seems risky to me as it could mean that other relevant matching sequences are simply skipped. In this case, I think this should be no issue since with the current order no other matching sequence follows that would begin withTokenType.StringInterpolation
. Subsequent matching sequences includingTokenType.StringInterpolation
don't use it for the first token, so all other occurrences should still match fine with the token lookahead done inmatchTokens
.More details also here.
To get rid of this problem overall, I'd prefer to address it in the parser refactoring (work ongoing).
Context
Closes #18317
Documentation (please check one with an [x])
How I've tested my work (please tick one)
I have verified these changes via:
Test repository: renovate-demo/18317-renovate-gradle-variable-interpolate-reproduction#4