]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/PropagateNewMarks.java
(refs #7563) Mark parents of new resource optional in graph.tg
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / procedures / PropagateNewMarks.java
index 58eae257f3dfc094fe41dd27b291d0589177890f..c9235361bae0bdb7000d2eb8a66e28d490daee26 100644 (file)
@@ -15,10 +15,23 @@ public class PropagateNewMarks implements Runnable {
                        if(identities.markNew(child))
                                propagateNewMarks(child);
        }
-       
+
+       /**
+        * Mark all parents of resources marked new as optional provisionally. This mark is removed
+        * in ValidateGraph.run, if the resource can be found in dependencies.
+        */
+       private void propagateOptionalMarks(int child) {
+               int parent = identities.getParent(child);
+               if(parent >= 0 && !identities.isRoot(parent) && !identities.isNewResource(parent) && identities.markOptional(parent))
+                       propagateOptionalMarks(parent);
+       }
+
        @Override
        public void run() {
-               for(int resource : identities.getNewResources())
-                       propagateNewMarks(resource);    
+               int[] originalNewResources = identities.getNewResources();
+               for(int resource : originalNewResources)
+                       propagateNewMarks(resource);
+               for(int resource : originalNewResources)
+                       propagateOptionalMarks(resource);
        }
 }