This is an automated email from the ASF dual-hosted git repository.

dbalek 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 8858dd5  LSP: Multiple problems with introduce constant fixed. (#3081)
8858dd5 is described below

commit 8858dd5a56c9c8d3463c7b8afdbfaaf95635a67a
Author: Dusan Balek <[email protected]>
AuthorDate: Fri Jul 30 08:37:04 2021 +0200

    LSP: Multiple problems with introduce constant fixed. (#3081)
---
 .../java/hints/introduce/IntroduceConstantFix.java | 13 +++++++----
 .../java/hints/introduce/IntroduceFieldFix.java    |  4 ++--
 ...s-modules-editor-settings-CustomPreferences.xml | 27 ++++++++++++++++++++++
 3 files changed, 37 insertions(+), 7 deletions(-)

diff --git 
a/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceConstantFix.java
 
b/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceConstantFix.java
index 76d1a91..a17230b 100644
--- 
a/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceConstantFix.java
+++ 
b/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceConstantFix.java
@@ -22,6 +22,8 @@ import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.IdentifierTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
+import java.io.IOException;
+import java.util.EnumSet;
 import java.util.concurrent.atomic.AtomicBoolean;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -30,14 +32,13 @@ import javax.lang.model.type.TypeKind;
 import javax.swing.JButton;
 import org.netbeans.api.java.source.CodeStyle;
 import org.netbeans.api.java.source.CompilationInfo;
-import org.netbeans.api.java.source.ElementHandle;
 import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.ModificationResult;
 import org.netbeans.api.java.source.TreePathHandle;
 import org.netbeans.api.java.source.TreeUtilities;
 import org.netbeans.api.java.source.WorkingCopy;
 import org.netbeans.modules.java.hints.StopProcessing;
 import org.netbeans.modules.java.hints.errors.Utilities;
-import org.netbeans.spi.editor.hints.Fix;
 import org.openide.util.NbBundle;
 
 /**
@@ -162,7 +163,9 @@ public class IntroduceConstantFix extends IntroduceFieldFix 
{
     protected TreePath findTargetClass(WorkingCopy copy, TreePath resolved) {
         return findAcceptableConstantTarget(copy, resolved);
     }
-    
-    
-    
+
+    @Override
+    public ModificationResult getModificationResult() throws IOException {
+        return js.runModificationTask(new Worker(guessedName, 
permitDuplicates, true, EnumSet.of(Modifier.PRIVATE), 
IntroduceFieldPanel.INIT_FIELD, null, false));
+    }
 }
diff --git 
a/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceFieldFix.java
 
b/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceFieldFix.java
index 21d0fd0..a8a9f9c 100644
--- 
a/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceFieldFix.java
+++ 
b/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceFieldFix.java
@@ -69,10 +69,10 @@ import org.openide.util.NbBundle;
  */
 class IntroduceFieldFix extends IntroduceFixBase implements Fix {
     protected final String guessedName;
+    protected final boolean permitDuplicates;
     private final int[] initilizeIn;
     private final boolean statik;
     private final boolean allowFinalInCurrentMethod;
-    private final boolean permitDuplicates;
     private final TreePathHandle targetHandle;
     
     /**
@@ -176,7 +176,7 @@ class IntroduceFieldFix extends IntroduceFixBase implements 
Fix {
      * The actual modification. Some javac related data are recorded in 
fields, inner class prevents
      * unintentional leak if someone keeps a reference to the Fix
      */
-    private final class Worker implements Task<WorkingCopy> {
+    protected final class Worker implements Task<WorkingCopy> {
         final String name;
         final boolean replaceAll;
         final boolean declareFinal;
diff --git 
a/java/java.lsp.server/nbcode/integration/release/config/Editors/text/x-java/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml
 
b/java/java.lsp.server/nbcode/integration/release/config/Editors/text/x-java/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml
new file mode 100644
index 0000000..60d1830
--- /dev/null
+++ 
b/java/java.lsp.server/nbcode/integration/release/config/Editors/text/x-java/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<!DOCTYPE editor-preferences PUBLIC "-//NetBeans//DTD Editor Preferences 
1.0//EN" "http://www.netbeans.org/dtds/EditorPreferences-1_0.dtd";>
+<editor-preferences>
+    <entry javaType="java.lang.String" name="classMemberInsertionPoint" 
xml:space="preserve">
+        <value><![CDATA[LAST_IN_CATEGORY]]></value>
+    </entry>
+</editor-preferences>

---------------------------------------------------------------------
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

Reply via email to