how to remove javadoc with IntelliJ IDEA - java

As it is mentioned in
Annotation to disable JavaDocs I was not able to disable generation of Javadocs by JAXB when generating Java classes from XSD.
I clearly do not need documentation for hundreds of getters/setters. Is there a way to automate deletion of javadocs instead of manually selecting and deleting them?

The solution that works so far is to use replace functionality with regex search enabled and to use the following regex for selection \/\*\s*[\s\S]*?\*\/$, then replace found javadoc entries with an empty string.

Someone should develop a plugin that loads and unloads the javadoc...on demand...so those that are puritanical and want absolutely no javadoc (setters and getters for sure dont make sense for javadoc) can remove them with one click.

Related

Add copyright at the end of Java class while writing documentation?

I'm writing documentation for my java file. In that documentation, I want to add some html links at the end of each generated file. For that, what I have to use while writing java documentation?
If you are using Eclipse as IDE, you can use the plugin JAutodoc:
http://jautodoc.sourceforge.net/
To add a default text at the beggining of each text file.
According to the javadoc manual (can't find a newer version right now), you should use -footer when you generate your java API documentation from the CLI, for instance:
javadoc -footer "<b>Copyright 2015 Lakshmi Prasanna</b><br>" com.mypackage
Here's a similar example, but that uses -header instead.
Now, if you use a good IDE, at the very least it should allow you to type that somewhere in the project settings. Back in the day Eclipse wasn't very flexible, so I had to make an Ant script (yuck).
EDIT:
One limitation with this approach is that the CLI -options depend on the tool. This works with the standard javadoc command but might not work with another vendor's doclet. However I'm not sure there's a universal way to achieve what the OP asked.
Anyway, it seems to be: NOT -footer but -bottom.

Override existing Eclipse plugin extension

I have an existing Eclipse plugin that provides an extension point. The plugin uses standard Eclipse mechanism to find the extensions. In this plugin's code, following code is used to get the extension.
IConfigurationElement[] config = Platform.getExtensionRegistry()
.getConfigurationElementsFor(extensionPoint);
if (config.length > 0) {
return config[0];
}
As you can see in the code, only the first found extension is used. This plugin already provides an extension and this extension is used in the default case.
Now I need to override the behavior of the default extension, so I created a new plugin and extends the same extension point. But it turns out that the default extension is always the first one in the IConfigurationElement array, so it's always picked up.
How can I make my own plugin appear first in the found IConfigurationElement array, then my own plugin is used instead of the default one?
The existing plugin is written by others and I don't want to make changes to it until it's absolutely necessary.
I'd say this is a bad way to get extensions from an extension point, either way. If they just want the use the pluginsystem to load a specific extension they have created, they could use the getConfigurationElementsFor(String namespace, String extensionPointName, String extensionId) method instead and close off the possibility for others to use the extension point. As of now there is no sure way of knowing which extension they will get. Chances are, there are instances in the code later on that assumes they will get their extension and when they don't get the extension they expect, Mr ClassCastException comes knocking on the door. (Had a bug like this in a system once)
Of course the best way is to change the code to handle many extensions!
But to your question; I dont know how the ExtensionRegistry fills the array, the API doesnt say. Perhaps there is a way to perhaps set a specific version of your extension that will allow it to be placed first in the array. You would have to look in the code of the ExtensionRegistry to know exactly how the extensions are found. I think it may be in alphabetical order, but im not sure.
Another way is to overload the existing plugin with your plugin and replace functionality. A very dirty approach, but in some cases it is doable. See one of my questions regarding this

Replacement for deprecated items in java

I am currently on a task, where I need to fix the deprecated items in the existing projects. I mean I have to replace the deprecated items with the corresponding replacing items as given in javadocs,
Eg: java.util.Date.setSeconds(int): Instead of this deprecated method, we need to use Calendar.set(Calendar.SECOND, int seconds).
I need to automate this using java code in eclipse IDE, by giving a project name in the workspace as input.
Kindly suggest me in doing this.
Thanks in advance.
I would go with the search & replace functionality of your IDE, by utilizing regex. (your parameter values should be captured with regex)
There isn't any specific utility to replace deprecated code, because it is not always that case that there is a straightforward replacement. Sometimes there is not replacement, and in other cases there is a completely different approach.
If the project is not really big probably easiest way is to do this by hand. It also handles the situations where there is no direct replacement.
Alternative (and definitely more interesting) way would be to write an eclipse plugin that extends eclipses JDT. Also if you are on Java 6 one possibility is to use Java compiler API.

Is a tool to add javadoc comments from the method declarations

I am wondering there is any tool can generate the javadoc's comment from the method declarations etc?
As #Bart commented, popular IDEs can generate the Javadoc skeleton from your method declaration. However, the content you have to fill in yourself. And you would better - in fact, it is better to have no Javadoc than to have loads of autogenerated Javadoc containing no useful (or even worse, obsolete) information. So please be careful when (ab)using your IDE to autogenerate Javadoc...
JAutodoc is an Eclipse plugin that has this functionality.
I believe that Eclipse and NetBeans both have facilities to do this. They just generate the outline, of course, no actual description of anything.

Modifying POM settings from plugin code

I've just recently started writing Maven plugins and was wondering if there is a common way to modify the values within the pom.xml file e.g. changing an artifacts version number. With the exception of the line being modified I would want the remaining formatting within the xml file to be preserved. I'm just about to start manually doing this via Java DOM libraries, but wanted to check first if there are any Maven convenience classes/functions for this.
Thanks.
My advice would be to check how this is done in the maven-release-plugin. Actually, the interesting parts are in maven-release-manager. Get the sources and dig :)
I don't think there's a prescribed way of manipulating the pom. All the plugins I've seen and written use one of the many DOM libraries. The docs for the XOM Serializer explicitly mention that it respects all whitespace unless instructed otherwise.

Categories