Пример #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);
            }
        }
        private IEnumerable <IValidationError> Validate(AstRoot ast, CancellationToken ct)
        {
            var context = new ValidationContext(ct);

            ast.Accept(this, context);
            foreach (var v in _validators)
            {
                context.CancellationToken.ThrowIfCancellationRequested();
                context.Errors.AddRange(v.ValidateWhitespace(ast.TextProvider));
            }
            return(context.Errors);
        }
Пример #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);
            }
        }
Пример #4
0
 public object Visit(AstRoot node)
 {
     return(node.Accept(this));
 }