Java Reference
In-Depth Information
we've typed the letter r and invoked basic code completion. All of the parameters,
fields, and methods in the current scope that begin with the letter r are shown in
the completion suggestion list. Scroll down the list with the arrow keys and press
Enter , or make the appropriate selection by double-clicking it.
To help you enter code even faster, IDEA has an option called Autocom-
plete common prefix that's enabled by default. This option scans all
methods and fields during auto-completion and looks for common pre-
fixes. In the previous example, if you type rat , IDEA will recognize that
only two fields match that pattern ( rateExpires and rateMap ) and that
both of these share the common prefix rate . IDEA will then automatically
complete the prefix in the editor, saving you typing it manually. This
feature is very visible—and very useful—in classes with many similarly
named members.
TIP
Code completion in version 5 has been enhanced to work with custom file types.
If you have specified a list of keywords in your custom file types, then IDEA offers
these up as code-completion possibilities when working with files of that type.
Keep in mind that, unlike Java code completion, IDEA isn't aware of the structure
and semantics of custom file types, and it offers any of the keywords as a comple-
tion option, legal or not.
You don't have to begin your code completion on a blank line. You can invoke it
anywhere. For example, in figure 3.12 (see code line 43) we have invoked code
completion immediately after the get in the call to rightNow , an instance of Cal-
endar , resulting in a list of all the reachable Calendar methods that begin with the
Figure 3.12 When in the context of a method name, code completion lists the methods of the
class that fit the pattern. In this case, because the cursor falls after the letters get , it lists all
the accessor methods of the Calendar .
 
 
 
Search WWH ::




Custom Search