Java Reference
In-Depth Information
imports to appear first, followed by third-party packages, and finally core API
packages. This way, you can get an idea of what internal dependencies exist by
glancing up at your import block.
12.2.6
Controlling line wraps
Lines of code can become excessively long. Method declarations with many
parameters, class declarations with extends and implements clauses, and array
declaration and initialization are all prime candidates for causing lines to extend
past the arbitrary right margin, the point where the full line of code is no longer
visible on the screen. Coding standards often dictate when and how to wrap lines
of code, and IDEA supports configuration options to enforce those rules.
From the Global Code Style window, the Wrapping tab controls this behav-
ior. It identifies multiple discrete contexts, such as method call arguments and
for statements, and lets you set a line wrap policy for each case. Possible set-
tings include:
Do not wrap —If selected, no special wrapping style is applied to the code.
Long lines are left as is and may extend past the right margin.
Wrap if long —If selected, lines that go beyond the right margin are
wrapped with proper indentation.
Chop down if long —If selected, elements in a list are chopped down (that
is, wrapped to give one element per line with proper indentation, if they
go beyond the right margin). Shorter lines are left alone.
Wrap always —If selected, all elements in a list are always chopped down
(wrapped to give one element per line with proper indentation, regardless
of the right margin setting).
You can set the right margin on the General tab of the Global Code Style panel.
12.2.7
Adherence to a code standard—made easy
With the addition of all these code-formatting features, IDEA absolves you of the
need to change your personal, effective coding habits in order to conform to an
imposed standard. The Java compiler doesn't care about your whitespace, your
layout, or how readable your code is; it just cares about syntactic accuracy. By
configuring the appropriate coding style schemes in IDEA , you can write code in
the style you find the most effective and then reformat your entire tree to
another standard before submitting it to a revision control system and sharing it
among a team.
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search