Java Reference
In-Depth Information
The types and style of suggested names can be controlled through your
Code
Style
settings, as discussed in chapter 12.
If you have defined local variable prefixes/suffixes in your
Code Style
settings, the suggested variable names appear with the specified prefix
and/or suffix.
TIP
Using SmartType code completion
The SmartType code-completion command works similarly to basic code comple-
tion, but it can filter its list of suggestions to include only those whose type is
applicable to the current context. You invoke SmartType through the
Code |
Complete Code | SmartType
command (
Ctrl+Shift+Space
). SmartType com-
pletion can only be used in situations where an appropriate type can be deter-
mined; for example:
On the right hand of assignment statements
■
In variable initializers
■
In return statements
■
In a method call's parameter list
■
After the
new
keyword in an object declaration
■
Figure 3.15 shows SmartType completion
being used inside the method call to
after()
, which requires an argument of
type
Date
. As you can see from the sugges-
tion list, only two appropriate
Date
objects
are reachable in the current scope:
expiry-
Date
and
warningDate
.
Figure 3.15 SmartType completion works
similarly to basic completion, but the list is
pruned to eliminate any entries that don't
contextually match the appropriate class.
SmartType completion automatically highlights the selection it thinks is
the most appropriate. You can further limit the code completion sugges-
tions by typing in the first few letters of the completion you want to ac-
cept. As you type, the list shrinks to include only those completions
beginning with the letters you've entered. Press the
Backspace
key to
erase any characters you've typed, and the list will expand appropriately.
TIP