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 2020/12/27 04:45:14 UTC
[GitHub] [netbeans] bradh opened a new pull request #2610: add extra cases to SizeEqualsZero java hints
bradh opened a new pull request #2610:
URL: https://github.com/apache/netbeans/pull/2610
Adds support for size() > 0, size() < 1, and size() <=0.
I think it would be useful to have unit tests for this, but I need a hint on how to write 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
[GitHub] [netbeans] bradh commented on a change in pull request #2610: add extra cases to SizeEqualsZero java hints
Posted by GitBox <gi...@apache.org>.
bradh commented on a change in pull request #2610:
URL: https://github.com/apache/netbeans/pull/2610#discussion_r579584937
##########
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:
Now added.
----------------------------------------------------------------
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
[GitHub] [netbeans] sdedic commented on a change in pull request #2610: add extra cases to SizeEqualsZero java hints
Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #2610:
URL: https://github.com/apache/netbeans/pull/2610#discussion_r578430210
##########
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:
is `not == true` correct in this invocation ?
----------------------------------------------------------------
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
[GitHub] [netbeans] bradh closed pull request #2610: add extra cases to SizeEqualsZero java hints
Posted by GitBox <gi...@apache.org>.
bradh closed pull request #2610:
URL: https://github.com/apache/netbeans/pull/2610
--
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-unsubscribe@netbeans.apache.org
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
[GitHub] [netbeans] bradh commented on a change in pull request #2610: add extra cases to SizeEqualsZero java hints
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [netbeans] bradh commented on a change in pull request #2610: add extra cases to SizeEqualsZero java hints
Posted by GitBox <gi...@apache.org>.
bradh commented on a change in pull request #2610:
URL: https://github.com/apache/netbeans/pull/2610#discussion_r578996305
##########
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
[GitHub] [netbeans] sdedic commented on a change in pull request #2610: add extra cases to SizeEqualsZero java hints
Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #2610:
URL: https://github.com/apache/netbeans/pull/2610#discussion_r578427650
##########
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:
Shouldn't be here also the flipped conditions like `1 > $subj.size()` ?
----------------------------------------------------------------
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
[GitHub] [netbeans] mbien commented on pull request #2610: add extra cases to SizeEqualsZero java hints
Posted by GitBox <gi...@apache.org>.
mbien commented on pull request #2610:
URL: https://github.com/apache/netbeans/pull/2610#issuecomment-962947690
@bradh unfortunately I overlooked this PR when https://github.com/apache/netbeans/pull/3164 got integrated :(
It is lacking the size() < 1 case though. If you still would like to contribute you could rebase to master and add the case + update the test just like the linked PR did.
You could start a new PR or reuse this one, whatever you prefer.
--
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-unsubscribe@netbeans.apache.org
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