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.
Related
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.
I'm writing java code using scala one (Kafka api), and I can't get eclipse to get the argument names in methods autocompletion, it's instead suggesting things like Method(String arg0, int arg1,...)
The source is apparently found correctly, as I can browse into it with F12, and I see the correct argument names, but it's still a bit tedious to go into every function, retrieve the argument names, and write the call after that.
I've installed the scala plugin for eclipse, which did not solve this.
Is is possible to solve this ? If yes, how ?
Thanks !
I had come across this issue a while ago and was figuring out how to fix it. Eventually used this plugin. You should take a look at his. https://stackoverflow.com/a/15520267/614867
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
I am working on an incremental builder for Java code in Eclipse. Eclipse provides a ResourceDelta that tells me which resources have changed since the last build. However, I would like to have more detailed information, e.g. what methods or what field definitions changed. There seems to be functionality similar to what I want in the "compare with -> each other" view. However, this code is quite disconnected from the build engine and seems incompatible with ResourceDeltas. What would be a good way to figure out what I want? The best solution I can see is to compare two ASTs, but I also could not find any built-in support for that.
JavaCore does supply this information via the IElementChangedListener and IJavaElementDelta interfaces. Here's a quick code sample to get you started:
JavaCore.addElementChangedListener(new MyJavaElementChangeReporter(), ElementChangedEvent.POST_RECONCILE);
More details available in Manipulating Java code from the JDT Plug-in Developer Guide.
Is there something equivalent to OmniCppComplete for java in vim ?
I know of eclim but I think it is overkill for such a simple feature.
See http://www.vim.org/scripts/script.php?script_id=1785
Also found VJDE - http://www.vim.org/scripts/script.php?script_id=1213 - Need to evaluate which one is better/more up-to-date
Seems you have some options for code-completion above.
I would recommend also grabbing a copy of TagList, which provides a sidebar displaying the structure of your current file.
The ctags which TagList uses can also be used for fast navigation in Vim. Ctrl+] over the text "curiousMethod()" should take you to the definition of that method.