public override bool BuildRegions(OutlineRegionCollection newRegions) { lock (_threadLock) { if (IsDisposed || !EditorTree.IsReady) { return(false); } AstRoot rootNode = null; try { // We are in a background thread so in order to walk the tree // we must obtain the read lock first. rootNode = EditorTree.AcquireReadLock(_treeUserId); if (rootNode != null) { OutliningContext context = new OutliningContext(); context.Regions = newRegions; // Walk the tree and construct new regions rootNode.Accept(this, context); OutlineSections(rootNode, context); } } catch (Exception) { } finally { if (rootNode != null) { EditorTree.ReleaseReadLock(_treeUserId); } else { // Tree was busy. Will try again later. GuardedOperations.DispatchInvoke(() => BackgroundTask.DoTaskOnIdle(), DispatcherPriority.Normal); } } return(true); } }
/// <summary> /// Resumes tree updates. If changes were made to the text buffer /// since suspend, full parse is performed. /// </summary> internal void Resume() { if (UpdatesSuspended) { UpdatesSuspended = false; if (TextBufferChangedSinceSuspend) { TextBufferChangedSinceSuspend = false; GuardedOperations.DispatchInvoke(() => ProcessPendingTextBufferChanges(async: true), DispatcherPriority.ApplicationIdle); } } }
public override bool BuildRegions(OutlineRegionCollection newRegions) { lock (_threadLock) { if (IsDisposed || !EditorTree.IsReady) { return(false); } AstRoot rootNode = null; try { rootNode = EditorTree.AcquireReadLock(_treeUserId); if (rootNode != null) { OutliningContext context = new OutliningContext(); context.Regions = newRegions; rootNode.Accept(this, context); } } catch (Exception ex) { Debug.Fail(String.Format(CultureInfo.CurrentCulture, "Exception in outliner: {0}", ex.Message)); } finally { if (rootNode != null) { EditorTree.ReleaseReadLock(_treeUserId); } else { // Tree was busy. Will try again later. GuardedOperations.DispatchInvoke(() => BackgroundTask.DoTaskOnIdle(), DispatcherPriority.Normal); } } return(true); } }