3

When I like to create a new variable of type ImageObserver and the line starts like this:

IO

and I press Ctrl+Space , I get a couple of wrong suggestions! Suggestions for abbrevs that do not fully match!

Eclipse's content assist suggestions are:

  • IOException (no! full abbrev is IOE, not IO!)
  • IOError (no! full abbrev is IOE too, but not IO!)
  • IndexOutOfBoundsException (no! full abbrev is IOOBE, not IO!)
  • ImageObserver (yes! full abbrev is IO)
  • ImageOutputStream (no! full abbrev is IOS, not IO!)

How to get rid of all the other non-full-matching-abbrevs?

2 Answers 2

1

Keep in mind that the completion proposals fall into a bunch of categories (ie, lots of different sources of potential matches). Your example text, IO, can logically be interpreted as either a camel-case abbreviation (such as ImageObserver) or as the start of a class name (such as IOException), or even as a camel-case-starts-with match (such as ImageOutputStream, whose abbreviation starts with IO).

I don't know of a tool that's clairvoyant enough to know which of those you want given such a small input. Eclipse, by default, uses a "relevance" ordering for completion proposals and it weighs "starts with" matches ahead of camel-case matches (rightly so, in my opinion). There's no publicly exposed way to change that weighting algorithm, that I know of.

If these are classes or packages that you simply never want to see in Content-Assist, you can define Type Filters to exclude them. In Preferences, go to Java > Appearance > Type Filters to do so. But be aware that Type Filters apply to the entire workspace and in multiple places in the UI, not just Content Assist completion proposals.

1

You really want IOException to be excluded on auto-complete when IO is typed even though IOException starts with IO?

If so, this sounds like a feature request, but unless you are ready to contribute I can't see it getting added anytime soon.

Contributing

If you are interested in contributing, you need to write a Java Completion Proposal Computer. Once you do that, you can enable only your proposer in the preferences (Java / Editor / Content Assist / Advanced ).

You can even bind your special completer to its own Keyboard Short-cut so you can get "full abbrev" completions only.

Here is a screenshot of my binding of Template Proposals to Ctrl+4 so with a single key combination I can get quickly get them all.

enter image description here

Code Recommenders

I also recommend reading about Code Recommenders, the project adds significantly more sophisticated code completion to Eclipse.

I have raised a bug with Eclipse to see if sorting perfect Camel Case matches could be on the cards.

5
  • I remember old eclipse 2 version they had this feature. Code recommenders is community driven afaik, the class is not widely used enougth to have ImageObserver resolved from IO by default.
    – Grim
    Jan 9, 2016 at 6:29
  • ... and yes, i expect ImageObserver resolved from IO. And i expect IOException be proposed from IOE. Why the question?
    – Grim
    Jan 9, 2016 at 6:30
  • Because what you are asking for is a significant subset of what auto-completion does and can do. Jan 9, 2016 at 6:42
  • As for code recommenders, it adds much more than just community driven, it is also driven by you, plus it adds other more intelligent completions (see stackoverflow.com/a/34565115/2796832). I am very impressed that you always remember the exact camel case abbreviation for every class you ever want to autocomplete, personally I can't remember if a class was called XmlParser or XMLParser (although I wish people would always have the ml lower case in Xml) Jan 9, 2016 at 6:49
  • The rules for naming classes did not change in the last years. If the abrev is more widly used than the complete name it is upcase, so XMLParser have the abrev XMLP naturally. Seriously? I do not know the Abrevs, but i know the classes i am looking for. In example the FileNotFoundException leads me to write only FNFE, so only as a fallback other proposals should be appear.
    – Grim
    Jan 9, 2016 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.