package org.simantics.graph.compiler.internal.procedures; import org.simantics.graph.store.GraphStore; import org.simantics.graph.store.IdentityStore; public class PropagateNewMarks implements Runnable { IdentityStore identities; public PropagateNewMarks(GraphStore store) { this.identities = store.identities; } private void propagateNewMarks(int resource) { for(int child : identities.getChildren(resource)) 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() { int[] originalNewResources = identities.getNewResources(); for(int resource : originalNewResources) propagateNewMarks(resource); for(int resource : originalNewResources) propagateOptionalMarks(resource); } }