Exemplo n.º 1
0
 public RewriteQueryTraverseVisitor(IScopeAwareExpressionVisitor visitor, ScopeWalker walker)
 {
     _visitor = visitor ?? throw new ArgumentNullException(nameof(visitor));
     _walker  = walker;
 }
Exemplo n.º 2
0
 private ScopeWalker(Scope scope, ScopeWalker parent)
     : this(scope)
 {
     _parent = parent;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Main function of the parsing thread.
        /// This function waits on the queue of the parsing requests and build the parsing tree for
        /// a specific file. The resulting tree is built using LibraryNode objects so that it can
        /// be used inside the class view or object browser.
        /// </summary>
        private void ParseThread()
        {
            const int waitTimeout = 500;

            // Define the array of events this function is interest in.
            WaitHandle[] eventsToWait = new WaitHandle[] { requestPresent, shutDownStarted };
            // Execute the tasks.
            while (true)
            {
                // Wait for a task or a shutdown request.
                int waitResult = WaitHandle.WaitAny(eventsToWait, waitTimeout, false);
                if (1 == waitResult)
                {
                    // The shutdown of this component is started, so exit the thread.
                    return;
                }
                LibraryTask task = null;
                lock (requests) {
                    if (0 != requests.Count)
                    {
                        task = requests.Dequeue();
                    }
                    if (0 == requests.Count)
                    {
                        requestPresent.Reset();
                    }
                }
                if (null == task)
                {
                    continue;
                }
                ScopeNode scope = null;
                if (null == task.Text)
                {
                    if (System.IO.File.Exists(task.FileName))
                    {
                        scope = ScopeWalker.GetScopesFromFile(task.FileName);
                    }
                }
                else
                {
                    scope = ScopeWalker.GetScopesFromText(task.Text);
                }
                LibraryNode module = new LibraryNode(
                    System.IO.Path.GetFileName(task.FileName),
                    LibraryNode.LibraryNodeType.PhysicalContainer);
                CreateModuleTree(module, module, scope, "", task.ModuleID);
                if (null != task.ModuleID)
                {
                    LibraryNode previousItem = null;
                    lock (files) {
                        if (files.TryGetValue(task.ModuleID, out previousItem))
                        {
                            files.Remove(task.ModuleID);
                        }
                    }
                    library.RemoveNode(previousItem);
                }
                library.AddNode(module);
                if (null != task.ModuleID)
                {
                    lock (files) {
                        files.Add(task.ModuleID, module);
                    }
                }
            }
        }
 public ToCSharpRewriteTreeTraverseVisitor(IToCSharpTranslationExpressionVisitor visitor, ScopeWalker walker)
 {
     _visitor = visitor ?? throw new ArgumentNullException(nameof(visitor));
     _walker  = walker;
 }