Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show public methods only in IDEA Intellij?

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?

like image 749
Lai Yu-Hsuan Avatar asked May 11 '13 21:05

Lai Yu-Hsuan


People also ask

How do I show all methods in IntelliJ?

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.

How do you know when a method should be private or public?

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.

Are methods always private?

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 .

How can I see my usage method in IntelliJ?

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 .


2 Answers

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.

like image 193
kan Avatar answered Nov 09 '22 22:11

kan


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.

like image 35
Erigami Avatar answered Nov 10 '22 00:11

Erigami