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.

7 comments
Comment actions Permalink

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.

0
Comment actions Permalink

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.

0
Comment actions Permalink

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.

0
Comment actions Permalink

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

0
Comment actions Permalink

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.

0
Comment actions Permalink

+1 for this issue

Stuck with same problem

0

Please sign in to leave a comment.