Structurally Replace with Static Import

Hello All,

I'd like to perform a batch refactoring that inserted a static import.  As far as I can tell the closest you can get is Shorten fully qualified names.  I'm not sure how to encode this request: maybe a replacement @Modifier("static") ?

$field$ = ($T$)@Modifier("static")com.google.common.base.Preconditions.checkNotNull($arg$);

Or maybe there's an easier way to achieve this already?

Please advise,
- Luke

0
3 comments

There is no way currently to achieve this.
I could add "Use static import if possible" checkbox to the Structural Replace dialog, similarly to the way it is done for Live Templates. Would that work for your use case?

Bas

0

Yes, I think that would solve my problem and forseeable variants.  The only thing Live Templates "Use static import if possible" does that's differs from my requirements is use xxx.* import(s) (e.g., import static com.google.common.base.Preconditions.*;) rather than a fully qualified imports (e.g., import static com.google.common.base.Preconditions.checkNotNull;), but Optimize Imports (properly configured) cleans this up and can be done in batch.

I look forward to this new feature!

Thanks in advance,
- Luke

0

There wasn't time to get this feature into version 13.1. I have created a YouTrack issue for it, so you can track it if you want
The Live Templates static import behavior should be better in 13.1, I did have a chance to make some improvements there.

Bas

0

Please sign in to leave a comment.