Global method/variable preference over local in autocompletion

Answered

Ever since late 2019 versions, IntelliJ prefers global methods/variables rather than local. Some examples:

  • when auto-completing a return statement for a method that return an interface, upon ctrl+space IntelliJ after typing `Defa` the first suggestion on the list is from `javax.validation.props.Default` interface rather than a local static class named `Default`
  • when trying to autocomplete methods for put or add on a Map, IntelliJ emphasizes putAll and addAll (it used to be put/add were a preference).
  • when autocompleting method names, IntelliJ prefers static method from some other classes rather than local within the class.
  • when autocompleting on the variables, IntelliJ prefers fields to local variable.

"prefers" in my wording refers to the way autocompletes sorts the results placing global names before local. This change affects development patters whereas I can no longer type + ctrl+space + enter with correct method. Having global priority disallows for fast development.

 

 

5 comments
Comment actions Permalink

Could you please share the screenshot with your code completion settings? Settings (Preferences on macOS) | Editor | General | Code Completion | Editor | General | Code Completion.

Did you install any third-party plug-ins that can affect completion?

IDE should learn what you complete and suggest according to your completion statistics.

0
Comment actions Permalink

Please see below. Am I missing some new setting?

0
Comment actions Permalink

Try enabling machine learning option for Java work for a couple of days and see if the suggestions get improved over time.

0
Comment actions Permalink

Thanks. Enabled. What exactly does that even do?

0
Comment actions Permalink

> Select if you want to utilize machine learning models to rank most suitable items higher in the suggestions list.

 

0

Please sign in to leave a comment.