Can Intellij IDEA handle access modifiers authomatically?
Answered
Not that I have ever seen it be done by another ide, but I was wondering if it was possible to let IDEA automatically give methods different access modifiers (public, private ... etc) depending on where those methods are being used. So when a method is never used or only used in the same class it would be private, but if you then try to call that method from another place it will remove the modifier automatically or set it to either public or protected, depending on where you call it from (So it always is as private as possible but still callable from anywhere it is called from).
Please sign in to leave a comment.
You can run "Declaration access can be weaker" inspection for the whole project using Analyze | Inspect Code.
Then apply the quick fix to weaken access to all the found results.
If you try to use a method/class that you can't access, IDE will provide an intention action to change the access level (like make it public).