Replace import of constant by static import in IntelliJ Idea

1.9k Views Asked by At

I have a code with some constants in format ClassName.CONSTANT_NAME. I want to quickly replace this by CONSTANT_NAME. But I have not found any efficient way of doing that. Every time I want to static import something I have to:

alt + enter
Add on demand static import for ....

for each class. But there is ~1000 classes

Is there any quick way of converting import to static import for many classes?

1

There are 1 best solutions below

0
On BEST ANSWER

It looks like Structural Search & Replace is a good way to do this.

Search template: ClassName.CONSTANT_NAME
Replace template: ClassName.CONSTANT_NAME

And make sure you have selected the checkbox Use static import. This will add the static import for you.

Structural Replace dialog from IntelliJ IDEA 2018.3