This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new ffec3dd80c Java Code Templates for records and sealed types
ffec3dd80c is described below
commit ffec3dd80c13af9c9489b7f943115b36269679f3
Author: Laszlo Kishalmi <[email protected]>
AuthorDate: Tue Feb 20 10:50:46 2024 -0800
Java Code Templates for records and sealed types
---
.../java/editor/resources/DefaultAbbrevs.xml | 29 ++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git
a/java/java.editor/src/org/netbeans/modules/java/editor/resources/DefaultAbbrevs.xml
b/java/java.editor/src/org/netbeans/modules/java/editor/resources/DefaultAbbrevs.xml
index 6ba5bf8ea9..3255d35139 100644
---
a/java/java.editor/src/org/netbeans/modules/java/editor/resources/DefaultAbbrevs.xml
+++
b/java/java.editor/src/org/netbeans/modules/java/editor/resources/DefaultAbbrevs.xml
@@ -45,8 +45,10 @@
<codetemplate abbreviation="im"><code><![CDATA[${no-indent}implements
]]></code></codetemplate>
<codetemplate abbreviation="iof"><code><![CDATA[${no-indent}instanceof
]]></code></codetemplate>
<codetemplate abbreviation="ir"><code><![CDATA[${no-indent}import
]]></code></codetemplate>
- <codetemplate
abbreviation="le"><code><![CDATA[${no-indent}length]]></code></codetemplate>
+ <codetemplate
abbreviation="le"><code><![CDATA[${no-indent}length]]></code></codetemplate>
+ <codetemplate abbreviation="nse"><code><![CDATA[${no-indent}non-sealed
]]></code></codetemplate>
<codetemplate abbreviation="pe"><code><![CDATA[${no-indent}protected
]]></code></codetemplate>
+ <codetemplate abbreviation="pt"><code><![CDATA[${no-indent}permits
]]></code></codetemplate>
<codetemplate abbreviation="pr"><code><![CDATA[${no-indent}private
]]></code></codetemplate>
<codetemplate abbreviation="psf"><code><![CDATA[${no-format}private static
final ]]></code></codetemplate>
<codetemplate abbreviation="psfi"><code><![CDATA[${no-format}private
static final int ]]></code></codetemplate>
@@ -54,7 +56,9 @@
<codetemplate abbreviation="psfb"><code><![CDATA[${no-format}private
static final boolean ]]></code></codetemplate>
<codetemplate abbreviation="pst"
contexts="BLOCK,CASE,LABELED_STATEMENT,DO_WHILE_LOOP,ENHANCED_FOR_LOOP,FOR_LOOP,IF,WHILE_LOOP,LAMBDA_EXPRESSION"><code><![CDATA[printStackTrace();]]></code></codetemplate>
<codetemplate abbreviation="pu"><code><![CDATA[${no-indent}public
]]></code></codetemplate>
+ <codetemplate abbreviation="rc"><code><![CDATA[${no-indent}record
]]></code></codetemplate>
<codetemplate abbreviation="re"><code><![CDATA[${no-indent}return
]]></code></codetemplate>
+ <codetemplate abbreviation="se"><code><![CDATA[${no-indent}sealed
]]></code></codetemplate>
<codetemplate abbreviation="serr"
contexts="BLOCK,CASE,LABELED_STATEMENT,DO_WHILE_LOOP,ENHANCED_FOR_LOOP,FOR_LOOP,IF,WHILE_LOOP,LAMBDA_EXPRESSION"><code><![CDATA[System.err.println("${cursor}");]]></code></codetemplate>
<codetemplate abbreviation="sout"
contexts="BLOCK,CASE,LABELED_STATEMENT,DO_WHILE_LOOP,ENHANCED_FOR_LOOP,FOR_LOOP,IF,WHILE_LOOP,LAMBDA_EXPRESSION"><code><![CDATA[System.out.println("${cursor}");]]></code></codetemplate>
<codetemplate abbreviation="st"><code><![CDATA[${no-indent}static
]]></code></codetemplate>
@@ -497,6 +501,27 @@ ${cursor}]]></code></codetemplate>
}
}
]]></code></codetemplate>
+
+ <!-- Record generation -->
+
+ <codetemplate abbreviation="Prec"><code><![CDATA[${no-format}public record
${Type}(${cursor}) {}]]></code></codetemplate>
+ <codetemplate abbreviation="Preci"><code><![CDATA[${no-format}public
record ${Type}(${cursor}) implements ${classVar editable="false" currClassName
default="getClass()"} {}]]></code></codetemplate>
+ <codetemplate abbreviation="prec"><code><![CDATA[${no-format}private
record ${Type}(${cursor}) {}]]></code></codetemplate>
+ <codetemplate abbreviation="preci"><code><![CDATA[${no-format}private
record ${Type}(${cursor}) implements ${classVar editable="false" currClassName
default="getClass()"} {}]]></code></codetemplate>
+ <codetemplate abbreviation="rec"><code><![CDATA[${no-format}record
${Type}(${cursor}) {}]]></code></codetemplate>
+ <codetemplate abbreviation="reci"><code><![CDATA[${no-format}record
${Type}(${cursor}) implements ${classVar editable="false" currClassName
default="getClass()"} {}]]></code></codetemplate>
+
+ <!-- Sealed Interfaces generation -->
+
+ <codetemplate abbreviation="psin"><code><![CDATA[public sealed interface
${Type} {
+ ${cursor}
+}]]></code>
+ </codetemplate>
+
+ <codetemplate abbreviation="psinp"><code><![CDATA[public sealed interface
${Type} permits ${cursor} {
+}]]></code>
+ </codetemplate>
+
<codetemplate abbreviation="if" descriptionId="CT_iff">
<code>
<![CDATA[if (${EXP instanceof="boolean" default="true"}) {
@@ -522,7 +547,7 @@ ${cursor}]]></code></codetemplate>
]]>
</code>
</codetemplate>
- <codetemplate abbreviation="ap"><code><![CDATA[${sb
instanceof="java.lang.StringBuilder" default="sb"}.append(${EXP
instanceof="<any>" default=""exp""});
+ <codetemplate abbreviation="ap"><code><![CDATA[${sb
instanceof="java.lang.StringBuilder" default="sb"}.append(${EXP
instanceof="<any>" default=""exp""});
${cursor}]]></code></codetemplate>
<codetemplate abbreviation="apo"><code><![CDATA[if (${sb
instanceof="java.lang.StringBuilder" default="sb"}.length() > 0) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists