Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Is there a setting for Ctrl+Space to evaluate required imports?
Is there a setting for Ctrl+Space to evaluate required imports? [message #1810130] Thu, 01 August 2019 00:01 Go to next message
Eclipse UserFriend
I want to perform an action on a random number through the use of java.util.Optional. So I start typing:

(new Random()).


At the period I press Ctrl+Space to invoke a completions list. There is an audible notification that something went wrong and a red error in the status bar: "Random cannot be resolved to a type".

I'm somewhere deep in the code of a random file somewhere. I don't actually know what imports are immediately available. No problem!

Ctrl+Shift+O (Oranize Imports) which automatically adds the required import and I can Ctrl+Space on my way.

But is this necessary? Can't I just Ctrl+Space and have it ask me if I want to import the missing class? Eclipse already knows that I want to request a completion on Random.
Re: Is there a setting for Ctrl+Space to evaluate required imports? [message #1810497 is a reply to message #1810130] Mon, 12 August 2019 13:57 Go to previous message
Eclipse UserFriend
Code completion is not designed to ask questions before making proposals. Consider also the case that different imports of the same simple name need to be considered. I'm pretty sure that many users would regard any additional dialogs during Ctrl+Space as an annoyance.

Personally I feel that the usability story is much clearer if one action does one thing. The next user would say: "why doesn't code completion offer to create the missing class Random?", just to illustrate: the simple thing "completion" will have exponential complexity if it tries to fix arbitrary problems alongside.

YMMV

PS: I didn't see any connection to Optional, typo?
Previous Topic:Java12
Next Topic:Not able to make child package for package
Goto Forum:
  


Current Time: Fri Jul 04 16:09:09 EDT 2025

Powered by FUDForum. Page generated in 0.03114 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top