You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Intelij: IntelliJ IDEA 2023.1.2 (Ultimate Edition)
google-java-format: 1.16.0.2
Mac M1
in Doc we read:
3.3.1 No wildcard imports
Wildcard imports, static or otherwise, are not used.
I see wildcard imports in my classes, try to correct them with Recormat Code and Reformat File but seems to me google format can not identify them. when I turn them off. intrlij can concert it to single class import. . when I turn google format back on. it can not correct the wildcard import.
Unfortunately, the Google format does not correct the usage of wildcard imports in my classes. From what I've found on the internet, this seems to be a bug. Is there any way to fix it locally? for example somehow override google format with intelij config?
In general google-java-format only tries to fix style issues that can be resolved by changing whitespace, it doesn't generally add or remove non-whitespace parts of the program, like replacing a wildcard import with single-type imports.
This isn't a problem the formatter can solve. One technical reason for that is that it is just looking at the syntax of one file at a time, it would need to compile the file (and have access to a classpath dependencies) to be able to figure out which imports a wildcard import corresponds to.
Activity
[-]No wildcard not formatedt[/-][+]Wildcard import not format[/+]cushon commentedon Aug 11, 2023
In general google-java-format only tries to fix style issues that can be resolved by changing whitespace, it doesn't generally add or remove non-whitespace parts of the program, like replacing a wildcard import with single-type imports.
This isn't a problem the formatter can solve. One technical reason for that is that it is just looking at the syntax of one file at a time, it would need to compile the file (and have access to a classpath dependencies) to be able to figure out which imports a wildcard import corresponds to.
tbroyer commentedon Aug 11, 2023
I believe the IntelliJ IDEA plugin could though. WDYT?
poliveira-fuze commentedon Sep 2, 2024
@ehsanazali were you able to fix it, through maven?