openrewrite / rewrite-templating

Automated templating using code snippets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detect method calls beyond static imports for `UsesMethod` in `Precondition.check`

timtebeek opened this issue · comments

What problem are you trying to solve?

We want to limit recipe execution to improve performance, by adding appropriate preconditions. As of #24 we have some rudimentary preconditions based on imports.

Describe the solution you'd like

It would be even better to detect additional method invocations in the before templates and use those in our preconditions.

Have you considered any alternatives or workarounds?

No.

Additional context

Additional note to pick up: #24 (comment)

For HashMap we could actually pass the [UsesType] second argument [includeImplicit] as false, because it must be directly referenced. Map is different, because you got that from the template's return type and not the template body. But we can still fix this later.

So in #24 we went for a quick solution where both before template input and return types both get includeImplicit = true, but that's only necessary for the return type, likely not for the input types.