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 2019/01/18 11:04:44 UTC

[GitHub] sarveshkesharwani commented on a change in pull request #1071: [NETBEANS-1728] fix for Exception encountered when break returns value

sarveshkesharwani commented on a change in pull request #1071: [NETBEANS-1728] fix for Exception encountered when break returns value
URL: https://github.com/apache/incubator-netbeans/pull/1071#discussion_r249004872
 
 

 ##########
 File path: java/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
 ##########
 @@ -1355,7 +1355,11 @@ public StatementTree getBreakContinueTarget(TreePath breakOrContinue) throws Ill
         
         switch (leaf.getKind()) {
             case BREAK:
-                return (StatementTree) ((JCTree.JCBreak) leaf).target;
+                Tree breakTarget = (Tree) ((JCTree.JCBreak) leaf).target;
+                if (breakTarget == null || !(breakTarget instanceof StatementTree)) {
+                    return null;
 
 Review comment:
   Thanks for the review, Jan. I see your point. It would indeed be better if I added a new method with return type as Tree. 
   
   I have done that in the latest commit. I am only calling the new method whenever we are trying to visit break, because, while visiting break, there is always a possibility that we might hit a break that is returning a value. In most of the places, using a Tree rather than a StatementTree did not raise any concerns, except in MarkOccurencesHighlighterBase.java, where I think I have made the necessary changes.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

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