mbien commented on code in PR #8197:
URL: https://github.com/apache/netbeans/pull/8197#discussion_r1934984604


##########
java/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/InnerOuterRecordTest.java:
##########
@@ -0,0 +1,635 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.refactoring.java.test;
+
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.TreePath;
+import java.io.IOException;
+import java.time.LocalDate;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Name;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+import org.netbeans.api.java.source.CompilationController;
+import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.Task;
+import org.netbeans.api.java.source.TreePathHandle;
+import org.netbeans.modules.refactoring.api.Problem;
+import org.netbeans.modules.refactoring.api.RefactoringSession;
+import org.netbeans.modules.refactoring.java.api.InnerToOuterRefactoring;
+import static 
org.netbeans.modules.refactoring.java.test.RefactoringTestBase.addAllProblems;
+import org.openide.util.Exceptions;
+
+/**
+ * Test inner to outer refactoring for test.
+ *
+ * In the input files, and the expected outcomes, the indentation does not
+ * really matter as far as the tests are concerned because the indentation is
+ * stripped away before the remaining source lines are compared to the expected
+ * lines.
+ *
+ * @author homberghp {@code <pieter.van.den.hombe...@gmail.com)>}
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class InnerOuterRecordTest extends RefactoringTestBase {
+
+    public InnerOuterRecordTest(String name) {
+        super(name, "16");
+        //ensure we are running on at least 16.
+        try {
+            SourceVersion.valueOf("RELEASE_16"); //NOI18N
+        } catch (IllegalArgumentException ex) {
+            //OK, no RELEASE_16, skip test
+            throw new RuntimeException("need at least Java 16 for record");
+        }
+    }
+
+    // for reference
+    public void test0_259004() throws Exception {
+        String source =
+                """
+            package t;
+            import java.util.function.Consumer;
+            public class A {
+                public static void main(String[] args) {
+                    Consumer<F> c = f -> {};
+                }
+                public static final class F {}
+            }""";
+        String newOuter =
+                """
+            package t;
+            import java.util.function.Consumer;
+            public class A {
+            public static void main(String[] args) {
+                Consumer<F> c = f -> {};
+            }
+            }""";
+        String newInner =
+                """
+            /*
+            * Refactoring License
+            */
+            package t;
+            /**
+             *
+             * @author junit
+             */
+            public final class F {
+            }
+            """;
+        innerOuterSetupAndTest(source, newOuter, newInner);
+    }

Review Comment:
   you missed this section, please align the """ manually, example:
   
   ```java
               """
               package t;
               import java.util.function.Consumer;
               public class A {
                   public static void main(String[] args) {
                       Consumer<F> c = f -> {};
                   }
                   public static final class F {}
               }
               """;
   ```
   this ensures that the resulting text block string has the expected 
indentation when used in the test (and it looks less noisy).



##########
java/java.source.base/src/org/netbeans/modules/java/source/base/SourceLevelUtils.java:
##########
@@ -34,6 +34,13 @@ public class SourceLevelUtils {
     public static final Source JDK1_9 = Source.lookup("9");
     public static final Source JDK14 = Source.lookup("14");
     public static final Source JDK15 = Source.lookup("15");
+    public static final Source JDK16 = Source.lookup("16");
+    public static final Source JDK17 = Source.lookup("17");
+    // for next release:
+//    public static final Source JDK18 = Source.lookup("18");
+//    public static final Source JDK19 = Source.lookup("19");
+//    public static final Source JDK20 = Source.lookup("20");
+//    public static final Source JDK21 = Source.lookup("21");

Review Comment:
   what I meant was that the two new fields you added aren't used anywhere in 
your patch : https://github.com/apache/netbeans/pull/8197.diff
   
   Lets avoid unnecessary changes beyond those needed to resolve the issue.
   
   It is esp questionable here since NB ships with latest javac out of the box 
now (since ~NB 13), the source values can be directly accessed (up to 
`Source.JDK24`), so this utility might have lost a bit of its original purpose.



##########
java/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java:
##########
@@ -84,7 +86,38 @@ public RefactoringTestBase(String name, String sourcelevel) {
         this.sourcelevel = sourcelevel;
     }
 
+    static boolean debug = false;
+//    static boolean skipIndexing = false;

Review Comment:
   unused -> can be removed



##########
java/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java:
##########


Review Comment:
   I suspected that this might have been unintended. But we really shouldn't do 
that when fixing bugs. This messes with git blame and makes it difficult to 
reason about repo history.
   
   here is a commit which reverts some of the changes in unrelated code 
https://github.com/mbien/netbeans/commit/9bcdda116bc739fbbb3ebcaa1b45690f13d54fc1
   
   its on a copy of your branch 
https://github.com/mbien/netbeans/tree/issue7044_copy



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to