Uniform behaviour for the methodInvocations that are needed for template unsubstitution #5658
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.
What's changed?
Added an overload to
Substitutions
maybeParameter
that accepts the prefixed element.When using a template that passes in a placeholder that must be replaced by an Object / parameter, the resulting template is shows as
__P__.<java.lang.Object>/*__p0__*/p()
The existing code will pass methodName's
Identifier
(/*__p0__*/p()
) to themaybeParameter
call which will cause it to use the prefix of this Identifier to parse the template resulting in trimmed template prefix.By overloading and passing the entire methodInvocation for prefix calculations we no longer need to overcome this in every recipe that is using templates but we can just rest assured that the prefix of the template will be also present in the result lst objects.
What's your motivation?
Stumbled into this investigation with @Laurens-W after having some other template issues.
Checklist