Sometimes I just want to know the public interface of a class, but File Structure
(Cmd-F12
) always show all methods(and fields) to me.
Could I filter them by modifiers, such as public, protected or private?
By default, IntelliJ IDEA shows all classes, methods, and other elements of the current file. To toggle the elements you want to show, click the corresponding buttons on the Structure tool window toolbar. to show class fields. to have protected class members shown in the tree.
Generally you should expose as little as possible and make everything private that is possible. If you make a mistake and hide something you should be exposing, no problem, just make it public.
Methods are normally public unless they are explicitly declared to be private or protected. One exception is the initialize method, which is always implicitly private. Another exception is any “global” method declared outside of a class definition—those methods are defined as private instance methods of Object .
In the editor, select a symbol for which you want to see the usages. From the main menu, select Edit | Find Usages | Show Usages In Code Ctrl+Alt+F7 . The usages window shows the current scope and total count of usages. If you want to quickly switch to the default scope, press Ctrl+Alt+F7 .
There is a "structure view" (Alt-7) which shows class members, and it has sort options, so it will show public methods at the top.
In IntelliJ 2017.1.2, the Structure View (Alt-7 or Cmd-7) includes a Show non-public
toggle that can be used to filter out private (etc) members.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With