You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/02/19 08:14:57 UTC

[GitHub] [netbeans] bradh commented on a change in pull request #2610: add extra cases to SizeEqualsZero java hints

bradh commented on a change in pull request #2610:
URL: https://github.com/apache/netbeans/pull/2610#discussion_r579000446



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/SizeEqualsZero.java
##########
@@ -82,6 +93,23 @@ public static ErrorDescription sizeNotEqualsZero(HintContext ctx) {
         return sizeEqualsZeroHint(ctx, true);
     }
 
+    @TriggerPatterns({
+        @TriggerPattern(value="$subj.size() > 0",
+            constraints = @ConstraintVariableType(type = "java.util.Collection", variable = "$subj")),
+        @TriggerPattern(value="$subj.size() > 0",
+            constraints = @ConstraintVariableType(type = "java.util.Map", variable = "$subj")),
+        @TriggerPattern(value="0 < $subj.size()",
+            constraints = @ConstraintVariableType(type = "java.util.Collection", variable = "$subj")),
+        @TriggerPattern(value="0 < $subj.size()",
+            constraints = @ConstraintVariableType(type = "java.util.Map", variable = "$subj")),
+    })
+    public static ErrorDescription sizeGreaterZero(HintContext ctx) {
+        if (!ctx.getPreferences().getBoolean(CHECK_GREATER_ZERO, CHECK_NOT_EQUALS_DEFAULT)) {
+            return null;
+        }
+        return sizeEqualsZeroHint(ctx, true);

Review comment:
       I believe so. Its essentially the same logic as the previous set of trigger patterns - another way of saying `sizeNotEqualsZero`.
   

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/SizeEqualsZero.java
##########
@@ -51,11 +51,22 @@
     @BooleanOption(displayName = "#LBL_org.netbeans.modules.java.hints.perf.SizeEqualsZero.CHECK_NOT_EQUALS", tooltip = "#TP_org.netbeans.modules.java.hints.perf.SizeEqualsZero.CHECK_NOT_EQUALS", defaultValue=CHECK_NOT_EQUALS_DEFAULT)
     public static final String CHECK_NOT_EQUALS = "check.not.equals";
 
+    @BooleanOption(displayName = "#LBL_org.netbeans.modules.java.hints.perf.SizeEqualsZero.CHECK_GREATER_ZERO", tooltip = "#TP_org.netbeans.modules.java.hints.perf.SizeEqualsZero.CHECK_GREATER_ZERO", defaultValue=CHECK_NOT_EQUALS_DEFAULT)
+    public static final String CHECK_GREATER_ZERO = "check.greater_zero";
+
     @TriggerPatterns({
         @TriggerPattern(value="$subj.size() == 0", 
             constraints = @ConstraintVariableType(type = "java.util.Collection", variable = "$subj")),
         @TriggerPattern(value="$subj.size() == 0", 
             constraints = @ConstraintVariableType(type = "java.util.Map", variable = "$subj")),
+        @TriggerPattern(value="$subj.size() <= 0",
+            constraints = @ConstraintVariableType(type = "java.util.Collection", variable = "$subj")),
+        @TriggerPattern(value="$subj.size() <= 0",
+            constraints = @ConstraintVariableType(type = "java.util.Map", variable = "$subj")),
+        @TriggerPattern(value="$subj.size() < 1",
+            constraints = @ConstraintVariableType(type = "java.util.Collection", variable = "$subj")),
+        @TriggerPattern(value="$subj.size() < 1",
+            constraints = @ConstraintVariableType(type = "java.util.Map", variable = "$subj")),

Review comment:
       I will add them.




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

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



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

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