ChatGPT解决这个技术问题 Extra ChatGPT

What is the IntelliJ shortcut key to create a javadoc comment?

In Eclipse, I can press Alt+Shift+J and get a javadoc comment automatically generated with fields, returns, or whatever would be applicable for that specific javadoc comment. I'm assuming that IntelliJ IDEA has this feature. Can anyone tell me if there is a keyboard shortcut for this?


J
Jared Burrows

Typing /** + then pressing Enter above a method signature will create Javadoc stubs for you.


When overriding a method, eclipse adds an @see tag with a link to the parent method. Can IntelliJ do the same?
@boardtc thanks for the update. I actually tried to revisit the link recently and the whole site was down. Nice one.
this seem to only create the comment block, no actual stub
x
xav

You can use the action 'Fix doc comment'. It doesn't have a default shortcut, but you can assign the Alt+Shift+J shortcut to it in the Keymap, because this shortcut isn't used for anything else. By default, you can also press Ctrl+Shift+A two times and begin typing Fix doc comment in order to find the action.


For anyone else searching for how to get IntelliJ to update javadoc after a code change, you can set this in Settings -> IDE Settings -> Keymap.
HOw do you run this "action" ?
Do I have to select something? Even if I select the whole file content or select nothing, nothing happens if I run this action. May I am missing something
@Honsa Stunna we have to exactly click the method line and go for action.
That is it. thank you
R
Robert Jakubowski

Shortcut Alt+Enter shows intention actions where you can choose "Add Javadoc".


I think that 3 could disagree with that statement. You should set pointer on the name.
put the cursor on the method name you want to add javadoc ,and then press alt + enter, there will be an add javadoc option in the popup.If the method already has a javadoc,then there will be no add javadoc option.
The only confusion I saw is people asking to put the cursor in function/class/variable to generate java docs. You have to keep the cursor on the object for which you are generating the documentation, just the way you will import a class by keeping cursor on the object and hit Alt+Enter
Getting to the intention is fine and all, but the goal is - what keymap can I use to add the comment without having to do extra stuff, thus the answer above - adding the keymapping to "Fix doc comment" is the correct answer for someone coming from Eclipse
@user1742058 Yes, you're right, but there are many people that found that answer helpful. Furthermore, The accepted answer is also not a shortcut. I think that all 3 answers are good and everyone could pick one.