private RecoverableSyntaxRoot( RecoverableSyntaxRoot <TRoot> originalRoot, IRecoverableSyntaxTree <TRoot> containingTree) : base(originalRoot) { _service = originalRoot._service; _storage = originalRoot._storage; _containingTree = containingTree; }
public RecoverableSyntaxRoot( AbstractSyntaxTreeFactoryService service, TRoot root, IRecoverableSyntaxTree <TRoot> containingTree) : base(new ConstantValueSource <TRoot>(containingTree.CloneNodeAsRoot(root))) { _service = service; _containingTree = containingTree; }
public RecoverableSyntaxRoot <TRoot> WithSyntaxTree(IRecoverableSyntaxTree <TRoot> containingTree) { if (this.TryGetValue(out var root)) { var result = new RecoverableSyntaxRoot <TRoot>(_service, root, containingTree); result._storage = _storage; return(result); } else { return(new RecoverableSyntaxRoot <TRoot>(this, containingTree)); } }
public RecoverableSyntaxRoot <TRoot> WithSyntaxTree(IRecoverableSyntaxTree <TRoot> containingTree) { // at this point, we should either have strongly held root or _storage should not be null if (this.TryGetValue(out var root)) { // we have strongly held root return(new RecoverableSyntaxRoot <TRoot>(_service, root, containingTree)); } else { // we have _storage here. _storage != null is checked inside return(new RecoverableSyntaxRoot <TRoot>(this, containingTree)); } }
/// <summary> /// Called by the constructor the parent tree. /// </summary> /// <remarks> /// This is to address the catch-22 dependency -- a tree needs it's recoverable root /// and vice versa. The dangerous bit is when we call TickleCache because it's the /// first place when this tree gets handed out to another system. We need to make sure /// both this object and the parent tree are fully constructed by that point.</remarks> public void SetContainingTree(IRecoverableSyntaxTree <TRoot> containingTree) { this.containingTree = containingTree; this.rootSource = new ConstantValueSource <TRoot>(containingTree.CloneNodeAsRoot(this.rootSource.GetValue())); this.OnRootAccessed(this.rootSource.GetValue()); }