Eclipse Content Assist Struggles - java

Lately Eclipse's content assist feature has been giving me some frustration.
I recently changed my Auto Activation trigger so that the autocomplete box would appear whenever I start typing, rather than just after I type a period.
This is great most of the time but it has some annoying downsides. For example:
Eclipse autocompletes 'String' to android.R.string. This is very very annoying considering it changes "String" to "string" when I press space or enter. Why would I want that? android.r.string hasn't even been imported!
Here is what my content assist settings look like:
Two desired solutions would be the following:
Don't show proposals that don't match case (little 's' shouldn't match big 'S')
Don't show proposals that I have not imported.
If anyone could help me out with this it would be greatly appreciated!

Try these:
1. Sort the proposals by relevance and not alphabetically.
2. Hide proposals not visible in the invocation context (you have this one) and
3. Hide deprecated references

Related

How to disable autocomplete but keep autosuggestion using GlazedLists?

This code makes an autocomplete and autosuggestion box for me:
if (dataAutoCompleteSearch != null) {
autoCompleteSupport = AutoCompleteSupport.install(jComboBox1, GlazedLists.eventListOf(dataAutoCompleteSearch));
}
The problem occurs when I search for names that contain UTF-8 characters that are not in the data, but start with a few words in the suggestion box.
I could not type these UTF-8 words correctly because the text was added by itself (blue highlighted).
I want to disable GlazedLists autocomplete (Auto add highlighted text when typing) because it is very difficult to type a UTF-8 character.
But I want to keep the suggestion box, looking like Google search.
No. The API of AutoCompleteSupport doesn't support this option. You'd basically have to roll your own version of AutoCompleteSupport (it's all open source) and modify it yourself to stop the auto-complete part. I've just had a quick peak at it and it's quite large and I don't have an immediate solution to offer. It'll probably require a bit of experimenting. The private AutoCompleteFilter class would be my first place to start looking at.

How to make Eclipse not insert Content Assist suggestion

In order to make Eclipse's content assist more like Intellij's, I changed the "auto activation triggers" setting to pop up the content assist window whenever I type, as mentioned in this question.
However, now whenever I press Space it inserts the content assist suggestion, even though I wanted to type a space.
Is there a way to make eclipse insert the suggestion only when I press Enter, not when I press space?
There is no way to control this. Open a feature request in Bugzilla: https://bugs.eclipse.org .
In Preferences>>Java>>Editor>>Content Assist, select Disable insertion triggers except 'Enter'. This handles the space bar issue.
You'll still get inserts sometimes, when there is only one proposal. I lived with this for a while, but I needed to disable it so I could use content assist in a plug-in to only provide suggestions.
You can turn this off by disabling Insert Single Proposals Automatically in the same menu.
Below image shows how can you bind the key to Content Assist command.

How to extend Eclipse's Java editor to recognize my own elements

I want to add references to other elements inside javadoc. The javadoc should look similar to:
/**
* ...
* #my.tag SomeElement
*/
I want to reuse the existing Java editor inside Eclipse. Of course I can type above javadoc already, however I'd like to add some features:
Navigation: upon Ctrl-Click / F3 I want to navigate to the editor showing SomeElement
Auto-completion: Ctrl-Space should complete the text / show valid alternatives
Checking: I want to create a warning marker and underline the SomeElement if it cannot be found
I already figured out that I can do the auto-completion by using the extension point org.eclipse.jdt.ui.javaCompletionProposalComputer, though this seems to be little more complex than I had hoped, so I might be on the wrong track here?
For checking my elements I might be able to use org.eclipse.jdt.core.compilationParticipant, which can generate markers upon compilation which afaik happens with every save operation.
But how can I can manage the navigation feature? Any pointers are welcome!
For navigation you can provide a Hyperlink Detector. You'll want to look at how the Java Editor and its existing detectors are declared in the org.eclipse.jdt.ui plug-in to determine the correct target ID.

Eclipse IDE Scope Highlighting?

When I first learned Java, I was using an IDE called "BlueJ." It had this feature called "Scope Highlighting" which made it very easy to read blocks of code. Now I've moved on from BlueJ and began using Eclipse. I'm currently in the process of customizing Eclipse to my liking and would like this Scope Highlighting feature inside Eclipse.
I've searched everywhere for an answer on how to do it but I cannot find any information pointing to a solution for doing it in Eclipse.
Here's a picture to demonstrate what Scope Highlighting looks like:
I think the best option for you is EditBox, a scope highlighting plugin for Eclipse:
http://editbox.sourceforge.net/
I'm afriad that closest you can get is Shift + Alt + arrow_up
It is selecting wider block of code. pressing this few times will give you very similar result to what you are searching for. I use it often.. it is useful, also for refactoring.
EDIT: As #j2emanue said: you can just double click the delimiter (like a bracket) and it will highlight the entire scope.
you can use Shift + Alt + arrow_up but many people dont realize you can just double click the delimiter (like a bracket) and it will highlight the entire scope. Try double clicking your if statements bracket for example and watch eclipse highlight the entire scope. It works with any delimiter. so you can use parenthesis as well.
as a side note: if your using intelliji checkout this plugin works great: https://github.com/izhangzhihao/intellij-rainbow-brackets#screenshots
This isn't exactly what you're after but you can put your cursor in a method and then click the Show Source Of Selected Element only button on the toolbar. Your editor gets reduced to just that method. Click again and your back to your entire file.
I doubt eclipse does have the same function as blue j.The best advise I can give you, is to change your theme to your liking which would enable you to easily select and highlight the block of code...and to customise your theme , go to http://eclipsecolorthemes.org/. ....
If you still have a problem, go to http://codejava.co.uk/contact.html and send your email.you can create a dummy one if want, then I will send you XML files I use for my eclipse themes.
can Bracketeer do this ? its an eclipse plug in ..
http://marketplace.eclipse.org/content/bracketeer-java-jdt#.UK6sY4fAdLc
Maybe you will also like the VSCode extension "Blockman". It highlights nested code blocks based on curly/square/round brackets, html/xml tags and Python/Yaml indentation. (I am the author of Blockman).
.
https://i.ibb.co/31F0rm9/vscode-blockman-intro-leodevbro-extension3.png
.
.

Improving Eclipse autocompletion?

Currently the Eclipse autocompletion seems only to be triggered after a dot or on parameters, I want to use it for variables too, e.g. if I have
String test="hello";
then I want the autocompletion to suggest "test" if I start typing "t" in the next line (e.g. if I intent to change the value of the variable test).
Is there any Eclipse plugin capable of doing this? I already checked the Eclipse content assist options, but seems like there no option for what I want? Thanks for any hint!
First of all, thanks for all the replies. They are correct, however you have to press the key combination each time. Here's how it's done automatically:
That plug-in is not necessary any more. Just go to
Preferences > Java > Editor > Content Assist
and paste:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.
into the "Auto activation triggers for Java:" field.
This simply triggers auto activation after any English alphabet character and after dot.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=159157#c12
Works fine :-)
Hint: You probably want to additionally set the auto activation delay to 0, at least if you are used to visual studio ;-)
In addition to the suggestions above, did you try ALT + / it does incremental matching? No?
ctrl + space
If you press ctrl+space key combination, eclipse will show you the code assist window.
Type t and then hit ctrl+space, it will show you possible matches
You can press "t" and then Ctrl+Space..
is it?
In Eclipse
Window--->Preferences---> search for Content Assist under Content Assist go for Advanced
and check the Java Praposals.
done.

Categories