You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by db...@apache.org on 2022/04/14 15:47:00 UTC

[netbeans] branch master updated: LSP: Minor bug fixes (#3984)

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 ff295f033f LSP: Minor bug fixes (#3984)
ff295f033f is described below

commit ff295f033f8c5a91f298b7364bd01cc978ddef78
Author: Dusan Balek <du...@oracle.com>
AuthorDate: Thu Apr 14 17:46:54 2022 +0200

    LSP: Minor bug fixes (#3984)
---
 .../lsp/server/protocol/TextDocumentServiceImpl.java | 20 ++++++++++++++++----
 .../java/lsp/server/refactoring/ui/MoveMembers.html  |  2 +-
 .../java/lsp/server/refactoring/ui/refactoring.css   |  3 +++
 .../modules/java/source/ui/LspElementUtils.java      |  2 +-
 .../netbeans/lib/nbjavac/services/NBClassReader.java | 10 ++--------
 5 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
index 5b8139c597..843da8014e 100644
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
@@ -902,8 +902,14 @@ public class TextDocumentServiceImpl implements TextDocumentService, LanguageCli
                 diagnostics.addAll(computeDiags(params.getTextDocument().getUri(), startOffset, ErrorProvider.Kind.HINTS, documentVersion(doc)));
             }
 
-            Map<String, org.netbeans.api.lsp.Diagnostic> id2Errors = (Map<String, org.netbeans.api.lsp.Diagnostic>) doc.getProperty("lsp-errors");
-            if (id2Errors != null) {
+            Map<String, org.netbeans.api.lsp.Diagnostic> id2Errors = new HashMap<>();
+            for (String key : VALID_ERROR_KEYS) {
+                Map<String, org.netbeans.api.lsp.Diagnostic> diags = (Map<String, org.netbeans.api.lsp.Diagnostic>) doc.getProperty("lsp-errors-valid-" + key);
+                if (diags != null) {
+                    id2Errors.putAll(diags);
+                }
+            }
+            if (!id2Errors.isEmpty()) {
                 for (Entry<String, org.netbeans.api.lsp.Diagnostic> entry : id2Errors.entrySet()) {
                     org.netbeans.api.lsp.Diagnostic err = entry.getValue();
                     if (err.getDescription() == null || err.getDescription().isEmpty()) {
@@ -1490,6 +1496,9 @@ public class TextDocumentServiceImpl implements TextDocumentService, LanguageCli
                     }
                 }
             });
+            for (String key : VALID_ERROR_KEYS) {
+                doc.putProperty("lsp-errors-valid-" + key, null);
+            }
         }
         runDiagnosticTasks(params.getTextDocument().getUri());
         reportNotificationDone("didChange", params);
@@ -1661,7 +1670,7 @@ public class TextDocumentServiceImpl implements TextDocumentService, LanguageCli
                         Document doc = server.getOpenedDocuments().getDocument(uri);
                         if (documentVersion(doc) == originalVersion) {
                             publishDiagnostics(uri, hintDiags);
-                }
+                        }
                     }).schedule(DELAY);
                 }
             });
@@ -1727,6 +1736,9 @@ public class TextDocumentServiceImpl implements TextDocumentService, LanguageCli
             }
             if (offset < 0) {
                 doc.putProperty("lsp-errors-" + keyPrefix, id2Errors);
+                doc.putProperty("lsp-errors-valid-" + keyPrefix, id2Errors);
+            } else {
+                doc.putProperty("lsp-errors-valid-offsetHints", id2Errors);
             }
             Map<String, org.netbeans.api.lsp.Diagnostic> mergedId2Errors = new HashMap<>();
             for (String k : ERROR_KEYS) {
@@ -1753,7 +1765,6 @@ public class TextDocumentServiceImpl implements TextDocumentService, LanguageCli
             if (offset >= 0) {
                 mergedId2Errors.putAll(id2Errors);
             }
-            doc.putProperty("lsp-errors", mergedId2Errors);
         } catch (IOException ex) {
             throw new IllegalStateException(ex);
         }
@@ -1842,6 +1853,7 @@ public class TextDocumentServiceImpl implements TextDocumentService, LanguageCli
     }
     
     private static final String[] ERROR_KEYS = {"errors", "hints"};
+    private static final String[] VALID_ERROR_KEYS = {"errors", "hints", "offsetHints"};
 
     private interface ProduceErrors {
         public List<ErrorDescription> computeErrors(CompilationInfo info, Document doc) throws IOException;
diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/MoveMembers.html b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/MoveMembers.html
index fdee365e2e..ed7ab7c0a6 100644
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/MoveMembers.html
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/MoveMembers.html
@@ -72,7 +72,7 @@
         </div>
         <label>Members to be moved:</label>
     </div>
-    <div class="flex-vscrollable section1">
+    <div class="flex-vscrollable section1 row-always-visible">
         <nobr data-bind="foreach: members">
             <div class="flex row">
                 <input type="checkbox" data-bind="checked: selected, attr: {id: 'member_' + $index()}">
diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/refactoring.css b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/refactoring.css
index 50c9fec31e..c1c7f0fcf2 100644
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/refactoring.css
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/refactoring.css
@@ -208,3 +208,6 @@ label {
     padding: 0px 15px;
     padding-top: 2px;
 }
+.row-always-visible {
+    min-height: calc(var(--vscode-font-size) * 2.2);
+}
diff --git a/java/java.sourceui/src/org/netbeans/modules/java/source/ui/LspElementUtils.java b/java/java.sourceui/src/org/netbeans/modules/java/source/ui/LspElementUtils.java
index 21974f3bb1..e2ec404603 100644
--- a/java/java.sourceui/src/org/netbeans/modules/java/source/ui/LspElementUtils.java
+++ b/java/java.sourceui/src/org/netbeans/modules/java/source/ui/LspElementUtils.java
@@ -332,7 +332,7 @@ public class LspElementUtils {
         }
         builder.expandedStartOffset((int)info[1]).expandedEndOffset((int)info[2]);
         builder.selectionStartOffset(selStart).selectionEndOffset(selEnd);
-       return builder;
+        return builder;
     }
     
     private static CompletableFuture<StructureProvider.Builder> setFutureOffsets(CompilationInfo ci, Element original, 
diff --git a/java/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java b/java/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
index 5a26320b86..d1ca38a3c1 100644
--- a/java/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
+++ b/java/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
@@ -22,29 +22,22 @@ import com.sun.tools.javac.code.ClassFinder.BadClassFile;
 import java.util.Set;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.jvm.ClassFile;
 import com.sun.tools.javac.jvm.ClassFile.Version;
 import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.invoke.MethodHandles;
-import java.lang.reflect.Field;
 import java.util.Arrays;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.tools.ForwardingJavaFileObject;
 import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-import javax.tools.SimpleJavaFileObject;
 
 /**
  *
@@ -54,6 +47,7 @@ public class NBClassReader extends ClassReader {
 
     public static void preRegister(Context context) {
         context.put(classReaderKey, new Context.Factory<ClassReader>() {
+            @Override
             public ClassReader make(Context c) {
                 return new NBClassReader(c);
             }
@@ -113,7 +107,7 @@ public class NBClassReader extends ClassReader {
                         return ;
                     }
                 } catch (IOException ex) {
-                    Logger.getLogger(NBClassReader.class.getName()).log(Level.SEVERE, null, ex);
+                    Logger.getLogger(NBClassReader.class.getName()).log(Level.FINE, null, ex);
                 } finally {
                     c.classfile = origFile;
                 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

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