You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ne...@apache.org on 2023/05/09 10:24:47 UTC
[netbeans] branch delivery updated: Do not attempt to remove unused binding variables for now.
This is an automated email from the ASF dual-hosted git repository.
neilcsmith pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/delivery by this push:
new 23ea44704d Do not attempt to remove unused binding variables for now.
new 42c5790ae6 Merge pull request #5902 from jlahoda/unused-binding-1
23ea44704d is described below
commit 23ea44704d3af52e060e14511510b795de2b1203
Author: Jan Lahoda <jl...@netbeans.org>
AuthorDate: Sun Apr 30 08:14:49 2023 +0200
Do not attempt to remove unused binding variables for now.
---
.../src/org/netbeans/modules/java/hints/bugs/Unused.java | 5 ++++-
.../org/netbeans/modules/java/hints/bugs/UnusedTest.java | 15 +++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java b/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java
index 23ac810033..207bbf4e54 100644
--- a/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java
+++ b/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java
@@ -87,7 +87,10 @@ public class Unused {
case NOT_WRITTEN: message = Bundle.ERR_NotWritten(name);
break;
case NOT_READ: message = Bundle.ERR_NotRead(name);
- fix = JavaFixUtilities.safelyRemoveFromParent(ctx, Bundle.FIX_RemoveUsedElement(name), ud.unusedElementPath);
+ //unclear what can be done with unused binding variables currently (before "_"):
+ if (ud.unusedElementPath.getParentPath().getLeaf().getKind() != Kind.BINDING_PATTERN) {
+ fix = JavaFixUtilities.safelyRemoveFromParent(ctx, Bundle.FIX_RemoveUsedElement(name), ud.unusedElementPath);
+ }
break;
case NOT_USED:
if (ud.unusedElement.getKind() == ElementKind.CONSTRUCTOR) {
diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/UnusedTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/UnusedTest.java
index 2b41dba167..b00212fe31 100644
--- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/UnusedTest.java
+++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/UnusedTest.java
@@ -50,4 +50,19 @@ public class UnusedTest extends NbTestCase {
"5:26-5:37:verifier:" + Bundle.ERR_NotRead("unusedParam"),
"7:12-7:16:verifier:" + Bundle.ERR_NotUsedConstructor());
}
+
+ public void testNoFixForBindings() throws Exception {
+ HintTest
+ .create()
+ .sourceLevel("17")
+ .input("package test;\n" +
+ "public class Test {\n" +
+ " boolean test(Object o) {\n" +
+ " return o instanceof String s;\n" +
+ " }\n" +
+ "}\n")
+ .run(Unused.class)
+ .findWarning("3:35-3:36:verifier:Variable s is never read")
+ .assertFixes();
+ }
}
---------------------------------------------------------------------
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