From 16306f7c32de8289b54db8fe5cb5c778ee3f1dec Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Sun, 27 Mar 2022 06:14:02 +0200 Subject: [PATCH] removed some less useful template links and other minor updates. - some snippet templates are so trivial that they don't need a link. - updated template header to mention ctrl/cmd buttons. - updated freemarker url. - tests needed repairs after the change. --- .../data/templates/GeneratedMethodBody.java | 2 +- .../project/ui/resources/license-default.txt | 4 +- .../hints/bugs/CloneAndCloneableTest.java | 2 +- .../java/hints/errors/CreateMethodTest.java | 45 +++++++++---------- .../ImplementAllAbstractMethodsTest.java | 10 ++--- .../suggestions/ImplementMethodsTest.java | 2 +- .../resources/GeneratedMethodBody.template | 2 +- .../integration/resources/LambdaBody.template | 2 +- .../resources/OverriddenMethodBody.template | 2 +- .../java/lsp/server/protocol/ServerTest.java | 12 ++--- .../java/source/GeneratorUtilitiesTest.java | 8 ++-- .../resources/GeneratedMethodBody.template | 4 +- .../java/source/resources/LambdaBody.template | 5 +-- .../resources/OverriddenMethodBody.template | 6 +-- 14 files changed, 52 insertions(+), 54 deletions(-) diff --git a/ide/libs.freemarker/test/unit/data/templates/GeneratedMethodBody.java b/ide/libs.freemarker/test/unit/data/templates/GeneratedMethodBody.java index 669f30e3a33c..aa0f1606eca6 100644 --- a/ide/libs.freemarker/test/unit/data/templates/GeneratedMethodBody.java +++ b/ide/libs.freemarker/test/unit/data/templates/GeneratedMethodBody.java @@ -1,5 +1,5 @@ <#-- -A built-in Freemarker template (see http://freemarker.sourceforge.net) used for +A built-in Freemarker template (see https://freemarker.apache.org/) used for filling the body of methods generated by the IDE. When editing the template, the following predefined variables, that will be then expanded into the corresponding values, could be used together with Java expressions and diff --git a/ide/projectui/src/org/netbeans/modules/project/ui/resources/license-default.txt b/ide/projectui/src/org/netbeans/modules/project/ui/resources/license-default.txt index 487df23f963c..b2dc3d1983c3 100644 --- a/ide/projectui/src/org/netbeans/modules/project/ui/resources/license-default.txt +++ b/ide/projectui/src/org/netbeans/modules/project/ui/resources/license-default.txt @@ -1,4 +1,4 @@ ${licenseFirst!""} -${licensePrefix}Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license -${licensePrefix}Click nbfs://nbhost/SystemFileSystem/${.data_model["org.openide.filesystems.FileObject"].getPath()} to edit this template +${licensePrefix}Ctrl/Cmd+Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license +${licensePrefix}Ctrl/Cmd+Click nbfs://nbhost/SystemFileSystem/${.data_model["org.openide.filesystems.FileObject"].getPath()} to edit this template ${licenseLast!""} diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneableTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneableTest.java index 4b0bf338c08a..e06b4849233d 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneableTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneableTest.java @@ -201,7 +201,7 @@ public void testCloneableWithoutClone() throws Exception { "public class CloneTest4 implements Cloneable {\n" + " @Override\n" + " public Object clone() throws CloneNotSupportedException {\n" + - " return super.clone(); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody\n" + + " return super.clone();\n" + " }\n" + "}" ); diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/CreateMethodTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/CreateMethodTest.java index 99b5fdf73c56..54daae111827 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/CreateMethodTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/CreateMethodTest.java @@ -19,7 +19,6 @@ package org.netbeans.modules.java.hints.errors; import com.sun.source.util.TreePath; -import java.io.IOException; import java.util.LinkedList; import java.util.List; import org.netbeans.api.java.source.CompilationInfo; @@ -86,14 +85,14 @@ public void testCreateMethod106255() throws Exception { performFixTest("test/Test.java", "package test; public class Test {public void test() {test2(null);}}", 82 - 25, "CreateMethodFix:test2(java.lang.Object object)void:test.Test", - "package test; public class Test {public void test() {test2(null);} private void test2(Object object) { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } }"); + "package test; public class Test {public void test() {test2(null);} private void test2(Object object) { throw new UnsupportedOperationException(\"Not supported yet.\"); } }"); } @RandomlyFails public void testCreateMethod77038() throws Exception { performFixTest("test/Test.java", "package test; public class Test {public void test() {b(test2() ? true : false);} void t(boolean b){}}", 82 - 25, "CreateMethodFix:test2()boolean:test.Test", - "package test; public class Test {public void test() {b(test2() ? true : false);} void t(boolean b){} private boolean test2() { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } }"); + "package test; public class Test {public void test() {b(test2() ? true : false);} void t(boolean b){} private boolean test2() { throw new UnsupportedOperationException(\"Not supported yet.\"); } }"); } @RandomlyFails public void testCreateMethod82923() throws Exception { @@ -105,7 +104,7 @@ public void testCreateMethod82931() throws Exception { "package test; import java.util.Collection; public class Test {public static void test() {fff(getStrings());} private static Collection getStrings() {return null;}}", 116 - 25, "CreateMethodFix:fff(java.util.Collection strings)void:test.Test", - "package test; import java.util.Collection; public class Test {public static void test() {fff(getStrings());} private static Collection getStrings() {return null;} private static void fff(Collection strings) { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } }"); + "package test; import java.util.Collection; public class Test {public static void test() {fff(getStrings());} private static Collection getStrings() {return null;} private static void fff(Collection strings) { throw new UnsupportedOperationException(\"Not supported yet.\"); } }"); } @RandomlyFails public void testCreateMethod74129() throws Exception { @@ -113,7 +112,7 @@ public void testCreateMethod74129() throws Exception { performFixTest("test/Test.java", "package test; public class Test {public void test() {TopLevel.f|ff();}} class TopLevel {}", "CreateMethodFix:fff()void:test.TopLevel", - "package test; public class Test {public void test() {TopLevel.fff();}} class TopLevel { static void fff() { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } }"); + "package test; public class Test {public void test() {TopLevel.fff();}} class TopLevel { static void fff() { throw new UnsupportedOperationException(\"Not supported yet.\"); } }"); } @RandomlyFails public void testCreateMethod76498() throws Exception { @@ -121,7 +120,7 @@ public void testCreateMethod76498() throws Exception { "package test; public class Test {public static class T extends Test {public void test() {super.fff();}}}", 122 - 25, "CreateMethodFix:fff()void:test.Test", - "package test; public class Test { private void fff() { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } public static class T extends Test {public void test() {super.fff();}}}"); + "package test; public class Test { private void fff() { throw new UnsupportedOperationException(\"Not supported yet.\"); } public static class T extends Test {public void test() {super.fff();}}}"); } @RandomlyFails public void testCreateMethod75069() throws Exception { @@ -129,35 +128,35 @@ public void testCreateMethod75069() throws Exception { "package test; public class Test {public void test() {this.fff();}}", 88 - 25, "CreateMethodFix:fff()void:test.Test", - "package test; public class Test {public void test() {this.fff();} private void fff() { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } }"); + "package test; public class Test {public void test() {this.fff();} private void fff() { throw new UnsupportedOperationException(\"Not supported yet.\"); } }"); } @RandomlyFails public void testCreateMethod119037() throws Exception { performFixTest("test/Test.java", "package test; public class Test {static {f|ff();}}", "CreateMethodFix:fff()void:test.Test", - "package test; public class Test {static {fff();} private static void fff() { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } }"); + "package test; public class Test {static {fff();} private static void fff() { throw new UnsupportedOperationException(\"Not supported yet.\"); } }"); } @RandomlyFails public void testCreateMethodWithAnonymousParameter104820() throws Exception { performFixTest("test/Test.java", "package test;public class Test {public static void method() {final Test ac = new Test();new Runnable() {public void run() {ac.a|ction(this);}};}}", "CreateMethodFix:action(java.lang.Runnable aThis)void:test.Test", - "package test;public class Test {public static void method() {final Test ac = new Test();new Runnable() {public void run() {ac.action(this);}};} private void action(Runnable aThis) { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } }"); + "package test;public class Test {public static void method() {final Test ac = new Test();new Runnable() {public void run() {ac.action(this);}};} private void action(Runnable aThis) { throw new UnsupportedOperationException(\"Not supported yet.\"); } }"); } @RandomlyFails public void testCreateMethodWithEnumParam() throws Exception { performFixTest("test/Test.java", "package test; public class Test { enum Paddle{UP, DOWN} public void foo() {f|ff(Paddle.UP);}}", "CreateMethodFix:fff(test.Test.Paddle paddle)void:test.Test", - "package test; public class Test { private void fff(Paddle paddle) { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } enum Paddle{UP, DOWN} public void foo() {fff(Paddle.UP);}}"); + "package test; public class Test { private void fff(Paddle paddle) { throw new UnsupportedOperationException(\"Not supported yet.\"); } enum Paddle{UP, DOWN} public void foo() {fff(Paddle.UP);}}"); } @RandomlyFails public void testCreateMethodWithParamOfEnumType199793() throws Exception { performFixTest("test/Test.java", "package test; public class Test { enum Paddle{UP, DOWN} public void foo(Paddle test) {f|ff(test);}}", "CreateMethodFix:fff(test.Test.Paddle test)void:test.Test", - "package test; public class Test { private void fff(Paddle test) { throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } enum Paddle{UP, DOWN} public void foo(Paddle test) {fff(test);}}"); + "package test; public class Test { private void fff(Paddle test) { throw new UnsupportedOperationException(\"Not supported yet.\"); } enum Paddle{UP, DOWN} public void foo(Paddle test) {fff(test);}}"); } @RandomlyFails public void test220582() throws Exception { @@ -179,7 +178,7 @@ public void test220582() throws Exception { " }\n" + " }\n" + " private boolean isNew(String name) {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + "}\n").replaceAll("[ \n\t\r]+", " ")); } @@ -201,7 +200,7 @@ public void test223011a() throws Exception { " Field f = method(c);\n" + " }\n" + " private Field method(Class c) {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + "}\n").replaceAll("[ \n\t\r]+", " ")); } @@ -223,7 +222,7 @@ public void test223011b() throws Exception { " Field f = method(c1, c2);\n" + " }\n" + " private Field method(Class c1, Class c2) {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + "}\n").replaceAll("[ \n\t\r]+", " ")); } @@ -245,7 +244,7 @@ public void test223011c() throws Exception { " Class cr = method(c);\n" + " }\n" + " private Class method(Class c) {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + "}\n").replaceAll("[ \n\t\r]+", " ")); } @@ -271,7 +270,7 @@ public void test203476() throws Exception { " getName(undefined());\n" + " }\n" + " private String undefined() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody \n" + + " throw new UnsupportedOperationException(\"Not supported yet.\"); \n" + " }\n" + "}\n" + "class Aux {\n" + @@ -297,7 +296,7 @@ public void test233502() throws Exception { " }\n" + " public static void m(String str) {}\n" + " private static void m(Number str) {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody \n" + + " throw new UnsupportedOperationException(\"Not supported yet.\"); \n" + " }\n" + "}\n").replaceAll("[ \n\t\r]+", " ")); } @@ -319,7 +318,7 @@ public void testMethodRefInstanceRefToInstance() throws Exception { " test(this::undef);\n" + " }\n" + " private void undef() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody \n" + + " throw new UnsupportedOperationException(\"Not supported yet.\"); \n" + " }\n" + "}\n").replaceAll("[ \n\t\r]+", " ")); } @@ -338,7 +337,7 @@ public void testMethodRefStaticRefToStatic() throws Exception { ("package test;\n" + "public class Test {\n" + " private static void undef() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody \n" + + " throw new UnsupportedOperationException(\"Not supported yet.\"); \n" + " }\n" + " public void test(Runnable r) {\n" + " test(Test::undef);\n" + @@ -367,7 +366,7 @@ public void testMethodRefStaticRefToInstance() throws Exception { " test(Test::undef);\n" + " }\n" + " private void undef() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody \n" + + " throw new UnsupportedOperationException(\"Not supported yet.\"); \n" + " }\n" + " public interface I {\n" + " public void run(T t);\n" + @@ -394,7 +393,7 @@ public void testMethodRefStaticRefToStatic2() throws Exception { ("package test;\n" + "public class Test {\n" + " private static void undef(Test t) {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody \n" + + " throw new UnsupportedOperationException(\"Not supported yet.\"); \n" + " }\n" + " public void test(I r) {\n" + " test(Test::undef);\n" + @@ -427,7 +426,7 @@ public void testMethodRefInstanceRefToInstance2() throws Exception { " test(this::undef);\n" + " }\n" + " private void undef(Test t) {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody \n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + " public interface I {\n" + " public void run(T t);\n" + @@ -455,7 +454,7 @@ public void testErroneousMethodRef() throws Exception { @Override protected List computeFixes(CompilationInfo info, String diagnosticCode, int pos, TreePath path) throws Exception { List fixes = new CreateElement().analyze(info, diagnosticCode, pos); - List result= new LinkedList(); + List result= new LinkedList<>(); for (Fix f : fixes) { if (f instanceof CreateMethodFix) diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethodsTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethodsTest.java index 27741fc99948..090a8b7b493f 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethodsTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethodsTest.java @@ -49,7 +49,7 @@ public void testImplementAllMethodsForEnums() throws Exception { "public enum Test implements Runnable {\n" + " A;\n" + " public void run() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + "}\n").replaceAll("[ \t\n]+", " ")); } @@ -83,7 +83,7 @@ public void test204252b() throws Exception { ("package test;\n" + "public class Test implements Runnable {\n" + " public void run() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + "}\n").replaceAll("[ \t\n]+", " ")); } @@ -123,7 +123,7 @@ public void test178153a() throws Exception { "public enum Test implements Runnable {\n" + " A {\n" + " public void run() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + " };\n" + "}\n").replaceAll("[ \t\n]+", " ")); @@ -143,7 +143,7 @@ public void test178153b() throws Exception { " A { public void run() {} },\n" + " B {\n" + " public void run() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + " };\n" + "}\n").replaceAll("[ \t\n]+", " ")); @@ -164,7 +164,7 @@ public void testEnumWithAbstractMethods() throws Exception { "\n" + " @Override\n" + " public int boo() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + " };\n" + " public abstract int boo();\n" + diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/suggestions/ImplementMethodsTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/suggestions/ImplementMethodsTest.java index 77c3f1022138..d2b1f8f59df7 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/suggestions/ImplementMethodsTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/suggestions/ImplementMethodsTest.java @@ -44,7 +44,7 @@ public void testSimple1() throws Exception { .assertOutput("package test;\n" + "public abstract class Test implements Runnable {\n" + " public void run() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n" + "}\n"); } diff --git a/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/GeneratedMethodBody.template b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/GeneratedMethodBody.template index 8e8e003ee7e6..92be052398ca 100644 --- a/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/GeneratedMethodBody.template +++ b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/GeneratedMethodBody.template @@ -1,5 +1,5 @@ <#-- -A built-in Freemarker template (see http://freemarker.sourceforge.net) used for +A built-in Freemarker template (see https://freemarker.apache.org/) used for filling the body of methods generated by the IDE. When editing the template, the following predefined variables, that will be then expanded into the corresponding values, could be used together with Java expressions and diff --git a/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/LambdaBody.template b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/LambdaBody.template index c02c161deed6..46219e0764a5 100644 --- a/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/LambdaBody.template +++ b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/LambdaBody.template @@ -1,5 +1,5 @@ <#-- -A built-in Freemarker template (see http://freemarker.sourceforge.net) used for +A built-in Freemarker template (see https://freemarker.apache.org/) used for filling the body of lambda expressions generated by the IDE. When editing the template, the following predefined variables, that will be then expanded into the corresponding values, could be used together with Java expressions and diff --git a/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/OverriddenMethodBody.template b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/OverriddenMethodBody.template index f08c475f6814..21c71b960f89 100644 --- a/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/OverriddenMethodBody.template +++ b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/resources/OverriddenMethodBody.template @@ -1,5 +1,5 @@ <#-- -A built-in Freemarker template (see http://freemarker.sourceforge.net) used for +A built-in Freemarker template (see https://freemarker.apache.org/) used for filling the body of overridden methods generated by the IDE. When editing the template, the following predefined variables, that will be then expanded into the corresponding values, could be used together with Java expressions and diff --git a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java index 0525b4a9104e..39253d16d2b8 100644 --- a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java +++ b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java @@ -1992,7 +1992,7 @@ public CompletableFuture applyEdit(ApplyWorkspaceEdi fileChanges.get(0).getRange()); assertEquals("\n" + " private String convertToString(int value) {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n", fileChanges.get(0).getNewText()); } @@ -2167,7 +2167,7 @@ public CompletableFuture applyEdit(ApplyWorkspaceEdi assertEquals("\n" + " @Override\n" + " public void run() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n", fileChanges.get(0).getNewText()); } @@ -2257,7 +2257,7 @@ public CompletableFuture applyEdit(ApplyWorkspaceEdi fileChanges.get(0).getRange()); assertEquals(" @Override\n" + " public void run() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n", fileChanges.get(0).getNewText()); } @@ -2345,7 +2345,7 @@ public CompletableFuture applyEdit(ApplyWorkspaceEdi fileChanges.get(0).getRange()); assertEquals(" @Override\n" + " public void run() {\n" + - " throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" + + " throw new UnsupportedOperationException(\"Not supported yet.\");\n" + " }\n", fileChanges.get(0).getNewText()); } @@ -3320,12 +3320,12 @@ public CompletableFuture> showQuickPick(ShowQuickPickParams assertEquals("\n" + " @Override\n" + " protected void finalize() throws Throwable {\n" + - " super.finalize(); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody\n" + + " super.finalize();\n" + " }\n" + "\n" + " @Override\n" + " public String toString() {\n" + - " return super.toString(); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody\n" + + " return super.toString();\n" + " }\n", fileChanges.get(0).getNewText()); } diff --git a/java/java.source.base/test/unit/src/org/netbeans/api/java/source/GeneratorUtilitiesTest.java b/java/java.source.base/test/unit/src/org/netbeans/api/java/source/GeneratorUtilitiesTest.java index 90d0261c1951..26d5fdc13f92 100644 --- a/java/java.source.base/test/unit/src/org/netbeans/api/java/source/GeneratorUtilitiesTest.java +++ b/java/java.source.base/test/unit/src/org/netbeans/api/java/source/GeneratorUtilitiesTest.java @@ -1489,7 +1489,7 @@ public void test232199a() throws Exception { "package test; public class Test implements I { } interface I { public default void t() { } } \n", "1.8", new T2(), - new ContentValidator("package test; public class Test implements I { \n\n @Override\n public void t() {\n I.super.t(); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody\n }\n } interface I { public default void t() { } } \n"), + new ContentValidator("package test; public class Test implements I { \n\n @Override\n public void t() {\n I.super.t();\n }\n } interface I { public default void t() { } } \n"), false); } @@ -1498,7 +1498,7 @@ public void test232199b() throws Exception { "package test; public interface Test extends I { } interface I { public void t(); } \n", "1.8", new T2(), - new ContentValidator("package test; public interface Test extends I { \n\n @Override\n public default void t() {\n throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n }\n } interface I { public void t(); } \n"), + new ContentValidator("package test; public interface Test extends I { \n\n @Override\n public default void t() {\n throw new UnsupportedOperationException(\"Not supported yet.\");\n }\n } interface I { public void t(); } \n"), false); } @@ -1507,7 +1507,7 @@ public void test232199c() throws Exception { "package test; public interface Test extends I { } interface I { public default void t() { } } \n", "1.8", new T2(), - new ContentValidator("package test; public interface Test extends I { \n\n @Override\n public default void t() {\n I.super.t(); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody\n }\n } interface I { public default void t() { } } \n"), + new ContentValidator("package test; public interface Test extends I { \n\n @Override\n public default void t() {\n I.super.t();\n }\n } interface I { public default void t() { } } \n"), false); } @@ -1516,7 +1516,7 @@ public void test232199d() throws Exception { "package test; public class Test implements I { } interface I { public void t(); } \n", "1.8", new T2(), - new ContentValidator("package test; public class Test implements I { \n\n @Override\n public void t() {\n throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n }\n } interface I { public void t(); } \n"), + new ContentValidator("package test; public class Test implements I { \n\n @Override\n public void t() {\n throw new UnsupportedOperationException(\"Not supported yet.\");\n }\n } interface I { public void t(); } \n"), false); } diff --git a/java/java.source/src/org/netbeans/modules/java/source/resources/GeneratedMethodBody.template b/java/java.source/src/org/netbeans/modules/java/source/resources/GeneratedMethodBody.template index 39dbb917b74b..92be052398ca 100644 --- a/java/java.source/src/org/netbeans/modules/java/source/resources/GeneratedMethodBody.template +++ b/java/java.source/src/org/netbeans/modules/java/source/resources/GeneratedMethodBody.template @@ -1,5 +1,5 @@ <#-- -A built-in Freemarker template (see http://freemarker.sourceforge.net) used for +A built-in Freemarker template (see https://freemarker.apache.org/) used for filling the body of methods generated by the IDE. When editing the template, the following predefined variables, that will be then expanded into the corresponding values, could be used together with Java expressions and @@ -10,4 +10,4 @@ ${method_name} name of the created method ${class_name} qualified name of the enclosing class ${simple_class_name} simple name of the enclosing class --> -throw new java.lang.UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody +throw new java.lang.UnsupportedOperationException("Not supported yet."); diff --git a/java/java.source/src/org/netbeans/modules/java/source/resources/LambdaBody.template b/java/java.source/src/org/netbeans/modules/java/source/resources/LambdaBody.template index e273e4bd4405..df27553ab970 100644 --- a/java/java.source/src/org/netbeans/modules/java/source/resources/LambdaBody.template +++ b/java/java.source/src/org/netbeans/modules/java/source/resources/LambdaBody.template @@ -1,5 +1,5 @@ <#-- -A built-in Freemarker template (see http://freemarker.sourceforge.net) used for +A built-in Freemarker template (see https://freemarker.apache.org/) used for filling the body of lambda expressions generated by the IDE. When editing the template, the following predefined variables, that will be then expanded into the corresponding values, could be used together with Java expressions and @@ -9,7 +9,6 @@ ${default_return_value} a value returned by the method by default ${method_name} name of the functional interface method --> <#if method_return_type?? && method_return_type != "void"> -return ${default_return_value}; // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/LambdaBody +return ${default_return_value}; <#else> -// Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/LambdaBody diff --git a/java/java.source/src/org/netbeans/modules/java/source/resources/OverriddenMethodBody.template b/java/java.source/src/org/netbeans/modules/java/source/resources/OverriddenMethodBody.template index f6eacad1c6b0..e6d9cf66290e 100644 --- a/java/java.source/src/org/netbeans/modules/java/source/resources/OverriddenMethodBody.template +++ b/java/java.source/src/org/netbeans/modules/java/source/resources/OverriddenMethodBody.template @@ -1,5 +1,5 @@ <#-- -A built-in Freemarker template (see http://freemarker.sourceforge.net) used for +A built-in Freemarker template (see https://freemarker.apache.org/) used for filling the body of overridden methods generated by the IDE. When editing the template, the following predefined variables, that will be then expanded into the corresponding values, could be used together with Java expressions and @@ -12,7 +12,7 @@ ${class_name} qualified name of the enclosing class ${simple_class_name} simple name of the enclosing class --> <#if method_return_type?? && method_return_type != "void"> -return ${super_method_call}; // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody +return ${super_method_call}; <#else> -${super_method_call!''}; // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody +${super_method_call!''};