Final in method parameter in eclipse - java

When I try to put final in method parameter eclipse doesn't help. Any idea how to get this to work?

This probably will be as close as you can get to it. It would be a lot of work to do this for every keyword, but since there is only so many of them it's possible. You could probably take it a step further and just write a template for your methods.
Preferences > Java > Editor > Templates
New > Name (alias)
Pattern: "final "

I don't think this is possible.
The closest thing to this is to set a "save action" which will automatically add final modifiers to method parameters when you save the file.
Preferences > Java > Editor > Save Actions

Assuming that you are complaining about the Eclipse Java editor's completion behavior, I don't think there's anything you can do about it.
If it really worries you, create a bug report on the relevant Eclipse component. Better still, create and submit a patch that fixes the problem.
EDIT
I had a trawl through the Eclipse JDT open bugs/issues, and there are various issues related to final in various contexts, though not specifically this one (as far as I can see). It is also worth noting that there are a LOT of open JDT issues ... so an issue with a viable patch is much more likely to receive attention.

Java makes a copy of the parameters, the final parameter in this case doesn't do anything, it doesn't help you access it through an inner/anonymous class. Is there a reason you want it?

Related

Is there a way to leave notes in library code in eclipse?

due to reasons I am working with undocumented java library code that I cannot alter in any way or write into. Im using eclipse 2020-06 and I would like to leaves some notes for myself to make things easier. Is there a way to do that? or maybe an eclipse extension?
You can use bookmarks. They work somewhat similarly to breakpoints, without pausing execution when you're debugging.
You can add them via the context menu.
If I recall, you're a bit limited by the amount of information you can add. It's basically just a single text box.
See the help section on bookmarks
Maybe there's some plugins which extend the functionality (e.g. this one for adding keyboard shortcuts)

Eclipse Auto-Correct Feature?

Is there a way to have Eclipse auto-correct certain misspellings? For example, I tend to type "System" as "Sysetm", and Eclipse catches it. However, it only tells me it's an invalid package, and I have to manually correct it. I'm hoping there's a way to have it be corrected automatically.
Unfortunately, I've found no documentation or information about doing this. I know it can be difficult at times, but Eclipse doesn't let you directly "add" spellings to it's local dictionary, which is something that you cannot edit.

Generate all stacks to a function

Eclipse allows to get all references to a function. I'd like to go further and know if anyone knows of a tool or script that would do this recursively ie from a function it would produce the list of different possible function stacks to access to it.
I am looking for this to make sure all the impacts of a change are captured in the spaghetti old legacy code I am looking at the moment. Thanks.
Try eclipse's Call Hierarchy.
It's CTRL-ALT-H on Windows, CTRL-OPTION-H on OS X.
(Hotkeys for eclipse 3.x, I have yet to use eclipse 4)
Its called the Call Hierarchy and you can open it with Ctrl+Alt+H
http://www.javaprogrammingforums.com/java-jdk-ide-tutorials/19-list-shortcuts-key-eclipse.html

Eclipse-based Custom Content Assistance? (Java)

Is it possible to edit the content assistance of Eclipse? Sort of add rules or functions for it? I'm aware that Eclipse is open-sourced, but I was there an "easier way" or an interface?
For example, I'm working in Java 1.4.2, so I don't believe I have the magical "autoboxing"(am I correct in thinking that autoboxing would solve this issue?) . So when I'm working with getting parameters from a request, they all return strings when I may need a Long or an Int. I'm always interested in making things more automated (as any computer scientist usually would), so I was wondering if it was possible to have content assist suggest to use the common java parse functions (Integer.parseInt, Long.parseLong, etc) for the passed in parameters.
If you want to actually augment Content Assist in a highly detailed, customized way, you'd have to write a plugin. Eclipse is very well architected such that there are endless extension points via which plugins can extend base functionality, including Content Assist. But, writing one is not a trivial matter (though a skill that could serve you well, if you have the time to learn it).
Another option is to write your own Java editor template, which can emit any pre-defined snippet of code you want (including inserting parameter values), and will be included in Content Assist. Open Eclipse's Preferences and navigate to Java > Editor > Templates. You can use the ? help button on that Preferences page to learn more about them.

How to make javadoc.jar take priority over javadoc in sources.jar?

I have a limited selection of original source code overlayed onto decompiled code in a sources jar.
This is great as it gives me easy ability to drill down into the code when debugging however it seems to have a side effect of disabling the javadoc from the associated javadoc.jar from working in eclipse despite me having a separate javadoc.jar file with the javadoc in it.
I assume this happening because eclipse is finding the 'source code' and assumes that all the javadoc is in the source and therefore there is no need to check the javadoc.jar file.
I'd like to be able to tell eclipse (preferably using maven) to not use the sources.jar for javadoc and only use the javadoc.jar. I would still like to use the sources.jar for source code.
I have assumed that eclipse is preferring to display javadoc from sources and may be wrong so please correct me if that is the case.
Also, I may just be doing something simple the wrong way so please let me know if that is the case.
I am hunting for the same thing. I have some source jars I created with jad (and since they are decompiled, they have no JavaDoc in them) and attached as source attachments. I also have the JavaDoc attached. It seems like it is a limitation of Eclipse. It will scrape the JavaDoc from the sources and display it (even if its empty) rather than looking to the JavaDoc. I wish it would notice that the JavaDoc was missing from the source and try the JavaDoc location instead. If I don't find a solution, I'm going to post the question and/or feature request over at the Eclipse site.
One workaround might be to integrate into the java decompiler (like jad) the ability to examine both the source an the javadoc, and put the javadoc back into the source. It would also then have parameter names for methods available too so it could put those back in. Lots of people have suggested this, but I cannot find anyone who has done it.
A couple of caveats. First, jad hasn't been maintained in a long time. The JD-Core/JD-Eclips website has vanished. And I have not found a better Java decompiler than jad. What happened to all the great Java decompiling gurus and solutions? Second, it might be tricky with the "align for debugging" feature to make sure the JavaDoc comments don't take up more room than is available.

Categories