For example, in our code base, we currently utilize a type OldType
from the npm package @old-package
.
Our goal is to substitute it with our custom type NewType
, which can be accessed through @new-package
.
Illustration
Existing imports
import {
AnyImport,
OldType,
AnotherImport
} from '@old-package';
needs to be updated as follows:
New imports
import {
AnyImport,
AnotherImport
} from '@old-package';
import { NewType } from '@new-package';
Is there a way to carry out this refactoring in IntelliJ so that the import statements are adjusted correctly?
Additional Information:
- I suspect a simple replacement using RegEx might not suffice, given that the old import could span multiple lines among many other imports
- I explored the IntelliJ Migrate function, but it appears to be tailored for Java code only
- I also looked into the Structural search and replace feature, without success in adapting it to my scenario
Given that this is a one-time task, I am open to alternatives like using another IDE or employing a command-line tool.