You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "junichi11 (via GitHub)" <gi...@apache.org> on 2023/04/09 22:58:37 UTC

[GitHub] [netbeans] junichi11 commented on a diff in pull request #5786: JS: Improve stability of JS model building (prevent cycles)

junichi11 commented on code in PR #5786:
URL: https://github.com/apache/netbeans/pull/5786#discussion_r1161351167


##########
webcommon/javascript2.model/src/org/netbeans/modules/javascript2/model/JsObjectImpl.java:
##########
@@ -192,7 +191,17 @@ public JsObject getParent() {
         return parent;
     }
 
+    @SuppressWarnings({"NestedAssignment", "AssertWithSideEffects"})
     public void setParent(JsObject newParent) {
+        boolean assertionsEnabled = false;
+        assert assertionsEnabled = true;
+        if (assertionsEnabled) {
+            for(JsObject checkParent = newParent; checkParent != null; checkParent = checkParent.getParent()) {
+                if(checkParent == this) {
+                    throw new AssertionError("Cycle detected in " + getFileObject().getPath());
+                }
+            }

Review Comment:
   Nitpick: formatting



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