In IDEA, how do you enable autoimport for javadoc links? - java

When writing Javadoc for a class and when I wish to add a link to another class, I type:
{#link SomeCl<TAB>}
and IDEA completes with the full import, ie it will yield {#link com.foo.SomeClass}; only afterwards can I choose to "replace with import".
Is there a way to tell IDEA to use imports in this situation instead?
(this is all the more frustrating that it does so automatically for code... Just not Javadoc)

Problem solved. I should explore the configuration options further!
File -> Settings -> Code Style -> Java, select tab "imports", there is an option to Use fully qualified classnames in Javadoc which was checked. Simply uncheck it...

Related

Auto-generate Javadoc comments in Eclipse?

Is it possible to auto-generate Javadoc comments for each method in one class in Eclipse (Indigo)?
There may be a better approach, but if you expand the class in Package Explorer, select the methods you would to document, then right-click and select "Source -> Generate Element Comment" that will add comments for all the selected methods.
The other choice might be to double click on the name of the method, then ALT+Shift+J shortcut.
There also exist external tools for javadoc generation, for example JAutodoc eclipse plugin. It is possible to customize it's templates to suit your expectation.
In Eclipse you have possiblity to create java doc template, and then just what need to do is type java-dock block /** above the element you want to document.
In case when the code is generate, the templates also generate the java-doc.
All this and even more you will be able to configure in Window -> Preferences, Java -> Code Style -> Code Templates -> Comments

How to force compile-warnings if not all public things are JavaDoc'd?

I want to get warnings at compile time for every public thing (class, interface, field, method) which doesn't have a Javadoc comment.
How can I enable this in Eclipse?
Based on your tag, I'll assume that you mean in Eclipse. To do so, Open the Window -> Preferences Menu Item, and then Under Java -> Compiler -> Javadoc, there will be a dropdown that will either let you treat missing javadoc tags as Error, Warning, or Ignore.
This answer was for the latest version of eclipse, but if you search for javadoc in the preferences search you should be able to find it easily enough.

Getting documention to appear in intellitext window using eclispe and java

When using the standard api, for example the collections library, the predictive text options windows also shows the comments on class/methods.
however when I do the same style comments on my own code - the open project I am working on (code completion works correctly, just no comments appear), and then reference it later. These comments are not displayed. I get the correct code completion options, just none of the associated comments/documentation. They are not in jar, they are source files, that are built using maven into a war file.
Is there a setting I need to enable in eclipse, or do I need to set up javadoc or something ?
How embarassing, you to have to specify double asterix at the begininng of comment to create a javdoc comment
/**
* read the documentation before asking questions on stackoverlow
*/
If the class is part of a jar you need to associate the javadoc jar or path. You can right click on the jar in eclipse and specify the path in the properties dialog.

Intellij generate javadoc for methods and classes

Is it possible to set up Intellij to generate javadoc for methods and classes, automatically, with #author and #since date? I had this feature in Eclipse.
I know that the files have templates and also I can manually semi-automatically add javadoc to selected method/class. But I want the generation to be automatic for every generated method/class/enum/interface/field etc.
This is useful for e.g. "extract method", "override/implement", "create getter/setter" etc. This would save hundreds of manual actions.
I'm using IntelliJ Idea 9.0 BETA Community Edition, #IC-90.96.
For IntelliJ 12:
Position caret above a method name, type /** and press Enter to let
IntelliJ IDEA automatically generate JavaDoc stubs for this method.
See here
For newer versions of IntelliJ (2018+), you can use this solution:
Typing /** + then pressing Enter above a method signature will create Javadoc stubs for you.
It's not possible at the moment. You may want to Vote for IDEABKL-1787.
for generate javadoc in intellij Idea go to Tools->Generate JavaDoc (4th option) click it and give path to save your Document
Now there is a new plugin available for that.
It works great, you can generate javadoc with alt+insert.
It's called "javaDoc", it's available directly in the plugin section.
The documentation is here : https://github.com/setial/intellij-javadocs/wiki
I have given up on hoping that IntelliJ will be able to do this.
I now open my project in Eclipse, go to the desired files and invoke JAutoDoc.
There is JavaDoc Sync Plugin 8. http://plugins.intellij.net/plugin/?idea&id=3403
Generates javadoc for all methods in class. Works in Idea 10.
Actually it's now possible, you can simply go to "Settings/Editor/File and Code Templates".
There, you can edit the template which is used to create classes, enums, interfaces etc.
My Intellij version is 2019.2.3 and on linux.
An easy option is to access Find Action menu (Macs: Cmd+Shift+A | Win: Ctrl+Shift+A) and type any part of the Generate JavaDoc action.
Once you found and clicked on that , an option menu for generation of JavaDocs is opened , containing a wide range of options and scopes.
Reference -> https://www.jetbrains.com/help/idea/mastering-keyboard-shortcuts.html

How do I modify Eclipse code formatting?

When I reformat code with Eclipse, it turns method headers like this:
public void myMethod(String param) {
into method headers like this:
public void myMethod(
String param) {
When I was brought on here I'd never used Eclipse before, and I imported project settings provided by someone else. I have seen that on small new projects I've worked on Eclipse does not do this, so it must be in the settings I've imported. But I've gone through every panel I can find, as well as every hidden file I can find in the workspace, and I can't figure out what is causing this.
How do I turn it off? I don't want a newline before parameters in my method signatures, and I can't imagine why anyone would!
Have a look at Window>Preferences>Java>Code Style>Formatter.
There you can configure almost everything. Your case is found at
Line Wrapping>Method Declarations>Parameters.
In my version of Eclipse, I found the option under Window->Preferences->Java->Code Style->Formatter, then clicked the Edit.. button.
In the new window, go to the Line Wrapping tab and find Method Declarations. You want to change the Line wrapping policy. The Force split check box seems to do the same.
Go into preferences: Java -> Code Style -> Formatter
Restore Defaults or edit what's there.
Additionally, Code Style -> Code Templates will allow you to define generate code formatting.
Note that this is for Eclipse Workspace as a whole, the same Preferences can be accessed under the project preferences if you want to get more fine grained at a per project level.
In eclipse you can define your code formatting use Code Style ,
for MAC System :--> Eclipse --> Preference -- > java--> code Style
for Window System :--> Window->Preferences->Java->Code Style->Formatter
The best way to change your format is to go to Window-> Preferences-> Java-> Code Style-> Formatter. Inside the formatter window, eclipse has a couple of built in styles, but the best way is create a new profile of your own by pressing on New. You can change the format as you please on the edit tab
You can change parentheses and curly braces positioning along with other stuff.

Categories