Java Reference
In-Depth Information
used when designing your template. These are listed in the description area of
each code template:
Catch Statement Body
—Template for filling in the body of a
catch
state-
ment generated by the
Code | Surround with
command (
Ctrl+Alt+T
).
By default, this template prints a stack trace.
■
New Method Body
—Template used when new methods are created. By
default, this template returns a default value based on the return type of
the method.
■
Implemented Method Body
—Template used when creating a new
method through the
Code | Implement Methods
command (
Ctrl+I
).
■
Overridden Method Body
—Template used when creating a new method
through the
Code | Override Methods
command (
Ctrl+O
).
■
3.8 Programming by intention
IDEA
has many code-completion features designed to ease the development pro-
cess while at the same time improving the quality of the code you write. Code-
completion features like SmartType completion only appear when you specifi-
cally request them. Another feature, intention actions, is always working silently
in the background.
3.8.1
What are intention actions?
Sometimes we can get ahead of ourselves while programming. We reference
classes we haven't yet imported, assign values to variables we haven't defined,
make calls to method we haven't written, and so forth. Technically, these could be
considered mistakes, but they're mistakes made with the best of intentions.
This is where intention actions come in. When
IDEA
suspects a possible prob-
lem with your code, it does much more than bring the problem to your attention.
If possible, it also suggests a solution for you. As an added bonus,
IDEA
can carry
out its recommendations on your behalf: It can change the way variables are
assigned, create missing references, and much more. Each of these operations is
known as an
intention action
. An intention action is an action that
IDEA
performs
for you because it knows what you intended to do.
A special class of intention action is called a
Quickfix
intention, denoted by the
little exclamation point in the intention light bulb. Quickfixes correct errors in
syntax or other problems that would prevent
IDEA
from building the class. For