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/08/03 21:16:41 UTC

[GitHub] [netbeans] jlahoda opened a new pull request #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

jlahoda opened a new pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293


   


----------------------------------------------------------------
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 #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293#discussion_r486798647



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?




----------------------------------------------------------------
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] jlahoda commented on a change in pull request #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

Posted by GitBox <gi...@apache.org>.
jlahoda commented on a change in pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293#discussion_r465481495



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -1172,37 +1207,63 @@ public Boolean visitBreak(BreakTree node, ConstructorData p) {
 
             Tree target = info.getTreeUtilities().getBreakContinueTargetTree(getCurrentPath());
             
-            resumeAfter(target, variable2State);
+            breakTo(target);
 
-            variable2State = new HashMap< Element, State>();
+            return null;
+        }
+
+        public Boolean visitYield(Tree node, ConstructorData p) {
+            scan(TreeShims.getYieldValue(node), p);
+
+            Tree target = info.getTreeUtilities().getBreakContinueTargetTree(getCurrentPath());
             
+            breakTo(target);
+
             return null;
         }
 
+        private void breakTo(Tree target) {
+            resumeAfter(target, variable2State);
+
+            variable2State = new HashMap< Element, State>();

Review comment:
       ```suggestion
               variable2State = new HashMap<>();
   ```




----------------------------------------------------------------
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] jlahoda-jackpot commented on a change in pull request #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

Posted by GitBox <gi...@apache.org>.
jlahoda-jackpot commented on a change in pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293#discussion_r464795921



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -1172,37 +1207,63 @@ public Boolean visitBreak(BreakTree node, ConstructorData p) {
 
             Tree target = info.getTreeUtilities().getBreakContinueTargetTree(getCurrentPath());
             
-            resumeAfter(target, variable2State);
+            breakTo(target);
 
-            variable2State = new HashMap< Element, State>();
+            return null;
+        }
+
+        public Boolean visitYield(Tree node, ConstructorData p) {
+            scan(TreeShims.getYieldValue(node), p);
+
+            Tree target = info.getTreeUtilities().getBreakContinueTargetTree(getCurrentPath());
             
+            breakTo(target);
+
             return null;
         }
 
+        private void breakTo(Tree target) {
+            resumeAfter(target, variable2State);
+
+            variable2State = new HashMap< Element, State>();

Review comment:
       Jackpot:
   warning: Redundant type arguments in new expression (use diamond operator instead).




----------------------------------------------------------------
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] lkishalmi commented on pull request #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293#issuecomment-708161099


   @jlahoda @sdedic what is the state of this PR? Can it go in?


----------------------------------------------------------------
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 #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293#discussion_r486798647



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?




----------------------------------------------------------------
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] lkishalmi merged pull request #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

Posted by GitBox <gi...@apache.org>.
lkishalmi merged pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293


   


----------------------------------------------------------------
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 #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293#discussion_r486798647



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?




----------------------------------------------------------------
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 #2293: Handling of switch expressions and rule cases in Flow and NPECheck hint.

Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #2293:
URL: https://github.com/apache/netbeans/pull/2293#discussion_r486798647



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
##########
@@ -444,11 +445,45 @@ protected boolean isCanceled() {
             return cancel.isCanceled();
         }
 
+        private TreePath currentPath;
+
+        public TreePath getCurrentPath() {
+            return currentPath;
+        }
+
+        public Boolean scan(TreePath path, ConstructorData p) {
+            TreePath oldPath = currentPath;
+            try {
+                currentPath = path;
+                return super.scan(path.getLeaf(), p);
+            } finally {
+                currentPath = oldPath;
+            }
+        }
+
         @Override
         public Boolean scan(Tree tree, ConstructorData p) {
             resume(tree, resumeBefore);
             
-            Boolean result = super.scan(tree, p);
+            Boolean result;
+
+            if (tree != null) {

Review comment:
       Wouldn't it be beneficial to build the `visitSwitchExpression` and `visitYield` into baseclasses ?




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