As I am looking for ways to speed development and usage with IDEA, I am using Intentions (I.e: Alt+Enter by default Keymapping) to auto-insert things like decelerations, constructors, and all that jazz, trying to keep myself well clear of using the mouse when I can.
One thing that does irritate me is with creating constants, fields, and parameters. After generating them, the IDE jumps to the position they are declared, and prompts for name and type. Usually this results in a double-hit of the enter key, however, leaves the cursor at there. Is there a way to jump back to the usage after declaring it through this feature?
Cheers.
Assuming you want a field foo, you can type foo and then immediately use the quick fix intention to create a field foo. Now you can type Alt +F7 ("Find Usages"). This will take you to the usage you just typed (since it is the only one). This assumes you have the "Skip results tab with one usage" option set in "Find Usages Settings (Edit > Find > Find Usages Settings or Ctrl+Alt+Shift+F7). If you do not have that setting configured, the result will open in the Find tool window with the usage highlighted. You can then type F4 (jump to source).
Related
I know how to jump to the next and previous error (F2, see SO Link, jetbrains.com), but is there a way to easily jump between suggestions?
If possible, I would really love to have a keyboard shortcut for this, as I am currently learning Kotlin and IntelliJ often has nice suggestions on how to improve the code.
If there is no keyboard shortcut to jump between suggestions, is there at least any other way?
With suggestion I mean things like the following (Ignore the "nonsense code")):
F2 also works to navigate between warnings. If there are errors in the file, it will jump to the next error. If not, it will jump to the next warning.
Adding to yole's answer: if you want to jump backwards you can use Shift + F2 instead.
Additionally you can alter the severity of each inspection (or inspection group) using the settings menu File | Settings | Editor | Inspections or directly using the intention action context menu (ALT + ENTER or similar) when dealing with a highlighted element (be it warning, error, information, etc.).
Note that some inspections are not enabled by default and many allow customization to your needs (e.g. class naming conventions, etc.).
I did once increase the severity of all the inspections and switch them back one by one as needed or even turned many off (or switched them to "weak warnings"), just to easily jump back and forth between them. I can't recommend that approach anymore ;-) (too many highlightings then... but it may help to find out about inspections you consider more helpful).
I have a tool that will list failed tests, and I would like a way to open a fully qualified class and goto a method in Eclipse with a single string I can copy from the results. It can use any pattern whatsoever (I can change the test results layout), but could be something like this example:
com.my.package.StringUtilTest:testValueOf
I shall use it for re-running tests, but could work with any methods. It could go to the first option when there are overloads (won't matter for me). It could also list all options and allow me to paste the string and enter to go to the first option (being the only one in my case), or selecting the correct one from the very narrowed down options, just like Ctrl + O will do (note Ctrl + O will work on current file only though). It could even accept (or require!) the parameter types, won't matter. Anything like that would be a huge thanks. Some place where I can paste a single string on (in any way that it may have to be) to open a specific method.
I've been looking for a while, could be built-in or configured shortcut, macro, plugin, et cetera, but could neither find nor wrap my head around doing something (not expert on eclipsetalities)... I tried searching for a lot different stuff, but as you can see my problem can be solved with a vast pletora of things (none of which I can find anywhere though).
Eclipse jdt doesn't have it yet, but I believe an open method dialog similar to the open type dialog is in the works.. Please create a bug at bugs.eclipse.org if one doesn't exist describing what you would want in such a dialog.
I've set up Content Assist to trigger on aAbBcCdDeEfFgGhHjIiJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ.() rather than only on .( (Under Window/Preferences/Java/Editor/Content Assist->Auto activation triggers for Java:) so that I can quickly select classes without pressing Ctrl+Space.
This was all good until I went back to creating variable names rather than using them, and it started suggesting a camel case variant of the name I just type, which doesn't yet exist, suffixed with the type! And of course pressing space afterwards uses this suggestion.
i.e. I type only the keys needed for
private static String HELLO = "hello";
I'll end up with the line
private static String hELLOString = "hello";
This comes under Java Proposals (Task-Focused), but turning this off under Advanced options obviously removes all the useful suggestions.
My aim is to allow auto-completion using known objects, not make them up, is there a way of doing this, and if so, How?
It looks like you're asking for code completion at a point (variable declaration) where there are no correct answers since only you know what name you want to enter. Eclipse does try to suggest a possible name, as you point out, from the already-entered type, but it can only guess.
Once you've declared the variable, Eclipse will be able to offer up that correct variable name later on in the code.
You can reduce the likelihood of accidentally selecting suggested variable names by increasing the 'Auto activation delay (ms)', and making sure that when you type a variable name you press [space] or [;] immediately afterwards before thinking about what to type next (if you haven't already).
Unfortunately there is no way (at least in the current Kepler SR1 release) of turning off variable name suggestion without also losing declared variable name suggestion, which is too useful to lose.
I've returned to IntelliJ after a long hiatus for Android development so I'm getting used to it again. The problem I have is that for example when you want to see where is a class being used, you'd position the caret in the class declaration and issue cmdaltF7 (on Mac OS X) to Find Usages, which is returning stuff from mapping.txt and seeds.txt as well as the .java results, and even tho I can set up the defaults by doing shiftcmdaltF7 and un-tick the: search for text occurrences and even change the scope from Project Files to a custom scope (for example), these options are not saved when I invoke Find Usages again.
Does anybody know of a way to personalize the Find Usages so it's more close to what Eclipse would do? (I.e., find the real usages instead of a text search for occurrences).
Reporting back from the future: the behaviour described in the question has now been implemented (Intellij issue mentioned in the comments).
To configure cmdaltF7 to run in a default scope, start by running it against some Symbol
Clicking on the wrench icon, one can select one of the pre-defined scopes, or create a new one (using the ... button).
The + creates a new scope. Find the folder in which to look, and click Include recursively. And voila!
Any consequent searches will use that scope until it is changed.
Instead of cmdaltF7, use the shortcut altF7. This will open a pop-up for you to make a selection about Scope, Test occurrences, and types of usage. You will have to make this selection one time. The next time you press altF7 then your choices are remembered.
The result is that altF7 followed by enter gives you what you need.
Is it normal that the default behavior for code completion when editing Java is the following?
If I import a package, after typing the first ., any key I press results in the first item in the list being selected
Sometimes while typing keywords like public and protected, NetBeans will make some wild leaps and insert private after just a p or pu are typed!
In general, it tends to make some big guesses in terms of autocompletion, guesses that are not supported by my previous input at all.
I feel like this cannot be the desired behavior for every user. Is there a way to make the code completion not autocomplete anything, or at least make it way less eager?
Edit: To be clear, I do not want to have to disable the sometimes-useful "Autopopup Window." I want the window to eagerly appear with tips and suggestions for methods, syntax, whatnot - I just don't want NetBeans to try to guess what I want, because it is wrong 90 - 100% of the time.
Which version of Netbeans are you using because that doesn't seem to be the behaviour I am seeing in 7.1.
AutoCompletion popups don't appear until I hit Ctrl+Space.
If I type "p" and then hit Ctrl + Space, the popup shows "private", "protected" and "public". I can either keep typing (and the list gets smaller as possible matches are removed) or use the cursors to select the word I want and hit Enter.
If there is only one logical option e.g. I start typing "pu" and then hit Ctrl+Space, then Netbeans inserts "public" automatically (though this can be turned off).
Code templates are a different story, I have them set to be activated using Shift+Space. As far as I know, templates don't show any popups. Anyone who likes pain can consider changing the activation key to just Space :P
I definitely share your complaints, especially re: 1. A quick google search reveals ways to turn off autocomplete:
AutoComplete drives me crazy. I’ve always hated it – I feel like it
slows my computer down and sometimes it even seems to derail me in the
middle of typing something because the window comes up and somehow
snags focus. I turn it off under Options, Editor, General (uncheck
Auto Popup Completion Window).
Item 2) sounds more like the "code template" feature rather than the auto-completion.
If that gets in your way, you have two options:
change the key that "triggers" the code-template expansion (e.g. from "Space" to "Tab"
remove all two-stroke templates (or any other abbreviation that you would rather not have)
Both can be done under "Tools -> Options -> Editor -> Code Templates"