I want to add a custom warning/error to IntelliJ that triggers if my Java project contains imports to a certain package.
This is not:
I also can't find examples of search templates that match on import statements. The closest thing I can find is an example in the above link where a "use static imports" checkbox is available that will make the replacement's output contain a static import.
Do search templates just not support matching on import statements for some reason, and if so why? Is there another way to do what I want to do?
Thanks in advance.
My IntelliJ version is 2022.2
CodePudding user response:
Structural search for imports/packages is not supported yet -
CodePudding user response:
I think "illegal package dependencies" inspection is what you are looking for. It can be found under "Settings/Editor/Inspections/JVM languages/Illegal package dependencies". You can create a custom scope for all the dependencies that you don't want in your project and apply them to the predefined "All" scope. Example