Searching references of a particular java class [closed] - java

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I was searching for a shortcut in Eclipse which would show the references of the selected Java class elsewhere. Presently I right click on the Java class and select References.
It would be great if I could be told the shortcut for this.
Is there a guide which I could refer to, to find out the most-used Eclipse shortcuts ?

Finding references in Eclipse is done by the CTRL + SHIFT + G keyboard shortcut. Just makes sure the mouse cursor is on the class and use the key combination. The same shortcut works for method or variables.

To find all References of selected item in Workspace : CTRL + SHIFT + G
To find all References of selected item in Current class : CTRL + U
Learning Eclipse Shortcuts
If you are starting out with Eclipse Shortcuts, I would suggest that it might not we worthwhile trying to learn them by just reading them.
Suggested strategy to remember shortcuts
Try this out :
Identify the one activity/action that you do most often.
Examples :
Open Resource (CTRL + SHIFT + R) which allows you to search for and open a file in the workspace.
Switch Between Tabs (CTRL + Page Up or Page Down )
Once you have identified the oft-used activity above, USE IT as often as possible ( which shouldn't be difficult given the fact that we identified an oft-used action to start with)
Repeat :)
Tip - Shortcut groups
It might be useful to remember shortcut Groups. Many a time you'll find that they are intuitive and easily lend themselves to memorization.
Example - The Execute Group of Shortcuts
Eclipse has this concept of multi-key shortcuts (something that I had not come across before Eclipse) which require you to press a sequence of Characters ( such as Alt + Shift + X) and then another Character after it. This allows the 'grouping' of related shortcuts.
For instance to Execute pretty much anything you first press ALT + SHIFT + X and then another character depending upon what you are executing. Thus, one would use the following combinations :
ALT + SHIFT + X, J : To execute the main method of a Java class
ALT + SHIFT + X, T : To run a Junit Test (this would run a specific test or all the test in the class depending upon the position of the cursor when this shortcut is pressed)
The above are easy to remember as Alt + Shift + X ecute, a J ava class or a JUnit T est.
Now the beauty of this is, once you are used to the above shortcuts you change X ecute to D ebug and just like that you have two new shortcuts to Run a Java class or JUnit test in debug mode.

Related

Keyboard shortcut to comment several lines of code in IntelliJ

I already made an investigation about the topic, and actually, you can find the answer in the official documentation of JetBrains or just going to File -> Settings -> Keymap. However, I can't implement that solution, which is CTRL + SHIFT + /.
I don't have a "/" key in my keyboard, but the combination of the number 7 and SHITF makes the "/" key, so what I do is to press CTRL + SHIFT + 7 trying to comment an entire block of code but nothing happens. Doesn't matter if I select English or Spanish in the Prefered Languages panel of Windows, I cannot comment several lines at the same time using that combination.
I know probably I am doing something very very dumb, but honestly, I have been stuck like 20 minutes trying to figure out what I am doing wrong and I am starting to lose any hope.
Sorry for making a dumb question dear folks, but I would really appreciate if you can help me with this.
Just add any keyboard shortcut that works on your system in Settings | Keymap:

Shortcut keys for java or eclipse notes [duplicate]

This question already has answers here:
Eclipse comment/uncomment shortcut?
(18 answers)
Closed 7 years ago.
Hello I needed to know how do I uncomment out code in eclipse? I know Crtl+Shift+C will comment out a set of code how do I undo that?
Here You have all shortcuts for Eclipse:
http://www.shortcutworld.com/en/win/Eclipse.html
As You can see on point 7, its Ctrl + Shift + \.
As Already said, It is the same shortcut to comment and uncomment.
I Would like to precise the most important, IMHO, shortcut in Eclipse : ctrl + shift + l which lists all the shortcuts.
To comment any code, select it and press Ctrl + 7.
Use again to undo.

eclipse add objects to class, automatically and retroactively

I changed the location of a object classes that my class in question relies on.
Now many references to other objects are broken
Is there an automated way for it to add those classes back without my right clicking on every object reference and choosing what the correct coarse of action should be (which is always Import this shockingly matching class)
Yes there is a way:
select all related projects from the project browser >> right click >> Source >> Organize imports.
OR
select all related projects from the project browser >> CTRL + SHIFT + O
And next time you want to move a class and automatically all the references, please select the class (right click the class name) and choose the Refactor menu item >> Move.. option.

How to get the return type of a method call in IntelliJ?

Normally you would expect just hovering over a method it would show a popup of the return type.
How do you get this information in intellij ultimate?
Hit Ctrl + Q (or ⌃J on Mac) when cursor is on a method declaration or call. It will show you the pop-up you want. As a bonus: Ctrl + Shift + I will display method body as well in a pop-up.
You hover it and hold down CTRL in windows or CMD in Mac
Try Ctrl + Space for quick definitionAlso Ctrl + Shift + P may help
In intellij, Go to Help > Productivity Guide
you will find a list of useful shortcuts to increase productivity
Regarding, this question in mac Press option+command+V to get the list of names that you can choose
Ctrl+ J in mac for getting the documentation
Find screenshots for ease:-
Ctrl+Shift+P works great with extra bonus by highlighting relevant return expression (IntelliJ 2020.2.3 CE)
Hot key for that: Ctrl + Shift + P
Toolbar: "View->Type Info"

Can't find Eclipse shortcut for Renaming

Used to know this, think its something like Ctrl + ??? + F11. Or something.
I have a class member/property that I would like to change the name of. Unfortunately it is sprinkled all over the class, some 100+ references to it. Throughout the various methods.
Eclipse has a shortcut that allows you to click on an identifier, hit the hotkey (whatever it is), and then modify the text composing the identifier. Then, once you click off of that text, it searches and replaces all references of the "old" identifier and replaces them with the new one.
I know I could just do a search & replace. I don't want that. I want the shortcut/hotkey. And its driving me crazy because I can't find it because I don't know what it's called!
Thanks to any Eclipse gurus that can help.
The shortcut combination is ALT + SHIFT + R.
CTRL+SHIFT+L list of all shortcuts.
The key combination is
Alt + Shift + R
The corresponding menu (and context menu) entry is
Refactor > Rename ...
I wanted to specify that the shortcut is Alt + Command + R if you're using Mac OS X.
PC
The shortcut for rename is:
Alt + Shift + r.
And the list of shortcuts will be displayed with:
Ctrl+Shift+L
Mac OS x
The shortcut defined for rename/refactoring will work:
option + ⌘ + R
The option for rename is:
F2
Both are shortcuts defined for Mac, open the Shortcuts List with
Shift + ⌘ + L:
Simply select the file and press F2. The rename option will open. Other option is ALt + Shift + R. But I prefer F2 is much easier way.
For renaming a file, the F2 works in all cases I've encountered.
However my experience shows that refactoring a class or a method can behave differently in different OS and desktop environments and that they may intercept key modifiers and thus render shortcuts ineffective.
However, eclipse is good at accessing its main menu from the keyboard. For instance, in plasma in linux (tested with eclipse 2019-09 and older) renaming is achieved pressing Alt-T, then releasing it and pressing N afterwards. The Alt-T effectively opens up the refactoring menu and the N orders eclipse to rename the selected element. Actually, the whole refactoring menu can be addressed in that manner, this achieving the goal with less friction.
For Mac, use the below keys
OPTION + COMMAND + R

Categories