When I type code in Sublime say, I just need to start with the first few letters of some variables and it would come up with a list of possible existing variable names that match what I just typed. But in Eclipse, I don't know how to realize this. In the preference-java-editor-content assist, I found this auto-activation pane and according to some other posts, I'm supposed to change the auto activation triggers for java. However this is how my default setting looks like. I don't understand the dot over there. Also I'm not sure if that's the right way to approach my problem?
Can someone help me out? Thanks!!
The auto activation will give you suggestions about fields and methods that are available. For example if you start typing in
new Object().
then the IDE (Eclipse) will give you suggestions (after 200ms from the "Auto activation delay") of toString(), equals(), and other methods.
If you just want to use plain auto-complete, I tend to use the shortcut CTRL+ Space (The spacebar key). So if I want Eclipse to auto-complete a method name for me (say the method is reallyLongMethodNameIDoNotWantToTypeOut()) I'll type in
reallyL press CTRL + Space and Eclipse will fill in the rest for me.
Related
I'm doing a project in NetBeans that uses JFrames. To begin with, I had created the window in a package called "uam.pvoe.form" and among many other elements, I added a Combo Box called "cmbUnit". For the purpose of my submission, it is necessary that this Combo Box accepts objects of type "Unit" instead of "String" which is the default value for "Type parameters".
NOTE: In the image it says "Unidad" instead of "Unit" because the project is in Spanish but I am translating it for you.
The problem is that when I make this change, part of the code generated by NetBeans is not updated, specifically this part (that is where I get an error and it does not allow me to run the project):
I have made this kind of changes before but this has never happened to me. I think the problem is that the type of objects is no longer of type "String" and that array is invalid but as it is part of the automatically generated code, it does not allow me to modify it. To look for a solution, I checked other projects where I made similar changes in the "Type Parameters" but that line does not even appear in the generated NetBeans code. Could anyone help me on any possible steps I am skipping or any way to fix this problem?
In the "Properties"-window you need to open the "Properties"-tab and delete the values of "model".
I'm considering switching from Eclipse to IntelliJ IDEA, but there's one thing holding me back: the autocomplete. Eclipse shows me all the information I want from the start whereas IntelliJ holds back some information. The only thing I'm still missing is separate entries in code completion for each constructor signature. And I believe it's pretty weird that's missing since method signatures are done separately.
My question being, is it possible (am I overlooking something) to get IntelliJ to show separate entries for each signature for constructors WITH documentation, instead of just showing the class name and making you figure out afterwards if you're even in the right place or not.
Eclipse way of showing (preferred)
IntelliJ IDEA way of showing (not preferred)
This answer is base on IDEA version 2021.2.2
In the Settings -> Editor -> General -> Code Completion, check Show parameter name hints on completion under Parameter Info session.
Combine with Ctrl + Q, you can view the javadoc for each constructor.
Type the class name and the parenthesis. Inside parenthesis, type Ctrl+P. Eg: new BufferedWriter( <ctrl+P> )
In fact you can type, ctrl+P to get details of any function, not just constructor.
It is also possible to show overloaded constructors by enabling a hidden option. Invoke the Help | Find Action menu item and type Registry to go to the Registry. Here enable the java.completion.show.constructors option.
Copied From: https://stackoverflow.com/a/43639241/2920861
Previously, I've been able to create a method stub in Eclipse (Java) by typing the method name and pressing CTRL - SPACE. This would then give me the option of automatically generating a void method stub.
Unfortunately, recently I've been unable to do this for any method name longer than two characters. Once the word is longer than 2 chars, the option is no longer there.
I've looked at the templates in the options, and found the private_method and public_method templates, which are similar, but not quite right. The void method stub is nowhere in there. Also, the icon next to the void method stub is different to the templates, which leads me to believe that it is indeed something other than templates.
Can anyone point me in the right direction of why this isn't working for anything longer than two characters?
Here's an image of the code suggestion I'm looking for (the selected one):
EDIT: For clarification, I've added two more images showing the problem, and a further description:
In the case where there are two characters and I press CTRL - SPACE, I get the autocomplete option for creating the method stub (which is what I want). However, when pressing CTRL - SPACE with more than two characters before the cursor, there is no such suggestion. See the second image below and you'll see what I mean.
It's related to Code Recommenders, which is now enabled by default in Eclipse (as of the Mars release, I think). To me it looks like a bug, either behavioral or, if it's working as intended, it's a usability and/or UI bug, because it's difficult to understand the new behavior.
One workaround is to disable Code Recommenders for code completion; see this screen shot for where to do so in the Preferences.
If you want to keep Code Recommenders enabled (it does seem to provide some valuable functionality), is to tweak a particular setting so that the method template is included for more characters. I'm not exactly sure how or why it's related to what you're seeing, but it does seem to work. I'm also not sure of the performance impact of adjusting this too much, as indicated by the UI instructions.
Increasing the "Maximum prefix length" for the sub-words completion seems to allow larger numbers of characters to trigger the method template suggestion. Again, I'm not sure why but I strongly suspect it's a bug in Code Recommenders.
I suggest asking about it on their forum and/or entering a bug about this: https://www.eclipse.org/recommenders/community/
form the image I can tell that you are trying to write your code within the class block and not within a method block...
Example
class a {
// you are trying to write your code here
}
This issue has been fixed with Eclipse Code Recommenders 2.2.5.
You can download it from the Recommenders stable update site stable update site.
I know there is a Ctrl+Space dialog box that show the methods options that I have.
But if i have a method that I not fully remember the name of it and I remember only a part of the name.
For example: There is a big static class which contains tons of methods starting with "add"
add1_Buffer, add2_Render, add7_Function and so on..
now I don't remember the fully name but i remember only "Buffer".
so I want to type "buffer" press Ctrl+Space and get the "add1_Buffer" method and all the names
that contain the name "buffer" in it.
Edit:
By the way, i need it on the OpenGL api where there are tons of functions and i am not familiar with all of them i know only keywords, I was searching for something like in visual studio that is really fast and easy.
If you start typing the a in add1_Buffer and then an upper B and then press Ctrl + Space you will find the correct method.
You can then continue writing the word Buffer if there are more methods starting with add and then having an upper B.
This means that you'll have to remember at least the first part of your method but hopefully you do.
Add the CodeRecommenders plugin to your installation. That has a subwords completion, which the normal JDT code completion does not have.
Use search. From the Search menu at the top of the window, select "Java Search". You can limit your search to methods and use wildcards to search for *Buffer* if you know that Buffer is in the method name.
The shortcut Ctrl + O gives an outline of the current source. So you can view and search all your methods in your current class. Use wildcards when needed.
This merely meets you req: alt+/, just a replacement for ctrl+space
Currently there is no direct way to do that in eclipse. But i found these are helpful. here
This post resembles your's look at it. Similar one here
Is there a simpler way of reordering methods within a class source file in IntelliJ than cutting and pasting the code manually? Nowadays I often need this while refactoring legacy code, e.g. to move related methods close to each other in the source code.
In Eclipse AFAIK there is a view similar to the Structure view of IntelliJ, where I can drag and drop methods around. However, this does not work in IntelliJ and I couldn't find any hints from its help either.
I am using IntelliJ 9.0.2 to be specific.
You can select a method name and hit: Ctrl+Shift+Up or Ctrl+Shift+Down to move it up and down.
On OS X: Cmd+Shift+Up or Cmd+Shift+Down
Beyond this the Rearranger Plugin lets you move methods around quickly, and even define a standard ordering based on your coding convention.
IntelliJ has a built in system that allows you to specify how to order your methods. You need to go to Settings (Ctrl + Alt +S) -> Editor -> Code Style -> Java -> Arrangement (tab) and scroll down until you find the icons with methods. There you can manipulate the options to sort them by visibility, or alphabetically, or to keep related ones grouped together.
Here is a screenshot of my settings which will order methods automatically by visibility (public, protected, private) and alphabetically (a-z).
The blue highlights show the currently selected rules.
Not a perfect answer yet, due to a bug in IntelliJ.
Though IntelliJ offers this feature implicitly, but it needs to be enabled as well as fixed. The OP's suggested way is technically arranging methods in depth-first order. However, if you use Breadth-first ordering(which works properly), it should reduce the manual work of moving functions by a lot, by arranging all caller and callee methods together.
Issue Link: https://youtrack.jetbrains.com/issue/IDEA-149524. Please do vote for its resolution.
The appropriate action for this is Rearrange Code. This has no key assigned to it, but you can define your own using Preferences->Keymap.
With your cursor on the method definition line (you do not have to and press ctrl+shift+up or ctrl+shift+down, to move up or down respectively.
You can also to ctrl+shift+numberpad - to quickly collapse everything so you can focus on moving around (plain - works on my laptop as well, not sure why) and ctrl+shift+numberpad + to get back to see everything (ctrl-shift-equals works on my laptop as well).
Select a block of text (hit Ctrl-W a few times) and then use Ctrl-Shift-Up and Ctrl-Shift-Down to move it around.
There is an automated way, which you can later tweak
Code -> show reformat file dialog
and tick "rearrange code" box