Auto Import After Find/Replace

I have about 70 entity classes.  I used regex replace to add an annotation to every getter in every entity class.  How do I tell IDEA to import the annotation's class without opening every file (which seems to be the only way).

What I've tried:

  1. Clicking the package --> Code --> Optimize Imports
  2. Clicking the package --> Code --> Reformat Code (incidentially this does successfully properly indent the newly added annotations)
  3. Selecting all classes in the package --> Code --> Optimize Imports
  4. Selecting all classes in the package --> Code --> Reformat Code
  5. Invalidate Caches and Restart
  6. Synchronize


Thanks.

1
8 comments

Automatic imports are inserted only in the file you are currently editing, this behavior is by design so that if there is a conflicting import, you can choose from several variants.

-1
Avatar
Permanently deleted user

I have it set to do the import automatically if there is no conflict and there is no conflict. There is only one class that matches the annotation. IDEA seems to want me to open every file and tell it to do the import, which defeats the whole purpose of an auto importer.

1

Auto import is designed to assists with manual code editing in the current file. Mass changes should be performed by refactorings that add/change imports automatically when needed.

-1
Avatar
Permanently deleted user

Does IntelliJ let me add an annotation to every getter in a package?

0
Avatar
Permanently deleted user

Also I find it very odd that Optimize Imports doesn't do this.  It will remove unused imports but it doesn't add unambiguous imports.

1
Avatar
Permanently deleted user

+1 for this issue

Stuck with same problem

1

Please sign in to leave a comment.