⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wrapping.html

📁 This the README for the Eclipse Plug-in distribution of the Jalopy Java Source Code Formatter.
💻 HTML
📖 第 1 页 / 共 3 页
字号:
Forces a line wrap after each parameter of a method call if at least oneparameter is a method call itself. This option can prove especially useful ifone prefers to nest method calls as parameters rather than adding localvariables just to hold those parameters.</p><div class="example"><a name="ex-wrap-method-call-nested-wrapped"></a><p class="title"><b>Example&nbsp;4.98.&nbsp;Method call if nested (wrapped)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">doSomething();_userDatabase.addUser("Name",                      encryptPassword("password", _secretKey),                      "123 fake address");doSomethingElse();</pre></td></tr></table></div><p></p></li><li><p>Ternary expression question mark (<tt class="literal">?</tt>)</p><p>Forces a line wrap after the first operand.</p><div class="example"><a name="ex-wrap-ternary-expr"></a><p class="title"><b>Example&nbsp;4.99.&nbsp;Ternary expression question mark (deep indented)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">String comma = spaceAfterComma               ? COMMA_SPACE : COMMA;</pre></td></tr></table></div><p>Indentation for consecutive lines depends on the used <a href="indentation.html#indentation-policy" title="4.3.3.1.1.&nbsp;Policy">indenatation policy</a>.You may further want to use <a href="indentation.html#indentation-misc-ternary-if-else">continuation indentation</a>.</p></li><li><p><a name="wrap-ternary-colon"></a>Ternary expression colon (<tt class="literal">:</tt>)</p><p>Forces a line wrap after the second operand.</p><div class="example"><a name="ex-wrap-ternary-values"></a><p class="title"><b>Example&nbsp;4.100.&nbsp;Ternary expression colon</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">String comma = spaceAfterComma ? COMMA_SPACE                               : COMMA;</pre></td></tr></table></div><p>If both switches are disabled, ternary expressions are printed in one line (if everything fits in one line, that is).</p><div class="example"><a name="ex-wrap-ternary"></a><p class="title"><b>Example&nbsp;4.101.&nbsp;Ternary expressions</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">String comma = spaceAfterComma ? COMMA_SPACE : COMMA;</pre></td></tr></table></div><p>If both switches are enabled, you can force a style like the following:</p><div class="example"><a name="ex-wrap-ternary-continued"></a><p class="title"><b>Example&nbsp;4.102.&nbsp;Ternary expressions (continued)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">String comma = spaceAfterComma    ? COMMA_SPACE    : COMMA;</pre></td></tr></table></div><p></p></li><li><p><a name="wrap-always-label"></a>Labels</p><a class="indexterm" name="d0e3222"></a><a class="indexterm" name="d0e3225"></a><p>Forces a line wrap after labels.</p><div class="example"><a name="ex-wrap-always-label"></a><p class="title"><b>Example&nbsp;4.103.&nbsp;Label</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">// advance to the first CLASS_DEF or INTERFACE_DEFLOOP:   for (AST child = tree.getFirstChild();             child != null;             child = child.getNextSibling())        {            switch (child.getType())            {                case JavaTokenTypes.CLASS_DEF :                case JavaTokenTypes.INTERFACE_DEF :                    next = child;                    break LOOP;                default :                    break;            }        }</pre></td></tr></table></div><p></p><div class="example"><a name="ex-wraping-always-label-wrapped"></a><p class="title"><b>Example&nbsp;4.104.&nbsp;Label (wrapped)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">// advance to the first CLASS_DEF or INTERFACE_DEFLOOP:        for (AST child = tree.getFirstChild();             child != null;             child = child.getNextSibling())        {            switch (child.getType())            {                case JavaTokenTypes.CLASS_DEF :                case JavaTokenTypes.INTERFACE_DEF :                    next = child;                    break LOOP;                default :                    break;            }        }</pre></td></tr></table></div><p></p></li></ul></div></div><div class="sect4" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="wrap-always-exceed"></a>4.3.4.2.2.&nbsp;Wrap always when exceed</h5></div></div><div></div></div><p>Lets you force wrapping for <span class="emphasis"><em>all</em></span> parameter or expressions ifthe parameter or expression list would otherwise exceed the maximal line length.If you enable any of the following switches, line wrappingmay occur for the specified cases no matter whether you have enabled generalline wrapping or not.</p><div class="itemizedlist"><ul type="disc"><li><p><a name="wrap-always-extends"></a>After extends types</p><p>Forces a line wrap after each type name of the <tt class="literal">extends</tt> clause of aclass/interface declaration if the whole clause does not fit in one line.</p><div class="example"><a name="ex-wrap-always-extends"></a><p class="title"><b>Example&nbsp;4.105.&nbsp;Extends types wrapped as needed (standard indented)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">public interface VeryImportantInterface                        |    extends LeastImportantInterface, LessImportantInterface,   |        ImportantInterface                                     |}                                                              |    ...                                                        |}                                                              |</pre></td></tr></table></div><p></p><div class="example"><a name="wrap-always-extends-enabled"></a><p class="title"><b>Example&nbsp;4.106.&nbsp;Extends types wrapping forced (standard indented)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">public interface VeryImportantInterface                        |    extends LeastImportantInterface,                           |        LessImportantInterface,                                |        ImportantInterface                                     |}                                                              |    ...                                                        |}                                                              |</pre></td></tr></table></div></li><li><p><a name="wrap-always-implements"></a>After implements types</p><p>Forces a line wrap after each type name of the <tt class="literal">implements</tt> clause of aclass/interface declaration if the whole clause does not fit in one line.</p><div class="example"><a name="ex-wrap-always-implements"></a><p class="title"><b>Example&nbsp;4.107.&nbsp;Implements types wrapped as needed (standard indented)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">public class ImportantClass                                    |    implements ImportantInterface, Serializable, Comparable,   |        Cloneable                                              |}                                                              |    ...                                                        |}                                                              |</pre></td></tr></table></div><p></p><div class="example"><a name="wrap-always-implements-enabled"></a><p class="title"><b>Example&nbsp;4.108.&nbsp;Implements types wrapping forced (standard indented)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">public class ImportantClass                                    |    implements ImportantInterface,                             |        Serializable,                                          |        Comparable,                                            |        Cloneable                                              |}                                                              |    ...                                                        |}                                                              |</pre></td></tr></table></div></li><li><p><a name="wrap-always-throws"></a>After throws types</p><p>Forces a line wrap after each type name of the <tt class="literal">throws</tt> clause of amethod/constructor declaration if the whole clause does not fit in one line.</p><div class="example"><a name="ex-wrap-always-throws"></a><p class="title"><b>Example&nbsp;4.109.&nbsp;Throws types wrapped as needed (deep indented)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">private File getDestinationFile(File dest, String packageName, |                                String filename)               |                         throws IOException, FooException,     |                                FooBarException                |{                                                              |    ...                                                        |}                                                              |</pre></td></tr></table></div><p></p><div class="example"><a name="wrap-always-throws-enabled"></a><p class="title"><b>Example&nbsp;4.110.&nbsp;Throws types wrapping forced (deep indented)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">private File getDestinationFile(File dest, String packageName, |                                String filename)               |                         throws IOException,                   |                                FooException,                  |                                FooBarException                |{                                                              |    ...                                                        |}                                                              |</pre></td></tr></table></div></li><li><p><a name="wrap-always-param"></a>After parameters/expressions</p><p>If enabled, this switch will cause all parameters/expressions to bewrapped, if and only if the first parameter/expression of the list has beenwrapped.</p><div class="example"><a name="ex-wrap-all"></a><p class="title"><b>Example&nbsp;4.111.&nbsp;Expression list (all wrapped)</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">if (    "pick".equals(m.getName()) &amp;&amp;    m.isStatic() &amp;&amp;    m.isPublic()) {    pickFound = true;}else if (    "pick".equals(m.getName()) &amp;&amp;    m.isStatic() &amp;&amp;    m.isPublic()) {    pickFound = true;}</pre></td></tr></table></div><p></p></li></ul></div></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="wrap-misc"></a>4.3.4.3.&nbsp;Misc</h4></div></div><div></div></div><p>Lets you control miscellaneous wrapping settings.</p><div class="sect4" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="wrap-misc-arrays"></a>4.3.4.3.1.&nbsp;Arrays</h5></div></div><div></div></div><p>Contains options to control the wrapping for arrays.</p><div class="itemizedlist"><ul type="disc"><li><p>Wrap as needed</p><p>Enabling this options means array elements will be wrapped so that theywill be limited within the current <a href="wrapping.html#wrap-sizes-line">line length</a> setting.</p><div class="example"><a name="ex-wrap-arrays-as-needed"></a><p class="title"><b>Example&nbsp;4.112.&nbsp;Wrap as needed</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">String[] constraints = {                                               |    "patternPanel.top=form.top", "patternPanel.hcenter=form.hcenter",  |    "okButton.top=patternPanel.bottom+20",                             |    "okButton.right=form.hcenter-10", "cancelButton.vcenter=10",       |    "cancelButton.left=10"                                             |};                                                                     |</pre></td></tr></table></div><p></p></li><li><p>Wrap after element</p><p>Forces a newline after every  n-th element.</p><div class="example"><a name="ex-wrap-arrays-after-one"></a><p class="title"><b>Example&nbsp;4.113.&nbsp;Wrap after element 1</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">String[] constraints = {                                               |    "patternPanel.top=form.top",                                       |    "patternPanel.hcenter=form.hcenter",                               |    "okButton.top=patternPanel.bottom+20",                             |    "okButton.right=form.hcenter-10",                                  |    "cancelButton.vcenter=10",                                         |    "cancelButton.left=10"                                             |};                                                                     |</pre></td></tr></table></div><p></p><div class="example"><a name="ex-wrap-arrays-after-two"></a><p class="title"><b>Example&nbsp;4.114.&nbsp;Wrap after element 2</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">String[] constraints = {                                               |    "patternPanel.top=form.top", "patternPanel.hcenter=form.hcenter",    "okButton.top=patternPanel.bottom+20", "okButton.right=form.hcenter-10",    "cancelButton.vcenter=10", "cancelButton.left=10"                  |};                                                                     |</pre></td></tr></table></div><p>If both options are left disabled, the array elements will be printed in oneline, right after the left curly brace.</p></li></ul></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="indentation.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="printer.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="separation.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.3.3.&nbsp;Indentation&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;4.3.5.&nbsp;Blank Lines</td></tr></table></div></td></tr></table></td></tr><tr><td bgcolor="#eeeecc" height="17" style="font-size:9px;padding-left:5px"><a href="#toppage">to top</a></td></tr><tr><td height="30"><br></td></tr><tr><td height="3"></td></tr><tr><td bgcolor="#336699" height="1"></td></tr><tr><td height="1"></td></tr><tr><td bgcolor="#336699" height="16"></td></tr><tr><td bgcolor="#ff9966" height="4"></td></tr><tr><td class="footer" align="center" height="15" valign="middle">            Copyright &copy; 2001-2004, <a class="footer" href="./contact.html">Marco Hunsicker</a>. All rights reserved. Hosted by <a href="http://sourceforge.net">SourceForge.net</a></td></tr></tbody></table><img src="http://sourceforge.net/sflogo.php?group_id=45216&amp;type=1" width="1" height="1" border="0" hspace="0" vspace="0" alt=""></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -