Variable use highlighting in Intellij IDEA - netbeans

One of the features I really like about Netbeans is that when you click on a variable, method, field etc. Netbeans shows you all the usages of this entity in the right hand bar as little bars of colour. Is there a way to get this behaviour in IntelliJ IDEA and if so, how do I turn it on? I haven't found anything in the settings or Google but I might be missing something!

file>settings or ctrl+alt+s (for windows) select editor from the list on the left and check Highlight usages of element at caret in the Highlight on Caret Movement section

Apart from enabling the "automatic highlight usages" setting described above, you can also invoke "highlight usages" manually, using the shortcut Ctrl+Shift+F7.
The benefits of using the "manual" highlight usages are:
You can highlight usages of multiple variables/methods/etc at the same time
You can remove highlighting for an individual element selectively, by invoking Ctrl+Shift+F7 again on that element
some users find it less distracting than "automatic highlight usage" - this is subjective or course

Above answers are correct but still to get the exact behavior like in Netbeans try to use Identyfier Highlighter plugin for Intellij Idea (available in default plugin list under window settings).
This is really strange as Idea features mentioned in previous answers would do the job if merged into the one configurable feature.

Related

Eclipse (Squish) add custom annotation types

Hay, has anybody experiences with adding custom annotation types or appearance color options to the eclipse squish IDE? I'm trying to find a way to highlight previously verbalized words in the editor (i.e. **markme_**something(parameter). Sadly I can't find any plugins and as far as I noticed squish is doing a good job to hamper any kinds of external not former installed or in the manual mentioned plugins.
Another of my thoughts are to write an addition to the syntax checker but that would be probably kinda over the top and not that easy to realize. The source code is written in python.
Greetings and thanks!
Eduard
To mark a search string in the editor you can use Search > Search... (Ctrl+H). Then just enter the search string and press Enter. (While this will open and populate the "Search" view, the search string occurrences are being marked in the editor anyway.)
Perhaps you are trying to let the script editor color (a customizable set of) substrings in a customizable way? I have not found an Eclipse plug-in that would achieve that. The closest I could find (and available in source code form) is Highlight On Selection.
PS: Note that custom plug-ins are not supported in the Squish IDE, but that you can use the Eclipse IDE Integration, and then install the desired plug-ins into this Eclipse installation.

How can I keep Eclipse from filling in auto-completions when I type an opening parenthesis ('(')?

So, on Eclipse Luna, I often encounter the situation where I'm typing a method name, but the first autocomplete suggestion is not the method I am looking for but something that is prefix-equivalent but longer, as in this example:
In the example, I just wanted the element(String name) method, so instead of hitting Return, I type ( instead. The result, quite annoyingly, is this:
This is clearly not what I was looking for. Is there a way to prevent Eclipse from performing auto-complete when I hit open-parenthesis (()?
These are my content assist settings (aparrently, I don't have code recommenders installed at all in this eclipse installation):
In Eclipse 4.11 (2019-03), and possibly earlier, the answer to this is under Preferences → Java → Editor → Content Assist → Disable insertion triggers except 'Enter'. After I checked that box, editing became a lot less annoying.
I have no idea why Eclipse doesn't do it by default. Who types map.put( and wants that to autocomplete to map.compute()?
A hack for this is to change the way Eclipse sorts the proposals.
You can go to Preferences menu and then go to the section for which you want to edit sorting. Then to de Editor section and Content Assist.
For example, for Java editor, it will be Preferences > Java > Editor > Content Assist.
There you will see, more or less in the middle of the window, a section called Sorting and filtering. Inside there is an option called Sort proposalswhich you can change from by relevance to alphabetically. Save an close.
With this you will get the proposals list order alphabetically and element() will be before other methods starting by element.
EDIT:
Tested in Eclipse Luna running in Ubuntu 14.04 and it works. You'll still get your code completed when writing ( but it will be completed with the shorter option available in the proposals list. If you want to use another method, you can continue writing some letters and the shortest option will disapear of proposals as it doesn't match what you are writing.
I guess your problem is the substring matches.
Go Window->Preferences->Java->Editor>Content Assist.
In Sort proposals section uncheck Show substring matches.
I found By relevance more useful then Alphabetically.
I have usually checked hidden Hide proposals not visible in the invocation target, and Hide deprecated references, too.
I hope it help.
The feature you're fighting with is the new "Intelligent code completion" which orders methods based on average usage count. Don't ask me where they get the data. See also here:
http://www.eclipse.org/recommenders/manual/#intelligent-code-completion
To disable the feature go to the preferences page Code Recommenders|Completions and uncheck "Enable intelligent code completion".
Another issue which might negatively affect code completions appears to be 'Java Proposals (Task-Focused)'. For example, it causes map.put() to be replaced with map.compute().
You can disable these from Preferences | Java | Editor | Content Assist | Advanced.
See also: http://literatejava.com/eclipse/bad-auto-completions-in-eclipse/

Eclipse content assist auto appends type for variable

I just started to use Juno for a couple of days, the content assist mechanism seems different from what it behaves before.
For example, if I try to declare a variable
Boolean isVisible
The content assist of Juno will give you a drop-down list with the variable name
isVisibleBoolean
as hint.
And the very annoying thing is that no matter what I typed in(; or SPACE), the "isVisibleBoolean" will be selected.
Does anybody know how can I disable the auto-variable-type-appending thing?
Much appreciated.
I'm using Mac OS X 10.8.1 currently, haven't tested it yet in windows.
Based on the discussion for Eclipse Bug 412992, check your Content Assist Auto Activation settings:
Window->Preferences->Java->Editor->Content Assist
If, for example, characters a-z are listed as "Auto activation triggers for Java", you can remove them and the type name will not be auto-appended to a new variable name when you hit ' ' or ';'. It's up to you to determine the best configuration/tradeoffs for your style based on the available options.
It seems that it is not possible.
See answers to Eclipse Bug 378588: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378588
This is still a problem in Eclipse 2018-12 and it only seems to occur if you changed the Auto activation triggers for Java setting to e.g. ._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, which'll make the Content Assist (almost) always pop up, even without pressing Ctrl+Space (Windows).
There's a new setting that was added in Eclipse 2018-12 and makes it a bit less annoying (mentioned in the comments below the bug report):
In Window - Preferences - Java - Editor - Content Assist tick the Disable insertion triggers except 'Enter' box.
With this setting enabled, Content Assist is still going to trigger (depending on the other settings) but you have to press Enter to accept a suggestion.
Not a perfect solution:
Window->Preference->Java->Editor->Content Assist->Auto activation Triggers for Java: .ABCDEFGHIJKLMNOPQRSTUVWXYZ
In this way, only classes and types will be popped up for proposals.
Just a suggestion, the choice is up to you.
What you see there is name completion for object types. And this may often make sense, e.g. pressing Ctrl-Space after List book will complete that to List bookList. For primitive types this is not done, so int count will not get any completion when pressing Ctrl-Space. This would be a (not really good) solution to your problem by declaring the variable as primitve boolean.
What I really recommend as solution is to change your style of writing variable declarations. For your example, write isVisible = false instead, have the editor complain about the missing type declaration, hit Ctrl-1 (from wherever your cursor might be placed), Enter.

How to replace Eclipse search dialog?

Is it possible to replace Eclipse search dialog to something more convenient, like the search dialog in Firefox or Chrome? The default one doesn't support F3 to search for the next match, it doesn't move itself away if the match is underneath the box and doesn't allow to highlight all the matches - and these are the features I really miss...
I don't think you can replace the Find dialog easily. You would probable need to (re-)write parts of Eclipse. Definitely doable, but not a small task...
That said, most of your problems can probably be addressed by the current dialog:
The default one doesn't support F3 to search for the next match
"search next match" is Ctrl-K by default. You can configure the keybindings under "Preferences / General / Keys": change the keybinding for "Find Next".
it doesn't move itself away if the match is underneath the box
Yes, that would be nifty. The dialog does however remember where you last put it, so just put it somewhere out of the way (e.g. over the package browser, or to the right), and it will stay there.
and doesn't allow to highlight all the matches
This is not yet available (though it has been discussed: https://bugs.eclipse.org/bugs/show_bug.cgi?id=29692 ). There are however two ways of getting a similar result:
Use the search function from the toolbar ("File Search" from the "torch" button). If you search there, it will highlight all matches in the editor (and provide marks in the editor ruler, and a list in the search view).
For Java elements, activate "Mark Occurences" ("highlight pen" button). This will highlight all occurences of a Java element if you mark in in the editor.
Maybe one of these will help you.
Finally, you can just open any file in an external editor (like (g)vim or Notepad++) right from inside Eclipse (right-click -> Open with). Then you can use any editor you want...
While it may not be exactely what you want, have you ever used the incremental search (Ctrl + J)? In my opinion it is much more convenient than the standard search.
A newer alternative is InstaSearch.
Information:
InstaSearch is an Eclipse plug-in for doing fast text search in the workspace. The search is performed instantly as-you-type and resulting files are displayed in an Eclipse view. It is a lightweight plug-in based on Apache Lucene search engine.
Each file then can be previewed using few most matching and relevant lines. A double-click on the match leads to the matching line in the file.
The "search the next match" is Ctrl-K. Previous is also available, see the "Edit" menu...
Only the highlight feature does not seem to be present. You might need a plugin for that (everythinhg is possible with plugins).
There was a Summer of Code project to implement a Firefox like search in Eclipse in 2007.
This is the official page, and this Blog shows a promising screenshot.
I never tried to install it, and I didn't find a final release or something though :(
SearchTab is an Eclipse plugin that shows a Firefox-like search tab
You do this by changing the key bindings under Preferences -> General -> Keys

PHPEclipse weird highlight

This is not a technical problem, but very annoying.
Does anyone know how to turn off or change the color for the name highlight in phpEclipse?
I use white-on-black scheme and this highlight has a white background which makes it unreadable and very ugly.
To better explain which highlight I'm refering to, it's when I move the cursor to a variable/function/method/constant, all other places that name is typed get highlighted.
I've spent a few days going thru the settings many, many times and I haven't found one that changes that specific annoying highligh.
Anyone? please? :)
For Java in Eclipse it is:
Window > Preferences > Java > Editor > Mark Occurrences.
My ruby plug-in has the same option. Do a search in the preferences window for 'Mark Occurrences' and hopefully the php plug-in has the same option.
Thanks, that was it, Mark Occurences.
When I searched thru the options I was looking for color pickers instead of checkboxes :)
It would be nicer to be able to change the highlight color for that, but even removing it is of huge help.
From Eclipse, go to Window > Preference, use the filter field ("type filter text") to search for "color". It will show all the config options related to the colors.
I suppose it's not a problem with phpEclipse, but an incompatibility with another Eclipse plugin.
PS: When you fix the problem please tell us what that setting!