How to refactor an import statement with something of multiple lines?
I want to replace
import org.apache.log4j.Logger;
with
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
What's the proper way of doing this in IntelliJ IDEA?
IntelliJ IDEA 14 Ultimate.
Please sign in to leave a comment.
What is the use case and workflow that requires this change?
I'm migrating log4j 1.* to log4j 2, part of which needs this subsitution. I didn't find a built-in refactoring feature to achieve this substitution automatically. So I'm doing search and replace. I ended up using File | Find | Find in Path with the checkbox "Regular expression" checked. And then replace
import org\.apache\.log4j\.Logger
with
import org.apache.logging.log4j.Logger\nimport org.apache.logging.log4j.LogManager
and it appeared to work.
Yes, that will work.
You could also try the Migrate feature: https://www.jetbrains.com/idea/help/migrate.html .