Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        /// <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);
                }
            }
        }
Exemplo n.º 3
0
        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);
            }
        }