Stop eclipse propose variable type after variable name - eclipse

Like I type:
public String name
Eclipse is suggesting nameString for the variable name.
I am using Eclipse 4.2
I saw the same question here, but by following the instruction in the answer, I am still not sure what to do.
How to stop Eclipse from putting the variable type after the variable name

In the
window -> preferences -> java -> editor -> content assist -> advanced
page you need to turn off Java Proposals or Java Proposals (Task-Focused)
Unfortunately this also turns off alot of useful content assists

Related

Eclipse CDT eclox reference autocompletion

I just started working with doxygen and eclox (eclipse CDT, C++) and love the whole package. There's only one thing I'm really missing: whenever I try to add a \ref to a function, class or variable, I have to manually remember the (fully namespace qualified) name of what I want to refer to.
It would be AWESOME if it was possible to use the (already existing) code completion feature from eclipse to suggest the right function, class, etc.
Like so:
/**
text yadayada bla \ref std::str<ctrl + space here> -> complete to std::string so that doxygen understands the link
*/
Is that possible? I'm actually surprised that I couldn't find anything about this elsewhere. Is everybody really inserting all references manually all the time?
It becomes quite cumbersome when referring to e.g. imed::helmbus::io::subclasses::CAN_Reader
Adding a reference to this should work the same way as when I'm actually coding:
/**
\ref ime<ctrl+space> -> show list of namespaces beginning with 'ime' -> complete to 'imed::'<ctrl+space> -> show list of subnamespaces -> ... -> imed::helmbus::io::subclasses::CAN_<ctrl+space> -> complete to CAN_Reader
*/
Or is there maybe a place somehwere where I can find out how to do this? Or why it's impossible?
Thanks!

Eclipse key for "go to typed in class"

Is there a key in Eclipse Neon.3 (Java) that allows me to type in a class name and which then takes me to that class, whichever project in my workspace contains it? Specifically, I am not sitting in a source file with a reference to it, but I have a case like someone emails me and says "I have a question about class StoreImportantData" and I want to be able to type that class name in and go to it without thinking about where it might be located. Various "Search" functions will work, but are very clumsy or require temporarily changing my default search settings.
Normally Ctrl+Shift+T is bound to Open Type - should be the default, I'm pretty sure that I've not changed it.
Note: Ctrl+Shift+L list all key bindings, and the preferences
Window -> Preferences -> General -> Keys
lists all commands and bindings. It not only allows changing the binding, but also has a filter field that helps searching a specific functionality..

Method reference shortcut transformation in Eclipse Luna

In Spring Tool Suite
(Version: 3.7.0.RELEASE
Build Id: 201506290649
Platform: Eclipse Luna SR2 (4.4.2))
Is there a shortcut to go from something like:
Function<String, Integer> func = str -> Integer.valueOf(str);
to something like this:
Function<String, Integer> func = Integer::valueOf;
(and backwards) via a keyboard shortcut?
I am aware of Ctrl+1 key combo, but it doesn't seem to offer the method reference conversion, hence this inquiry:
First, you need Eclipse 4.5 or greater, because that's when this particular assist was first published.
Next you should avoid the "unused" warning on the variable, because otherwise content assist will jump to the nearest warning / error rather than proposing a change unrelated to any problem in the current code (this is not strictly necessary, but makes the next step easier).
Finally, you need to position the cursor on the ->, because that's the only piece of syntax definitely identifying the lambda.
See also the first item in the 4.5 "New-&-Noteworthy", Section on JDT.
Select the lambda expression "str -> Integer.valueOf(str)" and press Ctrl-1. The first entry in the quick-fix list should be something like "convert to method reference".

Eclipse caret jumps to constructor while typing

While typing in Eclipse (Java) I often have the problem that when I begin to type accessors, the caret jumps down to the beginning of the constructor definition. So in a document like this:
private int mSomeInt;
public
in|public MyClass(){
}
I would like to manually type out the accessor (getter/setter) for mSomeInt, but when I press space after 'public' above, the caret jumps to the beginning of 'public MyClass'.
I often type complete lines to look up and find my methods jumbled with the constructor (like above).
Any help would be appreciated.
Note - this isn't only with accessors but rather any access modifiers that I define before the constructor or another method.
Edit
After unsuccessfully trying Deco's solution below, I've managed to narrow it down a little further.
The problem only happens if I have all the blocks in the file in a collapsed state (ctrl+shift+numPadDivide). I can see the problem is now that the new access modifier I type is then (quickly) collapsed into the below method. i.e. Eclipse is actually taking the first accessor modifier and collapsing everything from there, even though my intention is actually to write a new method.
The only solution I've been able to find is to only edit the source with all the 'fold' elements unfolded.
Under Window -> Preferences -> <Language> (e.g. Java) -> Editor there is a Content Assist menu item where you can configure auto completion and caret placement as well as auto-activation of it and the delay it uses.
Edit:
After your update to the original question I was able to successfully replicate this in Eclipse Indigo. When you have all of the code blocks collapsed it looks like Eclipse assumes that the code you are writing needs to be in that block (rather than as a variable declaration). I'm not sure if this is expected behaviour or not - but the only way around it I've found is to edit the code with the main block open, and then close it after the fact - or turn folding off altogether.
From what I can tell there are various folding plugins/addons that you can get for Eclipse which override the default behaviour and might function better? A quick Google search will be able to get you a list of them quickly.
I'd probably also suggest posting this as an issue on the Eclipse support site for their official answer.
Unfortunately this issue still exists for me in the latest Elcipse version (Kepler).
As the issue only occurs when the document is 'folded', the work around this is to either disable folding in the editor - or disable folding on 'Members' from the :
Preferences -> Java -> Editor -> Folding

Why eclipse is generating argument names as arg0,arg1,arg2.... for methods?

When I try to access some class's method; eclipse gets that method but arguments inside that method are replaced by arg0, arg1, arg2...
Example:-
Suppose I have this method in some class named ReadFile.java
#Override
public int readXXX(int start, int end, String xxx) throws IOException {
return 0;
}
When I try to access that method from an instance of class it shows me as follows:
readFile.readXXX(arg0, arg1, arg2);
It becomes hard to identify what I should pass in argument. The same thing also happens for java methods. i.e. when I implement interface all method under that will be generated but arguments in that methods are arg0, arg1.....
Is there any setting I can do prevent this?
I'm using Eclipse Galelio.
Eclipse can't work out the arguments because it can't find the source or javadoc attachments.
Make sure your source is attached.
To check, click on the method call readXXX and press F3 which should open the method declaration. If the source is not attached, Eclipse will say "Source not found" and will allow you to "Attach Source...".
Anyone having the same issue, try performing a Project > Clean, this will delete the old class files, and Eclipse will recompile them in debug mode this time. Worked for me in Indigo 3.7.2
The problem is that your class files lacks debug information embedded in them. JDT doesn't reparse the source files or the javadoc for dependencies, when building the AST for your project, so it doesn't have idea what the name of the parameter is, even when you are able to open the class and clearly see what are the method names.
In order to correct this, you need to recompile your class files with debug information enabled, which makes the class file considerably larger, but unless you are developing for memory-constraint devices, you should be fine.
for those like me who tried to apply one of our colleagues suggestions and unfortunately hasn't worked, please, give a try to check the option "Add variable attributes to generated class files (used by the debugger)" within Window -> Preferences -> Java + Compiler.
Once you've done that, try to build the project again.
Cheers.
I solved this by going to preferences
Java / Content Assist
On this page under "Sorting and Filtering" I unchecked "Hide proposals not visible in the invocation context" now instead of seeing (arg0, arg1, arg2) etc in autocomplete I see (catalog, schemaPattern, tableNamePattern...)
I am using Spring Tools Suite 3.7.2 which runs on the Eclipse Mars 4.5.1 platform.
This link helped me to solve this problem.
1) Right click on your android.jar and select Properties.
2) Select Java Source Attachment. Enter the source directory location (you can also use External Folder… to browse to the directory) and click on “Apply“.
The code names match the following version numbers, along with API levels and NDK releases provided for convenience: