コード例 #1
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();
            }

            lock (_files)
            {
                ModuleID[] keys = new ModuleID[_files.Keys.Count];

                _files.Keys.CopyTo(keys, 0);

                foreach (ModuleID id in keys)
                {
                    if (hierarchy.Equals(id.Hierarchy))
                    {
                        _library.RemoveNode(_files[id]);
                        _files.Remove(id);
                    }
                }
            }

            // 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();
                }
            }
        }
コード例 #2
0
        public void UnregisterHierarchy(IVsHierarchy hierarchy)
        {
            if ((null == hierarchy) || !this._hierarchies.ContainsKey(hierarchy))
            {
                return;
            }
            var info = this._hierarchies[hierarchy];

            if (null != info)
            {
                info.Listener.Dispose();
            }
            this._hierarchies.Remove(hierarchy);
            this._library.RemoveNode(info.ProjectLibraryNode);
            if (0 == this._hierarchies.Count)
            {
                UnregisterRDTEvents();
            }
            lock (this._files)
            {
                var keys = new ModuleId[this._files.Keys.Count];
                this._files.Keys.CopyTo(keys, 0);
                foreach (var id in keys)
                {
                    if (hierarchy.Equals(id.Hierarchy))
                    {
                        this._library.RemoveNode(this._files[id]);
                        this._files.Remove(id);
                    }
                }
            }
            // Remove the document listeners.
            var docKeys = new uint[this._documents.Keys.Count];

            this._documents.Keys.CopyTo(docKeys, 0);
            foreach (var id in docKeys)
            {
                var docListener = this._documents[id];
                if (hierarchy.Equals(docListener.FileID.Hierarchy))
                {
                    this._documents.Remove(id);
                    docListener.Dispose();
                }
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
0
        private IntPtr FindDocDataFromRDT()
        {
            // Get a reference to the RDT.
            IVsRunningDocumentTable rdt = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;

            if (null == rdt)
            {
                return(IntPtr.Zero);
            }

            // Get the enumeration of the running documents.
            IEnumRunningDocuments documents;

            ErrorHandler.ThrowOnFailure(rdt.GetRunningDocumentsEnum(out documents));

            IntPtr documentData = IntPtr.Zero;

            uint[] docCookie = new uint[1];
            uint   fetched;

            while ((VSConstants.S_OK == documents.Next(1, docCookie, out fetched)) && (1 == fetched))
            {
                uint         flags;
                uint         editLocks;
                uint         readLocks;
                string       moniker;
                IVsHierarchy docHierarchy;
                uint         docId;
                IntPtr       docData = IntPtr.Zero;
                try
                {
                    ErrorHandler.ThrowOnFailure(
                        rdt.GetDocumentInfo(docCookie[0], out flags, out readLocks, out editLocks, out moniker, out docHierarchy, out docId, out docData));
                    // Check if this document is the one we are looking for.
                    if ((docId == fileId) && (ownerHierarchy.Equals(docHierarchy)))
                    {
                        documentData = docData;
                        docData      = IntPtr.Zero;
                        break;
                    }
                }
                finally
                {
                    if (IntPtr.Zero != docData)
                    {
                        Marshal.Release(docData);
                    }
                }
            }

            return(documentData);
        }
コード例 #5
0
ファイル: ModuleId.cs プロジェクト: yxbdali/nodejstools
        public override bool Equals(object obj)
        {
            ModuleId other = obj as ModuleId;

            if (null == other)
            {
                return(false);
            }
            if (!_ownerHierarchy.Equals(other._ownerHierarchy))
            {
                return(false);
            }
            return(_itemId == other._itemId);
        }
コード例 #6
0
        public override bool Equals(object obj)
        {
            XSharpModuleId other = obj as XSharpModuleId;

            if (null == obj)
            {
                return(false);
            }
            if (!ownerHierarchy.Equals(other.ownerHierarchy))
            {
                return(false);
            }
            return(itemId == other.itemId);
        }
コード例 #7
0
ファイル: ModuleID.cs プロジェクト: ugurak/nemerle
        public override bool Equals(object obj)
        {
            ModuleID other = obj as ModuleID;

            if (null == obj)
            {
                return(false);
            }

            if (!_hierarchy.Equals(other._hierarchy))
            {
                return(false);
            }

            return(_itemID == other._itemID);
        }
コード例 #8
0
        /// <summary>
        /// Monitor for changes to the active project and notify the entity references user control when a
        /// new SHFB project is selected as the active project.
        /// </summary>
        /// <param name="pHierOld">The hierarchy for the previously selected item</param>
        /// <param name="itemidOld">Project item identifier for the previously selected item</param>
        /// <param name="pMISOld">Interface for previous multi-selection items</param>
        /// <param name="pSCOld">Interface for the previous selection container</param>
        /// <param name="pHierNew">The hierarchy for the new selection</param>
        /// <param name="itemidNew">Project item identifier for the new selection</param>
        /// <param name="pMISNew">Interface for new multi-selection items</param>
        /// <param name="pSCNew">Interface for the new selection container</param>
        /// <returns></returns>
        int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld,
                                                  IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew,
                                                  IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            SandcastleProject       shfbProject = null;
            EntityReferencesControl ucEntityReferences;
            object project;

            if (pHierOld == null || !pHierOld.Equals(pHierNew))
            {
                ucEntityReferences = base.Content as EntityReferencesControl;

                if (ucEntityReferences != null)
                {
                    if (pHierNew != null)
                    {
                        ErrorHandler.ThrowOnFailure(pHierNew.GetProperty(VSConstants.VSITEMID_ROOT,
                                                                         (int)__VSHPROPID.VSHPROPID_ExtObject, out project));

                        EnvDTE.Project envDTEProject = project as EnvDTE.Project;

                        if (envDTEProject != null)
                        {
                            SandcastleBuilderProjectNode projectNode =
                                envDTEProject.Object as SandcastleBuilderProjectNode;

                            if (projectNode != null)
                            {
                                shfbProject = projectNode.SandcastleProject;
                            }
                        }
                    }

                    // We'll keep the existing reference unless it changes or the project is closed
                    if ((shfbProject == null && pHierNew == null) ||
                        (shfbProject != null && (ucEntityReferences.CurrentProject == null ||
                                                 ucEntityReferences.CurrentProject.Filename != shfbProject.Filename)))
                    {
                        ucEntityReferences.CurrentProject = shfbProject;
                    }
                }
            }

            return(VSConstants.S_OK);
        }
コード例 #9
0
ファイル: Library.cs プロジェクト: orangesocks/XSharpPublic
        internal LibraryNode SearchHierarchy(IVsHierarchy hierarchy)
        {
            LibraryNode found = null;

            lock (this)
            {
                foreach (LibraryNode nd in root.children)
                {
                    if (nd is XSharpLibraryNode)
                    {
                        XSharpLibraryNode vln = (XSharpLibraryNode)nd;
                        if (hierarchy.Equals(vln.ownerHierarchy))
                        {
                            found = nd;
                            break;
                        }
                    }
                }
            }
            return(found);
        }
コード例 #10
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();

            lock (_files)
            {
                ModuleID[] keys = new ModuleID[_files.Keys.Count];

                _files.Keys.CopyTo(keys, 0);

                foreach (ModuleID id in keys)
                {
                    if (hierarchy.Equals(id.Hierarchy))
                    {
                        _library.RemoveNode(_files[id]);
                        _files.Remove(id);
                    }
                }
            }

            // 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();
                }
            }
        }
コード例 #11
0
        // Считывает содержимое файла из буфера, связанного с документом.
        // Такой способ позволяет получить еще не сохраненный на диск контент.
        private string ReadSourceFromBuffer()
        {
            IVsRunningDocumentTable rdt = NemerlePackage.GetGlobalService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;

            if (rdt != null)
            {
                IEnumRunningDocuments documents;

                rdt.GetRunningDocumentsEnum(out documents);

                IntPtr documentData = IntPtr.Zero;
                uint[] docCookie    = new uint[1];
                uint   fetched;

                while ((Microsoft.VisualStudio.VSConstants.S_OK == documents.Next(1, docCookie, out fetched)) && (1 == fetched))
                {
                    uint         flags;
                    uint         editLocks;
                    uint         readLocks;
                    string       moniker;
                    IVsHierarchy docHierarchy;
                    uint         docId;
                    IntPtr       docData = IntPtr.Zero;

                    try
                    {
                        ErrorHandler.ThrowOnFailure(rdt.GetDocumentInfo(docCookie[0], out flags, out readLocks, out editLocks, out moniker, out docHierarchy, out docId, out docData));

                        // Check if this document is the one we are looking for.
                        if (docId == _id && _hierarchy.Equals(docHierarchy))
                        {
                            documentData = docData;
                            docData      = IntPtr.Zero;
                            break;
                        }
                    }
                    finally
                    {
                        if (docData != IntPtr.Zero)
                        {
                            Marshal.Release(docData);
                        }
                    }
                }

                if (documentData != IntPtr.Zero)
                {
                    object       obj      = Marshal.GetObjectForIUnknown(documentData);
                    IVsTextLines txtLines = obj as IVsTextLines;

                    int totalLines;
                    ErrorHandler.ThrowOnFailure(txtLines.GetLineCount(out totalLines));
                    StringBuilder sb = new StringBuilder();

                    for (int line = 0; line < totalLines; ++line)
                    {
                        int lineLen;
                        ErrorHandler.ThrowOnFailure(txtLines.GetLengthOfLine(line, out lineLen));

                        string lineText;
                        ErrorHandler.ThrowOnFailure(txtLines.GetLineText(line, 0, line, lineLen, out lineText));

                        sb.AppendLine(lineText);
                    }

                    return(sb.ToString());
                }
            }

            return(null);
        }
コード例 #12
0
 public void UnregisterHierarchy(IVsHierarchy hierarchy)
 {
     if ((null == hierarchy) || !_hierarchies.ContainsKey(hierarchy)) {
         return;
     }
     HierarchyInfo info = _hierarchies[hierarchy];
     if (null != info) {
         info.Listener.Dispose();
     }
     _hierarchies.Remove(hierarchy);
     _library.RemoveNode(info.ProjectLibraryNode);
     if (0 == _hierarchies.Count) {
         UnregisterRDTEvents();
     }
     lock (_files) {
         ModuleId[] keys = new ModuleId[_files.Keys.Count];
         _files.Keys.CopyTo(keys, 0);
         foreach (ModuleId id in keys) {
             if (hierarchy.Equals(id.Hierarchy)) {
                 _library.RemoveNode(_files[id]);
                 _files.Remove(id);
             }
         }
     }
     // 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();
         }
     }
 }
コード例 #13
0
        /// <summary>
        /// Monitor for changes to the active project and notify the topic previewer user control when a
        /// new SHFB project is selected as the active project.
        /// </summary>
        /// <param name="pHierOld">The hierarchy for the previously selected item</param>
        /// <param name="itemidOld">Project item identifier for the previously selected item</param>
        /// <param name="pMISOld">Interface for previous multi-selection items</param>
        /// <param name="pSCOld">Interface for the previous selection container</param>
        /// <param name="pHierNew">The hierarchy for the new selection</param>
        /// <param name="itemidNew">Project item identifier for the new selection</param>
        /// <param name="pMISNew">Interface for new multi-selection items</param>
        /// <param name="pSCNew">Interface for the new selection container</param>
        /// <returns></returns>
        int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld,
          IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew,
          IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew)
        {
            SandcastleProject shfbProject = null;
            object project;

            if(pHierOld == null || !pHierOld.Equals(pHierNew))
            {
                if(ucTopicPreviewer != null)
                {
                    if(pHierNew != null)
                    {
                        ErrorHandler.ThrowOnFailure(pHierNew.GetProperty(VSConstants.VSITEMID_ROOT,
                            (int)__VSHPROPID.VSHPROPID_ExtObject, out project));

                        EnvDTE.Project envDTEProject = project as EnvDTE.Project;

                        if(envDTEProject != null)
                        {
                            SandcastleBuilderProjectNode projectNode =
                                envDTEProject.Object as SandcastleBuilderProjectNode;

                            if(projectNode != null)
                                shfbProject = projectNode.SandcastleProject;
                        }
                    }

                    // We'll keep the existing reference unless it changes or the project is closed
                    if((shfbProject == null && pHierNew == null && ucTopicPreviewer.CurrentProject != null) ||
                      (shfbProject != null && (ucTopicPreviewer.CurrentProject == null ||
                      ucTopicPreviewer.CurrentProject.Filename != shfbProject.Filename)))
                        ucTopicPreviewer.CurrentProject = shfbProject;
                }
            }

            return VSConstants.S_OK;
        }
コード例 #14
0
        public void UnregisterHierarchy(IVsHierarchy hierarchy)
        {
            if ((null == hierarchy) || !hierarchies.ContainsKey(hierarchy))
            {
                return;
            }
            // Retrieve the listener for that Tree/Hierarchy
            HierarchyListener listener = hierarchies[hierarchy];

            if (null != listener)
            {
                listener.Dispose();
            }
            hierarchies.Remove(hierarchy);
            if (0 == hierarchies.Count)
            {
                UnregisterRDTEvents();
            }
            // Now remove all nodes
            // for all files
            lock (files)
            {
                XSharpModuleId[] keys = new XSharpModuleId[files.Keys.Count];
                // Get all Keys (ModuleId)
                files.Keys.CopyTo(keys, 0);
                foreach (XSharpModuleId id in keys)
                {
                    // The file is owned by the Hierarchy ?
                    if (hierarchy.Equals(id.Hierarchy))
                    {
                        HashSet <XSharpLibraryNode> values = null;
                        // Ok, now remove ALL nodes for that key
                        if (files.TryGetValue(id, out values))
                        {
                            foreach (XSharpLibraryNode node in values)
                            {
                                if (node.parent != null)
                                {
                                    node.parent.RemoveNode(node);
                                }
                            }
                        }
                        // and then remove the key
                        files.Remove(id);
                    }
                }
            }
            //
            LibraryNode prjNode = this.library.SearchHierarchy(hierarchy);

            if (prjNode is XSharpLibraryProject)
            {
                library.RemoveNode(prjNode);
            }
#if TEXTCHANGELISTENER
            // 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();
                }
            }
#endif
        }
コード例 #15
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();
     }
     lock (files) {
         ModuleId[] keys = new ModuleId[files.Keys.Count];
         files.Keys.CopyTo(keys, 0);
         foreach (ModuleId id in keys) {
             if (hierarchy.Equals(id.Hierarchy)) {
                 library.RemoveNode(files[id]);
                 files.Remove(id);
             }
         }
     }
     // 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();
         }
     }
 }