How to quickly find constructor(s) in IntelliJ IDEA? - java

Is there way to quickly find constructors of a particular class in IntelliJ IDEA?

You can use ctrl + F12. This will show all members of the current class in a popup window, then you can select the constructor easily.
Command + F12 on Mac

I generally use the "Parameter Info" Keymap to show all options for a constructor.
If you type out the initial skeleton (new ConstructorClass()) and place the cursor in the brackets, the Parameter Info command will show all possible parameters for all overloaded constructors. This also works for overloaded methods.
N.B. My IntelliJ settings have Ctrl+p as the keymap for "Parameter Info". You will have to check your settings for your mapping.

Related

How to show method parameters hint in Intellij IDEA?

int beginIndex, int endIndex
is important when we invoke methods.
How to show this when the cursor is in the brackets?
Got the final answer.
Just Ctrl +P in Windows/Linux
or ⌘ +P in macOS.
JetBrains reference: Parameter Info
To view the method parameters
Place the caret anywhere within the call of the desired method or function.
Choose View | Parameter Info on the main menu or press Ctrl+P.
To configure the behavior of the view parameter information functionality
Open the IDE Settings and click Code Completion below the Editor node.
In the Parameter info section, define the following options:
To have a complete method or function signature shown rather than a list of required types, select the Show full signatures check box.
Make sure to include the required third-party libraries in the project source path. Otherwise, names of the parameters will not be displayed.
To have the list of parameter types for the called method or function shown automatically after a certain delay, select the Auto pop-up (in ms) check box and specify the time period in milliseconds.
If you have non-standard bindings (or want to change what this is bound to), then look here:
Settings > Keymap > Main menu > View > Tool Windows > Parameter Info
And see what the binding is and/or change it to what you want.
Default shortcut to show parameter info in IDEA is ctrl+P.
Here is a sheet from JetBrains with this and other useful keyboard shortcuts: https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf
This tooltip appears on mouse over events.
Workaround with keyboard:
Try to use quick documentation pop-up CTRL+Q .

In Eclipse, is it possible to find, where, a certain function, class or variable is called?

When you want to open the declaration of a class/function/variable in java you can press Ctrl and click on it, but is there are way to go the other way round? If you had to find all instances where a function or variable is called how would you quickly get that?
Ctrl + Alt + H shows you all the places where a variable or method is used or called.
On both Windows and Mac, right-click the method, and choose "Open Call Hierarchy."
You can use this for identifiers other than methods. For example, if a class does not have an explicit constructor, you can use this to find all the callers of its default constructor.

How to view class package type and parameters in IntelliJ?

When hovering your mouse over a Class or variable, how come I don't see any information on the type of the class?
Is this not a feature in IntelliJ?
For example, in vs.net, if I mouse over any variable or class it will popup and tell me what namespace that belongs to etc.
And when I am using a method of a class, it also tells me the different overloads for the method (like types for each parameter, and a list of all the overloads).
This must be a feature in IntelliJ, I just don't know how to get it.
Can someone please clear this up?
Also, how can I tidy up the formatting of a page?
It doesn't work on hover yet, please star/vote the issue.
You need to use keyboard shortcuts for quick documentation pop-up or parameter info pop-up (Ctrl+Q and Ctrl+P with default Windows keymap, F1 and Cmd+P with default OS X 10.5+ keymap).
Code | Reformat Code... is the answer to your second question.
Formatting: Code -> Reformat (shortcut: Ctrl-Alt-L)
Hover doesn't produce the kind of information I'd like either. You can get info with Ctrl-Q ("Quick Help") in Windows or F1 in OS X, which will show where it's from and what it is, with most stuff in the popup window linked up in a reasonable way.
That popup view can also be pinned and/or docked; I often have it docked on the bottom.

How to get eclipse to go to the ONLY implementation of an interface's method?

If I'm in an interface and pointing to a method name, what can I do to quickly go to the ONLY implementation of that method?
Using Eclipse 3.6.
F3 is the typical "go to implementation". For interfaces that go to the interface definition.
Instead use Ctrl + T to see all implementations of the interface definition. You can then easily go to the one you want with the arrow keys and Enter. I believe that the first one is automatically selected so that Ctrl-T + Enter will do what you need.
I just checked this on my Eclipse 3.6 install: Hold control (command on Mac), hover over the method name and select "Open Implementation".
You may assign a keyboard shortcut to this action by using Window > Preferences > General > Keys and searching for "Open Implementation".
In the keymap (General > Keys) search for "open implementation" and map it to whatever you want. I chose Ctrl + Shift + I. Make sure you select "Editing Java Source" in the When box. I tested it, and having the cursor over the method name and pressing Ctrl + Shift + I took me directly to the implementation instead of showing the hierarchy that you get with Ctrl + T.
Also you can see an answer to a nearly identical question for other options:
In eclipse, ctrl-click goes to the declaration of the method I clicked. For interfaces with one implementation, how can I just directly to that implementation?
If someone still need this information nowadays (Eclipse version 2022), to jump into interface method definition starting from an #Override method, now in Eclipse you can see on the left, next to the method signature, a little white triangle. By clicking on that you will jump to the implemented interface method. here an image of the little triangle
Oterwise, if you are on a interface method definition and you need to jump to one of the implementations, you must use CTRL+T shortcut to see the list of available implementations and than click on one of them.

How to get back auto-completion after misspelling a method name in Eclipse?

When I am coding Java in Eclipse I like the auto-completion feature. With that I mean the popup with method-names that comes when you start typing in a method name for an object. Or maybe it's called something different, i.e. method-suggestions?
But the popup is hidden if I misspells a method name, and it doesn't come back if I delete the misspelled part of the method name. Is there any way to get back the popup after a misspelling without starting to type in the hole method name again?
Press Ctrl+ (Blank). For a complete list of keyboard shortcuts have a look in the eclipse "Preferences" and there "General/Keys".
You should also check out Preferences->Java->Editor->Content Assist. You'll be able to select how it acts; things like if you use it in the middle of a word should it insert or overwrite, should it show deprecated methods, the delay before it automatically appears, and it can even (try to) guess your method parameters based on the variables in the current scope.
I think you're after the Ctrl-Space keyboard shortcut.
(In Eclipse this is called Content Assist. In Visual Studio it's called IntelliSense.)

Categories