Exemple #1
0
        public void RegisterHierarchy(IVsHierarchy hierarchy)
        {
            if ((null == hierarchy) || hierarchies.ContainsKey(hierarchy))
            {
                return;
            }
            if (0 == objectManagerCookie)
            {
                IVsObjectManager2 objManager = provider.GetService(typeof(SVsObjectManager)) as IVsObjectManager2;
                if (null == objManager)
                {
                    return;
                }
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    objManager.RegisterSimpleLibrary(library, out objectManagerCookie));
            }

            SQLanguageService ls       = (SQLanguageService)provider.GetService(typeof(SQLanguageService));
            HierarchyListener listener = new HierarchyListener(hierarchy, ls.GetSquirrelVersion());

            listener.OnAddItem    += new EventHandler <HierarchyEventArgs>(OnNewFile);
            listener.OnDeleteItem += new EventHandler <HierarchyEventArgs>(OnDeleteFile);
            listener.StartListening(true);
            hierarchies.Add(hierarchy, listener);
            RegisterForRDTEvents();

            parseThread = new Thread(new ThreadStart(ParseThread));
            parseThread.Start();
        }
Exemple #2
0
        public void UnregisterHierarchy(IVsHierarchy hierarchy)
        {
            if ((null == hierarchy) || !hierarchies.ContainsKey(hierarchy))
            {
                return;
            }
            HierarchyListener listener = hierarchies[hierarchy];

            if (null != listener)
            {
                listener.Dispose();
            }
            hierarchies.Remove(hierarchy);
            if (0 == hierarchies.Count)
            {
                UnregisterRDTEvents();
            }

            // Remove the document listeners.
            uint[] docKeys = new uint[documents.Keys.Count];
            documents.Keys.CopyTo(docKeys, 0);
            foreach (uint id in docKeys)
            {
                TextLineEventListener docListener = documents[id];
                if (hierarchy.Equals(docListener.FileID.Hierarchy))
                {
                    documents.Remove(id);
                    docListener.Dispose();
                }
            }

            // Make sure that the parse thread can exit.
            if (null != shutDownStarted)
            {
                shutDownStarted.Set();
            }
            if ((null != parseThread) && parseThread.IsAlive)
            {
                parseThread.Join(500);
                if (parseThread.IsAlive)
                {
                    parseThread.Abort();
                }
                parseThread = null;
            }
            requests.Clear();

            // Clear the class view
            lock (library)
            {
                library.Clear();
            }
        }